Message="A generic error occurred in GDI+." Source="System.Drawing" ErrorCode=-2147467259
-
hi.please note to my code and help me.source image format is jpeg. below is my code.thanks.
private void Saveimg(Image image)
{
MemoryStream stream = new MemoryStream();
image.Save(stream,System.Drawing.Imaging.ImageFormat.Jpeg);//throw exeptionbyte[]imgdata= new byte[stream.Length];
imgdata= stream.ToArray();
string Filename = "c:\\" + Convert.ToString(DateTime.Now.ToFileTime()) +".jpg";FileStream fs = new FileStream(Filename, FileMode.CreateNew, FileAccess.Write);
fs.Write(imgdata, 0, imgdata.Length);
fs.Close();}
-
hi.please note to my code and help me.source image format is jpeg. below is my code.thanks.
private void Saveimg(Image image)
{
MemoryStream stream = new MemoryStream();
image.Save(stream,System.Drawing.Imaging.ImageFormat.Jpeg);//throw exeptionbyte[]imgdata= new byte[stream.Length];
imgdata= stream.ToArray();
string Filename = "c:\\" + Convert.ToString(DateTime.Now.ToFileTime()) +".jpg";FileStream fs = new FileStream(Filename, FileMode.CreateNew, FileAccess.Write);
fs.Write(imgdata, 0, imgdata.Length);
fs.Close();}
This might be ExternalException ,which means that you are trying to save the image using invalid format.Try to replace in your code
System.Drawing.Imaging.ImageFormat.Jpeg
withimage.RowFormat
.Notice that .jpg or .jpeg extensions could not guarantee that the format is Jpeg. :)Life is a stage and we are all actors!
modified on Tuesday, August 18, 2009 5:11 AM
-
This might be ExternalException ,which means that you are trying to save the image using invalid format.Try to replace in your code
System.Drawing.Imaging.ImageFormat.Jpeg
withimage.RowFormat
.Notice that .jpg or .jpeg extensions could not guarantee that the format is Jpeg. :)Life is a stage and we are all actors!
modified on Tuesday, August 18, 2009 5:11 AM
-
The which kind of exception and where exactly it occurred? Make sure that Image.RowFormat is not equal to Emf, Exif, Icon, MemoryBmp Wmf,which might be not supported by the Image.Save(Stream,ImageFormat) method used into your code. :)
Life is a stage and we are all actors!
modified on Tuesday, August 18, 2009 7:56 AM
-
The which kind of exception and where exactly it occurred? Make sure that Image.RowFormat is not equal to Emf, Exif, Icon, MemoryBmp Wmf,which might be not supported by the Image.Save(Stream,ImageFormat) method used into your code. :)
Life is a stage and we are all actors!
modified on Tuesday, August 18, 2009 7:56 AM
I have a similiar situation when saving an image, no matter what type. It's a local winform client application. When I'm logged onto the machine (I am admistrator) it works fine. When other users without admin rights are logged on, the generic GDI+ error occurs while saving the image. Any ideas on how to get around this? Using Image.Save taking a .png, .jpeg, or .bmp file types, seems to make no difference.
-
I have a similiar situation when saving an image, no matter what type. It's a local winform client application. When I'm logged onto the machine (I am admistrator) it works fine. When other users without admin rights are logged on, the generic GDI+ error occurs while saving the image. Any ideas on how to get around this? Using Image.Save taking a .png, .jpeg, or .bmp file types, seems to make no difference.
Same shit. Save method creates file, but doesn't write. And the very strange is GDI+ error. As soon as I know it doesn't return any error besides cases when the pointer to Image raw data is not returned. In fact, GDI+ deals with windows context (Device Context) of the control where image is shown. Therefore, it might be GDI+ API can't get the control's handle or doesn't has an access right to the control.. maybe .NET blocks the access to its controls from outside dll request. From other side all components are in the same thread, though maybe this Save operation opens new thread???? Any idea?