Display an Image

NI IMAQ

Display an Image

Use the CWIMAQViewer control to display an image. Use the CWIMAQViewer.Attach method 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 Image property.

Use the following code to attach an image to the viewer:

Private Sub Start_Click()

CWIMAQ1.AcquisitionType = cwimaqAcquisitionContinuous

CWIMAQ1.Images.RemoveAll

CWIMAQ1.Images.Add 1

CWIMAQViewer1.Attach CWIMAQ1.Images(1)

CWIMAQ1.Start

End Sub

Private Sub Stop_Click()

CWIMAQ1.Stop

End Sub

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 the viewer. You can set the CWIMAQPalette.Type property to apply predefined color palettes. For example, if you need to display a binary image—an image containing particle regions with pixel values of 1 and a background region with pixel values of 0—set the Type property to cwimaqPaletteBinary. Refer to Chapter 2, Display, of the NI Vision Concepts Manual for more information about color palettes.

You also can set a default palette during design time using the Menu property page for the CWIMAQViewer control. You also can change the color palette during run-time by using the context menu on the viewer.