Flattened pixmap

From LabVIEW Wiki
Jump to: navigation, search

The flattened pixmap is a structure used to load and save images to and from disk.


A flattened pixmap is a cluster consisting of 6 elements:

  1. image type is reserved for a future use. It should be 0. It is a U16.
  2. image depth describes the bit depth of the colors in the image. It's value affects how the image and colors elements are interpreted. Valid values are: 1, 4, 8, 24, and 32. It is a U8.
  3. image is an one-dimensional array of U8s describing the color of each pixel. The meaning of this array changes depending on the value of image depth:
    • For 1-, 4-, and 8-bit images m x n pixels in size, image is m*n elements long. Each pixel value contains an index into the colors array, which contains the actual color for the pixel.
    • For 24-bit images m x n pixels in size, image is 3*m*n elements long. The elements are the red, green, and blue components for each pixel, in order.
    • For 32-bit images m x n pixels in size, image is 4*m*n elements long. This structure is the same as for 24-bit images, but includes a transparency element.
  4. Mask is a one-dimensional array of U8s that bitwise sets the transparency of a pixel. A bit-value of 0 makes the pixel transparent. The mask array handles each row of the image in order, padding with zeros to the end of an even-numbered byte if necessary.
  5. colors is a one-dimensional array of U32s listing the color palette for an indexed (1-, 4-, or 8-bit) image. The array will be up to 2, 16 or 256 elements long for 1-, 4-, and 8-bit images, respectively. For 24- or 32-bit images the array will be empty.
  6. Rectangle is a cluster describing the size of the image. It contains four elements as I16s: left, top, right, and bottom. Usually, left and top are zero, so right and bottom are the width and height of the image, respectively.

Image files

The Read BMP File, Read JPG File, and Read PNG File VIs read an existing image file from disk and return a flattened pixmap. Similarly, Write BMP File, Write JPG File, and Write PNG File accept a flattened pixmap and save it as the appropriate image file.


The Unflatten Pixmap VI can be used to convert a flattened pixmap to a two-dimensional array of colors (24- and 32-bit images) or an array of indexes into a colors palette.

A flattened pixmap is converted to the LabVIEW picture data type by using the Draw Flattened Pixmap VI.