Newsgroups: comp.windows.x
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!darwin.sura.net!sgiblab!news.kpc.com!kpc!nntphost!whaley
From: whaley@sigma.kpc.com (Ken Whaley)
Subject: Re: XCopyPlane Question
In-Reply-To: nancie@neko.CSS.GOV's message of 14 Apr 1993 15:19:05 -0400
Message-ID: <WHALEY.93Apr15103931@sigma.kpc.com>
Sender: usenet@kpc.com
Organization: Kubota Pacific Computer Inc.
References: <9304141450.AA04287@neko.CSS.GOV>
Date: Thu, 15 Apr 1993 18:39:31 GMT
Lines: 88

> 
> I am trying to use XCopyPlane to copy a single plane 
> from a depth-8 pixmap to a depth-1 pixmap.  Everytime I
> try this, I see absolutely nothing displayed.  I know there
> is data in the depth-8 pixmap becuase I have checked by doing
> an XCopyArea to the screen.
> 
> I have been successful getting XCopyPlane to work if I use
> two pixmaps of depth-8.  Is there a problem with what I am
> trying to do??
> 
> Could someone please scan my code segment and let me know
> where I am going wrong...
> 
> I have created a XmDrawingArea widget called canvas. 
>  
>     w_id = XtWindow(canvas);
>     display = XtDisplay(canvas);
>     screen = DefaultScreen (display);
>     pixmap8 = XCreatePixmap (display, RootWindow (display, screen),
>                     w_width, w_height, DefaultDepth (display, screen));
>     pixmap1 = XCreatePixmap (display, RootWindow (display, screen),
>                     w_width, w_height, 1);
> 
>     w_gc8 = XCreateGC (display, w_id, 0, NULL);
>     w_gc1 = XCreateGC (display, pixmap1, 0, NULL);
> 
> --> Code to read xwd image into pixmap8 is omitted <----
> 

Have you set the foreground and background colors in w_gc1 to 
something other than 0 and 1?  The WhitePixel and BlackPixel macros
on your server may not return values suitable for depth 1 drawables.


>     /* Copy one plane into the depth-1 pixmap */
>     XCopyPlane (display, pixmap8, pixmap1,
>                 w_gc1, 0, 0, w_width, w_height, 0, 0, 16);
> 

Are you sure that the fifth plane of the data isn't all the same?  You could
have different pixel values in the image, but the fifth plane (0x10 == 16)
might all be the same value?


>     /* Using the depth-1 pixmap as the clipmask, copy it to the screen */
>     values.foreground = fg_color;
>     values.clip_x_origin = 0;
>     values.clip_y_origin = 0;
>     values.clip_mask = pixmap1;
>     mask = GCForeground | GCClipMask;
>     XChangeGC (display, w_gc8, mask, &values);
> 
>     XFillRectangle (display, w_id, w_gc8, 0, 0, w_width, w_height);
> 


If you just want to see the plane of data and want better performance,
don't use ClipMasks, just use pixmap1 as the stipple in a stippled
rectangle fill.  Many servers are very stupid about handling complex
clip lists, and turn a bitmap clip region into hundreds and hundreds of
little clipping rectangles, and clips every drawing primitive against every
one of these little triangles.


Actually, I must also ask the FAQ's #1 most popular reason why graphics
don't show up: do you wait for an expose event before drawing your
rectangle?



> Other Info:  X11R5 Patchlevel 10
>              Motif 1.2.1
>              Sun Sparc2 running SunOS 4.1.1
>              
> 
> Thanks in Advance!
> 
>  ----------------------------------------------------------------
>  Nancie P. Marin      NET:  nancie@neko.css.gov
>  ENSCO Inc.           MAIL: 445 Pineda Ct.  Melbourne, Fl.  32940
>  (407)254-4122        FAX:  (407)254-3293
>  ----------------------------------------------------------------
--
Kenneth Whaley			 (408) 748-6347
Kubota Pacific Computer, Inc.	 Email: whaley@kpc.com
2630 Walsh Avenue
Santa Clara, CA.  95051
