A Generic error occurs at GDI+ at Bitmap.Save() after using SaveFileDialog

前端 未结 12 1547
情书的邮戳
情书的邮戳 2020-12-10 01:07

I use the following code block with some more code inside the using block:

using (System.Drawing.Bitmap tempImg =
       (System.Drawing.Bitmap)tempObj.GetDa         


        
12条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-10 01:35

    I also had once this problem- it happens because the bitmap locks and you can't save it( if you want I can find the exact explanation) so anyway a fix around is this: Create a new bitmap the size of the original bitmap you have- copy the original bitmap to the new created bitmap and then dispose the original bitmap and save the new one.

    Bitmap bm3 = new Bitmap(bm2);
    

    And then save.

提交回复
热议问题