Load bmp, png

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, I'm trying to load images from file using Bitmap class.

My code is like the following:

Bitmap myBmp = new Bitmap(sImageFileName);

I get ArgumentException error when I try to load PNG or BMP files. I get the
same error for a JPEG image while for another JPEG image I don't get any
error.

Which is the problem ? Has CF some limits ?

Thank you for your help.
 
sImageFileName is the path and the name of the images. The problem is not here.

The images are not so big, the biggest is less than 1 Mb.

Keven.
 
Make sure that sImageFileName is indeed the path, because one of the
situation where the ArgmentException could be thrown is that
sImageFileName is an empty string.

If it is not your case, provide a small reproducible sample.
 
This is my piece of code:

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

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

Because the path comes from OpenFileDialog it could not be wrong.

I repeat, for some images (a JPG and a GIF) this code works, for other image
(a JPEG, PNG and BMP) I get ArgumentException.

Thanks for your help.

Keven Corazza
 
This is tested heavily inside MS, and again by the community as a whole. I
seriously doubt there's an internal bug, but if there is it will be
repeatable. What are the characteristics of the BMP files (color depth,
etc)? Is it all BMPs or just some? Do those that fail always fail? If you
manually load the image with a simple bit of direct code will it load? What
are the process memory conditions at the time of failure?

-Chris
 
I will try to check better the type of the image and so on. Just to be sure
can I send you some of these images so you can confirm me if is my problem or
not.

Thank you.

Keven
 
Back
Top