Load image from file using Bitmap class

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi, I'm trying to load some images (png, bmp, jpeg) from file using Bitmap
class.
My code is very simple:

private void button1_Click(object sender, System.EventArgs e)
{
Bitmap img=null;

System.Windows.Forms.OpenFileDialog dlgOpen = new OpenFileDialog();
if (dlgOpen.ShowDialog()==DialogResult.OK)
{
img=new Bitmap(dlgOpen.FileName);
MessageBox.Show("Open!");
}
}

I made many test and I can load and work with small images (less than 300
Kb) while I get ArgumentException with medium size images.

The strange thing is that PictureBox component can load the images without
problem.

I made some mistake or there is some limits in Bitmap class ? I made also
some test in emulator and on real device: I've seen that real device can load
images than cannot be loaded in the emulator but again cannot load image over
a defined size.
It seems that somewhere there is a limit in the size.

Thank you in advance.

Regards

Keven Corazza


.


Quantcast