waynec@lion.cis.ohio-state.edu (Wayne Carlson) (09/27/90)
I have an x-window procedural question that someone out there might
be able to answer.
I need to create an X-window for an interactive graphics project.
Since I can't determine the pixel value in the X-window, I have
opted to use the XImage structure provided in Xlib to keep a
duplicate copy of the window, from which I can use GetPixel to
read the value. Now the problem.
Since I am using XDrawLine to create the image in the window, and
since the graphics primitives don't draw directly to the XImage
structure, I have chosen to use XGetSubImage to move the rectangle
that bounds the newly drawn line into the Image structure. When I
invoke the call, I get the following error message:
***************
X Error of failed request: BadValue (integer parameter out of range
for operation)
Major opcode of failed request: 73 (X_GetImage)
Minor opcode of failed request: 0
Resource id in failed request: 0x0
Serial number of failed request: 13
Current serial number in output stream: 13
***************
We are running R4 on aa SPARCstation SLC. The following is the 'c' code
for the window and image stuff:
if ((dpy = XOpenDisplay(NULL)) == NULL)
fperr("Couldn't open display!");
windowwidth = windowheight = 600;
window = XCreateWindow(dpy, RootWindow(dpy, DefaultScreen(dpy)),
20, 20, windowwidth, windowheight, 1,
DefaultDepth(dpy, DefaultScreen(dpy)), CopyFromParent,
&visual, (CWBackPixel | CWBorderPixel | CWBackingStore),
&attributes);
depth = 1;
format = XYBitmap;
bitmap_pad = 32;
ximage = XCreateImage(dpy,DefaultVisual(dpy,screen),depth,
format,0,0,windowwidth,windowheight,bitmap_pad,0);
ximage->data = malloc((ximage->bytes_per_line)*windowheight);
if (ximage->data == 0) fperr("Error in malloc() for XImage");
if (ximage == 0) fperr("Error creating XImage\n");
.
.
.
XDrawLine(dpy, window, gc, cx, cy, *x, windowheight - *y);
XGetSubImage(dpy,window,cx,windowheight-cy,abs(*x-cx)+1,abs(windowheight-*y-cy)+1,-1,format,ximage,cx,windowheight-cy);
cx and cy have the current value of x and y (from a 'moveto' command.
x and y have the values to which the line should be drawn. In the debug
program, cx=cy=10 and x=y=50. I added the +1 in the XGetSubImage command
to compensate for a null rectangle in the event of a vertical or
horizontal line.
Any clues?
Thanks...
please email to
waynec@cis.ohio-state.edu
Wayne Carlson