PixelFormatConvert
Top  Previous  Next

Description

Converts image data from a plain pixel format to the specified output format.

[C++]
unsigned int
 PixelFormatConvert(const charpSrc, char* pDstunsigned int width, unsigned int height, unsigned int inputFormat,
   
unsigned int outputFormat, unsigned int offsetX = 0, unsigned int offsetY = 0, unsigned int sizeX = width, unsigned int sizeY = height);

Parameters
[C/C++]
 
[in] const char* pSrc  
Pointer to the buffer containing the input image (top left pixel). The image data must be compatible with the pixel format specified by the inputFormat parameter.  
 
[in] const char* pDst  
String containing the name of the pixel format.  
 
[in] unsigned int width  
Integer value specifying the width of the image.  
 
[in] unsigned int height  
Integer value specifying the height of the image.  
 
[in] unsigned int inputFormat  
Integer value specifying the numerical ID of the input image format.  
 
[in] unsigned int outputFormat  
Integer value specifying the numerical ID of the output image format.  
 
[in] unsigned int offsetX  
Optional integer value specifying the horizontal offset of the upper left corner of the output image relative to the input one's.  
 
[in] unsigned int offsetY  
Optional integer value specifying the vertical offset of the upper left corner of the output image relative to the input one's.  
 
[in] unsigned int sizeX  
Optional integer value specifying the horizontal size of the output image. If zero or omitted, the right bottom corner of the output image will coincide with the input one's.  
 
[in] unsigned int sizeY  
Optional integer specifying the vertical size of the output image. If zero or omitted, the right bottom corner of the output image will coincide with the input one's.  
 
 
 
Return Values

S_OK  
Success  
E_FAIL  
Failure  
E_INVALIDARG  
Unsupported format ID  
 
 
Example
 
The following fragment of code converts the image data from RGB8 to BayerGB8 pixel format :

      char*
pOutputImage;
pOutputImage=new char*
[m_iWidth*m_iHeight];
int
inputFormat=GetFormatValueFromString("RGB8"
);
int
outputFormat=GetFormatValueFromString("BayerGB8"
);
      PixelFormatConvert (pInputImage, pOutputImage, m_iWidth, m_iHeight, inputFormat, outputFormat)

 
 
Remarks

This method converts an image data array presented in a plain pixel format into an output image data array encoded in a specified pixel format. It is typically used to reduce the streaming bandwidth by converting an input image into one of the packed pixel formats. For example, converting an input image of the RGB8 type into a raw Bayer8 image will reduce the size of each frames by a factor of 3.

The following input pixel formats are currently supported: Mono8, Mono16, RGB8, RGB16

The following output pixel formats are currently supported: Mono10Packed, Mono12Packed, Bayer**8, Bayer**10, Bayer**12, Bayer**10Packed, Bayer**12Packed.

Optional parameters offsetX, offsetY, sizeX and sizeY allow you to optimize the processing speed by performing the format conversion on a selected rectangular region in the input pixel array. If this parameters are used, they will define the size of the output image array.

For the list of pixel format values and associated number of bits per pixel refer to the table in SetPixelFormat.