00001 #ifndef _BMPFile_H 00002 #define _BMPFile_H 00003 00004 00005 00024 #ifdef _WINDOWS_USED_ 00025 00026 extern "C" 00027 { 00028 #include <windows.h> 00029 } 00030 00031 00032 00033 #define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4) 00034 #define BMP_HEADERSIZE (3 * 2 + 4 * 12) 00035 #define BMP_BYTESPERLINE (width, bits) ((((width) * (bits) + 31) / 32) * 4) 00036 #define BMP_PIXELSIZE(width, height, bits) (((((width) * (bits) + 31) / 32) * 4) * height) 00037 00038 #endif // #ifdef _WINDOWS_USED_ 00039 00040 class BMPFile 00041 { 00042 public: 00043 00044 // operations 00045 00046 BMPFile(); 00047 00048 #ifdef _WINDOWS_USED_ 00049 00050 BYTE * loadBMP(const char* fileName, int *width, int *height, int* channels); 00051 00052 void saveBMP(const char* fileName, // output path 00053 BYTE * buf, // RGB buffer 00054 int width, // size 00055 int height); 00056 00057 void saveBMP(const char* fileName, // output path 00058 BYTE * colormappedbuffer, // one BYTE per pixel colomapped image 00059 int width, 00060 int height, 00061 int bitsperpixel, // 1, 4, 8 00062 int colors, // number of colors (number of RGBQUADs) 00063 RGBQUAD *colormap); // array of RGBQUADs 00064 00065 public: 00066 // parameters 00067 DWORD m_bytesRead; 00068 00069 #endif // #ifdef _WINDOWS_USED_ 00070 00071 }; 00072 00073 #endif