|
-
Feb 2nd, 2001, 10:26 PM
#1
Thread Starter
Good Ol' Platypus
I'm not sure how to get the red, green, and blue bits from the long data type that is returned from the getpixel routine. Could anybody show me how to do this?
A=getpixel(5,5,me.hdc)
What is a's red value (0-255)?
What is a's green value (0-255)?
What is a's blue value (0-255)?
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Feb 2nd, 2001, 10:42 PM
#2
Fanatic Member
Enjoy!
Code:
Private Sub Form_Load()
Dim lColor As Long
lColor = RGB(225, 75, 180)
Debug.Print GetR(lColor)
Debug.Print GetG(lColor)
Debug.Print GetB(lColor)
End Sub
Private Function GetR(ByVal pCol As Long) As Byte
GetR = pCol Mod 256
End Function
Private Function GetG(ByVal pCol As Long) As Byte
pCol = pCol \ 256
GetG = pCol Mod 256
End Function
Private Function GetB(ByVal pCol As Long) As Byte
pCol = (pCol \ 256) \ 256
GetB = pCol Mod 256
End Function
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Feb 2nd, 2001, 10:44 PM
#3
Thread Starter
Good Ol' Platypus
Thanks Youngbuck; I thought it could only be done with hex. (I forgot the code, its in a microsoft MSChart MSDN thing or something)
Thanks!
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Feb 2nd, 2001, 10:49 PM
#4
Fanatic Member
Hex GetR, GetG, GetB
Code:
Private Sub Form_Load()
Dim lColor As Long
lColor = RGB(255, 255, 255)
Debug.Print GetR(lColor)
Debug.Print GetG(lColor)
Debug.Print GetB(lColor)
End Sub
Private Function GetR(ByVal pCol As Long) As Byte
GetR = pCol Mod &H100
End Function
Private Function GetG(ByVal pCol As Long) As Byte
pCol = pCol \ &H100
GetG = pCol Mod &H100
End Function
Private Function GetB(ByVal pCol As Long) As Byte
pCol = (pCol \ &H100) \ &H100
GetB = pCol Mod &H100
End Function
Better?
{Insert random techno-babble here}
{Insert quote from some long gone mofo here}
-
Feb 3rd, 2001, 07:05 AM
#5
transcendental analytic
Sas! Check out how you could do this without any mathematical operators:
http://forums.vb-world.net/showthrea...rgb#post219447
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Feb 3rd, 2001, 07:44 AM
#6
Fanatic Member
-
Feb 3rd, 2001, 05:53 PM
#7
Thread Starter
Good Ol' Platypus
yo kedaman, get a better avatar!
(not that i dont like your drawing)
goto www.yahoo.com
search for 'chrono trigger dance party'
go to the page and download your favourite character!
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Feb 3rd, 2001, 06:27 PM
#8
transcendental analytic
damn, why don't you like my cool avatari Sas?!
Ok, thanks for the suggestion
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
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
|