|
-
Aug 19th, 2000, 09:22 AM
#1
Thread Starter
Addicted Member
Hello,
I notice that when I use the GetPixel API the result isn’t in the RGB format. I’m unfamiliar to whichever method it is using so would someone please notify me of any method of converting the result from the GetPixel API into RGB format? Thanks
-
Aug 19th, 2000, 09:29 AM
#2
Frenzied Member
This one has always confused me, I never quite worked out exactly what it was doing, it always seemed to me that some API Functions came back with RGB results in the correct form and some come back with the components mixed up (the red bit where the blue should be etc.
I think it's a bug rather than anything else
Try putting the results of pixels coloured gompletley red, blue or green into an RGBQUAD, se if you can work out which colour componentss are going where.
-
Aug 19th, 2000, 09:33 AM
#3
Monday Morning Lunatic
The GetPixel function returns a BGR encoded colour, in the format: 0xBBGGRR. So, use this to extract the items:
Code:
Private Type ColourRGB
lRed As Integer
lGreen As Integer
lBlue As Integer
End Type
Private Sub Form_Load()
Dim z As ColourRGB
z = ExtractColour(RGB(&HAA, &HBB, &HCC))
Debug.Print Hex(z.lRed)
Debug.Print Hex(z.lGreen)
Debug.Print Hex(z.lBlue)
End Sub
Private Function ExtractColour(lColour As Long) As ColourRGB
Dim tempC As ColourRGB
tempC.lBlue = (lColour \ &H10000) And &HFF
tempC.lGreen = (lColour \ &H100) And &HFF
tempC.lRed = lColour And &HFF
ExtractColour = tempC
End Function
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 19th, 2000, 09:33 AM
#4
Try this:
Code:
lColor = GetPixel(Picture1.hdc, 32, 32)
'Get Red, Green and Blue
lRed = lColor Mod &H100
lGreen = Int(lColor / &H100) Mod &H100
lBlue = Int(lColor / &H10000) Mod &H100
-
Aug 19th, 2000, 09:34 AM
#5
Monday Morning Lunatic
Just noticed...it's buggered the numbers. The &h10000 and such should be all together, with no spaces.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 19th, 2000, 09:42 AM
#6
Thread Starter
Addicted Member
Thanks guys I'll give all the suggestions a try.
-
Aug 19th, 2000, 09:51 AM
#7
Thread Starter
Addicted Member
By the way, what does do? It's a command that I've never came across.
-
Aug 19th, 2000, 09:54 AM
#8
Monday Morning Lunatic
The Modulus operator divides two numbers and returns the remainder:
res is now 2 (since 20 / 6 = 18 r 2)
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Aug 19th, 2000, 11:11 AM
#9
Thread Starter
Addicted Member
Oh yes, it the equivalent to % in C++. Thanks Parksie.
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
|