1
// Image.hh for Fluxbox Window Manager
2
// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxbox@linuxmail.org)
4
// Image.hh for Blackbox - an X11 Window manager
5
// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
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:
14
// The above copyright notice and this permission notice shall be included in
15
// all copies or substantial portions of the Software.
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.
25
// $Id: Image.hh,v 1.5 2002/02/17 18:57:47 fluxgen Exp $
31
#include <X11/Xutil.h>
34
#include "BaseDisplay.hh"
45
unsigned char red, green, blue;
49
BColor(char r = 0, char g = 0, char b = 0)
50
{ red = r; green = g; blue = b; pixel = 0; allocated = 0; }
52
inline const int &isAllocated(void) const { return allocated; }
54
inline const unsigned char &getRed(void) const { return red; }
55
inline const unsigned char &getGreen(void) const { return green; }
56
inline const unsigned char &getBlue(void) const { return blue; }
58
inline const unsigned long &getPixel(void) const { return pixel; }
60
inline void setAllocated(int a) { allocated = a; }
61
inline void setRGB(char r, char g, char b) { red = r; green = g; blue = b; }
62
inline void setPixel(unsigned long p) { pixel = p; }
68
BColor color, colorTo, hiColor, loColor;
69
unsigned long texture;
72
BTexture(void) { texture = 0; }
74
inline BColor *getColor(void) { return &color; }
75
inline BColor *getColorTo(void) { return &colorTo; }
76
inline BColor *getHiColor(void) { return &hiColor; }
77
inline BColor *getLoColor(void) { return &loColor; }
79
inline const unsigned long &getTexture(void) const { return texture; }
81
inline void setTexture(unsigned long t) { texture = t; }
82
inline void addTexture(unsigned long t) { texture |= t; }
89
BImageControl *control;
98
int red_offset, green_offset, blue_offset, red_bits, green_bits, blue_bits,
100
unsigned char *red, *green, *blue, *red_table, *green_table, *blue_table;
101
unsigned int width, height, *xtable, *ytable;
105
Pixmap renderPixmap(void);
107
XImage *renderXImage(void);
112
void dgradient(void);
113
void egradient(void);
114
void hgradient(void);
115
void pgradient(void);
116
void rgradient(void);
117
void vgradient(void);
118
void cdgradient(void);
119
void pcgradient(void);
123
enum Bevel{FLAT=0x00002, SUNKEN=0x00004, RAISED=0x00008};
124
enum Textures{SOLID=0x00010, GRADIENT=0x00020};
129
CROSSDIAGONAL=0x00200,
137
BEVEL1=0x04000, BEVEL2=0x08000, // bevel types
138
INVERT=0x010000, //inverted image
139
PARENTRELATIVE=0x20000,
143
BImage(BImageControl *, unsigned int, unsigned int);
146
Pixmap render(BTexture *);
147
Pixmap render_solid(BTexture *);
148
Pixmap render_gradient(BTexture *);
152
class BImageControl : public TimeoutHandler {
155
BaseDisplay *basedisplay;
156
ScreenInfo *screeninfo;
165
int colors_per_channel, ncolors, screen_number, screen_depth,
166
bits_per_pixel, red_offset, green_offset, blue_offset,
167
red_bits, green_bits, blue_bits;
168
unsigned char red_color_table[256], green_color_table[256],
169
blue_color_table[256];
170
unsigned int *grad_xbuffer, *grad_ybuffer, grad_buffer_width,
172
unsigned long *sqrt_table, cache_max;
174
typedef struct Cache {
177
unsigned int count, width, height;
178
unsigned long pixel1, pixel2, texture;
181
typedef std::list<Cache *> CacheList;
187
Pixmap searchCache(unsigned int, unsigned int, unsigned long, BColor *,
192
BImageControl(BaseDisplay *, ScreenInfo *, Bool = False, int = 4,
193
unsigned long = 300000l, unsigned long = 200l);
194
virtual ~BImageControl(void);
196
inline BaseDisplay *getBaseDisplay(void) { return basedisplay; }
198
inline const Bool &doDither(void) { return dither; }
199
inline const Colormap &getColormap(void) const { return colormap; }
200
inline ScreenInfo *getScreenInfo(void) { return screeninfo; }
202
inline const Window &getDrawable(void) const { return window; }
204
inline Visual *getVisual(void) { return screeninfo->getVisual(); }
206
inline const int &getBitsPerPixel(void) const { return bits_per_pixel; }
207
inline const int &getDepth(void) const { return screen_depth; }
208
inline const int &getColorsPerChannel(void) const
209
{ return colors_per_channel; }
211
unsigned long getColor(const char *);
212
unsigned long getColor(const char *, unsigned char *, unsigned char *,
214
unsigned long getSqrt(unsigned int);
216
Pixmap renderImage(unsigned int, unsigned int, BTexture *);
218
void installRootColormap(void);
219
void removeImage(Pixmap);
220
void getColorTables(unsigned char **, unsigned char **, unsigned char **,
221
int *, int *, int *, int *, int *, int *);
222
void getXColorTable(XColor **, int *);
223
void getGradientBuffers(unsigned int, unsigned int,
224
unsigned int **, unsigned int **);
225
void setDither(Bool d) { dither = d; }
226
void setColorsPerChannel(int);
227
void parseTexture(BTexture *, char *);
228
void parseColor(BColor *, char * = 0);
230
virtual void timeout(void);