TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
dj_jay_smith
NA
3
0
GDI+ Generic Error
Nov 27 2007 6:40 AM
Hi,
I am trying to convert an image to a byte array. But I have searched the internet and most pretty much say to do something similar, which is the code I have below.
But when I call this I get a "generic GDI+ error has occured" exception on the imageIn.Save line, and I don't know why and many search have failed to reveal the problem.
I have tried different images, different machines, but I get the same problem. Can somebody help?
private byte[] byteImageConvert(System.Drawing.Image imageIn)
{
ImageCodecInfo codec = null;
foreach (ImageCodecInfo e in ImageCodecInfo.GetImageEncoders())
{
if (e.MimeType == "image/jpeg")
{
codec = e;
break;
}
}
using (EncoderParameters ep = new EncoderParameters())
{
ep.Param[0] = new EncoderParameter(Encoder.Quality, 100L);
using (MemoryStream ms = new MemoryStream())
{
imageIn.Save(ms, codec, ep);
return ms.ToArray();
}
}
}
Reply
Answers (
2
)
gdi+ error in windows service
Scrolling text is not smooth.