Brief
I want to display a PNG image in my PictureBox. At runtime the software asks the path of the image from the user.
Solution i am using
This is my code uptill now
picturebox1.Image = null;
OpenFileDialog ofDlg = new OpenFileDialog();
ofDlg.Filter = "Image files|*.png";
if (DialogResult.OK == ofDlg.ShowDialog())
{
picturebox1.Image = Image.FromFile(ofDlg.FileName); //Out of memory.
}
Problem
It was all working fine uptill now untill i got an image which was of 25.7 MB (8827 x 11350 pixels).
I know you might all suggest that i should get a lighter version of this image BUT the problem is that this software is used to zoom the image to view the image in detail. So i cannot resize it at any cost.
Now whenever i run the above code it gives me the exception
Out of memory.
I do not understand what is the problem here because i have 8GB of RAM installed on my PC then how it is out of memory? Below is my CPU usage at the time when this error message appeared.