VBspeed / Colors / SplitRGB
VBspeed © 2000-10, updated: 19-Nov-2001
SplitRGB


Function SplitRGB
RGB color longs look like this: &H00BBGGRR. SplitRGB extracts the red, green and blue parts. The returns can be organized in various ways. Below you see two of them: (a) a return argument for each color part, (b) the function itself returns a struct (Type) containing the parts.
(a) Sub SplitRGB(ByVal lColor As Long, _
          ByRef lRed As Long, _
          ByRef lGreen As Long, _
          ByRef lBlue As Long)

(b) Type RGB32
      Red   As Byte
      Green As Byte
      Blue  As Byte
      Pad   As Byte
    End Type
    
    Function SplitRGB(ByVal lColor As Long) As RGB32
Code
SplitRGB01
Public Sub SplitRGB01(ByVal lColor As Long, _
    ByRef lRed As Long, _
    ByRef lGreen As Long, _
    ByRef lBlue As Long)
' by www.Abstractvb.com, Date: 3/9/2001 9:26:43 PM, 20010922
  lColor = lColor And &HFFFFFF
  lRed = lColor Mod &H100&
  lColor = lColor \ &H100&
  lGreen = lColor Mod &H100&
  lColor = lColor \ &H100&
  lBlue = lColor Mod &H100&
End Sub
SplitRGB02
Public Sub SplitRGB02(ByVal lColor As Long, _
    ByRef lRed As Long, _
    ByRef lGreen As Long, _
    ByRef lBlue As Long)
' by Donald, donald@xbeat.net, 20010922
  lRed = lColor And &HFF
  lGreen = (lColor And &HFF00&) \ &H100&
  lBlue = (lColor And &HFF0000) \ &H10000
End Sub
SplitRGB03
Public Function SplitRGB03(ByVal lColor As Long) As RGB32
' by Donald, donald@xbeat.net, 20010922
  With SplitRGB03
    .Red = lColor And &HFF
    .Green = (lColor And &HFF00&) \ &H100&
    .Blue = (lColor And &HFF0000) \ &H10000
  End With
End Function
SplitRGB04
Public Function SplitRGB04(ByVal lColor As Long) As RGB32
' by Karl E. Peterson, http://www.mvps.org/vb, 20011119
  Call CopyMemory(SplitRGB04, lColor, 4&)
End Function
Calls
1lColor = &HFF0000
2lColor = &HFF00&
3lColor = &HFF&
Charts
 VB5 Charts
CodeAuthorDopingNotes
SplitRGB01 Abstractvb  
SplitRGB02 Donald  
SplitRGB03 Donald  
SplitRGB04 KarlAPI 
Call 1
21.720.094Ás
11.000.055Ás
33.890.213Ás
48.090.443Ás
Call 2
21.710.094Ás
11.000.055Ás
33.900.213Ás
48.110.443Ás
Call 3
21.710.094Ás
11.000.055Ás
33.900.213Ás
48.100.443Ás
 VB6 Charts
CodeAuthorDopingNotes
SplitRGB01 Abstractvb  
SplitRGB02 Donald  
SplitRGB03 Donald  
SplitRGB04 KarlAPI 
Call 1
21.450.083Ás
11.000.058Ás
33.350.193Ás
47.500.432Ás
Call 2
21.450.083Ás
11.000.057Ás
33.350.193Ás
47.510.432Ás
Call 3
21.450.084Ás
11.000.058Ás
33.350.193Ás
47.510.432Ás
Notes & Conclusions
The result is no surprise for speedcorers, but maybe for those who think "API" is synonymous to "speed".
Got comments? How to read all those numbers

top




VBspeed © 2000-10 by Donald Lessau