简体   繁体   中英

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.

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);

最简单的方法是:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM