Pixel Question

Scott Rossi scott at tactilemedia.com
Thu Mar 23 15:32:31 EST 2006


Recently, Bob Warren wrote:

> Suppose I have 2 cards in a stack and I am moving the mouse over the top
> card (naturally). I want to know what colour is under the mouse pointer
> in a corresponding position on the 2nd card which is hidden underneath.

I believe this function will retrieve the pixel color of a pixel in any
image using the X,Y position of the pixel as measured from the topleft of
the image.  Pass the long ID of the image and the X,Y coordinates as
follows:

on mouseUp
  answer retrievePixelColor(long id of myImage,5,5)
end mouseUp


function retrievePixelColor pObj,X,Y
  put imageData of pObj into tData
  put ((Y-1) * width of pObj * 4) + ((X-1)*4) into P
  repeat with N = 2 to 4
    put charToNum(char (P+N) of tData) & "," after tColor
  end repeat
  delete last char of tColor
  return tColor
end retrievePixelColor


Let me know if this works for you.

Regards,

Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
-----
E: scott at tactilemedia.com
W: http://www.tactilemedia.com




More information about the use-livecode mailing list