c# - gdi+ generic error when drawing image on Graphics object -
consider following code running in windows service.
graphics g = graphics.fromimage(printimage); (int rows = 1; rows <= thumbrows; rows++) { (int cols = 1; cols <= thumbcolumns; cols++) { using (image thumbimage = new bitmap(resourcequeue.peek())) { g.drawimage(thumbimage, targetrect, sourcerect, graphicsunit.pixel); resourcequeue.dequeue(); if (resourcequeue.count == 0) break; } } } the code draws list of images after making them smaller onto image. works fine of time exception thrown in middle of loop on image thumbimage = new bitmap. exception "a generic error occurred in gdi+". happens after 13th image created no matter images used.
after googling seems common problem when saving files difference here no file saved. image drawn on graphics object.
does know how fix this?
most stream used create bitmap (if is) closed. have stay open life of bitmap. can copy stream new memorystream, close original.
Comments
Post a Comment