Skip to content

BITMAP ​

Draws a raster graphic / image.

Syntax ​

Parameters for loading image from a file:

leo-grammar
BITMAP strValue [ x:measureValue ] [ y:measureValue ] [ w:measureValue ] [ h:measureValue ] .

Parameters for providing image as base64 encoded string:

leo-grammar
BITMAP base64:strValue [ x:measureValue ] [ y:measureValue ] [ w:measureValue ] [ h:measureValue ] .

Parameters ​

  • <main-parameter> (strValue) - The path to a file, either local, in the database or accessible via HTTP/S.
  • base64 (strValue) - The image content encoded in Base64.
  • x (measureValue, optional) - The x-coordinate of the top-left corner for the image. The default is 0cm.
  • y (measureValue, optional) - The y-coordinate of the top-left corner for the image. The default is 0cm.
  • w (measureValue, optional) - The width for the image. The default is 0cm.
  • h (measureValue, optional) - The height for the image. The default is 0cm.

Details ​

This command is not influenced by any style commands.

The image is drawn as a rectangle with the top left corner at x and y coordinates and the specified width w and height h. It will be squashed or stretched to fit into the rectangle and possibly further distorting the image if the original aspect ratio is different. Use the command BITMAPINFO to determine an image's original size.

The image data can either be loaded from a file or provided directly. The most common approach is to load the image data from a file by providing the file path via the <main-parameter>. The path can lead either to the local file system, the database (paths starting with "db:\\") or a resource on the internet accessible via HTTP/S (paths that start with "http://" or "https://"). As the path is provided as a string it is necessary to escape various characters, for example \ escaped as \\ in a path like c:\bitmaps\logo.png leading to "c:\\bitmaps\\logo.png". If loading the file is not possible, the graphical representation will be shown as if no file was specified.

The alternative is to specify the image data directly through the base64 parameter. This is however not recommended, as the length of a GraphRep attribute is limited and even small images require a lot of characters when their data is encoded in Base64.

The following file formats are supported (with color depths in parentheses):

  • bmp: Windows Bitmap (1, 4, 8, 16, 24, 32)
  • gif: Graphics Interchange Format (8)
  • ico: Windows Icon (1, 4, 8, 16, 24, 32)
  • jpeg: JPEG Graphics Format (8, 24)
  • png: Portable Network Graphics (1, 4, 8, 24, 32)
  • targa: Truevision Targa (8, 16, 24, 32)
  • tiff: Tagged Image File Format (1, 4, 8, 24, 32)
  • wbmp: Wireless Bitmap (1)
  • webp: WebP graphics format
  • xpm: X11 Pixmap (24)

The file extension is irrelevant, but the data of the image has to be according to one of those formats. Transparency is supported for formats where it is available, like PNG.

When loading the image data from a file, then the data is cached internally based on the path. Changes to the image file are not reflected until it is removed from the cache. The file is removed from the cache when all models where the file is used are closed.

Rotation of an image is not possible. This has an influence on the drawing of relations where a rectangular shape will change with different rotations.

See Also ​

Examples ​

Draw the image from a local file located at c:\temp\adoxx_logo.png scaled to a size of 2cm by 2cm.
The ADOxx logo

leo
GRAPHREP

BITMAP ("c:\\temp\\adoxx_logo.png") w:2cm h:2cm

Draw the image from a file stored as part of the library's database scaled down by a factor of 25.
The NEMO Summer School logo

leo
GRAPHREP

BITMAPINFO ("db:\\nemo_logo.webp")
# Image assumed at 120dpi (2.54cm = 1inch) scaled down by a factor of 25
BITMAP ("db:\\nemo_logo.webp") w:(bmpwidth / 120 * 2.54cm / 25) h:(bmpheight / 120 * 2.54cm / 25)

Draw the image accessible at the URL https://www.omilab.org/assets/images/omilab_logo_.png scaled down to 3cm by 1.5cm.
The OMiLAB logo

leo
GRAPHREP

BITMAP ("https://www.omilab.org/assets/images/omilab_logo_.png") w:3cm h:1.5cm

Draw the image from a file specified through an attribute of the object and keep the image's aspect ratio.

leo
GRAPHREP

AVAL sFilename:("Image file")
BITMAPINFO (sFilename)
# Image assumed at 96dpi (2.54cm = 1inch)
BITMAP (sFilename) x:0cm y:0cm w:(bmpwidth / 96 * 2.54cm) h:(bmpheight / 96 * 2.54cm)

Draw the image from a file specified through an attribute of the object and allow the object to be resizable while keeping the image's aspect ratio.

leo
GRAPHREP sizing:asymmetrical
SHADOW off

AVAL sFilename:("Image file")
# Default width and height.
SET d:3cm

# Use a table to handle the size of the object.
TABLE w:(d) h:(d) rows:1 cols:1
    w1:100%
    h1:100%
STRETCH off

# Mark the border of the object.
PEN color:"lightgray"
FILL style:null
RECTANGLE w:(tabw1) h:(tabh1)

# Get the image size and draw the image.
BITMAPINFO (sFilename)
IF (bmpwidth / CMS tabw1 < bmpheight / CMS tabh1) {
  # Use maximum height, space at the right
  SET w:(tabh1 * (bmpwidth / bmpheight))
  BITMAP (sFilename) x:(tabx0) y:(taby0) w:(w) h:(tabh1)
} ELSE {
  # Use maximum width, space at the bottom
  SET h:(tabw1 * (bmpheight / bmpwidth))
  BITMAP (sFilename) x:(tabx0) y:(taby0) w:(tabw1) h:(h)
}

Draw a tiny icon where the image data is specified directly as Base64.
Small image of a ferris wheel

leo
GRAPHREP

# The Base64 data is 2568 characters long.
BITMAP w:0.6cm h:0.6cm
  base64:"R0lGODlhIgAhAOf/AAYRDA8RDhISBw0UCRYXEg4aEBAaCRUZChMaFB4ZExodCRkdEBQeFxIgCxQfERggDB4gHRskCycgFx4jFiAjEhwlEhklHhslFx4nHiEoChsnLCIoGyQqBCsmISEqFzImESAqJiQrEygqFCcqGS4qEyYtECgsHy0rHictJSowDSguMCwvGCwxBzEuGTQvECsyFSwxHy0xJC4yKjIzFy81EjwyEzQzJi44BjA2GTU1Ez0zDi42MjA3HzI4DzI2KS03ODk4Ci44PTs5DD44EjM5MEE3ITQ9DDo7ID86Gjs9FTo9Gjo9Kzk9MDc9OTQ+PztBCj09NT1BEkE9PDlAN049GzxAQkRCFT5CP0ZFHT9FPEJFODtGSFQ/Qz5GQklEQ0tFP0RJPj9LVERLTUpKQ0VPOnBDOklOSj9RYEdSQ1VRUEtUVU1TWlhUSEpXYkxZX1pXW11XUVhYYVFbXFZaXFZhbV5gXWBfaFFkdGZgWFdkapJXV2xjaW1nYFtrdmdpeINlY1xvhWZue3Fsa2VvdWVwgmxwcmNzf212gml5hGh7kW56jHp4fHZ6gmp9jmZ/m2l/lXV+i4F8e5B5g4Z/eYWAf2mGp3mDkHiDln2Di4OCjJ97gHSHmHeGnnGIpIOFlIKGmnSKoImGin2Jm5aEhnCNroGKl3eNpI6JiJ2DmYqKk3aQrH6PrYCPp4aPnaGIjYyOnYSQo46Ol3aTtHOUu5qLmX2StoeQsJ2MlIyQpYGUpouSmn+VrHmWuJmQinaXvou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OOzek089+UScjzzybNKPNbFIo8+9xt6TCyaQlKLII2ioMQg84TRzjDnkVGyIGV2swEY8v5yiCz753COPxOT8AskVaUDxQx9d5CBHIYzEMIUPTPDwQhYriCGCJeiEAo4zEkvcDCaFINLEBkQs4YYcZGihRRN1QOGDDCZMUcIMIoBhzi7tdIOzxOmAU0r+K40EAQIDQGiRBBY49BDFEV0w4UYbMJTwgggvGIKIM/Tsg/cyy4SzSxs7XOCAEkawcIMQCnDQwxwo5NEIAhNQQMEIR8CARyin6JPPO7ogskgqoLSBwQAFxHBDCk/0oIAISqiRhxNb7CCCCCXQsMIIYzBCTTvtRLLFBCaMgEkjFhTwQwY3RJCBESeQcIQSOTgBAg00pPBACDRUUAEblDyzxxgyTICBCYi4gxhgwIATZEABGXiCDqjgAsOFYAEheEES4peBBzgAA3zohQ14sIITfAEOhlCDDBzQgBYoQAEkqAESdKADFlghAwt4AQ5KEIEHGAB4BZBCGjzwAApUYQ1mvaDGMLaAggcQ4AAJ+MAHhuACIZTABhQ4QAAOcIAHACAAN4yBDEAQgw3gIAhr4Ic9/NGLSVxhAAEQgQCKUIQUROAAEiAAAiBgAwYEIAAIWAAepFCFN8BBBR1QQRgEwQY82AAa9ggIADs="

Versions and Changes ​

Available since ADOxx 1.3