- XColor icolor;
- int ii, r, g, b;
- gulong dev, closest = 0xffffffff, close = 0;
-
- icolor.pixel = p8[x];
- XQueryColor(ob_display, render_colormap, &icolor);
-
- /* find the nearest color match */
- for (ii = 0; ii < pseudo_ncolors(); ii++) {
- /* find deviations */
- r = (pseudo_colors[ii].red - icolor.red) & 0xff;
- g = (pseudo_colors[ii].green - icolor.green) & 0xff;
- b = (pseudo_colors[ii].blue - icolor.blue) & 0xff;
- /* find a weighted absolute deviation */
- dev = (r * r) + (g * g) + (b * b);
-
- if (dev < closest) {
- closest = dev;
- close = ii;
- }
- }
- data[x] =
- (pseudo_colors[close].red & 0xff <<
- default_red_offset) +
- (pseudo_colors[close].green & 0xff <<
- default_green_offset) +
- (pseudo_colors[close].blue & 0xff <<
- default_blue_offset) +
- (0xff << default_alpha_offset);
+ if (!(((p8[x / 8]) >> (x % 8)) & 0x1))
+ data[x] = 0xff << default_alpha_offset; /* black */
+ else
+ data[x] = 0xffffffff; /* white */
+ }
+ data += im->width;
+ p8 += im->bytes_per_line;