コードを少し整理して、ファイルを分けた。あと、OS/2 のビットマップにも対応した。
実行例:
サンプルのファイルはここから拝借した。
cf. BMP ファイルフォーマット
takatoh@nightschool $ ./bmpinfo os-1.bmp File type = BM File size = 4232 bytes Data offset = 32 bytes Info header size = 12 bytes Width = 200 pixels Height = 150 pixels Planes = 1 Bit count = 1 bits/pixel takatoh@nightschool $ ./bmpinfo win-24.bmp File type = BM File size = 90054 bytes Data offset = 54 bytes Info header size = 40 bytes Width = 200 pixels Height = 150 pixels Planes = 1 Bit count = 24 bits/pixel Compression = 0 Size image = 90000 bytes X pixels per meter = 2835 Y pixels per meter = 2835 Color used = 0 colors takatoh@nightschool $ ./bmpinfo win-jpeg.bmp File type = BM File size = 4916 bytes Data offset = 54 bytes Info header size = 40 bytes Width = 200 pixels Height = 150 pixels Planes = 1 Bit count = 0 bits/pixel Compression = 4 Size image = 4862 bytes X pixels per meter = 0 Y pixels per meter = 0 Color used = 0 colors