home |
the black hole's front page. all the latest vb rpg development and vbgaming news, as well as this week's feature rpg project! |
rpg projects
|
vb rpg projects under development by members of the bhC. show them your
support, and check out their games! |
message board |
a forum to interact with your fellow vb rpg programmers. you do *not* have
to be a bhC member to post! |
contact |
you want to contact the guy behind the black hole? here's where to
do it! |
|
|
 |
|
<< Back to Category List
GetPixel - Retreiving a Pixel Color - page 1 |
pages:
prev | 1 | next
GetPixel is yet another member of the Windows API. It is used to determine the pixel color of an object at an (X, Y) location determined by you, the programmer. To begin, add the following to a new or existing module within your current project.
| Declare Function GetPixel Lib "GDI" (ByVal hDC As Integer, _
????ByVal X As Integer, ByVal Y As Integer) As Long
To use this function, begin by changing your Form's name to frmMain. Also, set its ScaleMode to 3 (pixel). Now add the following code to your Form_MouseDown procedure.
| Call MsgBox(GetPixel(frmMain.hDC, X, Y))
When you run the porgram and click on the form, a MessageBox will appear. The number written in this MessageBox is the pixel color at the (X, Y) coordinate you clicked. How to decode this number into its RGB values can be found in another tutorial. Enjoy, and good luck!
| Matt Huggins
Nobis Productions
|