1 // -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 #ifndef __imagecontrol_h
3 #define __imagecontrol_h
12 extern PyTypeObject OtkImageControl_Type
;
14 typedef struct OtkImageControl
{
15 struct OtkScreenInfo
*screen
;
17 // for the pixmap cache
18 struct OtkTimer
*timer
;
19 unsigned long cache_max
;
23 int cpc
; // colors-per-channel: must be a value between [2,6]
24 int bpp
; // bits-per-pixel
26 unsigned int *grad_xbuffer
;
27 unsigned int *grad_ybuffer
;
28 unsigned int grad_buffer_width
;
29 unsigned int grad_buffer_height
;
31 unsigned long *sqrt_table
;
33 // These values are all determined based on a visual
35 int red_bits
; // the number of bits (1-255) that each shade of color
36 int green_bits
; // spans across. best case is 1, which gives 255 shades.
38 unsigned char red_color_table
[256];
39 unsigned char green_color_table
[256];
40 unsigned char blue_color_table
[256];
42 // These are only used for TrueColor visuals
43 int red_offset
; // the offset of each color in a color mask
47 // These are only used for !TrueColor visuals
53 PyObject
*OtkImageControl_New(int screen
);
57 inline bool doDither(void) { return dither; }
59 inline const ScreenInfo* getScreenInfo() const { return screeninfo; }
61 inline Window getDrawable(void) const { return window; }
63 inline Visual *getVisual(void) { return screeninfo->visual(); }
65 inline int getBitsPerPixel(void) const { return bits_per_pixel; }
66 inline int getDepth(void) const { return screen_depth; }
67 inline int getColorsPerChannel(void) const
68 { return colors_per_channel; }
70 unsigned long getSqrt(unsigned int x);
72 Pixmap renderImage(unsigned int width, unsigned int height,
73 const BTexture &texture);
75 void installRootColormap(void);
76 void removeImage(Pixmap pixmap);
77 void getColorTables(unsigned char **rmt, unsigned char **gmt,
79 int *roff, int *goff, int *boff,
80 int *rbit, int *gbit, int *bbit);
81 void getXColorTable(XColor **c, int *n);
82 void getGradientBuffers(unsigned int w, unsigned int h,
83 unsigned int **xbuf, unsigned int **ybuf);
84 void setDither(bool d) { dither = d; }
86 static void timeout(BImageControl *t);
90 const ScreenInfo *screeninfo;
97 int colors_per_channel, ncolors, screen_number, screen_depth,
98 bits_per_pixel, red_offset, green_offset, blue_offset,
99 red_bits, green_bits, blue_bits;
100 unsigned char red_color_table[256], green_color_table[256],
101 blue_color_table[256];
102 unsigned int *grad_xbuffer, *grad_ybuffer, grad_buffer_width,
104 unsigned long *sqrt_table, cache_max;
106 typedef std::list<CachedImage> CacheContainer;
107 CacheContainer cache;
109 Pixmap searchCache(const unsigned int width, const unsigned int height,
110 const unsigned long texture,
111 const BColor &c1, const BColor &c2);
115 #endif // __imagecontrol_h