vb saving images

vb saving images

I looked at the script file as suggested to try to get an image saved in VB. I came up with the following sub routine which gives me the error message

'the requested file type is not supported'

In the help for the AvFileLoader it says

'Although you can load files in a number of file formats, you can save files in XML and HDF5 formats only'

which explains the error message.

I'm thus confused about how your script in the demos directory would thus work.

Can I or can I not save an image to a file? If so, how?


Sub PrintImage(myroot As IAvGroup)

Dim nWidth As Long
Dim nHeight As Long
Dim graphpath As String
Dim filename As String
Dim saveparams As String

Dim fileloader As AvFileLoader
Dim graph As IAvGraph2D

Set fileloader = CreateObject("Avis.AvFileLoader")
Set graph = myroot.Graphs(1)

   graphpath = "graph:/" & graph.Name
   filename = "C:" & graph.Name & ".png"
   nHeight = 400
   nWidth = 500

   If graph.FixedAspect Then
     nHeight = nWidth / graph.AspectRatio
     nHeight = nWidth * 0.6
   End If

   saveparams = filename & "?GRAPHPATH:" & graphpath & "?WIDTH:" & CInt(nWidth) & "?HEIGHT:" & CInt(nHeight)

   Call fileloader.SaveAs(myroot, saveparams, False)
Set fileloader = Nothing
Set graph = Nothing

End Sub
4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

The code you posted worked correctly on my system. If you run Array Viewer, bring up
the About Box and click on the "File Loader plug-in info button, do you see PNG listed as
one of the file formats? Are PNG files created when you run the CreateImage.vbs script?

Regarding the documentation: XML and HDF5 are the only formats that can be used
to save an entire object hierarchy to a file, but the image formats can be used to create image files of
Graph2D/3D objects. This will be clarified when the documentation is updated for the next release.

It works now. I didn't have the avpngfl.exe registered.

What I did notice though is that if you create an impage of a 3d the camera position is not as you see it in your application - it seems to be from behind. How do you make sure the 3d image created is as you see it on the screen.


The reason why you are seeing the different viewpoint is that the camera used by the fileloader object is the camera attached to the graph3d, not the camera used by the avGraphCtl. I had gone into the rational for the use of two camerasin a previous post: http://softwareforums.intel.com/ids/board/message?board.id=Visualizer&message.id=362.

You'll need to update the graph's camera with the viewpoint values of the graph control's camera before calling the Save method of avFileLoader.

Leave a Comment

Please sign in to add a comment. Not a member? Join today