Link to home
Start Free TrialLog in
Avatar of mainrotor
mainrotor

asked on

I need help converting a bitmap to an image in VB.Net

Hi Experts,
I am trying to convert a bitmap to an image in my VB.Net application, but I get this error "Value of type Bitmap cannot be converted to image"

Here is the line in my code that is throwing the error: Dim abc As Image = xyz

I use the same code in my WPF application with VB.Net code-behind, and it doesn't throw this error.  What am i doing wrong?
How do I fix this?

Below is a of my code:

            Dim xyz As New System.Drawing.Bitmap(stream)
            _MaingImageMemory = New MemoryStream
            _MaingImageMemory = stream 'xyz    'Added this for testing on 1/13/2016
            Dim PageCount As Integer
            PageCount = xyz.GetFrameCount(FrameDimension.Page)

            'Set Initial Page Numbers
            Nolbl.Content = "1"
            DblNolbl.Content = PageCount.ToString

            Dim abc As Image = xyz
            Dim images As New ArrayList
            Dim count As Integer = abc.GetFrameCount(FrameDimension.Page)

            For indexA = 0 To count - 1
                abc.SelectActiveFrame(FrameDimension.Page, indexA)
                Dim byteStream As New MemoryStream
                abc.Save(byteStream, ImageFormat.Bmp)
                byteStream.Position = 0
                Dim bitMapAgain As New BitmapImage
                bitMapAgain.BeginInit()
                bitMapAgain.StreamSource = byteStream
                bitMapAgain.EndInit()
                ListToScroll.Add(New ScrollingImages(bitMapAgain))
            Next

Open in new window


Thanks in advance,
mrotor
ASKER CERTIFIED SOLUTION
Avatar of mainrotor
mainrotor

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial