Pixels values

  • Thread starter Thread starter jesperd
  • Start date Start date
J

jesperd

is there a way to can get the color of a pixel in a picture?

in the form of

ActiveSheet.Shapes(xxxxxx).??????????????
 
You will not get this directly from normal VBA - or even Visual Basic, I
guess. However you may be successful using API functions via VBA.

Have a look at this for starters. A very useful site. :-
http://www.mentalis.org/apilist/GetPixel.shtml

Here is some code which tells you what the current mouse position is
(of course it depends on where the button is to run it.<<grin>>). This
may save you having to check a few million pixels one by one.

'-----------------------------
'- Get mouse co-ordinates
Type POINTAPI
x As Long
y As Long
End Type
Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As
Long
Dim z As POINTAPI
'------------------------------
Sub Mouse_XY()
GetCursorPos z
MsgBox ("Mouse X : " & z.x & vbCr & "Mouse Y : " & z.y)
End Sub
'------------------------------------------------------
'
 
Back
Top