Image Handling

B

bh

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...
 
G

Guest

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,697
Latest member
AugustNabo

Latest Threads

Top