在24位bmp中,像素被存储为BGR,每种颜色只占用1个字节。可读的
for(i=0;i<heigh*width;i++){ // foreach pixel
image[i][2] = getc(streamIn); // use BMP 24bit with no alpha channel
image[i][1] = getc(streamIn); // BMP uses BGR but we want RGB, grab byte-by-byte
image[i][0] = getc(streamIn); // reverse-order array indexing fixes RGB issue...
printf("pixel %d : [%d,%d,%d]\n",i+1,image[i][0],image[i][1],image[i][2]);
}但是在256色bmp中,每个像素只占用1个字节,那么如何读取此图像并获得所有像素值?
发布于 2013-02-06 10:00:17
256有一个查找表来映射字节值。
http://en.wikipedia.org/wiki/BMP_file_format
谷歌一些代码:(未测试)
http://paulbourke.net/dataformats/bmp/parse.c
https://stackoverflow.com/questions/14720349
复制相似问题