#include "rendertexture.hh"
extern "C" {
-#ifdef HAVE_STDLIB_H
-# include <stdlib.h>
-#endif // HAVE_STDLIB_H
-
#include "../src/gettext.h"
#define _(str) gettext(str)
}
+#include <cstdlib>
+
namespace otk {
PseudoRenderControl::PseudoRenderControl(int screen)
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