Wednesday, June 28, 2006

Crazy DWORD aligned dibs

I've a mental block on calculating dword aligned widths for DIB's - just noticed this nugget in the MSDN docs

biSizeImage :

Calculating the size of a bitmap is not difficult:

biSizeImage = ((((biWidth * biBitCount) + 31) &
~31) >> 3) * biHeight:

The crazy roundoffs and shifts account for the bitmap being DWORD-aligned at the end of every scanline.
I love it when the docs reflect my reality

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home