Results 1 to 6 of 6

Thread: [RESOLVED] color conversion

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Resolved [RESOLVED] color conversion

    I have attempted to find a color converter to convert colors like &H00C0C000& to RGB values. anyone know of anything?












    Added green "resolved" checkmark - Hack

  2. #2
    Frenzied Member Andrew G's Avatar
    Join Date
    Nov 2005
    Location
    Sydney
    Posts
    1,587

    Re: color conversion

    This?
    VB Code:
    1. 'Example by Bertrand DUMAS-PILHOU ([email protected])
    2. Private Declare Function TranslateColor Lib "olepro32.dll" Alias "OleTranslateColor" (ByVal clr As OLE_COLOR, ByVal palet As Long, col As Long) As Long
    3. Private Sub Form_Load()
    4.     Dim RealColor As Long
    5.     'Convert OLE colors to RGB colors
    6.     TranslateColor Me.BackColor, 0, RealColor
    7.     'show the result
    8.     MsgBox "The backcolor of this form is R=" + CStr(RealColor And &HFF&) + " G=" + CStr((RealColor And &HFF00&) / 2 ^ 8) + " B=" + CStr((RealColor And &HFF0000) / 2 ^ 16)
    9. End Sub

  3. #3

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] color conversion

    Why use a whole API when you can do it in 4 bitwise operations...

    VB Code:
    1. red = rgbValue And &HFF&
    2. green = (rgbValue And &HFF00&) \ &HFF&
    3. blue = rgbValue \ &HFF00&

    Much more efficient

  5. #5
    Fanatic Member
    Join Date
    Dec 2005
    Posts
    570

    Re: [RESOLVED] color conversion

    Quote Originally Posted by penagate
    Why use a whole API when you can do it in 4 bitwise operations...

    VB Code:
    1. red = rgbValue And &HFF&
    2. green = (rgbValue And &HFF00&) \ &HFF&
    3. blue = rgbValue \ &HFF00&

    Much more efficient
    Where to write this code in a load event or for command buuton?

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: [RESOLVED] color conversion

    Wherever you want. How should I know?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width