1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
13 #include "screeninfo.hh"
24 ImageControl *control;
29 int red_offset, green_offset, blue_offset, red_bits, green_bits, blue_bits,
31 unsigned char *red, *green, *blue, *red_table, *green_table, *blue_table;
32 unsigned int width, height, *xtable, *ytable;
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);
38 void OrderedPseudoColorDither(int bytes_per_line, unsigned char *pixel_data);
41 Pixmap renderPixmap(void);
42 Pixmap render_solid(const Texture &texture);
43 Pixmap render_gradient(const Texture &texture);
45 XImage *renderXImage(void);
50 void border(const Texture &texture);
57 void cdgradient(void);
58 void pcgradient(void);
62 Image(ImageControl *c, int w, int h);
65 Pixmap render(const Texture &texture);
75 unsigned int count, width, height;
76 unsigned long pixel1, pixel2, texture;
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);
86 inline bool doDither(void) { return dither; }
88 inline const ScreenInfo* getScreenInfo() const { return screeninfo; }
90 inline Window getDrawable(void) const { return window; }
92 inline Visual *getVisual(void) { return screeninfo->visual(); }
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; }
99 unsigned long getSqrt(unsigned int x);
101 Pixmap renderImage(unsigned int width, unsigned int height,
102 const Texture &texture);
104 void installRootColormap(void);
105 void removeImage(Pixmap pixmap);
106 void getColorTables(unsigned char **rmt, unsigned char **gmt,
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);
116 static void timeout(ImageControl *t);
120 const ScreenInfo *screeninfo;
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,
134 unsigned long *sqrt_table, cache_max;
136 typedef std::list<CachedImage> CacheContainer;
137 CacheContainer cache;
139 Pixmap searchCache(const unsigned int width, const unsigned int height,
140 const unsigned long texture,
141 const Color &c1, const Color &c2);