Differences between top-down and bottom-up bitmaps

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.