GetPixelColor ?

Discussion of Inner Space

Moderators: Lavish Software Team, Moderators

Post Reply
Aanya
GamingTools Subscriber
Posts: 18
Joined: Thu Jan 27, 2005 5:15 am

GetPixelColor ?

Post by Aanya » Fri Apr 15, 2005 3:20 am

Im wondering if its possible to retrieve the color of a specified pixel in IS today or if its something that is "on the table" to implement in the future ?

For games without custom extensions that read memory, the GetPixelColor command could be a way to make scripts just a tad more intelligent than what they currently are able to be. For example, it would make it a bit easier to determine health values, mana values etc and take action based on that information without reading memory through an extension.

Anyways dunno if its a bad idea or not. Just thought i'd mention the idea on the boards :)

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Fri Apr 15, 2005 9:54 am

It's actually been supported for a long time now :(

http://www.lavishsoft.com/wiki/index.ph ... ta_Type%29

# rgb GetPixel[x,y]: Retrieves color information of a specific pixel. Coordinates are relative to the viewable portion of the window, not the game's actual display mode
# string PixelSearch[x,y,color,-radius #,search ...]: Searches for the nearest pixel to x,y matching a set of conditions. Color and radius are required. Everything is given in decimal except for color, which must be lower case hexadecimal. Other optional search parameters include -within #, -redwithin #, -greenwithin #, -bluewithin #. These are used left to right, so to search for a color within 32 blue and green, but within 16 red, you could use -within 32,-redwithin 16. The returned string will be in the form x,y

Examples:
- ${Display.GetPixel[100,100]} retrieves the color of the pixel at 100,100
- ${PixelSearch[100,100,0000ff,-radius 10]} searches for a full blue pixel within 10 pixels of 100,100 -- note: "radius" is a misnomer, it actually searches a square of (2*radius)*(2*radius) pixels, centered on the location, e.g. in this case 90,90 to 110,110. Could also be used like ${PixelSearch[100,100,0000ff,-radius 10,-bluewithin 15]} to get the nearest blue pixel to 100,100 within that radius that is within 15 blue values (0000f0 to 0000ff). PixelSearch is currently quite slow when used in a relatively large area, so keep the radius and number of searches to a minimum

As the info says, the location is based on the size of the window, not the game's actual display mode -- this is because it uses standard windows API, and is independent of the game's display system. It is of course possible to use DirectX API to get pixel information, but it would be extremely slow because it would have to do a full screen capture. It would be better to calculate the location of the pixel given the game's resolution and the window's viewable area

Let me know if you need more information or this isn't sufficient (or hell, if it is sufficient, please let me know that too ;) )

Aanya
GamingTools Subscriber
Posts: 18
Joined: Thu Jan 27, 2005 5:15 am

Post by Aanya » Fri Apr 15, 2005 9:55 am

oops must have missed it in the help file.. :D sorry to be a pita :)

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Fri Apr 15, 2005 9:56 am

no not at all, that's what I'm here for. It's not entirely obvious that it exists, and I dont think anyone has used it yet :)

Fuergrissa
GamingTools Subscriber
Posts: 31
Joined: Fri Jul 16, 2004 2:46 am

Post by Fuergrissa » Mon Jul 31, 2006 1:34 pm

is this still working Lax, i allways get NULL when i use this statement

Code: Select all

echo ${Display.PixelSearch[262,383,d6ffff,-radius 3,-redwithin 50,-greenwithin 50,-bluewithin 50]}
If i use

Code: Select all

echo ${Display.GetPixel[262,383]}
I get a return of d6ffff,
I am baffled.

Fuergrissa
GamingTools Subscriber
Posts: 31
Joined: Fri Jul 16, 2004 2:46 am

Post by Fuergrissa » Wed Aug 02, 2006 12:57 am

Is there not anyone using this function ?

Sethric
GamingTools Subscriber
Posts: 17
Joined: Wed Oct 27, 2004 11:26 pm

Post by Sethric » Mon Aug 28, 2006 7:26 pm

Lax wrote:The returned string will be in the form x,y
What is the returned string if no pixel is found matching the search?

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Tue Aug 29, 2006 8:42 am

What is the returned string if no pixel is found matching the search?
http://www.lavishsoft.com/wiki/index.ph ... _Sequences

Note: your question is badly formed, pixel search returns rgbcolor not a string, and if no pixel is found, there is no returned rgbcolor. The answer to your question is found under both "Viewing Objects" and "Members" from the link

Post Reply