user2464884
user2464884

Reputation:

Bitmap class error in c# (The parameter is not valid)

I want to convert an image to bitmap format. Here's the code i wrote :-

Bitmap bmp = new Bitmap("c:\\images\\a10.png");

The parameter image is taken from the function parameter. It takes a full path with filename. When i run, an error pops up showing "The parameter is not valid". But this class accepts filename as constructor.

Upvotes: 1

Views: 11814

Answers (2)

CrownFord
CrownFord

Reputation: 719

The simplest way ever is:

Bitmap bm = new Bitmap("C:/images/a10.png");

Upvotes: 0

crthompson
crthompson

Reputation: 15875

The image path you set is not correct. That image does not exist at that location.

Check your path to verify the image.

This code will properly save a png to a bmp provided the png exists.

Bitmap bmp = new Bitmap("c:\\images\\a10.png");
bmp.Save("c:\\images\\a10.bmp");

EDIT:

The above worked for me, but here is another way:

Image bmp = Image.FromFile("c:\\images\\a10.png");
bmp.Save("c:\\images\\a10.bmp", ImageFormat.Bmp);

Upvotes: 0

Related Questions