version 0.3.17
[fms.git] / include / freenet / captcha / freeimage / bitmap.h
1 #ifndef _freeimage_bitmap_\r
2 #define _freeimage_bitmap_\r
3 \r
4 #include <FreeImage.h>\r
5 \r
6 #include <string>\r
7 #include <vector>\r
8 \r
9 namespace FreeImage\r
10 {\r
11 \r
12 class Bitmap\r
13 {\r
14 public:\r
15         Bitmap();\r
16         Bitmap(const Bitmap &bmp);\r
17         Bitmap(const std::string &typestr, const std::string &filename);\r
18         Bitmap(FIBITMAP *bmp);\r
19         Bitmap(const int width, const int height, const int bpp);\r
20         ~Bitmap();\r
21 \r
22         const bool Create(const int width, const int height, const int bpp);\r
23 \r
24         inline const unsigned int Height() const        { return m_bmp ? FreeImage_GetHeight(m_bmp) : 0 ; }\r
25         inline const unsigned int Width() const         { return m_bmp ? FreeImage_GetWidth(m_bmp) : 0 ; }\r
26         inline const unsigned int BPP() const           { return m_bmp ? FreeImage_GetBPP(m_bmp) : 0 ; }\r
27         void ConvertBPP(const int bpp);\r
28 \r
29         void Clear(const RGBQUAD color);\r
30         void ClearTransparent();\r
31 \r
32         const bool Save(const std::string &filename) const;\r
33         const bool SaveToMemory(const std::string &typestr, std::vector<unsigned char> &data) const;\r
34         const bool Load(const std::string &typestr, const std::string &filename);\r
35         const bool LoadFromMemory(const std::string &typestr, std::vector<unsigned char> &data);\r
36 \r
37         void SetTransparent();\r
38         \r
39         void PutPixel(const int x, const int y, RGBQUAD color);\r
40         RGBQUAD GetPixel(const int x, const int y) const;\r
41         const int GetPixelIndex(const int x, const int y) const;\r
42         void Line(const int x1, const int y1, const int x2, const int y2, const RGBQUAD color);\r
43         void FastLine(const int x1, const int y1, const int x2, const int y2, const RGBQUAD color);\r
44         //void Arc(const int cx, const int cy, const int r, const float start, const float end, const RGBQUAD color);\r
45         void Rect(const int x1, const int y1, const int w, const int h, const bool filled, const RGBQUAD color);\r
46         void Rotate(const double angle, const int shiftx, const int shifty, const int originx, const int originy);\r
47         void HorizontalOffset(const int y, const double shift);\r
48         void VerticalOffset(const int x, const double shift);\r
49 \r
50         void Blit(const Bitmap &bmp, const int destx, const int desty, const int sourcex, const int sourcey, const int w, const int h, const int alpha);\r
51         void BlitTrans(const Bitmap &bmp, const int destx, const int desty, const int sourcex, const int sourcey, const int w, const int h);\r
52 \r
53         Bitmap &operator=(const Bitmap &rhs);\r
54 \r
55 private:\r
56         void Destroy();\r
57         void AALine(const int x1, const int y1, const int x2, const int y2, const RGBQUAD color);\r
58         double LineFunction(const double slopex, const double slopey, const int startx, const int starty, const double testx, const double texty);\r
59 \r
60         FIBITMAP *m_bmp;\r
61 \r
62 };\r
63 \r
64 }       // namespace\r
65 \r
66 #endif  // _freeimage_bitmap_\r