I have an image that is 400, 400 and I am trying to get the color of the pixel at 200,200. I have been searching through the dictionary for a way to do this and now I am stumped.
thoughts on what i can use?
Getting the pixel color of X,Y on an image
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Getting the pixel color of X,Y on an image
- Rich
LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4
LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4
Re: Getting the pixel color of X,Y on an image
Hi Rich...
Put this into the script of your image ... and, err... move the mouse around..
be well
Dixie
Put this into the script of your image ... and, err... move the mouse around..
Code: Select all
on mouseWithin
put item 1 of the mouseLoc - item 1 of the topLeft of me into X
put item 2 of the mouseLoc - item 2 of the topLeft of me into Y
put the mouseColor into thePixColor
put X & "," & Y && "/" && thePixColor
end mouseWithin
Dixie
Re: Getting the pixel color of X,Y on an image
There are two ways - the shortcut (which only works if the image is visible, on screen, and not obscured by anything) and the more complex way:richh wrote:I have an image that is 400, 400 and I am trying to get the color of the pixel at 200,200. I have been searching through the dictionary for a way to do this and now I am stumped.
thoughts on what i can use?
Shortcut: Move the cursor to that location programmatically and then ask for the mouseColor:
Code: Select all
put the mouseLoc into tOldLoc
set the mouseLoc to globalLoc((the left of img 1+200),(the top of img 1+200))
put the mouseColor into tColor -- you'll use this, it's an RGB value
set the mouseLoc to tOldLoc
See this tip for info on how to do that.
Ken Ray
Sons of Thunder Software
Email: kray@sonsothunder.com
Web site: http://www.sonsothunder.com
Sons of Thunder Software
Email: kray@sonsothunder.com
Web site: http://www.sonsothunder.com
Re: Getting the pixel color of X,Y on an image
I am very appreciative with how fast you both got back to me and I will take some time looking at your example code and trying to implement.
I will keep you both posted with how I make out.
thank you again
I will keep you both posted with how I make out.
thank you again

- Rich
LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4
LiveCode 4.6.4
Dell Latitude E6400 running Windows XP SP3 / Mac Pro, Macbook Pro & Mac Mini running OS X 10.6.4
Re: Getting the pixel color of X,Y on an image
Hi Richh,
For an other way, you can look at the imagedata entry of the LC dictionary
(Poor frenchie, It is difficult for me to explain in English)
All the best
Jean-Marc
For an other way, you can look at the imagedata entry of the LC dictionary
(Poor frenchie, It is difficult for me to explain in English)
All the best
Jean-Marc
https://alternatic.ch