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);
g.DrawImage(Bmp, new Rectangle(0, 0, Bmp.Width, Bmp.Height),
0, 0, Bmp.Width, Bmp.Height, GraphicsUnit.Pixel, IA);
####
The code above will throw OutOfMemoryException in the DrawImage() function.
However, there will have no problem if I remove the "fs.Dispose()" statement.
I need to dispose off the FileSteam, because there are many other threads trying to read the same file.
I am using VS2008, on Windows XP SP2.
Any solution or clue on how to address this issue?
TIA!