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

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -