This topic is now archived and is closed to further replies.


How to get a color of a pixel ?!

Recommended Posts

NikEy    122
what do i have to do, to get the color of a pixel from a game, (Halflife for example) at a certain position ? anyone can halp me ? =) --nik

Share this post

Link to post
Share on other sites
finding out the color of a pixel costs so much time, that you would need a 1400 Mhz PC to reach more that 10 fps. :-)
You should make a 2D matrix(=Array) and store the info there. And when you need it just find out what is stored there.
For example:

thing : record
info that you need
bla bla

Map : Array[1..100] of
Array[1..100] of Thing;

Share this post

Link to post
Share on other sites
Paul_Johnstone    122
/me suspects NikEy is trying to make an aimbot for counterstrike. ;-)

There is am aimbot already made which samples the pixels around the crosshair and checks the colour. It doesn''t sample particularly often so the framrate doesn''t suffer.

I was trying to work out how this is done recently and couldnt find anything on the subject, (I play X-Tension and leave it running all night to make money, but I want to sample the pixels where the time acceleration guage is and check if it''s been switched off, and if it has, switch it back on again).

Anyone got any info/ideas on the subject?

Impaler - AI / Game Logic programmer
ZZICT Entertainment

Share this post

Link to post
Share on other sites
NikEy    122
there exists an aimbot for HL
i just want to know, how that pixelgrabbing is working, because u could do some funny stuff with it.

Share this post

Link to post
Share on other sites
Hunter-Killer    112
AH fuck I just saw you want it from a game not your game. Oh well I spent some time writing this so maybe it will help somehow.

Actually if you want to know how to do it it's quite simple.

1. use glReadPixels to get the current screen buffer.
2. determine color settings
3. find the color based on bpp and resolution

if its 16 bit do this:

//assuming you have the buffer
color = buffer[x*y*(bytes_per_line>>1)];

So what this does is multiply the x coord of the pixel with the y coord of the pixel. Then it divides the number of bytes per line, which at a res of 640x480 in 16bit color with linear hardware would be 1280 (or 640x2), by 2. Then it takes those values and multiplies them to get the exact position of your pixel in the screen buffer and the result is the color. This may not be true for GL but it works in thw windows GDI.


Edited by - Hunter-Killer on February 2, 2001 4:06:42 PM

Share this post

Link to post
Share on other sites