What do I need to do to convert DIB to BMP?

What do I need to do to convert DIB to BMP?

+1


source to share


3 answers


The bitmap header types documentation is found at http://msdn.microsoft.com/en-us/library/dd183386%28VS.85%29.aspx .

In the code, the difference between the bmp file and the dib memory view is the presence of the BITMAPFILEHEADER structure at the beginning ( http://msdn.microsoft.com/en-us/library/dd183374(v=vs.85).aspx ). So the literal answer for converting bmp to dib is to skip the BITMAPFILEHEADER and start at the DIB header memory address (just after the bitmap file header), which is always 14 bytes from the start of the bmp memory address.



BITMAPFILEHEADER *bmp = ...;
char * bmpBytes = reinterpret_cast<char *>(bmp);
void * myDib = (void *)bmpBytes + BMP_HEADER_LENGTH; /* (14 bytes) */
/* cast and do something with myDib */
...

      

NTN

+2


source


Check API GdipCreateBitmapFromGdiDib



Example: http://www.codeproject.com/KB/GDI-plus/DIBtoBitmap.aspx

+1


source


The Imagemagick function will do this (and many other transformations) for you on the command line. Free, open source, available on all major platforms. It's a great piece of software that should be in any toolbox.

+1


source







All Articles