| /*
* Environment:
*
* VAXStation 2000 running VMS 5.1-1 SDC version. Program was compiled
* using VAX C version 2.4. The program must run on a monochrome system.
*
* Problem: If XDrawImageString is executed with a foreground and background
* having the same color index, the text is displayed in the correct
* foreground against the opposite background color. If this code is
* executed on an 8 plane color system everything appears correctly.
*
* Method to reproduce:
*
* Run the program. The text appears in the window as black on white
* background, although both color indicies are set to black.
*
*/
#include <stdio.h>
#include "decw$include:xlib.h"
#include "decw$include:xutil.h"
/*
* Constant data
*/
#define SQUARE_HEIGHT 8
#define SQUARE_WIDTH 16
#define NUMBER_ROWS 10
#define NUMBER_COLUMNS 10
#define NUMBER_SQUARES NUMBER_ROWS * NUMBER_COLUMNS
Display *display; /* connection to the X server */
Window window; /* application window */
GC gc; /* g context for drawing ops */
main()
{
Colormap colormap; /* application specific colormap */
XEvent event; /* incoming events */
XSetWindowAttributes attr; /* window attributes structure */
/*
* Open the display
*/
if ((display = XOpenDisplay("")) == NULL)
fatalError("XOpenDisplay", "could not open display");
/*
* Create a read/write colormap, with no entries allocated.
*/
colormap = XDefaultColormap(display, XDefaultScreen(display));
/*
* Create a window of the same visual type as our colormap
*/
attr.event_mask = ExposureMask;
attr.background_pixel = XBlackPixel(display, XDefaultScreen(display));
window = XCreateWindow(display, RootWindow(display, 0), 0, 0,
NUMBER_COLUMNS * SQUARE_WIDTH,
NUMBER_ROWS * SQUARE_HEIGHT, 5,
DefaultDepth(display, 0), InputOutput,
DefaultVisual(display,0),
CWEventMask | CWBackPixel, &attr);
/*
* Map window
*/
XMapWindow(display, window);
XFlush(display);
/*
* Create a GC for drawing operations
*/
gc = XCreateGC(display, window, 0, NULL);
/*
* Process events
*/
while(1) {
XNextEvent(display, &event);
switch(event.type) {
case Expose:
drawSquares(display, window, gc);
break;
default:
break;
}
}
}
/*
* Draw text in square
*/
drawSquares(display, window, gc)
Display *display;
Window window;
GC gc;
{
int row, column, square;
XFontStruct *our_font;
if (our_font = XLoadQueryFont(display, "*COURIER_16*"))
XSetFont(display, gc, our_font->fid);
/*
* Draw filled squares in different foreground colors
*/
for (row = square = 0; row < NUMBER_ROWS; row++)
for (column = 0; column < NUMBER_COLUMNS; column++, square++) {
XSetForeground(display, gc, 0);
XSetBackground(display, gc, 0);
XDrawImageString(display, window, gc, column * 8, row * 16, "A", 1);
}
}
/*
* Something bad happened
*/
fatalError(string1, string2)
char *string1;
char *string2;
{
fprintf(stderr, "Fatal Error: %s in routine %s\n", string1, string2);
exit();
}
|