问题描述
FileStream fs = new FileStream(@"image.bmp",FileMode.Open,FileAccess.Read,FileShare.Delete);
Bitmap Bmps = new Bitmap(fs);
fs.Dispose();
FileStream fs = new FileStream(@"image.bmp", FileMode.Open, FileAccess.Read, FileShare.Delete);
Bitmap Bmps = new Bitmap(fs);
fs.Dispose();
ColorMatrix CM = new ColorMatrix() ; $
CM.Matrix33 = 0.5;
ImageAttributes IA = new ImageAttributes();
IA.SetColorMatrix(CM,ColorMatrixFlag.Default,ColorAdjustType .Bitmap);
ColorMatrix CM = new ColorMatrix();
CM.Matrix33 = 0.5;
ImageAttributes IA = new ImageAttributes();
IA.SetColorMatrix(CM, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
g.DrawImage(Bmp,new Rectangle(0,0,Bmp.Width,Bmp.Height),
0,0,Bmp .Width,Bmp.Height,GraphicsUnit.Pixel,IA);
g.DrawImage(Bmp, new Rectangle(0, 0, Bmp.Width, Bmp.Height),
0, 0, Bmp.Width, Bmp.Height, GraphicsUnit.Pixel, IA);
####
上面的代码会在DrawImage()函数中抛出OutOfMemoryException。
The code above will throw OutOfMemoryException in the DrawImage() function.
但是,如果删除"fs.Dispose()",则没有问题。语句。
However, there will have no problem if I remove the "fs.Dispose()" statement.
我需要处理FileSteam,因为还有很多其他线程试图读取同一个文件。
I need to dispose off the FileSteam, because there are many other threads trying to read the same file.
我正在使用VS2008,在Windows XP SP2上。
I am using VS2008, on Windows XP SP2.
有关如何解决此问题的任何解决方案或线索?
Any solution or clue on how to address this issue?
TIA!
推荐答案
这篇关于FileStream的位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!