#ifndef BITMAP_HEADER_FILE #define BITMAP_HEADER_FILE #include #include //note that the requirement for file byte ordering is for little endian, so this program //will have to be modified to handle big endian architectures class CBitMap{ class BITMAPFILEHEADER { // size start stdvalue purpose unsigned short bfType; // 2 1 19778 must always be set to 'BM' to declare that this is a .bmp-file. unsigned int bfSize; // 4 3 ?? specifies the size of the file in bytes. unsigned short bfReserved1; // 2 7 0 must always be set to zero. unsigned short bfReserved2; // 2 9 0 must always be set to zero. unsigned int bfOffBits; // 4 11 62 specifies the offset from the beginning of the file to the bitmap data. public: BITMAPFILEHEADER(){ bfType = 19778;//'BM' bfSize = 0; bfReserved1 = 0; bfReserved2 = 0; bfOffBits = 62; }; void Dump(FILE *fout){//must be opened in binary mode! fwrite(&bfType, 1, 2, fout); fwrite(&bfSize, 1, 4, fout); fwrite(&bfReserved1, 1, 2, fout); fwrite(&bfReserved2, 1, 2, fout); fwrite(&bfOffBits, 1, 4, fout); }; unsigned int GetOutputSize(){return 14;}; void SetSize(unsigned int size){bfSize = size;}; // void SetOffset(unsigned int offset){bfOffBits = offset;}; }; class BITMAPINFOHEADER { // start size stdvalue purpose unsigned int biSize; // 15 4 40 specifies the size of the BITMAPINFOHEADER structure, in bytes. unsigned int biWidth; // 19 4 100 specifies the width of the image, in pixels. unsigned int biHeight; // 23 4 100 specifies the height of the image, in pixels. unsigned short biPlanes; // 27 2 1 specifies the number of planes of the target device, must be set to zero. unsigned short biBitCount; // 29 2 8 specifies the number of bits per pixel. unsigned int biCompression; // 31 4 0 Specifies the type of compression, usually set to zero (no compression). unsigned int biSizeImage; // 35 4 0 specifies the size of the image data, in bytes. If there is no compression, it is valid to set this member to zero. unsigned int biXPelsPerMeter; // 39 4 0 specifies the the horizontal pixels per meter on the designated targer device, usually set to zero. unsigned int biYPelsPerMeter; // 43 4 0 specifies the the vertical pixels per meter on the designated targer device, usually set to zero. unsigned int biClrUsed; // 47 4 0 specifies the number of colors used in the bitmap, if set to zero the number of colors is calculated using the biBitCount member. unsigned int biClrImportant; // 51 4 0 specifies the number of color that are 'important' for the bitmap, if set to zero, all colors are important. public: BITMAPINFOHEADER(){ biSize = 40; biWidth = 0; biHeight = 0; biPlanes = 1; biBitCount = 1; biCompression = 0; biSizeImage = 0; biXPelsPerMeter = 0; biYPelsPerMeter = 0; biClrUsed = 0; biClrImportant = 0; }; void Dump(FILE *fout){//must be opened in binary mode! fwrite(&biSize, 1, 4, fout); fwrite(&biWidth, 1, 4, fout); fwrite(&biHeight, 1, 4, fout); fwrite(&biPlanes, 1, 2, fout); fwrite(&biBitCount, 1, 2, fout); fwrite(&biCompression, 1, 4, fout); fwrite(&biSizeImage, 1, 4, fout); fwrite(&biXPelsPerMeter, 1, 4, fout); fwrite(&biYPelsPerMeter, 1, 4, fout); fwrite(&biClrUsed, 1, 4, fout); fwrite(&biClrImportant, 1, 4, fout); }; unsigned int GetOutputSize(){return 40;}; void SetWidth(unsigned int width){biWidth = width;}; void SetHeight(unsigned int height){biHeight = height;}; }; class RGBQUAD { unsigned char rgbReserved; public: unsigned char rgbBlue, rgbGreen, rgbRed; RGBQUAD(){ rgbBlue=rgbGreen=rgbRed=rgbReserved=0; }; void Dump(FILE *fout){//must be opened in binary mode! fwrite(&rgbBlue, 1, 1, fout); fwrite(&rgbGreen, 1, 1, fout); fwrite(&rgbRed, 1, 1, fout); fwrite(&rgbReserved, 1, 1, fout); }; unsigned int GetOutputSize(){return 4;}; }; unsigned int height, width, intWidth; unsigned char *data[16]; BITMAPFILEHEADER bmfh; BITMAPINFOHEADER bmh; RGBQUAD rgbLetters, rgbBackground; public: ~CBitMap(); CBitMap(const std::string &number); void Dump(FILE *fout);//must be opened in binary mode! }; #endif //BITMAP_HEADER_FILE