Graphical Data Types

Overview

On Linux colormaps can be “grabbed” from a grabber object and be written to the framebuffer at a chosen position.

Bitmaps

A bitmap is a data structure that allows to store bilevel (B/W) images in a compact form in memory. Each line (row) is stored occupying one bit per pixel and is filled up to a byte boundary at the end.

A 0 represents a white, a 1 a black pixel. The origin of a bitmap (0,0) is in the upper left. Addressing generally follows a row/column scheme (row as the first, column as the second parameter).

The bit value interpretation follows the XBM (X Bitmap) file format, where 0 represents a white and 1 a black pixel: XBM image data consists of a line of pixel values stored in a static array. Because a single bit represents each pixel (0 for white or 1 for black), each byte in the array contains the information for eight pixels, with the upper left pixel in the bitmap represented by the low bit of the first byte in the array. If the image width does not match a multiple of 8, the extra bits in the last byte of each row are ignored.

Reading and writing bitmap to/from the following graphic formats on disk is supported: TIFF G4, TIFF G4 multi-page, XBM and PNG.

The internal structure of a bitmap has the following fields:

Field Description
h the actual height of the bitmap
w the actual width of the bitmap
orow the original row position of that bitmap in another bitmap, -1 if undefined
ocol the original column position of that bitmap in another bitmap, -1 if undefined
xres the X resolution in DPI (floating point value), -1 if undefined
yres the Y resolution in DPI (floating point value), -1 if undefined

The contents of these fields are accessible / settable using the appropriate procedures. Printing a bitmap shows the actual contents of these fields.

Example:

> (define a
(bitmap-create 100 100))
a
> a
#<bitmap orow:-1 ocol:-1 xres:-1 yres:-1 h:100 w:100>
>

Greymaps

A greymap is a data structure that allows the storage of greylevel images in memory. One byte (256 greylevels, 8 bit depth) is allocated for each pixel.

A value of 0 represents black, 255 a white pixel and all grey levels are in between. The origin of a greymap (0,0) is in the upper left. Generally, the same row/column addressing scheme as being used for bitmaps is used.

Reading greymaps from any PNG file is supported (performing a suitable conversion if necessary), greymaps may be written in greylevel format either interlaced or not.

The internal structure of a greymap has the following fields (similar to a bitmap):

Field Description
h the actual height of the greymap
w the actual width of the greymap
orow the original row position of that greymap in another greymap, -1 if undefined
ocol the original column position of that greymap in another greymap, -1 if undefined
xres the X resolution in DPI (floating point value), -1 if undefined
yres the Y resolution in DPI (floating point value), -1 if undefined

The contents of these fields are accessible / settable using the appropriate procedures. Printing a greymap shows the actual contents of these fields.

Example:

> (define a (greymap-create 100 100))
a
> a
#<greymap orow:-1 ocol:-1 xres:-1 yres:-1 h:100 w:100>
>

Graymaps (16 bit)

A graymap is a data structure that allows the storage of greylevel images in memory, similar to a greymap but with 16 bit depth per pixel.

Note the subtle spelling difference: A grAymap is this data type with 16 bits per pixel, where a grEymap holds 8 bits per pixel.

Colormaps

A colormap is a data structure that allows the storage of color images in memory. Three bytes representing RGB values are representing one pixel.

0 represents the lowest intensity of a RGB color channel, and 255 the highest intensity.

The origin of a colormap (0,0) is in the upper left. Generally the same row/column addressing scheme as for the other two graphical data types is used.

The internal structure of a colormap has the following fields (as with bitmaps and greymaps):

Field Description
h the actual height of the colormap
w the actual width of the colormap
orow the original row position of that colormap in another colormap, -1 if undefined
ocol the original column position of that colormap in another colormap, -1 if undefined
xres the X resolution in DPI (floating point value), -1 if undefined
yres the Y resolution in DPI (floating point value), -1 if undefined

The contents of these fields are accessible / settable using the appropriate procedures. Printing a colormap shows the actual contents of these fields.

Example:

> (define a (colormap-create 200 200))
a
> a
#<colormap orow:-1 ocol:-1 xres:-1 yres:-1 h:200 w:200>
>

Grabber Objects

A grabber object represents a connection to a camera or another imaging source capable to deliver image frames (RGB colormaps).

Example:

> (define g (grabber-create))
g
> g
#<grabber device:/dev/video0 width:1280 height:720 format:MJPG fd:3>
> (grabber? g)
#t
>

Framebuffer Objects

A framebuffer object represents an RGB display area and is capable to receive images (bitmaps, greymaps or colormaps) in order to display them. Framebuffer objects have an invisible graphical cursor which define the display position for the next image.

Example:

> (define g (grabber-create))
g
> (define f (framebuffer-create))
f
> (framebuffer-display! f (grabber-grab g))
ok
>