gmlBitmap class reference

Used to manipulate color and grayscale images.

constructor

gmlBitmap objectName ?-width     width?
                     ?-height    height?
                     ?-encoding  encoding?
                     ?-rowOffset rowOffset?
                     ?-fromTop   fromTop?

Create a new bitmap object named objectName. Geometry defaults to 320x240; encoding defaults to XRGB_8888. Row offset is the number of bytes between lines in the image. If unspecified, it will be choosen to maximise performance rather than space1. fromTop specifies the memory order of rows in the image (true means the first row in memory is the topmost).

[1]the address of the beginning of lines in the bitmap will be aligned to memory cachelines

object methods

objectName copy destination ?-srcRect rect0? ?-dstRect rect1?

This method is deprecated. Use gmlScannerCopy instead.

Copy the contents of the rectangular region rect0 of objectName into the rectangular region rect1 of the bitmap object named destination. rect0 and rect1 default to the bounding rectangle of the respective bitmaps. The dimensions of the regions must match. The bitmaps' specifications do not have to be identical. In particular, the encodings may be different, although:

  • all encoding pairs are not allowed;
  • performance will be reduced;
  • lossy transcoding may occur, e.g. when converting from XRGB_8888 to G_8.
objectName fill ?-color color? ?-alpha factor? ?-roi rect?

This method is deprecated. Use gmlScannerFill instead.

objectName getWidth
objectName getHeight
objectName getEncoding
objectName getRowOffset
objectName getFromTop

Return the corresponding property of the bitmap object objectName.

objectName getSpec

Return the list of all the above bitmap properties, in the documented order.

objectName load file fileName ?-format formatName?
objectName save file fileName ?-format formatName? ?-quality quality?

Load an image file or save to an image file named fileName. format may be one of tiff, jpeg, png, bmp, ppm, or some other format. If unspecified, it will be infered from the file itself (when loading) or the filename's extension. When saving in jpeg format, quality may be specified as an integer value from 1 to 100.

Note: the load method may change the specifications (in particular, the dimensions) of the bitmap.

objectName load variable varName ?-format formatName?
objectName save variable varName ?-format formatName? ?-quality quality?

Load an image from the binary data in variable varName or store and image into a variable named varName. These methods behave exactly as would the load file and save file methods, except

  • they use data from memory (variables) instead of files;
  • the image format cannot be infered from a filename extension.

These methods allow, for instance, to store images in a database or send images over a network connection.