GetImageArray
Top  Previous  Next

Description

This COM method returns the two-dimensional array of pixel values in the specified image.


Syntax


[VB]
Value=objImageWarp.GetImageArray ( Inp )


[C/C++]
HRESULT GetImageArray( int Inp, VARIANT* pArray );


Data Types
[VB]

Inp: Long
Return value
: Variant (SAFEARRAY)


Parameters
[C/C++]

Inp [in]  
Index of the image  
pArray [out,retval]  
Pointer to the SAFEARRAY containing the pixel values in the frame  


Return Values


S_OK  
Success  
E_FAIL  
Failure.  


Example


This VB code grabs an image, retrieves its content and displays the value of the specified element of the array.

IW.Call("grabIm(1)")
While IW.Status <> SS_IDLE
Wend
DataArray=IW.GetImageArray (1)
x=16
y=32
MsgBox DataArray(x,y)
IW.ReleaseImageArray (1)
 

Remarks


The data in the array is arranged from top to the bottom of the image, left to right. The type of data and dimensions of the array returned by GetImageArray method depends on the format of the image, as specified in the following table:



Format
Data type
Dimensions

8-bit monochrome
Byte
0 to SizeX -1, 0 to SizeY- 1
16-bit gray monochrome
Integer (word)
0 to SizeX -1, 0 to SizeY - 1
32-bit gray monochrome
Long (double word)
0 to SizeX -1, 0 to SizeY - 1
float
float (32-bit)
0 to SizeX -1, 0 to SizeY - 1
complex
float (32-bit)
0 to SizeX * 2 -1, 0 to SizeY - 1
24-bit RGB
Byte
0 to SizeX * 3 - 1, 0 to SizeY - 1
32-bit RGB
Byte
0 to SizeX * 4 - 1, 0 to SizeY - 1
48-bit RGB
Integer (word)
0 to SizeX * 3 - 1, 0 to SizeY - 1


Please note that the client application is responsible for freeing the memory occupied by the data array. In the example above Visual Basic does it automatically. If you write in C/C++, make sure to use the SafeArrayDestroy function from Win32 API after each call to GetImageArray method.