How can I specify the size of the bitmap being exported in a MapViewer script?

This article explains how to exit the export options when exporting a bitmap via a MapViewer script.

The Plot.Export command is accessible from the PlotDocument object. After you have a PlotDocument (Plot), you can export the map using the Export command.


To run this script:

  1. Copy the text below, from the Sub Main start line to the End Sub end line.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\MapViewer 8\Scripter.
  3. Double click on Scripter.exe to launch Scripter.
  4. Press Ctrl+A to select all of the existing lines.
  5. Press Ctrl+V to paste your copied script over top of these existing lines.
  6. Click Script | Run to run the script.



Sub Main

'Initializes MapViewer
Dim mvApp, Plot As Object
Set mvApp = CreateObject("MapViewer.Application")
mvApp.Visible = True

'Open a file so there is something to export
Set Plot = mvApp.Documents.Open(mvApp.ApplicationFolder+"\Samples\FlowMap.gsm")

'Export the map as a bitmap
Plot.Export(FileName:="c:\Temp\export.jpg", Options:="")

End Sub




When you are exporting to a bitmap format, such as a TIF, BMP, JPG, PNG, or GIF, there are some options that are available. These allow you to control the exported image size, color depth, and quality. The most common options are: Width and Height or HDPI and VDPI (dots per inch), ColorDepth, Automatic, and Quality. To use these, type the following into the empty Options string in the example above:

    • Width=1024, Height=720 - Sets the width and height of the exported bitmap
    • HDPI=300, VDPI=300 - Sets the horizontal and vertical depth per inch of the exported bitmap
    • Automatic=False - Turns off automatic compression of the exported bitmap (TIF only)
    • Quality=100 - Sets the quality to 100% (JPG only)
    • ColorDepth=32 - Sets the ColorDepth using an enumeration value:
        • -32=32-bit grayscale
        • -16=16-bit grayscale
        • -8=8-bit grayscale
        • -4=4-bit grayscale
        • -1=Monochrome
        • 1=1-bit color indexed
        • 4=4-bit color indexed
        • 8=8-bit color indexed
        • 24=24-bit color indexed
        • 32=32-bit true color with alpha


Updated March 3, 2015

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Please sign in to leave a comment.