- assert(wi);
-
- XGCValues gcv;
- gcv.cap_style = CapProjecting;
-
- int w = 255, h = 31;
- Pixmap p = XCreatePixmap(**display, wi->window(), w, h, _screen->depth());
- XImage *im = XCreateImage(**display, _screen->visual(), _screen->depth(),
- ZPixmap, 0, NULL, w, h, 32, 0);
- //GC gc = XCreateGC(**display, _screen->rootWindow(), GCCapStyle, &gcv);
-
- // XXX + 1?
- unsigned char *data = new unsigned char[im->bytes_per_line * h];
- unsigned char *dp = data;
-
- for (int x = 0; x < w; ++x, dp += im->bits_per_pixel/8)
- renderPixel(im, dp, 0);
- for (int y = 0; y < 10; ++y)
- for (int x = 0; x < w; ++x, dp += im->bits_per_pixel/8)
- renderPixel(im, dp, _red_color_table[x] << _red_offset);
- for (int y = 0; y < 10; ++y)
- for (int x = 0; x < w; ++x, dp += im->bits_per_pixel/8)
- renderPixel(im, dp, _green_color_table[x] << _green_offset);
- for (int y = 0; y < 10; ++y)
- for (int x = 0; x < w; ++x, dp += im->bits_per_pixel/8)
- renderPixel(im, dp, _blue_color_table[x] << _blue_offset);
-
- printf("\nDone %d %d\n", im->bytes_per_line * h, dp - data);
-
- im->data = (char*) data;
-
- XPutImage(**display, p, DefaultGC(**display, _screen->screen()),
- im, 0, 0, 0, 0, w, h);
-
- //delete [] image->data;
- //image->data = NULL;
- XDestroyImage(im);
-
- XSetWindowBackgroundPixmap(**display, wi->window(), p);
- XClearWindow(**display, wi->window());
-
- XFreePixmap(**display, p);
+ 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;
+ }