I'm getting the error "A generic error occurred in GDI+" from 3 files, the nearly 150 others there's no problem with at all. Does anyone have any kind of idea what can cause my code to fail on only 3 images, which is identical in dpi and resolution
as the rest?
Best regards
Please remember to post your code.
If this post answered your question or solved your problem, please Mark it as Answer.
I'm doing a simple resize of them using the DrawImage method along with Bitmap and Graphics. I am sorry, but I cannot access the code all day today, there's being done some hardware replacement on the server I've rented. This code is basicly identical to
mine, just some other destinations.
System.Drawing.Image image = System.Drawing.Image.FromFile(src);
int srcWidth=image.Width;
int srcHeight=image.Height;
int thumbHeight=(srcHeight/srcWidth)*thumbWidth;
Bitmap bmp = new Bitmap(thumbWidth, thumbHeight);
System.Drawing.Graphics gr = System.Drawing.Graphics.FromImage(bmp);
gr.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality ;
gr.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
System.Drawing.Rectangle rectDestination = new System.Drawing.Rectangle(0, 0, thumbWidth, thumbHeight);
gr.DrawImage(image, rectDestination, 0, 0, srcWidth, srcHeight, GraphicsUnit.Pixel);
bmp.Save(dest);
bmp.Dispose();
image.Dispose();
Please remember to post your code.
If this post answered your question or solved your problem, please Mark it as Answer.
Apart from the motive, the image is identical to the nearly 150 other images. Same camera, same format, same resolution, same dots per inch, same debth, so it's highly unlikely
Please remember to post your code.
If this post answered your question or solved your problem, please Mark it as Answer.
Trolderik
Member
645 Points
355 Posts
A generic error occurred in GDI+
Jul 06, 2012 07:00 PM|LINK
Hi,
I'm getting the error "A generic error occurred in GDI+" from 3 files, the nearly 150 others there's no problem with at all. Does anyone have any kind of idea what can cause my code to fail on only 3 images, which is identical in dpi and resolution as the rest?
Best regards
If this post answered your question or solved your problem, please Mark it as Answer.
Ken Tucker
All-Star
16797 Points
2608 Posts
MVP
Re: A generic error occurred in GDI+
Jul 06, 2012 10:08 PM|LINK
are you just showing these images on a web page? if you doing something to the image with code please post the code that is giving the error
Space Coast .Net User Group
Trolderik
Member
645 Points
355 Posts
Re: A generic error occurred in GDI+
Jul 07, 2012 10:11 AM|LINK
I'm doing a simple resize of them using the DrawImage method along with Bitmap and Graphics. I am sorry, but I cannot access the code all day today, there's being done some hardware replacement on the server I've rented. This code is basicly identical to mine, just some other destinations.
If this post answered your question or solved your problem, please Mark it as Answer.
Ken Tucker
All-Star
16797 Points
2608 Posts
MVP
Re: A generic error occurred in GDI+
Jul 07, 2012 10:28 AM|LINK
I suspect the error is happening when you try and open the image. Could the images giving the error be of a type not supported by the image class.
Space Coast .Net User Group
Trolderik
Member
645 Points
355 Posts
Re: A generic error occurred in GDI+
Jul 07, 2012 11:21 AM|LINK
Apart from the motive, the image is identical to the nearly 150 other images. Same camera, same format, same resolution, same dots per inch, same debth, so it's highly unlikely
If this post answered your question or solved your problem, please Mark it as Answer.