www.pudn.com > BitmapExample.rar > picture.h
#include#include #include struct BMPFILEHEADER //定义BMP的file文件头 { unsigned short bftype; //2 unsigned long bfsize; //4 unsigned short bfReserved1;//2 unsigned short bfReserved2;//2 unsigned long bfoffBits;//4 }; struct BMPINFOHEADER//定义BMP的info文件头 { unsigned long biSize;//4 unsigned long biWidth;//4 unsigned long biHeight;//4 unsigned short biPlanes;//2 unsigned short biBitCount;//2 unsigned long biComprission;//4 unsigned long biSizeImage;//4 unsigned long biXPeIsPerMeter;//4 unsigned long biYPeIsperMeter;//4 unsigned long biClrUsed;//4 unsigned long biClrImportant;//4 }; class BMPfile { public: double *outRGB[3];//定义指针数组,分别存储RGB三个数组的首地址 BMPFILEHEADER bitmapfile; BMPINFOHEADER bitmapinfo; int width,height; bool loadBMP(char *filename); bool writeBMP(BMPfile n,char *filename); }; bool BMPfile::loadBMP(char *filename) { FILE *fp; int i,j; unsigned char temp; fp=fopen(filename,"rb"); if(fp==NULL) { cerr<<"open error!"< =0;i--)//把fp文件象素的rgb值分别读到3个数组中 { for(j=0;j =0;i--) //把rgb3个数组写到ft中 { for(j=0;j