ardatta@odin.wright.edu (Arpita Datta) (11/03/89)
I have a Pixmap with some graphics objects (lines, arcs, points, etc) drawn on it. On an Expose event I would like to copy the objects from the Pixmap onto the exposed areas of the window, rather than redrawing them on the window. How can I copy objects drawn on the Pixmap, onto the window without destroying the tiled background of the window ? XCopyArea() copies all pixel values in a particular area and thereby destroys the background of the corresponding area in the window. The GC boolean functions (GXCopy, Gxand, GXor, etc) don't seem to be general enough for arbitrary background tiles. A "transparent" pixmap with objects drawn in the foreground color would have helped. Is there anyway of specifying a pixel value to be "transparent" ?
medmunds@Verity.COM (Mike Edmunds x7645) (11/04/89)
In article <809@thor.wright.EDU> ardatta@odin.wright.edu (Arpita Datta) writes: >How can I copy objects drawn on the Pixmap, onto the window without >destroying the tiled background of the window ? I've had some success with setting the clip_mask in a GC to a bitmap with objects drawn on it, and then painting through this "stencil" using XFillRectangle over the entire area. Only pixels that were set in the bitmap are affected in the destination window. If your original pixmap was more than one plane deep, you'll have to separate it into components (I keep a separate bitmap for each color) and paint multiple times. If somebody knows of a better way to do this... - Mike Edmunds Verity, Inc. (All opinions my own)
joel@nastar.UUCP (Joel Rives) (11/07/89)
>medmunds@verity.com (Mike Edmunds x7645) (medmunds@verity.com, <9692@zodiac.ADS.COM>): >I've had some success with setting the clip_mask in a GC to a bitmap >with objects drawn on it, and then painting through this "stencil" >using XFillRectangle over the entire area. Only pixels that were set >in the bitmap are affected in the destination window. If your >original pixmap was more than one plane deep, you'll have to separate >it into components (I keep a separate bitmap for each color) and paint >multiple times. According to the "Xlib -- C Language Interface", the XCopyArea() function uses the clip-mask component of the GC specified in the call. I have used this feature to restrict displaying of a pixmap to a rectangular sub-region. There is no reason that i can see why one could not use the stencil method that Mike mentions. However, instead of using multiple calls to XFillRectangle(), simply make one call to XCopyArea(). The bitmap clip-mask does not restrict the copy function to a single plane. It merely determines which pixels will be copied and which will be filtered out. Joel Rives
madd@world.std.com (jim frost) (11/07/89)
medmunds@Verity.COM (Mike Edmunds x7645) writes: >In article <809@thor.wright.EDU> ardatta@odin.wright.edu (Arpita Datta) writes: >>How can I copy objects drawn on the Pixmap, onto the window without >>destroying the tiled background of the window ? >I've had some success with setting the clip_mask in a GC to a bitmap >with objects drawn on it, and then painting through this "stencil" >using XFillRectangle over the entire area. Only pixels that were set >in the bitmap are affected in the destination window. If your >original pixmap was more than one plane deep, you'll have to separate >it into components (I keep a separate bitmap for each color) and paint >multiple times. What I've done in the past is to draw the object twice, once on a pixmap in full living color and once on a monochrome pixmap. Make a GC with the clip_mask set to the monochrome pixmap and use XCopyArea to copy the color pixmap through the monochrome mask onto the destination. If you only have a single color to draw, draw on a monochrome pixmap, use that pixmap as clip_mask for the GC, and copy from itself through itself to the destination. This works well on even very complicated "transparent" images, which is why I did it in the first place. Note that this technique has a side-effect; the mask can be used to accomplish picking (ie it's easy to tell if the cursor is on a solid part of a drawn item), something which I have needed in the past and which is generally available on true high-end hardware. Happy hacking, jim frost software tool & die "The World" Public Access Unix for the '90s madd@std.com +1 617-739-WRLD 24hrs {3,12,24}00bps