the black hole 
it all ends here. 
bhC login
name:
pass:
 
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!
articles
 
rpg theory (7)
directx in vb (3)
vb rpg programming (4)
miscellaneous (4)
files
 
rpg / tile engine source (23)
full vb games w/ source (5)
'helper' libraries and utilities (13)
effect samples (5)
miscellaneous (10)
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!
links
 
vb rpg programming (5)
vb gaming (14)
general game programming (6)
vb sites (6)
miscellaneous (2)
general rpg programming (2)
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



pages: prev | 1 | next