Image Handling

Discussion in 'ASP .Net' started by bh, Apr 28, 2010.

  1. bh

    bh 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...
    bh, Apr 28, 2010
    #1
    1. Advertising

  2. On Apr 28, 9:39 pm, "bh" <> 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
    Alexey Smirnov, Apr 30, 2010
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?d2FsdGVy?=

    Error handling for html/image resource

    =?Utf-8?B?d2FsdGVy?=, Mar 31, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    440
    Bruce Barker
    Mar 31, 2006
  2. Laszlo Zsolt Nagy
    Replies:
    1
    Views:
    1,273
    Kartic
    Jan 26, 2005
  3. Mark Tarver
    Replies:
    22
    Views:
    1,298
    J Kenneth King
    Apr 26, 2009
  4. Peter
    Replies:
    34
    Views:
    1,933
    James Kanze
    Oct 17, 2009
  5. Iñaki Baz Castillo
    Replies:
    1
    Views:
    182
    Iñaki Baz Castillo
    Apr 15, 2008
Loading...

Share This Page