To convert a DIB image to the
IplImage
format, use the function
iplTranslateDib(),
as shown in this code example.
If the original DIB data for some reason could not be used in the
IplImage,
the function copies the image data and sets the variable
clone
to
true.
In this case, later you'll have to deallocate memory used for both
IplImage
data and the original DIB image data.
To run the example from the command line, type this command:
>create -t5 -fimages\g256.bmp
(-f
specifies the image file name).
The source:
void create_translate_dib( const char* fname ) { BITMAPINFOHEADER* bmphdr = ipLoad( fname ); if( bmphdr ) { int clone; IplImage* img = iplTranslateDIB( bmphdr, &clone ); if( img ) { ipView( img, fname, is_modal ); iplDeallocate( img, clone ? IPL_IMAGE_ALL : IPL_IMAGE_HEADER ); } free( bmphdr ); } else { TRACE0( "Problem reading the BMP file" ); } }
The ipLoad function used in this example can be found in the cookroom subdirectory of the tutorial.
* Legal Information © 1998-2000, Intel Corporation