用C语言对BMP文件进行读取
loadbmp.h
#ifndef _LOADBMP_H_
#define _LOADBMP_H_
typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef unsigned long DWORD;
typedef struct {
/* BITMAPFILEHEADER*/
BYTE bfType[2];
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} BMPFILEHEAD;
#define FILEHEADSIZE 14
/* windows style*/
typedef struct {
/* BITMAPINFOHEADER*/
DWORD BiSize;
DWORD BiWidth;
DWORD BiHeight;
WORD BiPlanes;
WORD BiBitCount;
DWORD BiCompression;
DWORD BiSizeImage;
DWORD BiXpelsPerMeter;
DWORD BiYpelsPerMeter;
DWORD BiClrUsed;
DWORD BiClrImportant;
} BMPINFOHEAD;
#define INFOHEADSIZE 40
typedef struct _BMP {
BMPINFOHEAD info;
unsigned char *rgba;
unsigned char *yuy2;
unsigned char *yv12;
} BMP, *PBMP;