469,352 Members | 1,661 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

Bitmap Save method gives "Parameter is not valid"

I have an image which I'm trying to save using

my_image.Save(some_path, System.Drawing.Imaging.ImageFormat.Path);

and then I get the error "Parameter is not valid".
What could be the reason for this error? I know I can store it as a Png file.
Jul 31 '07 #1
7 20429
On 31 Jul, 10:58, Joachim <Joac...@discussions.microsoft.comwrote:
I have an image which I'm trying to save using

my_image.Save(some_path, System.Drawing.Imaging.ImageFormat.Path);

and then I get the error "Parameter is not valid".
What could be the reason for this error? I know I can store it as a Png file.
ImageFormat.Path doesn't exist as far as I can see. Try changing it to
Jpeg just to test. What format do you want to save it as?

Jul 31 '07 #2
Sorry, I wrote wrong. It should be Png

"DeveloperX" wrote:
On 31 Jul, 10:58, Joachim <Joac...@discussions.microsoft.comwrote:
I have an image which I'm trying to save using

my_image.Save(some_path, System.Drawing.Imaging.ImageFormat.Path);

and then I get the error "Parameter is not valid".
What could be the reason for this error? I know I can store it as a Png file.

ImageFormat.Path doesn't exist as far as I can see. Try changing it to
Jpeg just to test. What format do you want to save it as?

Jul 31 '07 #3
Joachim wrote:
Sorry, I wrote wrong. It should be Png

"DeveloperX" wrote:
>On 31 Jul, 10:58, Joachim <Joac...@discussions.microsoft.comwrote:
>>I have an image which I'm trying to save using

my_image.Save(some_path, System.Drawing.Imaging.ImageFormat.Path);

and then I get the error "Parameter is not valid".
What could be the reason for this error? I know I can store it as a Png file.
ImageFormat.Path doesn't exist as far as I can see. Try changing it to
Jpeg just to test. What format do you want to save it as?

Then there's only one parameter left that can be invalid.

What does some_path contain?

--
Göran Andersson
_____
http://www.guffa.com
Jul 31 '07 #4
An existing path, including file name (which does not exist).

"Göran Andersson" wrote:
Joachim wrote:
Sorry, I wrote wrong. It should be Png

"DeveloperX" wrote:
On 31 Jul, 10:58, Joachim <Joac...@discussions.microsoft.comwrote:
I have an image which I'm trying to save using

my_image.Save(some_path, System.Drawing.Imaging.ImageFormat.Path);

and then I get the error "Parameter is not valid".
What could be the reason for this error? I know I can store it as a Png file.
ImageFormat.Path doesn't exist as far as I can see. Try changing it to
Jpeg just to test. What format do you want to save it as?


Then there's only one parameter left that can be invalid.

What does some_path contain?

--
Göran Andersson
_____
http://www.guffa.com
Jul 31 '07 #5
On 31 Jul, 12:04, Joachim <Joac...@discussions.microsoft.comwrote:
An existing path, including file name (which does not exist).

"Gran Andersson" wrote:
Joachim wrote:
Sorry, I wrote wrong. It should be Png
"DeveloperX" wrote:
>On 31 Jul, 10:58, Joachim <Joac...@discussions.microsoft.comwrote:
>>I have an image which I'm trying to save using
>>my_image.Save(some_path, System.Drawing.Imaging.ImageFormat.Path);
>>and then I get the error "Parameter is not valid".
>>What could be the reason for this error? I know I can store it as aPng file.
>ImageFormat.Path doesn't exist as far as I can see. Try changing it to
>Jpeg just to test. What format do you want to save it as?
Then there's only one parameter left that can be invalid.
What does some_path contain?
--
Gran Andersson
_____
http://www.guffa.com- Hide quoted text -

- Show quoted text -
Check what the string holds. If you've got something like

string some_path = "C:\pics\whatever";
that will actually turn the \p and \w into escape codes (if they're
valid ones)

so use the @ like so:
string some_path = @"C:\pics\whatever";

if you've got my_image.Save("C:\mypath",
System.Drawing.Imaging.ImageFormat.Png);
again just put an @ at the start.
my_image.Save(@"C:\mypath", System.Drawing.Imaging.ImageFormat.Png);
Jul 31 '07 #6
I've got double backslash (\\).

"DeveloperX" wrote:
On 31 Jul, 12:04, Joachim <Joac...@discussions.microsoft.comwrote:
An existing path, including file name (which does not exist).

"Gvran Andersson" wrote:
Joachim wrote:
Sorry, I wrote wrong. It should be Png
"DeveloperX" wrote:
On 31 Jul, 10:58, Joachim <Joac...@discussions.microsoft.comwrote:
>I have an image which I'm trying to save using
>my_image.Save(some_path, System.Drawing.Imaging.ImageFormat.Path);
>and then I get the error "Parameter is not valid".
>What could be the reason for this error? I know I can store it as a Png file.
ImageFormat.Path doesn't exist as far as I can see. Try changing it to
Jpeg just to test. What format do you want to save it as?
Then there's only one parameter left that can be invalid.
What does some_path contain?
--
Gvran Andersson
_____
>http://www.guffa.com- Hide quoted text -
- Show quoted text -

Check what the string holds. If you've got something like

string some_path = "C:\pics\whatever";
that will actually turn the \p and \w into escape codes (if they're
valid ones)

so use the @ like so:
string some_path = @"C:\pics\whatever";

if you've got my_image.Save("C:\mypath",
System.Drawing.Imaging.ImageFormat.Png);
again just put an @ at the start.
my_image.Save(@"C:\mypath", System.Drawing.Imaging.ImageFormat.Png);
Aug 1 '07 #7
I'm having the same problem...my path is correct, and the ImageFormat is correct. But it continues to give me the same error "Parameter is not valid"

If you figured the solution out, please post, I'll continue to look around.
Aug 8 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by amatuer | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.