473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

annoying reproducable Bitmap.Save() crash

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
1 4321
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: charsh | last post by:
Hi, I using the code below to draw a text in a pictureBox1. //Start--------------------------------------------------------------- private void button1_Click(object sender, System.EventArgs e)...
9
by: Mark Johnson | last post by:
How can you save all or a portion of the Grafics object to a Image/Bitmap ? I am try to save the Images from Cards.dll to a BitMap file. I can read in the Images to the Grafics, but when I try this...
0
by: CroDude | last post by:
Hi all! I have problems when writting bitmap to a byte array and after reading it back form byte to Bitmap object. What I do is this: First I throw Bitmap to a memory-stream and then I write it...
2
by: active | last post by:
I find Bitmap.Save works for WMF files but Bitmap.FromFile does not. If I use FromFile on a WMF file that came with VS I get an exception. If I use it on a WMF file created with Bitmap.Save I...
8
by: Nathan Sokalski | last post by:
I am trying to write code to rotate a graphic that I have. Here is the code I am currently using: Dim frogbitmap As New Bitmap(Drawing.Image.FromFile(Server.MapPath("images/frog.gif"))) Dim...
7
by: Nathan Sokalski | last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving,...
1
by: Smokey Grindel | last post by:
I have a bitmap object I want to return as a JPEG image with a compression set at 90% and progressive passes enabled, how can I do this in .NET 2.0? Progressive passes are not necessary but the...
14
by: eliss.carmine | last post by:
I'm using TCP/IP to send a Bitmap object over Sockets. This is my first time using C# at all so I don't know if this is the "right" way to do it. I've already found out several times the way I was...
9
by: poifull | last post by:
Hi All, I have the following task: 1. create an image object in memory (a rectangle with nothing on it) 2. write some text on the rectangle 3. rotate the image 90 degree 4. save the image to a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.