如何确定BMP图像的颜色深度和每个像素的位数?

问题描述:

我必须调用哪种神奇的方法来确定BMP图像的每个像素中有多少位,并确定其颜色代码格式(是灰度图像还是RGB图像)?

What manner of arcane magic must I invoke to determine how many bits are in each pixel of a BMP image, and also divine its color code format (whether it is a gray-scale image or an RGB image)?

位图像素的大小可以在1到32位之间变化.位图文件可以是灰度或彩色的,并且可以使用多种编码来获取颜色信息.查阅此Wikipedia文章以了解更多详细信息:

http://en.wikipedia.org/wiki/BMP_file_format [
Bitmap pixels can vary in size from 1 to 32 bits. Bitmap files can be grayscale or color and use several kinds of encoding for color information. Check out this Wikipedia article for more details:

http://en.wikipedia.org/wiki/BMP_file_format[^]