|
-
May 14th, 2002, 07:13 AM
#1
Thread Starter
New Member
Color Snap
I wish to build to program which is able snap a point in windows or i should say get a coordinate of that point based on the given color. Do anyone have idea how to do it? Thanks for help.
-
May 14th, 2002, 10:56 AM
#2
Not NoteMe
Do you meen search through a graphic (picbox etc or screen) looking for a certain colour?
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
May 14th, 2002, 11:05 AM
#3
Thread Starter
New Member
yes. I think WinAPI can do it but i dont know which command to use. Please give me an example code if you can. Thanks again for help.
-
May 14th, 2002, 11:29 AM
#4
Fanatic Member
use the GetPixel API (or you can use the point method of pictureboxes/forms).
-
May 14th, 2002, 03:03 PM
#5
Good Ol' Platypus
That won't help much - he needs to know how.
Ok, add the declaration from the API viewer as you would any other API call. Then, use the function like below. Remember you'll also have to get the PointAPI declaration from the Types field of the API viewer:
VB Code:
Function SearchForColour(ByRef mPic As PictureBox, ByRef Ret() As PointAPI, ByRef Colour As Long)
Dim X As Long
Dim Y As Long
Dim Count As Long
mPic.ScaleMode = 3 'vbPixels
For Y = 0 To mPic.ScaleHeight
For X = 0 To mPic.ScaleWidth
If GetPixel(X, Y, mPic.hDC) = Colour Then
Count = Count + 1
Redim Preserve Ret(0 To Count - 1) As PointAPI
With Ret(Count - 1)
.X = X
.Y = Y
End With
Next X
Next Y
The code hasn't been tested, but should work. Just go through the Ret() array, just Ret(0) if you aren't expecting more than 1 match. You might use it like this:
VB Code:
Dim myArr() As PointAPI
Dim I As Long
On Error Goto NoBlack
SearchForColour Picture1, myArr, RGB(0, 0, 0)
For I = LBound(myArr) To UBound(myArr)
Msgbox "Pure Black found at X: " & myArr(I).X & " Y: " & myArr(I).Y & ".", , "Black Found!"
Next I
NoBlack:
Msgbox "No Pure Black in Picturebox!", , "No Black!"
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
May 14th, 2002, 03:08 PM
#6
Not NoteMe
Don't forget the Extra type used there!
VB Code:
Public Type POINTAPI
x As Long
y As Long
End Type
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
May 15th, 2002, 05:14 AM
#7
Thread Starter
New Member
I think those example is sufficient for me to build the program. I appreciate the advises from you guys and thanks a lot.
-
May 15th, 2002, 09:13 PM
#8
Good Ol' Platypus
Ok, add the declaration from the API viewer as you would any other API call. Then, use the function like below. Remember you'll also have to get the PointAPI declaration from the Types field of the API viewer:
SLH -
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
May 16th, 2002, 01:49 AM
#9
Not NoteMe
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|