PDA

Click to See Complete Forum and Search --> : Getting Pixel Color


*Super Sniper*
Feb 16th, 2000, 07:05 AM
How do you get the color of a pixel?

I would like some sorce code. Thanks in advance :)

------------------
Website (http://www.kaynor.net)

Fox
Feb 16th, 2000, 05:36 PM
The easiest way is using Point which is supported by picture boxes:

-
Color=Picture1.Point (10,10)
-

But ya can also use the *much* faster API command. (You need the DC of the picture box):

-
'In module
Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long

'Anywhere
Dim DC as Long
Dim Color as Long

DC = Picture1.hDC
Color = GetPixel( DC, 10, 20 )
-

i think that's enough ;)

------------------
fox_mccloud@gmx.net
...
Every program can be reduced to one instruction which doesn't work.

*Super Sniper*
Feb 17th, 2000, 07:52 AM
Thanks again. :)
Also will this work if the picture's on a form?

------------------
Website (http://www.kaynor.net)

[This message has been edited by *Super Sniper* (edited 02-17-2000).]

Fox
Feb 17th, 2000, 03:01 PM
Yes, Forms and Pictures are nearly the same.

*Super Sniper*
Feb 18th, 2000, 08:51 AM
It doesn't work. :(

------------------
Website (http://www.kaynor.net)