Specifications
Intel
®
Image Processing Library Reference Manual
4-14
4
Example 4-2 Allocating and Deallocating the Image Data
int example42( void ) {
IplImage img;
char colorModel[4] = "RGB";
char channelSeq[4] = "BGR";
img.nSize = sizeof( IplImage );
img.nChannels = 3; // number of channels
img.alphaChannel = 0; // no alpha channel
img.depth = IPL_DEPTH_16U; // data of ushort type
img.dataOrder = IPL_DATA_ORDER_PIXEL;
img.origin = IPL_ORIGIN_TL; // top left
img.align = IPL_ALIGN_QWORD; // align
img.width = 100;
img.height = 100;
img.roi = NULL; // no ROI
img.maskROI = NULL; // no mask ROI
img.tileInfo = NULL; // not tiled
// The following fields will be set by the function
img.widthStep = 0;
img.imageSize = 0;
img.imageData = NULL;
img.imageDataOrigin = NULL;
*((int*)img.colorModel) =* *((int*)colorModel);
*((int*)img.channelSeq) =* *((int*)channelSeq);
iplAllocateImage( &img, 0, 0 ); // allocate image data
if( NULL == img.imageData ) return 0; // check result
iplDeallocate( &img, IPL_IMAGE_DATA );
// deallocate image data only
return Ipl_StsOk == iplGetErrStatus();
}