'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.
Solution 1:[1]
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);
Solution 2:[2]
The simplest way ever is:
Bitmap bm = new Bitmap("C:/images/a10.png");
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | |
| Solution 2 | CrownFord |
