bchen@esvax.berkeley.edu (Benjamin Chen) (10/04/89)
I'm having tremendous difficulty in drawing a Pixmap to a window! Basically, I set up my gc like this: 1) Set the clipmask to the pixmap to be displayed. 2) Set the clip origin to the coordinates where I want the pixmap to be displayed. 3) Set the fill_style to FillSolid Then I call XFillRectangle using the gc to fill an area of the screen. The area is defined by the pixmap's width and height and the same coordinates as those used in the clip origin. Unfortunately, only a small diagonal of the window is affected by any of the draw commands! Here's the code, in case my explanation isn't clear: values.foreground = dotColor; values.clip_x_origin = sx; values.clip_y_origin = sy; if (gc) { XChangeGC(ez_Display, gc, GCForeground|GCClipXOrigin|GCClipYOrigin, &values); } else { values.clip_mask = ezSmallDotBitmap; values.fill_style = FillSolid; gc = (GC) XCreateGC(ez_Display, (Drawable) win, GCClipMask|GCFillStyle|GCForeground| GCClipXOrigin|GCClipYOrigin, &values); } XFillRectangle(ez_Display, (Drawable) win, gc, win, sx, sy, (unsigned int) small_dot_width, (unsigned int) small_dot_height); Can any one help, or point me to some sample code? I have the O'Reilly book volume 1 which explains the clip stuff, but the above code is basically the result of reading that part of the book. BC Benjamin Chen Office: 550-A4 Cory Hall, 2-4332 UUCP: !ucbvax!esvax!bchen HEPNET: LBL::"bchen@esvax.Berkeley.EDU"
rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (10/04/89)
1) Set the clipmask to the pixmap to be displayed. 2) Set the clip origin to the coordinates where I want the pixmap to be displayed. 3) Set the fill_style to FillSolid Without thinking too hard, this oughta work, but it's an awfully twisted way to get the job done. If you're going 1-bit to 1-bit, just use XCopyArea. If you're going 1-bit to N-bit, just use XCopyPlane. (BTW, you fail to set the ClipMask in the case when you already have a gc, can't tell if that's your problem or not. If you're running an MIT R3 server and you think it's buggy, send a complete program demonstrating the bug to xbugs@expo.)
madd@bu-cs.BU.EDU (Jim Frost) (10/04/89)
In article <8910041226.AA05387@expire.lcs.mit.edu> rws@EXPO.LCS.MIT.EDU (Bob Scheifler) writes: |If you're going 1-bit to 1-bit, just use |XCopyArea. If you're going 1-bit to N-bit, just use XCopyPlane. Use XCopyPlane always so you don't have to worry about the depth of the other pixmap. This is what I use when sending bitmap images to both mono and color displays; allocate a mono pixmap, XPutImage to it, then XCopyPlane with GC foreground and background set to recolor the image appropriately. This is a bit slower to mono displays (you don't really need the extra copy) but is a lot more flexible. Now for a question: what do the GC foreground and background specifiers do on an XPutImage command? What I really hoped was that I could use them to specify colors when transferring a mono image to a color display, but the destination must be the same depth (ie 1) so I'm kind of confused as to what they do. jim frost software tool & die madd@std.com
rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (10/05/89)
Use XCopyPlane always so you don't have to worry about the depth of the other pixmap. Reasonable if the bitmap is "colorless" and you're applying the colors externally. Less confusing to use XCopyArea if the image is already "colored". Now for a question: what do the GC foreground and background specifiers do on an XPutImage command? They do what you want. An XYBitmap PutImage is equivalent to your sending the data to a bitmap and then using CopyPlane. but the destination must be the same depth (ie 1) so I'm kind of confused as to what they do. No such restriction for XYBitmap.
root@johnbob.uucp (/4194303) (10/07/89)
>In article <8910041743.AA07208@expire.lcs.mit.edu> rws@EXPO.LCS.MIT.EDU (Bob Scheifler) writes: >>In article ? >> Now for a question: what do the GC foreground and background >> specifiers do on an XPutImage command? >> >They do what you want. An XYBitmap PutImage is equivalent to your >sending the data to a bitmap and then using CopyPlane. > but the destination must be the same depth (ie 1) so > I'm kind of confused as to what they do. >No such restriction for XYBitmap. The XYPixmap has the restriction that the src and dst must be the same depth, and foreground and background are not used. The XYBitmap must be depth 1 and a putimage color expands with foreground and background to whatever depth dst is. O' course I could be wrong... ...!uunet!cs.utexas.edu!ibmaus!auschs!johnbob.austin.ibm.com!root !john John Harvey !johnbob I don't speak for anybody. Not even myself. Please forgive my employers. They know not what I do. ..!uunet!cs.utexas.edu!ibmaus!auschs!johnbob.austin.ibm.com!root !john John Harvey !johnbob I don't speak for anybody. Not even myself. Please forgive my employers. They know not what I do.