aboutsummaryrefslogtreecommitdiff
path: root/src/Image.hh
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2002-11-30 19:57:54 (GMT)
committerfluxgen <fluxgen>2002-11-30 19:57:54 (GMT)
commitda452116d38cc8854914e90d384042f703742d52 (patch)
treec3f484ee21be123c5b622508f76f2c038f57fa40 /src/Image.hh
parent7efd955b432332c74e765e5eb4ee6fc7e165001d (diff)
downloadfluxbox_pavel-da452116d38cc8854914e90d384042f703742d52.zip
fluxbox_pavel-da452116d38cc8854914e90d384042f703742d52.tar.bz2
changed name to ImageControl
Diffstat (limited to 'src/Image.hh')
-rw-r--r--src/Image.hh187
1 files changed, 0 insertions, 187 deletions
diff --git a/src/Image.hh b/src/Image.hh
deleted file mode 100644
index 8ee126c..0000000
--- a/src/Image.hh
+++ /dev/null
@@ -1,187 +0,0 @@
1// Image.hh for Fluxbox Window Manager
2// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxbox@linuxmail.org)
3//
4// Image.hh for Blackbox - an X11 Window manager
5// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
6//
7// Permission is hereby granted, free of charge, to any person obtaining a
8// copy of this software and associated documentation files (the "Software"),
9// to deal in the Software without restriction, including without limitation
10// the rights to use, copy, modify, merge, publish, distribute, sublicense,
11// and/or sell copies of the Software, and to permit persons to whom the
12// Software is furnished to do so, subject to the following conditions:
13//
14// The above copyright notice and this permission notice shall be included in
15// all copies or substantial portions of the Software.
16//
17// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE.
24
25// $Id: Image.hh,v 1.17 2002/11/27 22:03:00 fluxgen Exp $
26
27#ifndef IMAGE_HH
28#define IMAGE_HH
29
30
31#include "BaseDisplay.hh"
32#include "Color.hh"
33#include "Texture.hh"
34#include "Timer.hh"
35
36#include <X11/Xlib.h>
37#include <X11/Xutil.h>
38#include <list>
39
40class BImageControl;
41
42/**
43 Renders to pixmap
44*/
45class BImage {
46public:
47 BImage(BImageControl *ic, unsigned int width, unsigned int height);
48 ~BImage();
49 /// render to pixmap
50 Pixmap render(const FbTk::Texture &src_texture);
51 /// render solid texture to pixmap
52 Pixmap renderSolid(const FbTk::Texture &src_texture);
53 /// render gradient texture to pixmap
54 Pixmap renderGradient(const FbTk::Texture &src_texture);
55
56protected:
57 /**
58 Render to pixmap
59 @return rendered pixmap
60 */
61 Pixmap renderPixmap();
62 /**
63 Render to XImage
64 @returns allocated and rendered XImage, user is responsible to deallocate
65 */
66 XImage *renderXImage();
67 /**
68 @name render functions
69 */
70 //@{
71 void invert();
72 void bevel1();
73 void bevel2();
74 void dgradient();
75 void egradient();
76 void hgradient();
77 void pgradient();
78 void rgradient();
79 void vgradient();
80 void cdgradient();
81 void pcgradient();
82 //@}
83
84private:
85 BImageControl *control;
86 bool interlaced;
87
88 XColor *colors; // color table
89
90 const FbTk::Color *from, *to;
91 int red_offset, green_offset, blue_offset, red_bits, green_bits, blue_bits,
92 ncolors, cpc, cpccpc;
93 unsigned char *red, *green, *blue, *red_table, *green_table, *blue_table;
94 unsigned int width, height, *xtable, *ytable;
95};
96
97/**
98 Holds screen info and color tables
99*/
100class BImageControl : public TimeoutHandler {
101public:
102 BImageControl(const ScreenInfo *screen, bool dither = false, int colors_per_channel = 4,
103 unsigned long cache_timeout = 300000l, unsigned long cache_max = 200l);
104 virtual ~BImageControl();
105
106 inline bool doDither() const { return m_dither; }
107 inline Colormap colormap() const { return m_colormap; }
108 inline const ScreenInfo *getScreenInfo() const { return screeninfo; }
109 inline Window drawable() const { return window; }
110
111 /// @return visual of screen
112 inline Visual *visual() { return screeninfo->getVisual(); }
113 /// @return Bits per pixel of screen
114 inline int bitsPerPixel() const { return bits_per_pixel; }
115 /// @return depth of screen
116 inline int depth() const { return screen_depth; }
117 inline int colorsPerChannel() const { return colors_per_channel; }
118
119 unsigned long getSqrt(unsigned int val);
120 /**
121 Render to pixmap
122 @param width width of pixmap
123 @param height height of pixmap
124 @param src_texture texture type to render
125 @return pixmap of the rendered image, on failure None
126 */
127 Pixmap renderImage(unsigned int width, unsigned int height,
128 const FbTk::Texture &src_texture);
129
130 void installRootColormap();
131 void removeImage(Pixmap thepix);
132 void colorTables(unsigned char **, unsigned char **, unsigned char **,
133 int *, int *, int *, int *, int *, int *);
134 void getXColorTable(XColor **, int *);
135 void getGradientBuffers(unsigned int, unsigned int,
136 unsigned int **, unsigned int **);
137 void setDither(bool d) { m_dither = d; }
138 void setColorsPerChannel(int cpc);
139
140 virtual void timeout();
141
142protected:
143 /**
144 Search cache for a specific pixmap
145 @return None if no cache was found
146 */
147 Pixmap searchCache(unsigned int width, unsigned int height, unsigned long texture_type,
148 const FbTk::Color &color, const FbTk::Color &color_to);
149
150private:
151 bool m_dither;
152 const ScreenInfo *screeninfo;
153
154 BTimer m_timer;
155
156 Colormap m_colormap;
157
158 Window window;
159 XColor *colors; ///< color table
160
161 int colors_per_channel, ncolors, screen_number, screen_depth,
162 bits_per_pixel, red_offset, green_offset, blue_offset,
163 red_bits, green_bits, blue_bits;
164
165 unsigned char red_color_table[256], green_color_table[256],
166 blue_color_table[256];
167 unsigned int *grad_xbuffer, *grad_ybuffer, grad_buffer_width,
168 grad_buffer_height;
169
170 static unsigned long *sqrt_table; /// sqrt lookup table
171
172 typedef struct Cache {
173 Pixmap pixmap;
174
175 unsigned int count, width, height;
176 unsigned long pixel1, pixel2, texture;
177 } Cache;
178
179 unsigned long cache_max;
180 typedef std::list<Cache *> CacheList;
181
182 CacheList cache;
183};
184
185
186#endif // IMAGE_HH
187