Top-down vs. Bottom-up dibs
If you are new to graphics programming, you might should CT that a bitmap wocould be arranged in memory so that the top row of the image appeared at the start of the buffer, followed by the next row, and so forth. however, this is not necessarily the case. in Windows, device-independent bitmaps (dibs) can be placed in memory in two different orientations, bottom-up and top-down.
InBottom-upDib, the image buffer starts withBottomRow of pixels, followed by the next row up, and so forth. The top row of the image is the last row in the buffer. Therefore, the first byte in memory isBottom-leftPixel of the image. In GDI, all Dibs are bottom-up. The following diwing shows the physical layout of a bottom-up DiB.
In a bottom-up bitmap, the image buffer starts from the pixels of the underlying row, and the top row of the image is the last row of the image buffer. Therefore, the first byte of memory points to the pixels in the lower left corner of the image. In GDI, all device-independent bitmaps are of the bottom-up type, indicating the physical order of a bottom-up bitmap.
In a top-down Dib, the order of the rows is reversed.TopRow of the image is the first row in memory, followed by the next row down. the bottom row of the image is the last row in the buffer. with a top-down Dib, the first byte in memory isTop-leftPixel of the image. DirectDraw uses top-down dibs. The following diwing shows the physical layout of a top-down Dib:
In a top-down bitmap, the order of rows is the opposite.
For RGB dibs, the image orientation is indicated byBiheightMember ofBitmapinfoheaderStructure. IfBiheightIs positive, the image is bottom-up. IfBiheightIs negative, the image is top-down.
Dibs In YUV formats are always top-down, and the sign ofBiheightMember is ignored. decoders shoshould offer YUV formats with positiveBiheight, But they shoshould also accept YUV formats with negativeBiheightAnd ignore the sign.
Also, any Dib type that usesFourccInBicompressionMember, shocould express itsBiheightAs a positive number no matter what its orientation is, sinceFourccItself identifies a compression scheme whose image orientation shoshould be understood by any compatible filter.
Differences between top-down and bottom-up bitmaps