WriteBMPFile Method

NI Vision for Visual Basic

WriteBMPFile Method

Syntax

CWIMAQVision.WriteBMPFile SourceImage, Path [, BMPFileOptions = False] [, 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 in BMP format.

Remarks

Use this method with U8 and RGB32 images.

Parameters

SourceImage As CWIMAQImage

The image to write to a file.

Path As String

The name of the file to write.

BMPFileOptions As Variant

[Optional] Options to use when writing the file. You can set this parameter to one of two different types of values. Set this parameter to True if you want to write a compressed BMP file. If you want to specify further options, set this parameter to a CWIMAQBMPFileOptions object.

This parameter has a default value of False.

ColorPalette As Variant

[Optional] A color table to associate with U8 images. The default is a grayscale palette.

If the color table has less than 256 elements, the function fills the remaining elements with grayscale values to increase the size of the color table to 256 elements.

Example

Dim Filename1 As String
Dim Filename2 As String
Dim Filename3 As String
Dim Filename4 As String
Dim BmpOptions As New CWIMAQBMPFileOptions

'Write an image in Viewer1 to an uncompressed BMP file
'The name of the file is in Filename1
CWIMAQVision1.WriteBMPFile CWIMAQViewer1.Image, Filename1

'Write an image in Viewer1 to a compressed BMP file
'The name of the file is in Filename2
CWIMAQVision1.WriteBMPFile CWIMAQViewer1.Image, Filename2, True

'Write an image in Viewer1 to an uncompressed BMP file with a color palette
'The name of the file is in Filename3
CWIMAQVision1.WriteBMPFile CWIMAQViewer1.Image, Filename3, BmpOptions, CWIMAQViewer1.Palette

'Write an image in Viewer1 to an compressed BMP file with the currently selected
'color palette on Viewer1
BmpOptions.Compress = True
CWIMAQVision1.WriteBMPFile CWIMAQViewer1.Image, Filename4, BmpOptions, CWIMAQViewer1.Palette

See Also

CWIMAQBMPFileOptions

ReadImage

WriteImageAndVisionInfo

WriteJPEGFile

WriteJPEG2000File

WritePNGFile

WriteTIFFFile