X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=otk%2Fpseudorendercontrol.cc;h=cf9929248586e4e2c12d0b002eba771bcfb610fe;hb=bfea000a7407e51b5659590415e410a47f6f046b;hp=990a60dd8e52c0c7bcf3b6f7ce53888bfc516a33;hpb=7393a17bf9b427675df3a6688845db5e2df6f155;p=chaz%2Fopenbox diff --git a/otk/pseudorendercontrol.cc b/otk/pseudorendercontrol.cc index 990a60dd..cf992924 100644 --- a/otk/pseudorendercontrol.cc +++ b/otk/pseudorendercontrol.cc @@ -9,14 +9,12 @@ #include "rendertexture.hh" extern "C" { -#ifdef HAVE_STDLIB_H -# include -#endif // HAVE_STDLIB_H - #include "../src/gettext.h" #define _(str) gettext(str) } +#include + namespace otk { PseudoRenderControl::PseudoRenderControl(int screen) @@ -124,18 +122,19 @@ inline const XColor *PseudoRenderControl::pickColor(int r, int g, int b) const void PseudoRenderControl::reduceDepth(Surface &sf, XImage *im) const { pixel32 *data = sf.pixelData(); - char *p = (char *)data; + pixel32 *ret = (pixel32*)malloc(im->width * im->height * 4); + char *p = (char *)ret; int x, y; - for (y = 0; y < im->height; y++) { - for (x = 0; x < im->width; x++) { - p[x] = pickColor(data[x] >> default_red_shift, - data[x] >> default_green_shift, - data[x] >> default_blue_shift)->pixel; - } - data += im->width; - p += im->bytes_per_line; + for (y = 0; y < im->height; y++) { + for (x = 0; x < im->width; x++) { + p[x] = pickColor(data[x] >> default_red_shift, + data[x] >> default_green_shift, + data[x] >> default_blue_shift)->pixel; } - + data += im->width; + p += im->bytes_per_line; + } + im->data = (char*)ret; } void PseudoRenderControl::allocateColor(XColor *color) const