
Example 21-1. The color_logo.c program (continued)
xlogo64_bits, xlogo64_width, xlogo64_height);
/* setup gc for rendering logos to screen */
gcvalues.graphics_exposures = False;
gcvalues.background = pixel_table[WHITE];
gc = XCreateGC(xv_get(frame, XV_DISPLAY), xv_get(frame, XV_XID),
GCBackground | GCGraphicsExposures, &gcvalues);
xv_main_loop(frame);
}
/* Draws onto the canvas using Xlib drawing functions.
* Draw the X logo into the window in three colors. In each case,
* change the GC’s foreground color to the pixel value specified.
*/
void
canvas_repaint_proc(canvas, pw, display, win, xrects)
Canvas canvas; /* unused */
Xv_Window pw; /* unused */
Display *display;
Window win;
Xv_xrectlist *xrects; /* unused */
{
/* Use XCopyPlane because the logo is a 1-bit deep pixmap. */
XSetForeground(display, gc, pixel_table[RED]);
XCopyPlane(display, xlogo, win, gc, 0, 0,
xlogo64_width, xlogo64_height, 64, 64, 1);
XSetForeground(display, gc, pixel_table[GREEN]);
XCopyPlane(display, xlogo, win, gc, 0, 0,
xlogo64_width, xlogo64_height, 192, 64, 1);
XSetForeground(display, gc, pixel_table[BLUE]);
XCopyPlane(display, xlogo, win, gc, 0, 0,
xlogo64_width, xlogo64_height, 320, 64, 1);
}
Example 21-1 uses Xlib routines to draw into the canvas’s paint window. Therefore, the GC’s
foreground color is set to an index from the colormap being used by that paint window. In
order to get the correct color from the colormap, we need