|
1 /* |
|
2 * GraphLCD graphics library |
|
3 * |
|
4 * bitmap.h - cBitmap class |
|
5 * |
|
6 * based on graphlcd plugin 0.1.1 for the Video Disc Recorder |
|
7 * (c) 2001-2004 Carsten Siebholz <c.siebholz AT t-online.de> |
|
8 * |
|
9 * This file is released under the GNU General Public License. Refer |
|
10 * to the COPYING file distributed with this package. |
|
11 * |
|
12 * (c) 2004 Andreas Regel <andreas.regel AT powarman.de> |
|
13 */ |
|
14 |
|
15 #ifndef _GLCDGRAPHICS_BITMAP_H_ |
|
16 #define _GLCDGRAPHICS_BITMAP_H_ |
|
17 |
|
18 #include <string> |
|
19 |
|
20 namespace GLCD |
|
21 { |
|
22 |
|
23 enum eColor |
|
24 { |
|
25 clrBlack, |
|
26 clrWhite |
|
27 }; |
|
28 |
|
29 class cFont; |
|
30 |
|
31 class cBitmap |
|
32 { |
|
33 protected: |
|
34 int width; |
|
35 int height; |
|
36 int lineSize; |
|
37 unsigned char * bitmap; |
|
38 |
|
39 public: |
|
40 cBitmap(int width, int height, unsigned char * data = NULL); |
|
41 cBitmap(const cBitmap & b); |
|
42 ~cBitmap(); |
|
43 |
|
44 int Width() const { return width; } |
|
45 int Height() const { return height; } |
|
46 int LineSize() const { return lineSize; } |
|
47 const unsigned char * Data() const { return bitmap; } |
|
48 |
|
49 void Clear(); |
|
50 void Invert(); |
|
51 void DrawPixel(int x, int y, eColor color); |
|
52 void Draw8Pixels(int x, int y, unsigned char pixels, eColor color); |
|
53 void DrawLine(int x1, int y1, int x2, int y2, eColor color); |
|
54 void DrawHLine(int x1, int y, int x2, eColor color); |
|
55 void DrawVLine(int x, int y1, int y2, eColor color); |
|
56 void DrawRectangle(int x1, int y1, int x2, int y2, eColor color, bool filled); |
|
57 void DrawRoundRectangle(int x1, int y1, int x2, int y2, eColor color, bool filled, int size); |
|
58 void DrawEllipse(int x1, int y1, int x2, int y2, eColor color, bool filled, int quadrants); |
|
59 void DrawSlope(int x1, int y1, int x2, int y2, eColor color, int type); |
|
60 void DrawBitmap(int x, int y, const cBitmap & bitmap, eColor color); |
|
61 int DrawText(int x, int y, int xmax, const std::string & text, const cFont * font, |
|
62 eColor color = clrBlack, bool proportional = true, int skipPixels = 0); |
|
63 int DrawCharacter(int x, int y, int xmax, char c, const cFont * font, |
|
64 eColor color = clrBlack, int skipPixels = 0); |
|
65 |
|
66 cBitmap * SubBitmap(int x1, int y1, int x2, int y2) const; |
|
67 unsigned char GetPixel(int x, int y) const; |
|
68 |
|
69 bool LoadPBM(const std::string & fileName); |
|
70 void SavePBM(const std::string & fileName); |
|
71 }; |
|
72 |
|
73 } // end of namespace |
|
74 |
|
75 #endif |