I need to constantly get the pixel values in a drawable. The only way I can
see to do this is call XGetImage() then XGetPixel() , but calling XGetImage()
every iteration seems horribly inefficient. Is there a way I can get a pixel
value directly instead of having to copy the entire window contents each time?
Thanks for any help
B2003
Thats the problem though - it is changing in quite a complex way because its
a game. Trying to work out what exact pixels will be where from the drawing
commands sent would be a thankless task.
>window contents will now be in your local memory space (instead of the
>server's) and you
>now use XGetPixel() in a loop to pull out any individual pixels you want.
>XGetPixel()
>runs quickly since it does not involve communication with the server.
But calling XGetImage() all the time I imagine would not be quick.
B2003
Tim
Ah ok , so I guess I'd create a drawable 1x1 pixel , copy into that then
do XGetImage and XGetPoint on that 1x1 drawable?
You'd think that something like XReadPoint() would be an obvious thing
to include since many other graphics systems had it but... oh well.
Thanks for the info!
B2003
Part of the complexity of XWindow is its power: the server for your XWindow
protocol requests *can* be running on a machine half way around the world
with display characteristics quite foreign to the
machine your client application is running on. The pattern of bits you pack
into a 'long' variable to define the 3 RGB colors
of a line, text, or pixel going into a drawable residing in the server's
memory can be rearranged by the server to best fit the
physical screen memory. But you'd like to think there was at least one
function to pull a pixel from the server's drawable and
then rearrange it to fit the usual pattern you originally packed into your
'long' variable. But I don't see any such function in my
O'Reilly & Associates "Xlib Programming Manual" Copyright 1992 book that I
have.
However, it does seem to have a
slightly simpler function that would eliminate your idea of having to create
a 1x1 pixel drawable and XCopy() your source
window into. Look at XGetSubImage(). This will permit you to pull a 1x1 (or
any size you want) sub-portion of your
game window into your pre-created XImage structure. Then you use XGetPixel()
to pull the pixel's color in client-side
'long' variable format. So, instead of XCopy(), XGetImage(), XGetPoint() you
would use XGetSubImage(), XGetPoint().
HTH
Tim
Even better, thanks for that.
B2003