GetComponentData
Top  Previous  Next

Description

Returns the two-dimensional array of pixel values in the specified color component of the current frame.


Syntax


[VB]
Value=objActiveGeni.GetComponentData( Component )


[C/C++]
HRESULT GetComponentData( short Component, VARIANT* pArray );


Data Types
[VB]

Y: Integer
Component: Integer
Return value: Variant (SAFEARRAY)


Parameters
[C/C++]

Component [in]  
The index of the selected color component. Must be one of the following values:  
0 - returns the luminance data  
1 - returns the red component data  
2 - returns the green component data  
3 - returns the blue component data  
pArray [out,retval]  
Pointer to the SAFEARRAY containing the pixel values in the frame  


Return Values


S_OK  
Success  
E_FAIL  
Failure.  
E_INVALIDARG  
Invalid input argument.  


Example


This VB example grabs a frame, retrieves its green component and displays the value of the specified element of the array.

Dim
 pix 
as Long

ActiveGeni1.Grab
DataArray=ActiveGeni1.GetComponentData(1)
x=16
y=32
pix=DataArray(x,y)
if
 pix < 0 
then

pix=65535-pix
endif


 

Remarks


The array returned by GetComponentData has the dimensions 0 to SizeX - 1, 0 to SizeY - 1. The type of data in the array depends on the format of the video acquired. For the 24-bit video the method will return an array of bytes. If the video is of the high-bit depth, the array will contain integer (word) values.

Note that modifying elements of the array will not change actual pixel values in the frame buffer. The image data in the array are stored in the standard order from top to bottom, therefore the first element of the array is first pixel of the top line of the image. This is opposite to the order of rows in the array returned by GetImageData.

If the video has a grayscale format, the Component parameter will have no effect and the output array will contain the luminance data.

For integer (word) type of data you can receive negative numbers if pixel values exceed 32767. In C and C# you can convert signed integers to unsigned ones by using data casting. To get rid of negative values in VB and Delphi, subtract them from 65535 (see the example above).

Note that in C/C++ applications it is required to call SafeArrayDestroy() to delete the SAFEARRAY returned by GetComponentData..