Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Camera.SaveAsBitmap() Aspect Ratio

3 REPLIES 3
Reply
Message 1 of 4
rjay75
336 Views, 3 Replies

Camera.SaveAsBitmap() Aspect Ratio

Is this by design?

 

In 2014 when saving an image using the Camera.SaveAsBitMap method the saved image aspect ratio seems distorted by width / height.

 

If the width and height are set to the same value the ratio is correct.

3 REPLIES 3
Message 2 of 4
Vladimir.Ananyev
in reply to: rjay75

I tried the following code for the same view in the Inventor 2014 UI:

 

Private Sub SizeTest()
    Dim V As View
    Set V = ThisApplication.ActiveView
    Dim cam As Camera
    Set cam = V.Camera
    
    Call cam.SaveAsBitmap("C:\Temp\Test_100x200.png", 100, 200)
    Call cam.SaveAsBitmap("C:\Temp\Test_200x100.png", 200, 100)
    Call cam.SaveAsBitmap("C:\Temp\Test_200x200.png", 200, 200)
    Call cam.SaveAsBitmap("C:\Temp\Test_ViewSize.png", V.Width, V.Height)
  Beep
End Sub

 Here are my results:

Test_100x200.png Test_200x100.png Test_200x200.png

 

Test_ViewSize.png

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 4
rjay75
in reply to: Vladimir.Ananyev

Thanks for the reponse. I tried your code and it worked the same for me as it did for you. Then I modified it to mimic the way I am using the command. The difference is I create a camera manually, set the view and save with a different background color. 

 

Here's my code.

Sub Main
    Dim V As View
    V = ThisApplication.ActiveView
    Dim cam As Camera
    cam = ThisApplication.TransientObjects.CreateCamera()
    cam.SceneObject = ThisDoc.Document.ComponentDefinition
    cam.ViewOrientationType = ViewOrientationTypeEnum.kFrontViewOrientation
    cam.ApplyWithoutTransition()
	
    Dim bkColor As Color
    bkColor = ThisApplication.TransientObjects.CreateColor(255, 255, 255, 0)
    
    cam.SaveAsBitmap("C:\Temp\RTest_100x200.png", 100, 200, bkColor, bkColor)
    cam.SaveAsBitmap("C:\Temp\RTest_200x100.png", 200, 100, bkColor, bkColor)
    cam.SaveAsBitmap("C:\Temp\RTest_200x200.png", 200, 200, bkColor, bkColor)
    cam.SaveAsBitmap("C:\Temp\RTest_ViewSize.png", V.Width, V.Height, bkColor, bkColor)
End Sub

 

And here are my results.

RTest_100x200.pngRTest_200x100.pngTest_200x200.png

RTest_ViewSize.png

 

If the background color is not changed it still produces the same results. Is the camera created through TransientObjects and the ActiveView camera different types of camera objects?

 

Thanks

Message 4 of 4
Vladimir.Ananyev
in reply to: rjay75

It looks like you found a problem in the API.  I can reproduce this effect with TransientCamera.  It looks like TransientCamera.SaveAsBitmap method works correctly only if Width = Height.  I noticed also that the result could be additionally distorted if you call Camera.Fit method.

I logged appropriate change request.
Thank you a lot!
Cheers


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report