From: boltar2003 on
Hi

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


From: TR Oltrogge on

<boltar2003(a)yahoo.co.uk> wrote in message news:hb6sbt$rbf$1(a)aioe.org...
> Hi
>
> 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
>
If the drawable is not changing then you only need to execute XGetImage()
once and the entire
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.


From: boltar2003 on
On Thu, 15 Oct 2009 11:09:45 -0400
"TR Oltrogge" <troltrogge(a)verizon.net> wrote:
><boltar2003(a)yahoo.co.uk> wrote in message news:hb6sbt$rbf$1(a)aioe.org...
>> Hi
>>
>> 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
>>
>If the drawable is not changing then you only need to execute XGetImage()
>once and the entire

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

From: TR Oltrogge on

<boltar2003(a)yahoo.co.uk> wrote in message news:hb7eii$kv5$1(a)aioe.org...
> On Thu, 15 Oct 2009 11:09:45 -0400
> "TR Oltrogge" <troltrogge(a)verizon.net> wrote:
>><boltar2003(a)yahoo.co.uk> wrote in message news:hb6sbt$rbf$1(a)aioe.org...
>>> Hi
>>>
<snip>
>>>
>>If the drawable is not changing then you only need to execute XGetImage()
>>once and the entire
>
> 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
>
Correct, XGetImage is an expensive operation.
If you only want a portion (even a single pixel) of a drawable you can use
XCopyArea()
with width and height equal to one to read a single pixel from the server
into your code.
This is sort of the opposite of XDrawPoint(). I don't know why the
implementors of
XWindow didn't include an XReadPoint() but XCopyArea() with dimensions of
one will
accomplish the same thing.

Tim


From: boltar2003 on
On Thu, 15 Oct 2009 11:33:26 -0400
"TR Oltrogge" <troltrogge(a)verizon.net> wrote:
>Correct, XGetImage is an expensive operation.
>If you only want a portion (even a single pixel) of a drawable you can use
>XCopyArea()
>with width and height equal to one to read a single pixel from the server
>into your code.
>This is sort of the opposite of XDrawPoint(). I don't know why the
>implementors of
>XWindow didn't include an XReadPoint() but XCopyArea() with dimensions of
>one will
>accomplish the same thing.

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