GDI Exception
-
Hi I m facing exception while saving an image. The code is //this line throws Exception picturebox.Image.Save(memorystream, System.Drawing.Imaging.ImageFormat.Jpeg ); and exception is: "A generic error occurred in GDI+." So plz tell me the solution Regards
Shanzay
-
Hi I m facing exception while saving an image. The code is //this line throws Exception picturebox.Image.Save(memorystream, System.Drawing.Imaging.ImageFormat.Jpeg ); and exception is: "A generic error occurred in GDI+." So plz tell me the solution Regards
Shanzay
My guess is that there is something up with the memory stream. Try saving the image to a file (by passing a string) instead of a stream. If the error still occurs, then it must be a problem with the image.
My current favourite word is: Waffle Cheese is still good though.
-
Hi I m facing exception while saving an image. The code is //this line throws Exception picturebox.Image.Save(memorystream, System.Drawing.Imaging.ImageFormat.Jpeg ); and exception is: "A generic error occurred in GDI+." So plz tell me the solution Regards
Shanzay
Hi, almost all errors occuring in GDI+ lead to the same message, so it can be many things. Most liekly in your case: you have forgotten to reposition the stream, if you write data to a stream, its position advances; now if you want to save the image, you need to set the position to zero again. Try
memorystream.Position=0
before Image.Save :)Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
Hi, almost all errors occuring in GDI+ lead to the same message, so it can be many things. Most liekly in your case: you have forgotten to reposition the stream, if you write data to a stream, its position advances; now if you want to save the image, you need to set the position to zero again. Try
memorystream.Position=0
before Image.Save :)Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
hi, Thanx for reply. I did this but still getting this error.Actually I m sending Live video from server to client and after recieving every frame this error is displaying so what should I do in this Scenario.
Shanzay
-
hi, Thanx for reply. I did this but still getting this error.Actually I m sending Live video from server to client and after recieving every frame this error is displaying so what should I do in this Scenario.
Shanzay
did you succeed in saving to a file as the other reply suggested?
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
-
did you succeed in saving to a file as the other reply suggested?
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips: - use PRE tags to preserve formatting when showing multi-line code snippets - before you ask a question here, search CodeProject, then Google
yah well I got success by adding two things 1. used thread.Sleep() before saving 2. used file.jpg instead memorystream. Thanx.
Shanzay