]>
Dogcows Code - chaz/openbox/blob - src/Image.h
2 // Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
3 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
27 #include <X11/Xutil.h>
38 #define BImage_Flat (1l<<1)
39 #define BImage_Sunken (1l<<2)
40 #define BImage_Raised (1l<<3)
43 #define BImage_Solid (1l<<4)
44 #define BImage_Gradient (1l<<5)
47 #define BImage_Horizontal (1l<<6)
48 #define BImage_Vertical (1l<<7)
49 #define BImage_Diagonal (1l<<8)
50 #define BImage_CrossDiagonal (1l<<9)
51 #define BImage_Rectangle (1l<<10)
52 #define BImage_Pyramid (1l<<11)
53 #define BImage_PipeCross (1l<<12)
54 #define BImage_Elliptic (1l<<13)
57 #define BImage_Bevel1 (1l<<14)
58 #define BImage_Bevel2 (1l<<15)
61 #define BImage_Invert (1l<<16)
63 // parent relative image
64 #define BImage_ParentRelative (1l<<17)
67 // fake interlaced image
68 # define BImage_Interlaced (1l<<18)
74 unsigned char red
, green
, blue
;
78 BColor(char r
= 0, char g
= 0, char b
= 0)
79 { red
= r
; green
= g
; blue
= b
; pixel
= 0; allocated
= 0; }
81 inline const int &isAllocated(void) const { return allocated
; }
83 inline const unsigned char &getRed(void) const { return red
; }
84 inline const unsigned char &getGreen(void) const { return green
; }
85 inline const unsigned char &getBlue(void) const { return blue
; }
87 inline const unsigned long &getPixel(void) const { return pixel
; }
89 inline void setAllocated(int a
) { allocated
= a
; }
90 inline void setRGB(char r
, char g
, char b
) { red
= r
; green
= g
; blue
= b
; }
91 inline void setPixel(unsigned long p
) { pixel
= p
; }
97 BColor color
, colorTo
, hiColor
, loColor
;
98 unsigned long texture
;
101 BTexture(void) { texture
= 0; }
103 inline BColor
*getColor(void) { return &color
; }
104 inline BColor
*getColorTo(void) { return &colorTo
; }
105 inline BColor
*getHiColor(void) { return &hiColor
; }
106 inline BColor
*getLoColor(void) { return &loColor
; }
108 inline const unsigned long &getTexture(void) const { return texture
; }
110 inline void setTexture(unsigned long t
) { texture
= t
; }
111 inline void addTexture(unsigned long t
) { texture
|= t
; }
117 BImageControl
&control
;
126 int red_offset
, green_offset
, blue_offset
, red_bits
, green_bits
, blue_bits
,
127 ncolors
, cpc
, cpccpc
;
128 unsigned char *red
, *green
, *blue
, *red_table
, *green_table
, *blue_table
;
129 unsigned int width
, height
, *xtable
, *ytable
;
133 Pixmap
renderPixmap(void);
135 XImage
*renderXImage(void);
140 void dgradient(void);
141 void egradient(void);
142 void hgradient(void);
143 void pgradient(void);
144 void rgradient(void);
145 void vgradient(void);
146 void cdgradient(void);
147 void pcgradient(void);
151 BImage(BImageControl
&, unsigned int, unsigned int);
154 Pixmap
render(BTexture
*);
155 Pixmap
render_solid(BTexture
*);
156 Pixmap
render_gradient(BTexture
*);
160 class BImageControl
: public TimeoutHandler
{
163 BaseDisplay
&basedisplay
;
164 ScreenInfo
&screeninfo
;
173 int colors_per_channel
, ncolors
, screen_number
, screen_depth
,
174 bits_per_pixel
, red_offset
, green_offset
, blue_offset
,
175 red_bits
, green_bits
, blue_bits
;
176 unsigned char red_color_table
[256], green_color_table
[256],
177 blue_color_table
[256];
178 unsigned int *grad_xbuffer
, *grad_ybuffer
, grad_buffer_width
,
180 unsigned long *sqrt_table
, cache_max
;
182 typedef struct Cache
{
185 unsigned int count
, width
, height
;
186 unsigned long pixel1
, pixel2
, texture
;
189 typedef std::list
<Cache
*> CacheList
;
194 Pixmap
searchCache(unsigned int, unsigned int, unsigned long, BColor
*,
199 BImageControl(BaseDisplay
&, ScreenInfo
&, Bool
= False
, int = 4,
200 unsigned long = 300000l, unsigned long = 200l);
201 virtual ~BImageControl(void);
203 inline BaseDisplay
&getBaseDisplay(void) { return basedisplay
; }
205 inline const Bool
&doDither(void) { return dither
; }
207 inline ScreenInfo
&getScreenInfo(void) { return screeninfo
; }
209 inline const Window
&getDrawable(void) const { return window
; }
211 inline Visual
*getVisual(void) const { return screeninfo
.getVisual(); }
213 inline const int &getBitsPerPixel(void) const { return bits_per_pixel
; }
214 inline const int &getDepth(void) const { return screen_depth
; }
215 inline const int &getColorsPerChannel(void) const
216 { return colors_per_channel
; }
218 unsigned long getColor(const char *);
219 unsigned long getColor(const char *, unsigned char *, unsigned char *,
221 unsigned long getSqrt(unsigned int);
223 Pixmap
renderImage(unsigned int, unsigned int, BTexture
*);
225 void installRootColormap(void);
226 void removeImage(Pixmap
);
227 void getColorTables(unsigned char **, unsigned char **, unsigned char **,
228 int *, int *, int *, int *, int *, int *);
229 void getXColorTable(XColor
**, int *);
230 void getGradientBuffers(unsigned int, unsigned int,
231 unsigned int **, unsigned int **);
232 void setDither(Bool d
) { dither
= d
; }
233 void setColorsPerChannel(int);
234 void parseTexture(BTexture
*, const char *);
235 void parseColor(BColor
*, const char * = 0);
237 virtual void timeout(void);
This page took 0.048735 seconds and 4 git commands to generate.