mjc@me.brunel.ac.uk (Mike Crawley) (12/22/87)
I have a Sun 3/110 and bug fixes 1-92 included.
It is Sun OS 3.2 unfortunately.
Everything is compiled *WITHOUT* the FLOAT_OPTION environment variable.
Server compiled *WITHOUT* -O
Clients and libraries *WITH* -O
I have discovered what I think is a bug in the Sun server
when drawing stipple patterns. The following three files
are a simple program to draw some solid and stippled
areas in a window. I have two bitmaps created in the 'bitmap'
editor and I use XCreateBitmapFromData to turn them into pixmaps.
Use a link or edit the #include in the C to switch between the two bitmaps.
When drawing with the 64x64 bitmap as a stipple everything is
fine in colour and monochrome on my Sun 3/110.
When drawing with the 16x16 bitmap the monochrome stipple has lost
its Y origin setting, and on colour the result is completely messed up.
Try moving the window with wm/uwm and then a refresh to force a redraw.
The patterns should stay anchored to the top left if the
ts_x_origin/ts_y_origin are working correctly.
I think the bugs are in the server.
I'm trying a temporary fix -
copy all 16x16 bitmaps onto 64x64 bitmaps before drawing them.
Mike Crawley email: mjc@ahl.co.uk
Abstract Hardware Limited tel: 44 895 58501
/*************************** triangle.64x64 ************************/
#define triangle_width 64
#define triangle_height 64
static char triangle_bits[] = {
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x01, 0x80, 0x0f, 0xc0, 0x07, 0xe0, 0x03, 0x80, 0x01, 0x60, 0x30, 0x30,
0x18, 0x18, 0x0c, 0x80, 0x01, 0x10, 0x40, 0x08, 0x20, 0x04, 0x10, 0x80,
0x01, 0x10, 0x40, 0x08, 0x20, 0x04, 0x10, 0x80, 0x01, 0x08, 0x80, 0x04,
0x40, 0x02, 0x20, 0x80, 0x01, 0x08, 0x80, 0x04, 0x40, 0x02, 0x20, 0x80,
0x01, 0x08, 0x80, 0x04, 0x40, 0x02, 0x20, 0x80, 0x01, 0x08, 0x80, 0x04,
0x40, 0x02, 0x20, 0x80, 0x01, 0x08, 0x80, 0x1f, 0xc0, 0x0f, 0x20, 0x80,
0x01, 0x10, 0xc0, 0x68, 0x60, 0x34, 0x10, 0x80, 0x01, 0x10, 0x60, 0x88,
0x30, 0x44, 0x10, 0x80, 0x01, 0x60, 0x30, 0xb0, 0x18, 0x58, 0x0c, 0x80,
0x01, 0x80, 0x1f, 0xc0, 0x0f, 0xe0, 0x03, 0x80, 0x01, 0x00, 0x10, 0x00,
0x09, 0x80, 0x00, 0x80, 0x01, 0x00, 0x10, 0x00, 0x09, 0x80, 0x00, 0x80,
0x01, 0x00, 0x10, 0x00, 0x09, 0x80, 0x00, 0x80, 0x01, 0x00, 0x10, 0x00,
0x09, 0x80, 0x00, 0x80, 0x01, 0x00, 0x20, 0x80, 0x10, 0x40, 0x00, 0x80,
0x01, 0x00, 0x20, 0x80, 0x10, 0x40, 0x00, 0x80, 0x01, 0x00, 0xc0, 0x60,
0x60, 0x30, 0x00, 0x80, 0x01, 0x00, 0x00, 0x1f, 0x80, 0x0f, 0x00, 0x80,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x01, 0x80, 0x0f, 0xc0, 0x07, 0xe0, 0x03, 0x80, 0x01, 0x60, 0x30, 0x30,
0x18, 0x18, 0x0c, 0x80, 0x01, 0x10, 0x40, 0x08, 0x20, 0x04, 0x10, 0x80,
0x01, 0x10, 0x40, 0x08, 0x20, 0x04, 0x10, 0x80, 0x01, 0x08, 0x80, 0x04,
0x40, 0x02, 0x20, 0x80, 0x01, 0x08, 0x80, 0x04, 0x40, 0x02, 0x20, 0x80,
0x01, 0x08, 0x80, 0x04, 0x40, 0x02, 0x20, 0x80, 0x01, 0x08, 0x80, 0x04,
0x40, 0x02, 0x20, 0x80, 0x01, 0x08, 0x80, 0x1f, 0xc0, 0x0f, 0x20, 0x80,
0x01, 0x10, 0xc0, 0x68, 0x60, 0x34, 0x10, 0x80, 0x01, 0x10, 0x60, 0x88,
0x30, 0x44, 0x10, 0x80, 0x01, 0x60, 0x30, 0xb0, 0x18, 0x58, 0x0c, 0x80,
0x01, 0x80, 0x1f, 0xc0, 0x0f, 0xe0, 0x03, 0x80, 0x01, 0x00, 0x10, 0x00,
0x09, 0x80, 0x00, 0x80, 0x01, 0x00, 0x10, 0x00, 0x09, 0x80, 0x00, 0x80,
0x01, 0x00, 0x10, 0x00, 0x09, 0x80, 0x00, 0x80, 0x01, 0x00, 0x10, 0x00,
0x09, 0x80, 0x00, 0x80, 0x01, 0x00, 0x20, 0x80, 0x10, 0x40, 0x00, 0x80,
0x01, 0x00, 0x20, 0x80, 0x10, 0x40, 0x00, 0x80, 0x01, 0x00, 0xc0, 0x60,
0x60, 0x30, 0x00, 0x80, 0x01, 0x00, 0x00, 0x1f, 0x80, 0x0f, 0x00, 0x80,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
/************************** triangle.16x16 *****************/
#define triangle_width 16
#define triangle_height 16
static char triangle_bits[] = {
0xff, 0x7f, 0x01, 0x40, 0xe1, 0x43, 0x11, 0x44, 0x09, 0x48, 0x05, 0x50,
0x05, 0x50, 0x05, 0x50, 0x05, 0x50, 0x05, 0x50, 0x09, 0x48, 0x11, 0x44,
0xe1, 0x43, 0x01, 0x40, 0xff, 0x7f, 0x00, 0x00};
/************************** triangle.c *********************/
#include <stdio.h>
#include <X11/Xlib.h>
static Display *dpy = 0 ;
static int screen = 0 ;
static Window root = 0 ;
static Window w = 0 ;
static GC gc = 0 ;
static Visual *default_visual = 0 ;
static Colormap default_cmap = 0 ;
static XColor WHITE = { 0 } ;
static XColor GREEN = { 0 } ;
static XColor BLUE = { 0 } ;
static Pixmap triangle = 0 ;
static void DrawStipple ( window,x,y,w,h,fg )
Window window ;
int x,y,w,h,fg ;
{
XGCValues gcv ;
long mask = GCForeground |
GCFillStyle |
GCStipple |
GCTileStipXOrigin |
GCTileStipYOrigin |
GCFunction ;
gcv.foreground = fg ;
gcv.fill_style = FillStippled ;
gcv.stipple = triangle ;
gcv.ts_x_origin = x ;
gcv.ts_y_origin = y ;
gcv.function = GXcopy ;
XChangeGC ( dpy,gc,mask,& gcv ) ;
XFillRectangle ( dpy,window,gc,x,y,w,h ) ;
}
static void DrawOpaque ( window,x,y,w,h,bg,fg )
Window window ;
int x,y,w,h,bg,fg ;
{
XGCValues gcv ;
long mask = GCForeground |
GCBackground |
GCFillStyle |
GCStipple |
GCTileStipXOrigin |
GCTileStipYOrigin |
GCFunction ;
gcv.foreground = fg ;
gcv.background = bg ;
gcv.fill_style = FillOpaqueStippled ;
gcv.stipple = triangle ;
gcv.ts_x_origin = x ;
gcv.ts_y_origin = y ;
gcv.function = GXcopy ;
XChangeGC ( dpy,gc,mask,& gcv ) ;
XFillRectangle ( dpy,window,gc,x,y,w,h ) ;
}
static void DrawSolid ( window,x,y,w,h,i )
Window window ;
int x,y,w,h,i ;
{
XGCValues gcv ;
long mask = GCForeground | GCFillStyle | GCFunction ;
gcv.foreground = i ;
gcv.fill_style = FillSolid ;
gcv.function = GXcopy ;
XChangeGC ( dpy,gc,mask,& gcv ) ;
XFillRectangle ( dpy,window,gc,x,y,w,h ) ;
}
static void DrawPicture()
{
DrawSolid ( w,100,100, 80,100,GREEN.pixel ) ;
DrawSolid ( w,200,150,100, 40,BLUE.pixel ) ;
DrawStipple ( w,300,200, 80,100,BLUE.pixel ) ;
DrawStipple ( w,200,300,100, 80,GREEN.pixel ) ;
DrawOpaque ( w, 0,250, 80,100,GREEN.pixel,BLUE.pixel ) ;
DrawOpaque ( w,100,350,100, 80,WHITE.pixel,GREEN.pixel ) ;
}
#include "triangle.bitmap" /* points to either triangle.16x16 or triangle.64x64 */
static void BestStipple ( sw,sh )
int sw,sh ;
{
int bw,bh ;
XQueryBestStipple ( dpy,root,sw,sh,& bw,& bh ) ;
printf ("Best stipple for %dx%d is %dx%d\n",sw,sh,bw,bh ) ;
}
main()
{
XGCValues gcv ;
int quit = 0 ;
dpy = XOpenDisplay ( NULL ) ;
if ( dpy == NULL )
{
printf ("Cannot open X display\n") ;
exit ( 1 ) ;
}
screen = DefaultScreen ( dpy ) ;
root = RootWindow ( dpy,screen ) ;
default_visual = DefaultVisual ( dpy,screen ) ;
default_cmap = DefaultColormap ( dpy,screen ) ;
WHITE.pixel = WhitePixel ( dpy,screen ) ;
GREEN.red = 0 ;
GREEN.green = 40000 ;
GREEN.blue = 0 ;
XAllocColor ( dpy,default_cmap,& GREEN ) ;
printf ("Pixel %d = (%d,%d,%d)\n",
GREEN.pixel,
GREEN.red,
GREEN.green,
GREEN.blue ) ;
BLUE.red = 0 ;
BLUE.green = 0 ;
BLUE.blue = 40000 ;
XAllocColor ( dpy,default_cmap,& BLUE ) ;
printf ("Pixel %d = (%d,%d,%d)\n",
BLUE.pixel,
BLUE.red,
BLUE.green,
BLUE.blue ) ;
BestStipple ( 16,16 ) ;
BestStipple ( 32,32 ) ;
BestStipple ( 40,48 ) ;
BestStipple ( 64,64 ) ;
triangle = XCreateBitmapFromData ( dpy,root,
triangle_bits,
triangle_width,
triangle_height ) ;
w = XCreateSimpleWindow ( dpy,root,200,200,400,500,1,
BlackPixel(dpy,screen),
WhitePixel(dpy,screen) ) ;
gc = XCreateGC ( dpy,root,0,& gcv ) ;
XSelectInput ( dpy,w,ExposureMask | ButtonPressMask ) ;
XMapWindow ( dpy,w ) ;
while ( ! quit )
{
XEvent ev ;
XNextEvent ( dpy,& ev ) ;
if ( ev.type == Expose ) DrawPicture() ;
if ( ev.type == ButtonPress )
{
}
}
}dshr@SUN.COM (David Rosenthal) (01/09/88)
Please report any and all bugs in X11 to xbugs@athena.mit.edu, as requested in the documentation - a template for the bug report is in doc/bugs. Do NOT report bugs to xpert - no action will be taken on such reports. David.