GDI+ exception saving a Bitmap to a MemoryStream

后端 未结 2 981
终归单人心
终归单人心 2021-01-06 14:36

I have a problem in a Windows Forms application with Bitmap.Save failing when I save to a MemoryStream. The problem only seems to occur intermittently on one machine (so fa

2条回答
  •  一整个雨季
    2021-01-06 14:57

    Have you tried moving

       picture.releasePixelData(pPixels);
    

    to

       finally
       {
           memStream.Dispose();
           picture.releasePixelData(pPixels);
       }
    

    it definitely sounds like a threading issue (especially since you state that the releasePixelData could happen on a background thread). Threading issues are always the ones that only happen on one machine, and it is always on the clients machine (probably due to the fact they only have 256Megs of memory or something ridiculous and garbage collector is kicking in early, or the machine has quad core and your developer machine is dual core or something).

提交回复
热议问题