iProperty Thumbnail to Image

iProperty Thumbnail to Image

Anonymous
Not applicable
2,033 Views
8 Replies
Message 1 of 9

iProperty Thumbnail to Image

Anonymous
Not applicable

Hi,

 

i have some Problems to find a Solution to Convert  the Thumbnail iProperty Value

 

 

  Dim thumbnail As IPictureDisp = thumbProp.Value
   Dim objImage As System.Drawing.Image
                objImage = Microsoft.VisualBasic.Compatibility.VB6.Support.IPictureDispToImage(thumbnail)

 

 

and all this without ...Support.IPictureDispToImage then this is !!Obsulet!!

 

so Wayne Brill  have some Solution on this Side but this is Image ==> iPictureDisp

 

http://modthemachine.typepad.com/my_weblog/2012/02/bitmaps-without-vb6-icontoipicture.html

 

or this in Support Blog from Philippe Leefsma

 

http://adndevblog.typepad.com/manufacturing/2012/06/how-to-convert-iconbitmap-to-ipicturedisp-withou...

 

and the solution from Microsoft or some other Peoples work rundomized most Time not!

 

Public Class PictureToImageConverter
    Inherits System.Windows.Forms.AxHost

    Public Sub New()
        MyBase.New("{63109182-966B-4e3c-A8B2-8BC4A88D221C}")
    End Sub

    Public Shared Function Convert(ByVal iPicture As stdole.IPictureDisp) As System.Drawing.Image
        Return CType(System.Windows.Forms.AxHost.GetPictureFromIPicture(iPicture), System.Drawing.Image)
    End Function

End Class

 

pls Help thx 

 

Mario

 

0 Likes
Accepted solutions (1)
2,034 Views
8 Replies
Replies (8)
Message 2 of 9

manuel.lanthaler
Enthusiast
Enthusiast

Hi Mario,

 

im also using the last approach you posted and its working well for me.

 

Another possible solution could be to directly extract the Thumbnail from the file using the Windows API Code Pack library. 

An example can be found here: http://stackoverflow.com/questions/1439719/c-sharp-get-thumbnail-from-file-via-windows-api

 

hope it helps

 

Manuel

coolOrange
www.coolOrange.com
––––––––––––––––––
Please mark this response as "Accept as Solution" if it answers your question.
If you have found any post to be helpful, even if it's not a direct solution, then please provide that author kudos.


0 Likes
Message 3 of 9

Balaji_Ram
Alumni
Alumni
Accepted solution

Hi Mario,

 

Here is a code snippet that my colleague Philippe Leefsma had recently used for converting the IPictureDisp to a System.Drawing.Image.

It uses the OleSavePictureFile to save a temporary WMF file which is then read into a System.Drawing.Image.

 

<DllImport("oleaut32.dll", EntryPoint:="OleSavePictureFile", ExactSpelling:=True, PreserveSig:=False, SetLastError:=True)> _
        Public Shared Sub OleSavePictureFile(Picture As stdole.IPictureDisp, <MarshalAs(UnmanagedType.BStr)> filename As String)
        End Sub

Dim oPD As Inventor.IPictureDisp
oPD = thumbProp.Value


'Check that an image was returned.  It's possible for a 
                'file to not have a thumbnail. 
                If oPD Is Nothing Then
                    MsgBox("The active document doesn't have a thumbnail.")
                    Return
                End If

                Dim fileName As String
                fileName = "D:\Temp\PartThumbnail.wmf"
                OleSavePictureFile(oPD, fileName)

                Dim img As System.Drawing.Image
                img = System.Drawing.Image.FromFile(fileName, True)

Regards,

Balaji

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 4 of 9

Anonymous
Not applicable

Hi,

 

thanx for the Answers

is there another Solution to get a "Thumbnail" from Document to a ImageBox without IPictureDisp from iPropertys?

 

thx

Mario

0 Likes
Message 5 of 9

Balaji_Ram
Alumni
Alumni

Hi Mario,

 

In this blog post, Brian explains all the other possibilities. 

But i think all of them deal with IPictureDisp.

 

http://modthemachine.typepad.com/my_weblog/2010/06/accessing-thumbnail-images.html

 

Is there a specific issue that you have with the code that i posted earlier ?

It saves the WMF to a folder and any image format can be created from it.

 

Regards,

Balaji

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 6 of 9

Anonymous
Not applicable
 
0 Likes
Message 7 of 9

Anonymous
Not applicable
Works Perfect thx
0 Likes
Message 8 of 9

Anonymous
Not applicable
Yes, It works fine with great performance. (it takes only 2ms in my PC)
0 Likes
Message 9 of 9

martinhoos
Advocate
Advocate

Hello, would you so kind and post the hole code. I like to get the thumbnails as pic.

Thanks in advance

Regards

Martin

0 Likes