从使用C#免费图片文件 [英] C# Free Image file from use
本文介绍了从使用C#免费图片文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我与
Bitmap CapturedImg = (Bitmap)Image.FromFile("Item/Item.bmp");
和因为是临时,我想为进一步使用其它图像来取代它,但该计划仍然在使用这种形象,我不能做任何事情。
and because is temp i want to replace it with another image for further use, but the program still using that image and i cannot do anything.
如何让从图像中去,以更换?
How to let go from the image in order to be replaced?
推荐答案
我也有类似的问题,不能用用,因为文件被一些异步代码覆盖。我通过位图的副本,并释放原来的解决了这个问题:
I had a similar problem and could not use using, since the file was overwritten by some asynchronous code. I solved the issue by making a copy of the Bitmap and freeing the original one:
Bitmap tmpBmp = new Bitmap(fullfilename);
Bitmap image= new Bitmap(tmpBmp);
tmpBmp.Dispose();
这篇关于从使用C#免费图片文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文