Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
705 Views, 1 Reply

Convert Thumbnail to image

Hello

 

the Thumbnail is in IPictureDisp format, and the picturebox requires an image.

 

How can it be converted?


The sugestion found on the fourms to use VB6 does not seem to work anymore. (removed because obsolete, and not compatible with 64 bit system)

 

In the addin template there is the image converter that converts from image to IPictureDisp but not the inverse.

 

Thank you!

Anonymous
in reply to: Anonymous

Solved with this code:

 

 

 

Public NotInheritable Class IPictureDispConverter : Inherits System.Windows.Forms.AxHost

        Private Sub New()

            MyBase.New("")

        End Sub


        Public Shared Function ImageToPictureDisp(image As Image) As IPictureDisp

            Try

                Return DirectCast(GetIPictureDispFromPicture(image), IPictureDisp)

            Catch ex As Exception

                'Add error message or logging here if desired.

                'Handle the conversion error by simply returning Nothing.

                Return Nothing

            End Try

        End Function



        Public Shared Function PictureDispToImage(pictureDisp As IPictureDisp) As Image

            Try

                Return GetPictureFromIPicture(pictureDisp)

            Catch ex As Exception

                'Add error message or logging here if desired.

                'Handle the conversion error by simply returning Nothing.

                Return Nothing

            End Try

        End Function

    End Class