| 发表于:2007-02-20 21:37:233楼 得分:0 |
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <sys/stat.h> #define exit_err 1 #define exit_nor 0 #define com_err -1 #define com_nor 0 #define ret_err com_err #define ret_nor com_nor /* #pragma pack(1) */ /* typedef unsigned short uint; typedef int dword; typedef short word; typedef int long; typedef unsigned char byte; */ typedef unsigned int uint; typedef long dword; typedef int word; typedef long long; typedef unsigned char byte; /* bmp file head */ typedef struct tagbitmapfileheader { uint bftype; /* identifier 'bm ' */ dword bfsize; /* file size: complete file size in bytes */ uint bfreserved1; /* reserved for later use */ uint bfreserved2; /* reserved for later use */ dword bfoffbits; /* bitmap data offset: offset from beginning of file to the beginning of the bitmap data */ }bitmapfileheader; /* */ typedef struct tagbitmapinfoheader { dword bisize; /* bitmap header size */ long biwidth; /* horizontal width of bitmap in pixels */ long biheight; /* vertical height of bitmap in pixels */ word biplanes; /* number of planes in this bitmap ,const 1 */ word bibitcount; /* 1 - monochrome bitmap, 4 - 16 color bitmap, 8 - 256 color bitmap, 16 - 16bit(high color) bitmap, 24 - 24bit(true color)bitmap, 32 - 32bit(true color)bitmap */ dword bicompression; /* compression specifications. the following values are possible: 1 - rle 8bit/pixel,2 - rle 4bit/pixel */ dword bisizeimage; /* size of the bitmap data in butes.this number must be rounded to the next 4 byte boundary */ long bixpelspermeter; /* horizontal resolution */ long biypelspermeter; /* vertical resolution */ dword biclrused; /* number of colors used by this bitmap. */ dword biclrimportant; /* important colors: number of important colors. this number will be equal to the number of colors when every color is important */ }bitmapinfoheader; /* rgb */ typedef struct tagrgbquad { byte rgbblue; byte rgbgreen; byte rgbred; byte rgbreserved; }rgbquad; /* bmp info head */ typedef struct tagbitmapinfo { bitmapinfoheader bmiheader; rgbquad bmicolors[1]; }bitmapinfo; typedef struct tagbitmapdata { byte bicount; byte biindexvalue; }bitmapdata; /* output infomation of per pixel */ int outputpixelinfo(char* ); void printfileheader(bitmapfileheader *,file *); void printimageheader(bitmapinfoheader *,file *); void printimagedatainfo(rgbquad*,bitmapdata*,int,file *); void writedatatofile(char *,file *); | | |
|