00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __BITMAP_INCLUDED
00019 #define __BITMAP_INCLUDED
00020
00021 #include <string>
00022
00023 #include "common/global.h"
00024
00025 using namespace std;
00026
00027
00028
00029
00030
00031
00032 typedef struct tBMPFileHeader
00033 {
00034 int2 iType;
00035 uint4 uSize;
00036 int2 iReserved1;
00037 int2 iReserved2;
00038 uint2 uOffbits;
00039 };
00040
00041 typedef struct tBMPInfo
00042 {
00043 uint2 uSize;
00044 int2 uWidth;
00045 int2 iPlanes;
00046 int2 uHeight;
00047 int2 iBitCount;
00048 uint2 uCompression;
00049 uint2 uImageSize;
00050 int2 iXpelspermeter;
00051 int2 iYpelspermeter;
00052 int2 uColorsUsed;
00053 int2 uColorsImportant;
00054 };
00055
00056 struct tBMPHeader
00057 {
00058 tBMPFileHeader File;
00059 tBMPInfo Info;
00060 };
00061
00062
00063
00064
00075 class TBitmap
00076 {
00077 public:
00078 struct tRGBColor
00079 {
00080 byte red;
00081 byte green;
00082 byte blue;
00083 };
00084
00085 TBitmap();
00086 TBitmap( string sFileName );
00087 ~TBitmap();
00088
00089
00090
00091 void Clear();
00092 void ConvertToGrayScale();
00093 bool Empty() const;
00094 uint2 GetHeight() const;
00095 tRGBColor GetPixel(int2 x, int2 y) const;
00096 uint2 GetWidth() const;
00097 void Invert();
00098 bool Load(string sFileName);
00099 bool LoadBMP(string sFileName);
00100 void SetAllPixels(tRGBColor Color);
00101 void SetAllPixels(uint2 uGray=0);
00102
00103 private:
00104 tRGBColor** Bitmap;
00105 uint2 uWidth, uHeight;
00106
00107 bool AllocateMemoryForBitmap();
00108 void DeleteBitmap();
00109 void Reset();
00110 void WriteBMPHeaderToLog(const tBMPHeader Header) const;
00111 };
00112
00113
00114
00115
00116
00117 #endif // __BITMAP_INCLUDED
00118
00119
00120
00121
00122