[comp.windows.x] Trouble saving bitmaps from color workstations

mouse@LIGHTNING.MCRCIM.MCGILL.EDU (11/05/90)

> The following function was written by my Computer Graphics professor.
> On a HP-UX series 300 monochrome workstation it will correctly save
> the area enclosed by the points (x1,y1) - (x2,y2).  However on a
> color workstation (6 planes deep) the program will crash with the
> following error (shortened) returned:

> X protocol error - Bad Match, invalid parameter attributes
> Failed request major opcode 63 (X_CopyPlane)

> This would seem to indicate that the pixmap copyed from the window is
> not one plane deep.

Not really.  I suspect a different problem: I suspect that your GC is
not one bit deep.  From the Xlib documentation:

	To create a new GC that is usable on a given screen with a
	depth of drawable, use XCreateGC.
[...description of XCreateGC...]
	The XCreateGC function creates a graphics context and
	returns a GC.  The GC can be used with any destination draw-
	able having the same root and depth as the specified draw-
	able.  Use with other drawables results in a BadMatch error.

You don't show how the GC is created; it's being passed to your
function as an argument.  I suspect it is as deep as the root window,
but for it to be usable for copying to a bitmap, it must be only one
bit deep.

	  pixmap = XCreatePixmap(display,win,width,height,1);
	  XCopyPlane(display,win,pixmap,gc,x,y,width,height,0,0,plane_mask);
	
	/* CRASHES ON THE WRITE BITMAP FILE */
	  err = XWriteBitmapFile(display,fname,pixmap,width,height,-1,-1);

You don't say why you think it crashes on the XWriteBitmapFile.  I
suspect you determined this from a run that did not have Xlib set
synchronous, and that it's just an effect of Xlib buffering.  That is,
the CopyPlane request was merely buffered by the XCopyPlane call and
wasn't actually sent to the server until XWriteBitmapFile (which
necessitates a server round-trip) was called.

					der Mouse

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