ArrayToImage Method

NI Vision for Visual Basic

ArrayToImage Method

Syntax

CWIMAQImage.ArrayToImage Array

Purpose

Creates an image from an array.

Remarks

The Type property determines the resulting image type. For example, to create a color image from an input 2D array of integers, set the Type property to cwimaqImageTypeRGB32 and call ArrayToImage.

If the image type is not cwimaqImageTypeComplex or cwimaqImageTypeRGBU64, the input array is a 2D array of scalars.

If the image type is cwimaqImageTypeComplex, the input array is a 1D array of two elements. The first element is a 2D array containing the real plane, and the second element is a 2D array containing the imaginary plane. Both the arrays must have the same size.

If the image type is cwimaqImageTypeRGBU64, the input array is a 2D array of 1D arrays with 4 integer elements (the Red, Blue, Green, and Alpha channels of each pixel).

Parameters

Array As Variant

The source array of image data.

Example

Private Sub Run_Click()
    Const Size = 127
    Dim a(0 To Size, 0 To Size) As Long
    Dim i, j
    
    For i = 0 To Size
        For j = 0 To Size
            a(i, j) = i + j
        Next j
    Next i
    
    CWIMAQViewer1.Palette.Type = cwimaqPaletteRainbow
    CWIMAQViewer1.Image.ArrayToImage a
End Sub 

See Also

Type