]> Dogcows Code - chaz/openbox/blob - otk/image.hh
new authors. this is how we dooo iiiit...
[chaz/openbox] / otk / image.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __image_hh
3 #define __image_hh
4
5 extern "C" {
6 #include <X11/Xlib.h>
7 #include <X11/Xutil.h>
8 }
9
10 #include <list>
11
12 #include "color.hh"
13 #include "screeninfo.hh"
14 #include "timer.hh"
15
16 namespace otk {
17
18 class ImageControl;
19 class Texture;
20 class ScreenInfo;
21
22 class Image {
23 private:
24 ImageControl *control;
25 bool interlaced;
26 XColor *colors;
27
28 Color from, to;
29 int red_offset, green_offset, blue_offset, red_bits, green_bits, blue_bits,
30 ncolors, cpc, cpccpc;
31 unsigned char *red, *green, *blue, *red_table, *green_table, *blue_table;
32 unsigned int width, height, *xtable, *ytable;
33
34 void TrueColorDither(unsigned int bit_depth, int bytes_per_line,
35 unsigned char *pixel_data);
36 void PseudoColorDither(int bytes_per_line, unsigned char *pixel_data);
37 #ifdef ORDEREDPSEUDO
38 void OrderedPseudoColorDither(int bytes_per_line, unsigned char *pixel_data);
39 #endif
40
41 Pixmap renderPixmap(void);
42 Pixmap render_solid(const Texture &texture);
43 Pixmap render_gradient(const Texture &texture);
44
45 XImage *renderXImage(void);
46
47 void invert(void);
48 void bevel1(void);
49 void bevel2(void);
50 void border(const Texture &texture);
51 void dgradient(void);
52 void egradient(void);
53 void hgradient(void);
54 void pgradient(void);
55 void rgradient(void);
56 void vgradient(void);
57 void cdgradient(void);
58 void pcgradient(void);
59
60
61 public:
62 Image(ImageControl *c, int w, int h);
63 ~Image(void);
64
65 Pixmap render(const Texture &texture);
66 };
67
68
69 class ImageControl {
70 public:
71 #ifndef SWIG
72 struct CachedImage {
73 Pixmap pixmap;
74
75 unsigned int count, width, height;
76 unsigned long pixel1, pixel2, texture;
77 };
78 #endif
79
80 ImageControl(const otk::ScreenInfo *scrn,
81 bool _dither= False, int _cpc = 4,
82 unsigned long cache_timeout = 300000l,
83 unsigned long cmax = 200l);
84 virtual ~ImageControl(void);
85
86 inline bool doDither(void) { return dither; }
87
88 inline const ScreenInfo* getScreenInfo() const { return screeninfo; }
89
90 inline Window getDrawable(void) const { return window; }
91
92 inline Visual *getVisual(void) { return screeninfo->visual(); }
93
94 inline int getBitsPerPixel(void) const { return bits_per_pixel; }
95 inline int getDepth(void) const { return screen_depth; }
96 inline int getColorsPerChannel(void) const
97 { return colors_per_channel; }
98
99 unsigned long getSqrt(unsigned int x);
100
101 Pixmap renderImage(unsigned int width, unsigned int height,
102 const Texture &texture);
103
104 void installRootColormap(void);
105 void removeImage(Pixmap pixmap);
106 void getColorTables(unsigned char **rmt, unsigned char **gmt,
107 unsigned char **bmt,
108 int *roff, int *goff, int *boff,
109 int *rbit, int *gbit, int *bbit);
110 void getXColorTable(XColor **c, int *n);
111 void getGradientBuffers(unsigned int w, unsigned int h,
112 unsigned int **xbuf, unsigned int **ybuf);
113 void setDither(bool d) { dither = d; }
114 void setColorsPerChannel(int cpc);
115
116 static void timeout(ImageControl *t);
117
118 private:
119 bool dither;
120 const ScreenInfo *screeninfo;
121 Timer *timer;
122
123 Colormap colormap;
124
125 Window window;
126 XColor *colors;
127 int colors_per_channel, ncolors, screen_number, screen_depth,
128 bits_per_pixel, red_offset, green_offset, blue_offset,
129 red_bits, green_bits, blue_bits;
130 unsigned char red_color_table[256], green_color_table[256],
131 blue_color_table[256];
132 unsigned int *grad_xbuffer, *grad_ybuffer, grad_buffer_width,
133 grad_buffer_height;
134 unsigned long *sqrt_table, cache_max;
135
136 typedef std::list<CachedImage> CacheContainer;
137 CacheContainer cache;
138
139 Pixmap searchCache(const unsigned int width, const unsigned int height,
140 const unsigned long texture,
141 const Color &c1, const Color &c2);
142 };
143
144 }
145
146 #endif // __image_hh
147
This page took 0.040279 seconds and 4 git commands to generate.