ado@elsie.UUCP (Arthur David Olson) (11/29/89)
Elsie is our Sun 3/280 running SunOS 4.0.3. If I log in to elsie from the console of our SGI IRIS 4D/70G and try to drop pixels into an X window, things go awry--in particular, only the low-order four bits of the pixels being written seem to make it to the window. I've attached a typescript showing the problem (the incorrect results are marked with ">>>>"s). If you can tell me what I'm doing wrong, I'd appreciate hearing from you by electronic mail. -- Arthur David Olson ado@alw.nih.gov ADO is a trademark of Ampex. Script started on Thu Nov 16 14:16:02 1989 elsie$ cat try.c #include <stdio.h> #include <X11/Xlib.h> #define WIDTH 20 #define HEIGHT 1 Display * display; int screen_number; Visual * visual; Window root_window; Window window; GC default_gc; XImage * ximage; char data[WIDTH][HEIGHT]; main() { int x, y; display = XOpenDisplay((char *) NULL); if (display == 0) abort(); root_window = DefaultRootWindow(display); screen_number = XDefaultScreen(display); visual = DefaultVisual(display, screen_number); default_gc = DefaultGC(display, screen_number); window = XCreateSimpleWindow(display, root_window, 300, 300, WIDTH, HEIGHT, 2, 0, 1); XMapWindow(display, window); XSync(display, 0); (void) printf("Tap RETURN when the window is in place.\n"); (void) getchar(); ximage = XCreateImage(display, visual, 8, ZPixmap, 0, (char *) data, WIDTH, HEIGHT, 8, 0); if (ximage == 0) abort(); for (x = 0; x < WIDTH; ++x) for (y = 0; y < HEIGHT; ++y) XPutPixel(ximage, x, y, x); XPutImage(display, window, default_gc, ximage, 0, 0, 0, 0, WIDTH, HEIGHT); ximage = XGetImage(display, window, 0, 0, WIDTH, HEIGHT, (unsigned long) ~0, ZPixmap); for (x = 0; x < WIDTH; ++x) for (y = 0; y < HEIGHT; ++y) (void) printf("data[%d][%d]\t%d\n", x, y, XGetPixel(ximage, x, y)); return 0; } elsie$ cc -g try.c -lX11 -o try elsie$ try Tap RETURN when the window is in place. data[0][0] 0 data[1][0] 1 data[2][0] 2 data[3][0] 3 data[4][0] 4 data[5][0] 5 data[6][0] 6 data[7][0] 7 data[8][0] 8 data[9][0] 9 data[10][0] 10 data[11][0] 11 data[12][0] 12 data[13][0] 13 data[14][0] 14 data[15][0] 15 >>>> data[16][0] 0 >>>> data[17][0] 1 >>>> data[18][0] 2 >>>> data[19][0] 3 elsie$ exit script done on Thu Nov 16 14:16:47 1989