Quantcast
Channel: Manufacturing DevBlog
Viewing all articles
Browse latest Browse all 532

How to save on the disk the thumbnail image of an Inventor file?

$
0
0

By Philippe Leefsma

Saving the thumbnail image of an Inventor document as a file of your disk might be a bit tricky.

Here is how to do it in C#. The code will save as a .jpg but saving to other formats will be very easy, by simply changing the filename and the ImageFormat enum:

[DllImport(

    "oleaut32.dll",

    EntryPoint = "OleSavePictureFile",

    ExactSpelling = true,

    PreserveSig = false,

    SetLastError = true)]

publicstaticexternvoid OleSavePictureFile(

    stdole.IPictureDisp Picture,

    [MarshalAs(UnmanagedType.BStr)] string filename);

 

void SaveThumbnail(Document doc)

{

    stdole.IPictureDisp pic = doc.Thumbnail;

 

    string filename = System.IO.Path.GetTempFileName();

 

    //Temp file is a .wmf

    OleSavePictureFile(pic, filename);

 

    Image img = Image.FromFile(filename, true);

 

    img.Save(

        @"C:\Temp\thumbnail.jpg",

        System.Drawing.Imaging.ImageFormat.Jpeg);

 

    System.IO.File.Delete(filename);

}

 


Viewing all articles
Browse latest Browse all 532

Latest Images

Trending Articles



Latest Images