Inventor API Save as JPEG with Transparent Background

Inventor API Save as JPEG with Transparent Background

Anonymous
Not applicable
1,217 Views
3 Replies
Message 1 of 4

Inventor API Save as JPEG with Transparent Background

Anonymous
Not applicable

I have been scouring the forum and API help section to see if there is a command similar to "SaveAsBitmapWithOptions" for JPEG, but haven't found anything.  What I want to be able to do is shown in the code, but I need to export to JPEG for my cloud database. I can change the file type to .JPG, but I lose the ability to make the background transparent. Is there a command to do this, or a workaround to convert the exported .BMP to .JPG?

 

Public Sub ExportToJPG()
    ' Get the active view.
    Dim oView As View
    Set oView = ThisApplication.ActiveView
    
 'Create a new NameValueMap Object
    Dim oOptions As NameValueMap
    Set oOptions = ThisApplication.TransientObjects.CreateNameValueMap '.TransientObjects.CreateNameValueMap
    
    oOptions.Value("TransparentBackground") = True

    Call oView.SaveAsBitmapWithOptions("C:\Temp\TestB.bmp", 200, 150, oOptions)
End Sub

0 Likes
Accepted solutions (1)
1,218 Views
3 Replies
Replies (3)
Message 2 of 4

mcgyvr
Consultant
Consultant
Accepted solution

JPEG files don't support transparent backgrounds..

PNG will.. 

 



-------------------------------------------------------------------------------------------
Inventor 2023 - Dell Precision 5570

Did you find this reply helpful ? If so please use the Accept Solution button below.
Maybe buy me a beer through Venmo @mcgyvr1269
Message 3 of 4

Curtis_Waguespack
Consultant
Consultant

Hi @Anonymous 

 

Firstly API related questions are better handled  on the Inventor Customization forum :
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/bd-p/120

 

Secondly, I don't think JPG supports transparent backgrounds, so if you save a file that has a transparent background to JPG the transparency is lost and you just get a white background.

 

So would a JPG with a white back ground work? 

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes
Message 4 of 4

Anonymous
Not applicable

Didn't realize JPEG did not support transparent background.  .PNG will work for my application. Thanks for the help!

0 Likes