M***@dastardlyhq.com
2023-10-27 09:18:08 UTC
Hi
I'm hoping to write some code to save the contents of a window clicked on by
the mouse to a file and my plan was to get its image, save the pixels then
reload them into an image created by XCreateImage. However on one of the 3
systems I'm using the XQueryColor() call fails in the following code (but never
fails on the other 2). The only difference is the one it crashes on is a dual
monitor system:
:
:
screen = DefaultScreen(display);
cmap = DefaultColormap(display,screen);
:
:
win = event.xbutton.subwindow ?
event.xbutton.subwindow : event.xbutton.window;
XGetWindowAttributes(display,win,&att);
printf("Window %ld, width = %d, height = %d\n",
win,att.width,att.height);
puts("Grabbing image...");
oldimg = XGetImage(
display,win,
0,0,att.width,att.height,AllPlanes,XYPixmap);
puts("Pixels...");
for(x=0;x < att.width;++x)
{
for(y=0;y < att.height;++y)
{
printf("X,Y = %d,%d\n",x,y);
pixel = XGetPixel(oldimg,x,y);
col.pixel = pixel;
XQueryColor(display,cmap,&col);
$ ./a.out
Window 54532344, width = 786, height = 1037
Grabbing image...
Pixels...
:
:
X,Y = 12,26
X,Y = 12,27
X,Y = 12,28
X,Y = 12,29
X,Y = 12,30
X Error of failed request: BadValue (integer parameter out of range for operati
on)
Major opcode of failed request: 91 (X_QueryColors)
Value in failed request: 0x1000000
Serial number of failed request: 11
Current serial number in output stream: 11
Is there some obvious mistake I'm making?
Thanks for any help
I'm hoping to write some code to save the contents of a window clicked on by
the mouse to a file and my plan was to get its image, save the pixels then
reload them into an image created by XCreateImage. However on one of the 3
systems I'm using the XQueryColor() call fails in the following code (but never
fails on the other 2). The only difference is the one it crashes on is a dual
monitor system:
:
:
screen = DefaultScreen(display);
cmap = DefaultColormap(display,screen);
:
:
win = event.xbutton.subwindow ?
event.xbutton.subwindow : event.xbutton.window;
XGetWindowAttributes(display,win,&att);
printf("Window %ld, width = %d, height = %d\n",
win,att.width,att.height);
puts("Grabbing image...");
oldimg = XGetImage(
display,win,
0,0,att.width,att.height,AllPlanes,XYPixmap);
puts("Pixels...");
for(x=0;x < att.width;++x)
{
for(y=0;y < att.height;++y)
{
printf("X,Y = %d,%d\n",x,y);
pixel = XGetPixel(oldimg,x,y);
col.pixel = pixel;
XQueryColor(display,cmap,&col);
$ ./a.out
Window 54532344, width = 786, height = 1037
Grabbing image...
Pixels...
:
:
X,Y = 12,26
X,Y = 12,27
X,Y = 12,28
X,Y = 12,29
X,Y = 12,30
X Error of failed request: BadValue (integer parameter out of range for operati
on)
Major opcode of failed request: 91 (X_QueryColors)
Value in failed request: 0x1000000
Serial number of failed request: 11
Current serial number in output stream: 11
Is there some obvious mistake I'm making?
Thanks for any help