By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,144 Members | 1,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,144 IT Pros & Developers. It's quick & easy.

annoying reproducable Bitmap.Save() crash

P: n/a
Bitmap.Save() does crash very often on Saving jpg's. It seems to dislike
pictures on a random basis, but when it dislikes a picture there is no way
around it.

Take for example the picture
http://home.foni.net/~sjost/fremd/IMGP5753-2.JPG

I load the picture, and save it rotated by 270 degree. Works like charm:

[Test] public void Rotate270AndSaveTest()
{
ImageCodecInfo jpegCodec = null;
foreach (ImageCodecInfo c in ImageCodecInfo.GetImageEncoders())
{
if (c.MimeType == "image/jpeg")
{
jpegCodec = c;
break;
}
}
Image Picture =
Image.FromFile(@"\pwSam\2004\Bilder\BildTests\IMGP 5753-2.JPG");
EncoderParameters EncParms = new EncoderParameters(1);
EncParms.Param[0] = new
EncoderParameter(System.Drawing.Imaging.Encoder.Tr ansformation,
(long)EncoderValue.TransformRotate270);
Picture.Save(@"\pwSam\2004\Bilder\BildTests\IMGP57 53-2-Rotate270.JPG",
jpegCodec, EncParms);
}

on the other hand, I load the same picture, save and rotate it 90 degree,
and Save crashes with some fancy error message:

[Test] public void Rotate90AndSaveTest()
{
ImageCodecInfo jpegCodec = null;
foreach (ImageCodecInfo c in ImageCodecInfo.GetImageEncoders())
{
if (c.MimeType == "image/jpeg")
{
jpegCodec = c;
break;
}
}
Image Picture =
Image.FromFile(@"\pwSam\2004\Bilder\BildTests\IMGP 5753-2.JPG");
EncoderParameters EncParms = new EncoderParameters(1);
EncParms.Param[0] = new
EncoderParameter(System.Drawing.Imaging.Encoder.Tr ansformation,
(long)EncoderValue.TransformRotate90);
Picture.Save(@"\pwSam\2004\Bilder\BildTests\IMGP57 53-2-Rotate90.JPG",
jpegCodec, EncParms);
}

TestCase 'Sam.Tests.BildTests.Rotate90AndSaveTest' failed:
System.ArgumentException : Ungültiger Parameter verwendet.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
EncoderParameters encoderParams)
c:\pwsam\2004\sam.tests\bildtests.cs(143,0): at
Sam.Tests.BildTests.Rotate90AndSaveTest()
This does happen with all kinds of pictures, mostly pictures coming directly
from my digital kamera (Pentax *istD). Some work, some dont.

it is very annoying and makes it nearly impossible to write an app to work
with my pictures!

Anybody can help here? Can I somehow find what causes these errors, or find
a way to stop them?

thanks!!!!
Sam
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I don't know how to solve this, but in case it helps someone else:

Ungültiger Parameter verwendet

is German for

Invalid parameter used.

Eric
TestCase 'Sam.Tests.BildTests.Rotate90AndSaveTest' failed:
System.ArgumentException : Ungültiger Parameter verwendet.
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder,
EncoderParameters encoderParams)
c:\pwsam\2004\sam.tests\bildtests.cs(143,0): at
Sam.Tests.BildTests.Rotate90AndSaveTest()


Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.