WriteImage Method

NI Vision for Visual Basic

WriteImage Method

Syntax

CWIMAQVision.WriteImage SourceImage, Path, Format [, ColorPalette]

Return Type

Long

On success, this method returns 0. On failure, this method returns a negative number.

Purpose

Writes an image to a file.

Remarks

Use this method with all image types. The following table indicates the image types that each image file format supports.

File TypesImage Types
AIPDall image types
BMP, JPEG8-bit, RGB32
TIFF8-bit, 16-bit, RGB32, RGBU64
PNG8-bit, 16-bit, RGB32, RGBU64
JPEG20008-bit, 16-bit, RGB32, RGBU64

This method does not write overlay information, calibration information, pattern matching template information, or custom data to the file. To write this data, use CWIMAQVision.WriteImageAndVisionInfo.

Parameters

SourceImage As CWIMAQImage

The image to write to a file.

Path As String

The name of the file.

Format As CWIMAQFileFormats

The standard file format to create. If this value is cwimaqFileUnknown, the method creates a file with the BMP file format.

ColorPalette As Variant

[Optional] A CWIMAQPalette object that defines a color table to associate with 8-bit images. Do not provide this input to write a grayscale palette to the file.

Example

Private Sub Run_Click()
    Dim Filename As String
    
    'Write an image in Viewer1 to a JPEG file.
    'The name of the file is in Filename.
    CWIMAQVision1.WriteImage CWIMAQViewer1.Image, Filename, _
                            cwimaqFileJPEG, CWIMAQViewer1.Palette
End Sub

See Also

ReadImage

WriteImageAndVisionInfo

WriteBMPFile

WriteJPEGFile

WriteJPEG2000File

WritePNGFile

WriteTIFFFile