hello EveryBody
I have an interface with many objects inside (buttons, graphics, ...) in the background .some of these objects are moving alone depending random trajectories. I need to know the color of the pixel in a X,Y part of the interface.
I know the use of mouseColor who give us what color the mouse is over and the background of this interface is not an image (imagedata property is not usable)
I need to know the color of the interface under the four corners of a square . This square is controlled with the mouse and I need to compare the fours colors (one by corner) at each time I move the square with the mouse. I can't use the mouseColor function because the mouse is inside the square
If someone has a solution, I will be grateful
Thanks for help
fm31
color of a pixel without use of mouseColor
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: color of a pixel without use of mouseColor
Hi fm31,
I use this script, it works for my needs (a kind of answer color) but sometimes it return some strange results as you can see at the last line
I hope this help
Best regards
Jean-Marc
I use this script, it works for my needs (a kind of answer color) but sometimes it return some strange results as you can see at the last line
I hope this help
Code: Select all
function getMyPixColor pImage,x,y
put x - the left img pImage + 1 into tImgX
put y - the top of img pImage + 1 into tImgY
put the imageData of image pImage into tData
put the width of image pImage into tWidth
put the height of image pImage into tHeight
put tImgX into tColumn
put tImgY into tRow
put tWidth * tRow * 4 into tAllRows
put tColumn * 4 into tTheColumns
put tAllRows + tTheColumns into tByte -- for loc 1,1 it gives byte 4, see above how the 4 bytes of the pixel work
-- we want byte 2 to 4 of the pixel
put charToNum (char tByte - 2 of tData) into tRed -- byte
put charToNum (char tByte - 1 of tData) into tGreen
put charToNum (char tByte of tData) into tBlue
put tRed & comma & tGreen & comma & tBlue into tWholeRGB
return tWholeRGB -- & cr & the mousecolor -- compare results
end getMyPixColor
Jean-Marc
https://alternatic.ch