chatty@lri.lri.fr (Stephane Chatty) (04/01/89)
Our X server modifies the pixmaps used as stipples in a GC when they do not have
the 'best size'.
We work on a SUN3/60, and our server is MIT's X11r3 with fixes 1-8, Purdue and
Purdue+ patches, and was compiled with gcc-1.33.
The 'best size' for stipples is 32x32, and when we use a 16x16 bitmap for
filling a rectangle on another pixmap, in FillStippled mode, our bitmap is
changed into a 32x16 one! Is it a feature of X that stipples are not kept,
or is it a bug of our server ?
Here is a little program which shows that behaviour. As it is hard to get info
from a Pixmap, we test them by making cursors in a sample window. We could as
well have used a XCopyPlane.
---------------------------------------------------------------------------
#include <X11/Xlib.h>
#define arrow_width 16
#define arrow_height 16
static char arrow_bits[] = {
0xff, 0xff, 0x1f, 0xf8, 0xdf, 0xfb, 0xdf, 0xfb, 0xdf, 0xfb, 0xdf, 0xfb,
0xdf, 0xfb, 0xdf, 0xfb, 0xc3, 0xc3, 0xfb, 0xdf, 0xf7, 0xef, 0xef, 0xf7,
0xdf, 0xfb, 0xbf, 0xfd, 0x7f, 0xfe, 0xff, 0xff};
main ()
{
Display* dpy;
int scn;
GC gc;
Pixmap source = 0;
Pixmap result;
Window test_window;
Colormap cmap;
XColor WHITE, BLACK, c;
Cursor test_cursor;
dpy = XOpenDisplay (0);
scn = DefaultScreen (dpy);
/* What we need for testing pixmaps : */
cmap = DefaultColormap (dpy, scn);
XAllocNamedColor (dpy, cmap, "white", &WHITE, &c);
XAllocNamedColor (dpy, cmap, "black", &BLACK, &c);
test_window = XCreateSimpleWindow (dpy, RootWindow (dpy, scn), 50, 1,
50, 50, 2, BlackPixel (dpy, scn), WhitePixel (dpy, scn));
XMapWindow (dpy, test_window);
XFlush (dpy);
/* The graphic context */
gc = XCreateGC (dpy, RootWindow (dpy, scn), 0, 0);
XSetFillStyle (dpy, gc, FillStippled);
/* Load a pixmap from data, and call it 'source' */
source = XCreateBitmapFromData (dpy, RootWindow (dpy, scn),
arrow_bits, arrow_width, arrow_height);
/* Create another pixmap from scratch */
result = XCreatePixmap (dpy, RootWindow (dpy, scn),
arrow_width, arrow_height, 1);
/* Use 'source' as a stipple for drawing */
XSetStipple (dpy, gc, source);
/* A simple test for a pixmap : use it as a cursor */
test_cursor = XCreatePixmapCursor (dpy, source,
source, &BLACK, &WHITE, 0, 0);
XDefineCursor (dpy, test_window, test_cursor);
XFlush (dpy);
getchar ();
/*Draw in 'result', using 'source' as a stipple */
XFillRectangle (dpy, result, gc, 0, 0, arrow_width, arrow_height);
/* Check 'source' again : it has been modified !! */
test_cursor = XCreatePixmapCursor (dpy, source,
source, &BLACK, &WHITE, 0, 0);
XDefineCursor (dpy, test_window, test_cursor);
XFlush (dpy);
getchar ();
}
-------------------------------------------------------------------------------
Stephane CHATTY chatty@frlri61.bitnet, chatty@lri.lri.fr