Debian Codegraph @

extern/agg24-svn/include/platform/win32/agg_win32_bmp.h

raw
1 //----------------------------------------------------------------------------
2 // Anti-Grain Geometry - Version 2.4
3 // Copyright (C) 2002-2005 Maxim Shemanarev (http://www.antigrain.com)
4 //
5 // Permission to copy, use, modify, sell and distribute this software
6 // is granted provided this copyright notice appears in all copies.
7 // This software is provided "as is" without express or implied
8 // warranty, and with no claim as to its suitability for any purpose.
9 //
10 //----------------------------------------------------------------------------
11 // Contact: [email protected]
12 // [email protected]
13 // http://www.antigrain.com
14 //----------------------------------------------------------------------------
15 //
16 // class pixel_map
17 //
18 //----------------------------------------------------------------------------
19 #ifndef AGG_WIN32_BMP_INCLUDED
20 #define AGG_WIN32_BMP_INCLUDED
21
22
23 #include <windows.h>
24 #include <stdio.h>
25
26
27 namespace agg
28 {
29 enum org_e
30 {
31 org_mono8 = 8,
32 org_color16 = 16,
33 org_color24 = 24,
34 org_color32 = 32,
35 org_color48 = 48,
36 org_color64 = 64
37 };
38
39 class pixel_map
40 {
41 public:
42 ~pixel_map();
43 pixel_map();
44
45 public:
46 void destroy();
47 void create(unsigned width,
48 unsigned height,
49 org_e org,
50 unsigned clear_val=256);
51 HBITMAP create_dib_section(HDC h_dc,
52 unsigned width,
53 unsigned height,
54 org_e org,
55 unsigned clear_val=256);
56
57 void clear(unsigned clear_val=256);
58 void attach_to_bmp(BITMAPINFO* bmp);
59 BITMAPINFO* bitmap_info() { return m_bmp; }
60 bool load_from_bmp(FILE* fd);
61 bool save_as_bmp(FILE* fd) const;
62 bool load_from_bmp(const char* filename);
63 bool save_as_bmp(const char* filename) const;
64
65 void draw(HDC h_dc,
66 const RECT* device_rect=0,
67 const RECT* bmp_rect=0) const;
68 void draw(HDC h_dc, int x, int y, double scale=1.0) const;
69
70 void blend(HDC h_dc,
71 const RECT* device_rect=0,
72 const RECT* bmp_rect=0) const;
73 void blend(HDC h_dc, int x, int y, double scale=1.0) const;
74
75
76 unsigned char* buf();
77 unsigned width() const;
78 unsigned height() const;
79 int stride() const;
80 unsigned bpp() const { return m_bpp; }
81
82 //Auxiliary static functions
83 static unsigned calc_full_size(BITMAPINFO *bmp);
84 static unsigned calc_header_size(BITMAPINFO *bmp);
85 static unsigned calc_palette_size(unsigned clr_used,
86 unsigned bits_per_pixel);
87 static unsigned calc_palette_size(BITMAPINFO *bmp);
88 static unsigned char* calc_img_ptr(BITMAPINFO *bmp);
89 static BITMAPINFO* create_bitmap_info(unsigned width,
90 unsigned height,
91 unsigned bits_per_pixel);
92 static void create_gray_scale_palette(BITMAPINFO *bmp);
93 static unsigned calc_row_len(unsigned width, unsigned bits_per_pixel);
94
95 private:
96 pixel_map(const pixel_map&);
97 const pixel_map& operator = (const pixel_map&);
98 void create_from_bmp(BITMAPINFO *bmp);
99
100 HBITMAP create_dib_section_from_args(HDC h_dc,
101 unsigned width,
102 unsigned height,
103 unsigned bits_per_pixel);
104
105 private:
106 BITMAPINFO* m_bmp;
107 unsigned char* m_buf;
108 unsigned m_bpp;
109 bool m_is_internal;
110 unsigned m_img_size;
111 unsigned m_full_size;
112 };
113
114 }
115
116
117 #endif