c# - System.OverflowException while Editing large size images(A0,A1,A2) -


i have draw lozenge & text inside lozenge in image specific coordinates given user. have succeeded using graphics class below-

        var memorystream = new memorystream();         using (var bmp = new bitmap(filepath, false))         {             using (var grp = graphics.fromimage(bmp))             {                 // measure text size                 //sizef textsize = grp.measurestring(inputtext1, font);                 var count = 0;                 var maxcount = (printpositions.count < inputtexts.count)                     ? printpositions.count                     : inputtexts.count;                 (var = 0; < maxcount; i++)                 {                     var printposition = printpositions.elementat(i);                      // calculating font size per dpi.                     printposition.fontsize = (printposition.fontsize * 300) / 74;                     var cornerradius = commonhelper.getcornerradius(size);                     //convert.toint32(printposition.fontsize / 0.95);                      if (printposition.islozenge)                     {                         var recpoint = imageservices.getcoordinates(printposition.printtextposition);                         var converter = new colorconverter();                         var color = color.slategray;                         if(!string.isnullorempty(printposition.lozengecolor))                         {                             var colorstring = converter.convertfromstring(printposition.lozengecolor) ??                                                color.slategray;                         color = (color)colorstring;                         }                         using (var sbrush = new solidbrush(color))                         {                             using (var gpath = new graphicspath())                             {                                 gpath.addline(recpoint.x + cornerradius, recpoint.y,                                     recpoint.x + recpoint.width - (cornerradius * 2), recpoint.y);                                 gpath.addarc(recpoint.x + recpoint.width - (cornerradius * 2), recpoint.y,                                     cornerradius * 2, cornerradius * 2, 270, 90);                                 gpath.addline(recpoint.x + recpoint.width, recpoint.y + cornerradius,                                     recpoint.x + recpoint.width, recpoint.y + recpoint.height - (cornerradius * 2));                                 gpath.addarc(recpoint.x + recpoint.width - (cornerradius * 2),                                     recpoint.y + recpoint.height - (cornerradius * 2), cornerradius * 2,                                     cornerradius * 2, 0, 90);                                 gpath.addline(recpoint.x + recpoint.width - (cornerradius * 2),                                     recpoint.y + recpoint.height, recpoint.x + cornerradius,                                     recpoint.y + recpoint.height);                                 gpath.addarc(recpoint.x, recpoint.y + recpoint.height - (cornerradius * 2),                                     cornerradius * 2, cornerradius * 2, 90, 90);                                 gpath.addline(recpoint.x, recpoint.y + recpoint.height - (cornerradius * 2),                                     recpoint.x, recpoint.y + cornerradius);                                 gpath.addarc(recpoint.x, recpoint.y, cornerradius * 2, cornerradius * 2, 180, 90);                                  gpath.closefigure();                                 grp.fillpath(sbrush, gpath);                             }                         }                     }                      // adding padding top & left                     var positions = printposition.printtextposition.split(',');                     var newposition = string.empty;                     (var n = 0; n < positions.count(); n++)                     {                         var position = positions.elementat(n);                         if (n == 0)                         {                             var toppadding = commonhelper.gettoppadding(size, cornerradius);                             newposition = (int.parse(position) + toppadding).tostring(cultureinfo.invariantculture);                             continue;                         }                         if (n == 1)                         {                             var leftpadding = commonhelper.getleftpadding(size, cornerradius);                             newposition += "," + (int.parse(position) + leftpadding);                             continue;                         }                         newposition += "," + position;                     }                      brush brush = new solidbrush(color.white);                     var fontstyle = fontstyle.regular;                     if (printposition.font.equals("proxima nova rg") ||                         printposition.font.equals("helveticaneuelt std"))                         fontstyle = fontstyle.bold;                     var font = new font(printposition.font, printposition.fontsize, fontstyle,                         graphicsunit.pixel);                     var ps = imageservices.getcoordinates(newposition);                     var point = new point(ps.x, ps.y);                     var printtext = (inputtexts.elementat(count).length > printposition.textlimit)                         ? inputtexts.elementat(count).substring(0, printposition.textlimit)                         : inputtexts.elementat(count);                     grp.drawstring(printtext, font, brush, point);                     count++;                 }                 //save watermarked image memorystream.                 bmp.save(memorystream, imageformat.png); 

but works a3,a4,a5 paper sizes less 10mb image. else sizes a0,a1,a2 & file size greater 16mb, throwing exception system.overflowexception. there wrong in code or other way in c# achieve this? if not free nuget package can this? using .net framework 4.5 on 64bit machine.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -