Reading a file, Converting an array to an image, Display an image – National Instruments IMAQTM User Manual
Page 23: Display an image -6

Chapter 2
Getting Measurement-Ready Images
IMAQ Vision for Visual Basic User Manual
2-6
ni.com
Private Sub Stop_Click()
CWIMAQ1.Stop
End Sub
Reading a File
Use the
CWIMAQVision.ReadImage
method to open and read data from
a file stored on the computer into the image reference. You can read from 
image files stored in several standard formats, such as BMP, TIFF, JPEG, 
PNG, and AIPD. In all cases, the software automatically converts the pixels 
it reads into the type of image you pass in.
Use the
CWIMAQVision.ReadImageAndVisionInfo
method to open an
image file containing additional information, such as calibration 
information, template information for pattern matching, or overlay 
information. For more information about pattern matching templates 
and overlays, refer to Chapter 5, 
Performing Machine Vision Tasks
.
You also can use the
CWIMAQVision.GetFileInformation
method
to retrieve image properties—image size, pixel depth, recommended image 
type, and calibration units—without actually reading all the image data.
Converting an Array to an Image
Use the
CWIMAQImage.ArrayToImage
method to convert an array to an
image. You also can use the
CWIMAQImage.ImageToArray
method to
convert an image to an array.
Display an Image
Display an image using the CWIMAQViewer control. Use
CWIMAQViewer.Attach
to attach the image you want the viewer
to display. When you attach an image to a viewer, the image automatically 
updates the viewer whenever an operation modifies the contents of the 
image. You can access the image attached to the viewer using the 
CWIMAQViewer.Image
property. Before you attach an image to the
viewer, the viewer already has an image attached by default. Therefore, the 
viewer has an image attached to it at all times. You can use the attached 
image as either a source image, destination image, or both using the 
CWIMAQViewer.Image
property.
You can use the
CWIMAQViewer.Palette
property to access the
CWIMAQPalette object associated with the viewer. Use the 
CWIMAQPalette object to programmatically apply a color palette to 
