Pixel Format Conversion
In order to use software pixel format conversion, the user must first create a MultiCam surface (refer to How to Create and Delete Surfaces ) then configure its parameters.
The following code example shows how to convert a BAYER8 surface into an RGB24 surface. We assume that surfaceIn is the MCHANDLE
to an acquired surface to convert which is in the PROCESSING state.
// Get surfaceIn properties INT32 width, height, pitchIn; McGetParamInt(surfaceIn, MC_SurfaceSizeX, &width); McGetParamInt(surfaceIn, MC_SurfaceSizeY, &height); McGetParamInt(surfaceIn, MC_SurfacePitch, &pitchIn); // Create surfaceOut and allocate buffer MCHANDLE surfaceOut = 0; McCreate(MC_DEFAULT_SURFACE_HANDLE, &surfaceOut); INT32 pitchOut = pitchIn * 3; INT32 sizeOut = pitchOut * height; unsigned char *buffer = new unsigned char[sizeOut]; // Configure surfaceOut to hold the RGB24 converted data McSetParamPtr(surfaceOut, MC_SurfaceAddr + 0, buffer); McSetParamInt(surfaceOut, MC_SurfaceSize + 0, sizeOut); McSetParamInt(surfaceOut, MC_SurfacePitch + 0, pitchOut); McSetParamInt(surfaceOut, MC_SurfaceSizeX, width); McSetParamInt(surfaceOut, MC_SurfaceSizeY, height); McSetParamInt(surfaceOut, MC_SurfaceColorFormat, MC_ColorFormat_RGB24); McSetParamInt(surfaceOut, MC_SurfaceColorComponentsOrder, MC_ColorComponentsOrder_BGR); // Convert surfaceIn into surfaceOut McConvertSurface(surfaceIn, surfaceOut);
Later, in cleanup code:
// Delete surfaceOut and associated buffer when no longer used if (surfaceOut != 0) McDelete(surfaceOut); if (buffer != NULL) delete[] buffer;