Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!cs.utexas.edu!uunet!mcsun!ukc!stc!stl!siesoft!huw From: huw@siesoft.co.uk (Huw Roberts) Newsgroups: comp.windows.x Subject: HELP needed with BadMatch error Summary: I can't put an image into a one bit deep pixmap Keywords: badmatch image pixmap problem Message-ID: <1991Mar21.083826.6036@siesoft.co.uk> Date: 21 Mar 91 08:38:26 GMT Sender: usenet@siesoft.co.uk (NNTP Poster) Distribution: comp Organization: Siemens-Nixdorf Systems Development Group, UK Lines: 76 The following program gives the following protocol error and I can't work out why. Enlightenment would be greatly appreciated. A sensible mechanism for fixing it would also be appreciated. The protocol error: ------------------------------------------------------------------------------- X Error: BadMatch, invalid parameter attributes Request Major code 72 () Request Minor code ResourceID 0xe00002 Error Serial #13 Current Serial #14 ------------------------------------------------------------------------------- The code: ------------------------------------------------------------------------------- #include #include #include #include #include #include int data[3][3] = { 0,1,0, 1,1,1, 0,1,0 }; Display *display; int rows=3, cols=3; main( argc, argv ) int argc; char *argv[]; { int row, col; Widget toplevel; XImage *mask; Screen *screen; Pixmap maskp; int n; Arg args[10]; extern char *pm_progname = argv[0]; toplevel = XtInitialize ("viewer", "Pgmtoxpm", NULL, NULL, &argc, argv); display = XtDisplay(toplevel); screen = XtScreen(toplevel); XSynchronize(display, True); mask = XCreateImage(display, DefaultVisualOfScreen(screen), 1, XYBitmap, 0, 0, ((cols>>3)+1)<<3, rows, 8, 0); mask->data = malloc((mask->bytes_per_line+100) * (rows+100)); /* Initialize. */ for ( row = 0; row < rows; row++) { for ( col = 0; col < cols; col++) XPutPixel(mask, col, row, data[row][col]); } maskp = XCreatePixmap(display, RootWindowOfScreen(screen), cols, rows, 1); XPutImage(display, maskp, DefaultGCOfScreen(screen), mask, 0, 0, 0, 0, cols, rows); } ------------------------------------------------------------------------------- Basically the problem is with the last statement. Note that both the Image and the Pixmap have depth 1. Huw P.S. Could you mail any replies because we tend to lose articles from comp.windows.x. Thanks -- If you want to flame, mail me directly and I'll summarise the best. Huw Roberts (huw@siesoft.co.uk) Siemens Plc., System Development Group, Woodley House, 65-73, Crockhamwell Road, Woodley, Reading, Berkshire, RG5 3JP England.