WriteJPEGFile Method

NI Vision for Visual Basic

WriteJPEGFile Method

Syntax

CWIMAQVision.WriteJPEGFile SourceImage, Path [, JPEGFileOptions = 750]

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 JPEG format.

Remarks

Use this method with U8 and RGB32 images.

This method uses lossy compression even if you set the quality to 1,000.

Parameters

SourceImage As CWIMAQImage

The image to write to a file.

Path As String

The name of the file.

JPEGFileOptions As Variant

[Optional] Options to use when writing the file. Set this parameter to a numerical value that represents the quality of the image. As quality increases, the method uses less lossy compression. Acceptable values range from 0 to 1,000 with 750 as the default. You can also change the quality of the image by setting this parameter to a CWIMAQJPEGFileOptions object.

This parameter has a default value of 750.

Example

Dim Filename1 As String
Dim Filename2 As String
Dim Filename3 As String
Dim JpegOptions As New CWIMAQJPEGFileOptions

'Write an image in Viewer1 to a JPEG file using the default quality without using the 'CWIMAQJPEGFileOptions object
'The name of the file is in Filename1
CWIMAQVision1.WriteJPEGFile CWIMAQViewer1.Image, Filename1

'Write an image in Viewer1 to a JPEG file with a quality of 300 without using the 'CWIMAQJPEGFileOptions object
'The name of the file is in Filename2
CWIMAQVision1.WriteJPEGFile CWIMAQViewer1.Image, Filename2, 300

'Write an image in Viewer1 to a JPEG file with a quality of 300 using the 
'CWIMAQJPEGFileOptions object. 
'The name of the file is in Filename3
JpegOptions.Quality = 300
CWIMAQVision1.WriteJPEGFile CWIMAQViewer1.Image, Filename3, JpegOptions

See Also

CWIMAQJPEGFileOptions

ReadImage

WriteImageAndVisionInfo

WriteBMPFile

WriteJPEG2000File

WritePNGFile

WriteTIFFFile