ConvertFromDIB Function

Sometimes you need to specify the parameters of IplImage into which you convert the DIB image, rather than preserving the original DIB parameters. For example, you might want to get an IplImage with 16-bit unsigned data. To perform such conversion tasks, call the function iplConvertFromDIB() as shown in this code example.

To run the example from the command line, type:
>create -t6 -fimages\g256.bmp
(-f specifies the image file name).

The source:

void create_convert_dib( const char* fname )
{
   BITMAPINFOHEADER* bmphdr = ipLoad( fname );
   if( bmphdr ) {
      IplImage* img = iplCreateImageHeader(
         3,                    // number of channels
         0,                    // alpha channel
         IPL_DEPTH_8U,         // data of byte type 
         "RGB", "BGR",         // color model and channel seq
         IPL_DATA_ORDER_PIXEL, // channel arrangement
         IPL_ORIGIN_TL,        // top left orientation
         IPL_ALIGN_DWORD,      // 4-bytes alignment
         bmphdr->biWidth, bmphdr->biHeight, NULL, // ROI
         NULL, NULL, NULL );   // no mask, ID, not tiled

      if( img ) {
         iplConvertFromDIB( bmphdr, img );
         ipView( img, fname, is_modal );
         iplDeallocate( img, IPL_IMAGE_ALL );
      }
      free( bmphdr );
   }
   else {
      TRACE0( "Problem reading the BMP file" );
   }
}

* Legal Information © 1998-2000, Intel Corporation