Read PNG File VI

Owning Palette: Graphics Formats VIs

Requires: Base Development System

Reads a PNG file and creates the data necessary to display the file in a picture control.

Use the Draw Flattened Pixmap VI to display the bitmap you acquire with this VI. Use the Unflatten Pixmap VI to work with the data as a 2D array.

Note  This VI can read 32-bit PNG files.

Details  

 Add to the block diagram  Find on the palette
path to PNG file specifies the path to and name of the PNG file to read. If you do not specify a path, LabVIEW displays a file dialog box so the user can navigate to the file.
error in describes error conditions that occur before this node runs. This input provides standard error in functionality.
Transparency Thresh incorporates alpha information for a 32-bit PNG image into the mask of the resulting image data. LabVIEW treats as opaque any alpha values equal to or greater than Transparency Thresh. LabVIEW treats all other alpha values as fully transparent. The value of Transparency Thresh must be between 0 and 255.
path specifies the path of the pixmap.
image data returns information about the image so you can use the Draw Flattened Pixmap VI to draw it as a picture.
image type is reserved for future use.
image depth specifies the color depth of the image, which is the number of bits to use to describe the color of each pixel in the image. Valid values include 1, 4, 8, 24, and 32 bits per pixel. image depth affects how LabVIEW interprets the values of image and colors.
image is an array of bytes that describes the color of each pixel in the image in raster order. The value of image depth determines how LabVIEW interprets the value of this output.

If image depth is 32, each pixel has three bytes to describe its color, and a fourth byte to describe transparency. The fourth byte is known as the 8-bit alpha channel. The first byte for each pixel describes the red value, the second byte describes the green value, and the third byte describes the blue value.

If image depth is 24, each pixel has three bytes to describe its color. When the image depth is 24, the behavior is similar to when image depth is 32. However, 24-bit images do not have an extra fourth byte to describe transparency.

If image depth is 8, each pixel has one byte to describe its color. The value of each bit corresponds to an element in colors, which stores 32-bit RGB values where the most significant byte is zero, followed in order by red, green, and blue values. Valid values include 0 through 255.

If image depth is 4, the behavior is similar to when image depth is 8 except valid values in image include 0 through 15.

If image depth is 1, any value of zero in image corresponds to element 0 in colors. All other values correspond to element 1 in colors.

The size of the array might be larger than expected due to padding.
mask is an array of bytes in which each bit describes mask information for a pixel. The first byte describes the first eight pixels, the second byte describes the next eight pixels, and so on. In 32-bit cases, the mask is always filled. For all other cases in this VI, the mask array is empty. If the array is empty, LabVIEW draws all pixels without transparency. If the array does not contain a bit for each pixel in the image, LabVIEW draws any pixels missing from the array without transparency.
colors is an array of RGB color values that correspond to the values in image. The value of image depth determines how LabVIEW interprets the value of this output.

If image depth is 32 or 24, LabVIEW ignores this output.

If image depth is 8, the array can have 256 elements.

If image depth is 4, the array can have 16 elements.

If image depth is 1, the array can have 2 elements.

If the array is empty for any depth other than 24 bits per pixel, the image is using the default LabVIEW color palette.
Rectangle is a cluster that contains coordinates that describe the bounding rectangle of the image. Horizontal coordinates increase to the right, and vertical coordinates increase to the bottom.
left is the horizontal coordinate of the left edge of the rectangle.
top is the vertical coordinate of the top edge of the rectangle.
right is the horizontal coordinate of the right edge of the rectangle.
bottom is the vertical coordinate of the bottom edge of the rectangle.
error out contains error information. This output provides standard error out functionality.

Read PNG File Details

You might receive an error if you attempt to read a PNG file whose image type is not supported in LabVIEW. LabVIEW supports JPG, BMP, and PNG images. To load a PNG image with an unsupported image type in LabVIEW, use a third-party graphics format converter to save the image as a standard file format that LabVIEW can load (JPG, BMP, or PNG).