[comp.windows.x] XPutImage problem

devin@samwise.Colorado.EDU (Yampalimardilor) (01/14/91)

This piece of code generates a BadMatch.  What am I doing wrong?

(I'm running vanilla MIT X11R4)

I'm trying to XPutImage an image into a 1 plane Pixmap.  If I comment
out the XPutImage, the BadMatch goes away, so I assume that it this
particular call that's doing it.

*** Start code

    map = XCreatePixmap(_display,DefaultRootWindow(_display),
			defaultwidth,defaultheight,1);
    char *mapdata = new char[defaultwidth*defaultheight];
    if ((fp = open(pathname,O_RDONLY)) < 0) {
	// ERROR
	delete mapdata;
	return;
    }
    if (read(fp,mapdata,defaultwidth*defaultheight) < 0) {
	// ERROR
	delete mapdata;
	return;
    }
    XImage *txi = XCreateImage(_display,_visual,1,XYBitmap,0,mapdata,
			       defaultwidth,defaultheight,8,defaultwidth);
    for (int i=0;i<defaultwidth*defaultheight;i++)
	if (mapdata[i]) mapdata[i] = 255;
    XPutImage(_display,map,_gc,txi,0,0,0,0,defaultwidth,defaultheight);

*** end code

	-Devin

Devin Hooker     (RP90)     DoD #0034
"Time - don't ponder it too long..."
"Performing on a stool we've a sight to make you drool
	Seven virgins and a mule.  Keep it cool.  Keep it cool." -ELP

mouse@larry.mcrcim.mcgill.EDU (01/21/91)

> This piece of code generates a BadMatch.  What am I doing wrong?

Insufficient information to say with any certainty, but I have a guess.

>     map = XCreatePixmap(....,1);
....
>     XPutImage(_display,map,_gc,txi,0,0,0,0,defaultwidth,defaultheight);

You say nothing about where you get _gc from.  I suspect it may be the
default GC of the screen, or perhaps a GC created early on for general
use.  In any case, I suspect its depth is that of the screen, and
you're on a display whose default screen is not one bit deep.  Thus,
the GC is incompatible with the drawable, and you get a BadMatch.

If this isn't it, I would need more information.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu