CVTTOBM

The CVTTOBM function converts a byte array in which each byte represents one pixel into a " bitmap byte array" in which each bit represents one pixel. This is useful when creating bitmap labels for buttons created with the WIDGET_BUTTON function.

Bitmap byte arrays are monochrome; by default, CVTTOBM converts pixels that are darker than the median value to black and pixels that are lighter than the median value to white. You can supply a different threshold value via the THRESHOLD keyword.

Most of IDL's image file format reading functions (READ_BMP, READ_PICT, etc.) return a byte array which must be converted before use as a button label. Note that there is one exception to this rule; the READ_X11_BITMAP routine returns a bitmap byte array that needs no conversion before use.

This routine is written in the IDL language. Its source code can be found in the file cvttobm.pro in the lib subdirectory of the IDL distribution.

Calling Sequence

Result = CVTTOBM( Array )

Arguments

Array

A 2-dimensional pixel array, one byte per pixel.

Keywords

THRESHOLD

A byte value (or an integer value between 0 and 255) to be used as a threshold value when determining if a particular pixel is black or white. If THRESHOLD is not specified, the threshold is calculated to be the average of the input array.

Example

The following example creates a bitmap button label from a byte array:

image = BYTSCL(DIST(100)) ; Create a byte array.

base = WIDGET_BASE(/COLUMN) ; Create a widget base.

button = WIDGET_BUTTON(base, VALUE = CVTTOBM(image))
; Use CVTTOBM to create a bitmap byte array for a button label.

WIDGET_CONTROL, base, /REALIZE ;; Realize the widget.