[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

2078.0. "How to use XSetStipple() ?" by WPOMM2::ZAMBOTTI () Fri Jan 19 1990 04:14

Hi again,

can anyone tell me the correct way to use the XSetStipple() function.  I have
set up a simple example but I can't make it work.

	.
	.
	.
{
Pixmap  HatchStipple ;

    HatchStipple = XCreatePixmap(Disp, Win1, 4, 4,
                       XDefaultDepth(Disp, XDefaultScreen(Disp))) ;

    /* some code to load my pattern into the HatchStipple Pixmap */

	.
	.
	.

    XSetStipple(Disp, GCID, HatchStipple) ;
}


When I run this piece of code I get :

(dbx) cont to 77
[3] stopped at [sethatchstyle:77 ,0x401444]     XSetStipple(Disp, GCID, HatchStipple) ;
(dbx) s
X Protocol error detected by server: parameter mismatch
  Failed request major op code 56 X_ChangeGC
  Failed request minor op code 0 (if applicable)
  ResourceID 0x40000004 in failed request (if applicable)
  Serial number of failed request 195
  Current serial number in output stream 196

Program exited with code 1
(dbx)

What's my problem?

Walter Zambotti.
T.RTitleUserPersonal
Name
DateLines
2078.1The stipple should have depth 1OPHION::MIKEYMike YangFri Jan 19 1990 18:565
    The stipple pixmap should have depth 1 (i.e. it's a bitmap).  The GC's
    foreground pixel will be painted where there are 1's, and the
    background pixel used where there are 0's.  Presumably, you're using a
    color display and that's why you're getting the "parameter mismatch"
    error from XSetStipple because DefaultDepth is > 1.
2078.2Know you've confused me!WPOMM2::ZAMBOTTISun Jan 21 1990 21:5421
Thanks for the response Mike,

but know you have created a paradox for me.  My situation is I have an eight
plane color display and I would like to set a stipple for a GC which I have
created on that display.

The GC has as is depth 8 planes (obviously) and the Xlib Library manual states
(page 5-32) that

   "The stipple and the GC must have the same depth, or a BadMatch error
    results."

How can I accomplish this feat?  A GC that has both a depth of 8 and 1 planes
simultaneously???

Could you give me or point me to an example of using XSetStipple on a color
display!

Regards,

Walter.
2078.3Oops, I liedOPHION::MIKEYMike YangMon Jan 22 1990 14:377
    What I said in .1 is wrong.  The stipple pixmap can be of any depth,
    as long as it matches the depth of the GC.
    
    Now I'm not sure what you're doing wrong.  Are you sure your GCID is
    the depth of the screen?
    
    I'll try and find a short stipple example.
2078.4Here's an example of XSetStippleOPHION::MIKEYMike YangMon Jan 22 1990 14:5995
                                               
    Here's a short example that uses stipples on arbitrary-depth displays.
    MB1 and MB2 choose the pattern displayed in the window, and MB3 exits.
    
    #include <stdio.h>
    #include <X11/Xlib.h>
    
    static char pattern1[] =
    {   0x88, 0x88, 0x88, 0x88,
        0x44, 0x44, 0x44, 0x44,
        0x22, 0x22, 0x22, 0x22,
        0x11, 0x11, 0x11, 0x11,
        0x88, 0x88, 0x88, 0x88,
        0x44, 0x44, 0x44, 0x44,
        0x22, 0x22, 0x22, 0x22,
        0x11, 0x11, 0x11, 0x11};
    
    static char pattern2[] =
    {   0xF8, 0xF8, 0xF8, 0xF8,
        0x88, 0x88, 0x88, 0x88,
        0x88, 0x88, 0x88, 0x88,
        0x88, 0x88, 0x88, 0x88,
        0x8F, 0x8F, 0x8F, 0x8F,
        0x88, 0x88, 0x88, 0x88,
        0x88, 0x88, 0x88, 0x88,
        0x88, 0x88, 0x88, 0x88};
    
    main(argc,argv)
    int argc;
    char **argv;
    {
      Display    *dpy;
      Window      win1;
      GC gc1, gc2, gc_solid;
      XGCValues values;
      unsigned long value_mask;
      Pixmap p1, p2, q1, q2;
    
      dpy = XOpenDisplay(NULL);
      win1 = XCreateSimpleWindow(dpy, DefaultRootWindow(dpy),
                                 0, 0, 300, 300, 1,
                                 BlackPixel(dpy, DefaultScreen(dpy)),
                                 WhitePixel(dpy, DefaultScreen(dpy)));
    
      values.foreground = BlackPixel(dpy, DefaultScreen(dpy));
      values.background = WhitePixel(dpy, DefaultScreen(dpy));
      values.fill_style = FillSolid;
      values.graphics_exposures = False;
      value_mask = GCForeground | GCBackground | GCFillStyle |
    			GCGraphicsExposures;
    
      gc_solid = XCreateGC(dpy, win1, value_mask, &values);
      values.fill_style = FillOpaqueStippled;
      gc1 = XCreateGC(dpy, win1, value_mask, &values);
      gc2 = XCreateGC(dpy, win1, value_mask, &values);
      p1 = XCreatePixmapFromBitmapData(dpy, win1, pattern1,
                                       16, 16, 1, 0, 1);
      p2 = XCreatePixmapFromBitmapData(dpy, win1, pattern2,
                                       16, 16, 1, 0, 1);
      XSetStipple(dpy, gc1, p1);
      XSetStipple(dpy, gc2, p2);
      q1 = XCreatePixmap(dpy, win1, 16, 16,
                         DefaultDepth(dpy,DefaultScreen(dpy)));
      q2 = XCreatePixmap(dpy, win1, 16, 16,
                         DefaultDepth(dpy,DefaultScreen(dpy)));
      XCopyPlane(dpy, p1, q1, gc_solid, 0, 0, 16, 16, 0, 0,
                 (unsigned long)1);
      XCopyPlane(dpy, p2, q2, gc_solid, 0, 0, 16, 16, 0, 0,
                 (unsigned long)1);
    
      XMapWindow(dpy, win1);
      XSelectInput(dpy, win1, ButtonPressMask);
    
      while (1) {
        XEvent      event;
    
        XNextEvent(dpy, &event);
        if (event.type == ButtonPress && event.xbutton.button == Button1) {
          XSetWindowBackgroundPixmap(dpy, win1, q1);
          XClearWindow(dpy, win1);
        } else if (event.type == ButtonPress && event.xbutton.button ==
    		Button2) {
          XSetWindowBackgroundPixmap(dpy, win1, q2);
          XClearWindow(dpy, win1);
        } else if (event.type == ButtonPress && event.xbutton.button ==
    		Button3) {
          exit(1);
        }
      }
    }
    
    
    
    
                              
2078.5To bad Jim is not still offering his reward!DECWIN::FISHERBurns Fisher 381-1466, ZKO3-4/W23Mon Jan 29 1990 12:089
I think that you have discovered a bug in Scheiffler and Gettys:  Stipples must
be depth 1, not the depth of the GC.  This is confirmed by the protocol section
of S&G.  As you say, though, the Xlib section says in XSetStipple that the stipple
must match the GC.

Note that in the example from the previous reply, the window and the gc
are at the default depth, while the stipple is always 1.

Burns