Welcome Guest! To enable all features, please Login or Register.



Last Go to last post Unread Go to first unread post
#1 Posted : Friday, May 12, 2006 2:19:23 AM(UTC)


Groups: Registered
Posts: 6

I would like to load an image stored in an SQL server database.

How do I convert either a byte array or a System.Drawing.Image object into an IRasterImage object which can be loaded into a RasterImageViewer?

Try the latest version of LEADTOOLS for free for 60 days by downloading the evaluation: https://www.leadtools.com/downloads

Wanna join the discussion? Login to your LEADTOOLS Support accountor Register a new forum account.

#2 Posted : Monday, May 15, 2006 9:47:47 AM(UTC)


Groups: Guests
Posts: 3,022

Was thanked: 2 time(s) in 2 post(s)

You will need to store the byte array into a memory stream, then use
the RasterCodecs.Load method to load the data in the memory
stream.  The Load method is overloaded to take a file name on disk and a stream.

#3 Posted : Tuesday, May 16, 2006 6:05:23 PM(UTC)


Groups: Registered
Posts: 6

Thanks, Basher.

I solved my problem as follows:

Pass a byte array to this function to return an image object:

 Public Function ByteArrayToImage(ByRef myByteArray() As Byte) As Image
        Dim myStream As New IO.MemoryStream
        Dim myImage As Image

        myStream.Write(myByteArray, 0, myByteArray.GetUpperBound(0))
        myImage = Image.FromStream(myStream)
        Return myImage

    End Function

Pass the returned image object to this function to return a RasterImage object:

 Private Function ImageToRasterImage(ByRef myImage As System.Drawing.Image) As IRasterImage
            Dim myRasterImage As IRasterImage
            myRasterImage = New RasterImage(myImage)
            myRasterImage.MakeGdiPlusCompatible(Imaging.PixelFormat.DontCare, True)
            Return myRasterImage

    End Function

Assign the returned RasterImage object to the viewer's image property.
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Powered by YAF.NET | YAF.NET © 2003-2024, Yet Another Forum.NET
This page was generated in 0.102 seconds.