// CSE 373 // University of Washington // Header file for manipulating .bmp files // Homework 5 // 5/2000 // see end of file for function prototypes ////////////////////////////////////////////// //// Definitions below taken from //// Microsoft Windows header files //// for bitmaps. ////////////////////////////////////////////// //typedef struct RGBTRIPLE_ { // unsigned char r, g, b; //} RGBTRIPLE; typedef unsigned char BYTE; typedef unsigned short WORD; typedef unsigned long DWORD; typedef unsigned long LONG; typedef struct tagRGBQUAD { // rgbq BYTE rgbBlue; BYTE rgbGreen; BYTE rgbRed; BYTE rgbReserved; } RGBQUAD; #define FAR typedef long FXPT2DOT30; typedef struct tagCIEXYZ { FXPT2DOT30 ciexyzX; FXPT2DOT30 ciexyzY; FXPT2DOT30 ciexyzZ; } CIEXYZ; typedef CIEXYZ FAR* LPCIEXYZ; typedef struct tagCIEXYZTRIPLE { CIEXYZ ciexyzRed; CIEXYZ ciexyzGreen; CIEXYZ ciexyzBlue; } CIEXYZTRIPLE; typedef CIEXYZTRIPLE FAR* LPCIEXYZTRIPLE; typedef struct tagBITMAPFILEHEADER { // bmfh WORD bfType; DWORD bfSize; WORD bfReserved1; WORD bfReserved2; DWORD bfOffBits; } BITMAPFILEHEADER; typedef struct tagBITMAPINFOHEADER{ // bmih DWORD biSize; LONG biWidth; LONG biHeight; WORD biPlanes; WORD biBitCount; DWORD biCompression; DWORD biSizeImage; LONG biXPelsPerMeter; LONG biYPelsPerMeter; DWORD biClrUsed; DWORD biClrImportant; } BITMAPINFOHEADER; typedef struct tagBITMAPINFO { // bmi BITMAPINFOHEADER bmiHeader; RGBQUAD bmiColors[1]; } BITMAPINFO; typedef struct { DWORD bV5Size; LONG bV5Width; LONG bV5Height; WORD bV5Planes; WORD bV5BitCount; DWORD bV5Compression; DWORD bV5SizeImage; LONG bV5XPelsPerMeter; LONG bV5YPelsPerMeter; DWORD bV5ClrUsed; DWORD bV5ClrImportant; DWORD bV5RedMask; DWORD bV5GreenMask; DWORD bV5BlueMask; DWORD bV5AlphaMask; DWORD bV5CSType; CIEXYZTRIPLE bV5Endpoints; DWORD bV5GammaRed; DWORD bV5GammaGreen; DWORD bV5GammaBlue; DWORD bV5Intent; DWORD bV5ProfileData; DWORD bV5ProfileSize; DWORD bV5Reserved; } BITMAPV5HEADER, FAR *LPBITMAPV5HEADER, *PBITMAPV5HEADER; #define BI_JPEG 4L //////////////////////// // hw5 stuff // expected image size const int rows = 256; const int cols = 256; const int palsize = 256; // palette size // print 1,2,3,4 chars to output file // (you shouldn't need to use these) void out(FILE *f, unsigned char *pch); void out2(FILE *f, unsigned char *pch); void out3(FILE *f, unsigned char *pch); void out4(FILE *f, unsigned char *pch); // read in a bitmap file (assume 256 colors, 256x256 image) // echo header info to output file void readbmp(FILE *f, RGBQUAD palette[palsize], unsigned char pixels[rows][cols]); // write pixel data to output file void writebmp(FILE *f, unsigned char pixels[rows][cols]);