开发者

Why is the bpp information at 0x1C in this .bmp image wrong?

Why is the bpp information at 0x1C in this .bmp image wrong?

Address 1D indicates the image is eight bits per pixel, but it isn't, each pixel is represented by 3 bytes (24 bits).

At first, I thought photoshop did this in error, but I found that this format was used for a开发者_C百科ll greyscale images.

Instead of using four bytes for pixel, why don't .bmp images use a value from 0 - FF to describe the greyscale value of each pixel?

EDIT: I was able to answer my own question about the file structure

from Wikipedia

The 8-bit per pixel (8bpp) format supports 256 distinct colors and stores 1 pixel per 1 byte.

Each byte is an index into a table of up to 256 colors. This Color Table is in 32bpp 8.8.8.0.8 RGBAX format.

The color table shown in the hex editor is four bytes per pixel.

Far below that is the actual pixel array, which is 8 bits per pixel.

Why is the bpp information at 0x1C in this .bmp image wrong?

I figured that out by a calculation, the image is 64 x 64, 4096 pixels.

The pixel array starts at 436, and ends at 1437. In decimal, the difference between those two numbers is 4097, so the pixel array is exactly one byte per pixel.

I am still curious as to why a color table is necessary for a greyscale image, though


I am still curious as to why a color table is necessary for a greyscale image, though

It looks like bmp files have no special greyscale mode. So you cannot set in the header the format is greyscale, so you need the color table to define the colors you use. Even if all colors are greyscale.

If you look at the .png format, you can define that you are using a greyscale image, so you don't need a color table there. (but it would also be possible to use a color table to create a grayscale image).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜