what is the difference between bisizeimage , bisize and bfsize?

后端 未结 4 1207
失恋的感觉
失恋的感觉 2021-02-15 11:26

i\'m new to this field ,and i get confused between some terms!

bisizeimage, bisize and bfsize!

please i need a s

4条回答
  •  别跟我提以往
    2021-02-15 11:47

    @Roman Abashin's answer has a slight but important error. biSize is not the combined size of both headers.

    biSize is the size of the BITMAPINFOHEADER only. It is 40 bytes.

    biSize = 40
    

    The combined size of both headers is actually bfOffBits (you can think of the "Off" as referring to the offset of the actual bitmap from the beginning of the headers - remember, the bitmap comes straight after the headers).

    bfOffBits = 54
    

    Therefore all the following are correct formulas for bfSize:

    bfSize = biSizeImage + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER)
    bfSize = biSizeImage + sizeof(BITMAPFILEHEADER) + biSize
    bfSize = biSizeImage + 14                       + 40
    bfSize = biSizeImage + 54
    bfSize = biSizeImage + bfOffbits
    

    And @Roman Abashin's formula for biSizeImage, the size of the actual bitmap, is correct for a 24-bit bitmap.

    Confusingly, biSize, bfOffBits, bfSize and biSizeImage are all in units of bytes, whereas biWidth and biHeight are in units of pixels. The number of bytes per pixel is defined in the biBitCount part of the header. It is 3 bytes (or 24 bits) for a 24-bit bitmap.

    Note that bfOffBits's units are in bytes and biBitCount's units are in bits.

    More detail can be found on Microsoft's pages:

    Info on BITMAPFILEHEADER

    Info on BITMAPINFOHEADER

    Edit: I added some annotations to the bitmap overview below to clarify things even more![layout of bitmap and headers with size information Edit: Changed biSizeImage + 24 (etc etc) to + 14.

提交回复
热议问题