imaqWriteFile

NI Vision for LabWindows/CVI Function

imaqWriteFile

Usage

int imaqWriteFile(const Image* image, const char* fileName, const RGBValue* colorTable);

Purpose

This function writes an image to a file. In addition to writing pixel information, the function writes calibration information if the file format supports calibration information. The following list details file formats that support calibration information.

  • AIPD Files—Stores any type of CalibrationUnit but stores only one step size. The function stores the xStep from the supplied image as the step size.
  • BMP and JPEG2000 Files—Stores a CalibrationUnit of IMAQ_METER only. If you pass an image to this function that has a CalibrationUnit other than IMAQ_METER, the function converts xStep and yStep from the supplied unit into meters.
  • JPEG and TIFF Files—Stores a CalibrationUnit of IMAQ_CENTIMETER or IMAQ_INCH only. If you pass an image to this function that has a metric CalibrationUnit other than IMAQ_CENTIMETER, the function converts xStep and yStep from the supplied unit into centimeters. If you pass an image to this function that has an English CalibrationUnit other than IMAQ_INCH, the function converts xStep and yStep from the supplied unit into inches.
  • PNG Files—Stores any type of CalibrationUnit.

To write specific file types with more flexibility, use imaqWriteBMPFile(), imaqWriteJPEGFile(), imaqWriteJPEG2000File, imaqWriteTIFFFile(), or imaqWritePNGFile2().

The file type is determined by the extension, as follows:

Extension File Type
.aipd or .apd AIPD
.bmp BMP
.jpg or .jpeg JPEG
.jp2 JPEG2000
.png PNG
.tif or .tiff TIFF

The following are the supported image types for each file type:

File Types Image Types
AIPD all image types
BMP, JPEG 8-bit, RGB
PNG, TIFF, JPEG2000 8-bit, 16-bit, RGB, RGBU64

Image Types Supported

IMAQ_IMAGE_U8, IMAQ_IMAGE_U16, IMAQ_IMAGE_I16, IMAQ_IMAGE_SGL, IMAQ_IMAGE_COMPLEX, IMAQ_IMAGE_RGB, IMAQ_IMAGE_HSL, IMAQ_IMAGE_RGB_U64

Parameters

Name

Type

Description

image const Image* The image to write to a file. The function cannot write all image types to all file types.
fileName const char* The name of the file. This parameter is required and cannot be NULL.
colorTable const RGBValue* An optional color table to associate with 8-bit images. If you provide a color table, the table must have 256 elements. Set this parameter to NULL to write a grayscale palette to the image.

Return Value

Type

Description

int On success, this function returns a non-zero value. On failure, this function returns 0. To get extended error information, call imaqGetLastError().