|
-
Apr 7th, 2000, 12:47 AM
#1
Thread Starter
Junior Member
The GetPixel api returns a RGB value of a certain pixel at a certain point but it gives it in a single value (i.e. it doesn't give you the individual RGB values as in R,G,B) Is there anyway of discovering the individual RGB values from the single value passed back by this API? Is there maybe any other way of getting the R,G,B value of a pixel?
This is really making me stand on my head so if somone can help me, I would be very appreciative.
"He who laughs at a question is not worth being asked"
RavenCrow

-
Apr 7th, 2000, 12:53 AM
#2
Junior Member
Hmmm....
I don't remember all the GetPixel stuff but I think you could try and make a sub that reads all three RGB values and returns them or something. Once again, I don't know all the specifics of GetPixel so I'm not sure.
-
Apr 7th, 2000, 01:19 AM
#3
Fanatic Member
Functions
Hi,
These functions work fine for me.
OET
Private Function GetRed(colorVal As Long) As Integer
On Error Resume Next
GetRed = colorVal Mod 256
End Function
Private Function GetGreen(colorVal As Long) As Integer
On Error Resume Next
GetGreen = ((colorVal And &HFF00FF00) / 256&)
End Function
Private Function GetBlue(colorVal As Long) As Integer
On Error Resume Next
GetBlue = (colorVal And &HFF0000) / 65535 '(256& * 256&)
End Function
-
Apr 7th, 2000, 01:38 AM
#4
Code:
Option Explicit
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Const CLR_INVALID = &HFFFF
Private Sub Command1_Click()
Dim MyColor As Long
Dim r As Byte
Dim g As Byte
Dim b As Byte
MyColor = GetPixel(Me.hdc, 10&, 10&)
If MyColor <> CLR_INVALID Then
r = MyColor And &HFF
g = (MyColor And &HFF00FF00) / &H100
b = (MyColor And &HFF0000) / &H10000
MsgBox "Red : " & r & vbCrLf & "Green : " & g & vbCrLf & "Blue : " & b
End If
End Sub
-
Apr 7th, 2000, 01:44 AM
#5
Thread Starter
Junior Member
Thank you!!
Thank you soooo much for the Red Green & blue functions!!!
It is very very much appretiated!!

"He who laughs at a question is not worth being asked"
RavenCrow

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
|