- assert(sf);
-
- int w = sf->width(), h = sf->height();
-
- XImage *im = XCreateImage(**display, _screen->visual(), _screen->depth(),
- ZPixmap, 0, NULL, w, h, 32, 0);
-
- unsigned char *data = new unsigned char[im->bytes_per_line * h];
- unsigned char *dp = data;
-
- for (int y = 0; y < h/3; ++y)
- for (int x = 0; x < w; ++x, dp += im->bits_per_pixel/8)
- renderPixel(im, dp, (255*x/w) << _red_offset << _red_shift);
- for (int y = 0; y < h/3; ++y)
- for (int x = 0; x < w; ++x, dp += im->bits_per_pixel/8)
- renderPixel(im, dp, (255*x/w) << _green_offset << _green_shift);
- for (int y = 0; y < h/3; ++y)
- for (int x = 0; x < w; ++x, dp += im->bits_per_pixel/8)
- renderPixel(im, dp, (255*x/w) << _blue_offset << _blue_shift);
-
- im->data = (char*) data;
-
- if (!sf->_pm)
- sf->_pm = XCreatePixmap(**display, _screen->rootWindow(), w, h,
- _screen->depth());
- XPutImage(**display, sf->_pm, DefaultGC(**display, _screen->screen()),
- im, 0, 0, 0, 0, w, h);
-
- //delete [] image->data;
- //image->data = NULL;
- XDestroyImage(im);
+ const ScreenInfo *info = display->screenInfo(_screen);
+ if (!XAllocColor(**display, info->colormap(), color)) {
+ fprintf(stderr, "TrueRenderControl: color alloc error: rgb:%x/%x/%x\n",
+ color->red & 0xff, color->green & 0xff, color->blue & 0xff);
+ color->pixel = 0;
+ }