From: bh on
I have a Function in an external class, that accepts a byte array and tries
to convert it to a .bmp image, but I'm getting "A generic error occurred in
GDI+" exception error on the 3rd line when I try to save the image. The
code I have is as follows. Any help you can offer would be appreciated.
Thank you in advance:

Public Overloads Shared Function ResizeImage(ByVal ImageBytes As Byte(),
ByVal width As Integer, ByVal height As Integer) As Bitmap

Dim ms As New MemoryStream(ImageBytes, 0, ImageBytes.Length)

Dim imgIn As System.Drawing.Image = System.Drawing.Image.FromStream(ms,
True)

imgIn.Save(ms, Imaging.ImageFormat.Bmp)

remaining code...


From: Alexey Smirnov on
On Apr 28, 9:39 pm, "bh" <some...(a)somewhere.com> wrote:
> I have a Function in an external class, that accepts a byte array and tries
> to convert it to  a .bmp image, but I'm getting "A generic error occurred in
> GDI+" exception error on the 3rd line when I try to save the image.  The
> code I have is as follows.  Any help you can offer would be appreciated..
> Thank you in advance:
>
> Public Overloads Shared Function ResizeImage(ByVal ImageBytes As Byte(),
> ByVal width As Integer, ByVal height As Integer) As Bitmap
>
>     Dim ms As New MemoryStream(ImageBytes, 0, ImageBytes.Length)
>
>     Dim imgIn As System.Drawing.Image = System.Drawing.Image.FromStream(ms,
> True)
>
>     imgIn.Save(ms, Imaging.ImageFormat.Bmp)
>
> remaining code...

Are you sure that the stream has image in ImageFormat.Bmp format?
Maybe this is the problem