VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Converts RGB to QBColor. Very fast. Doesn't use any API, DLL, or OCX!

by Nichols Software (5 Submissions)
Category: Graphics
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Originally Published: Fri 6th October 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Converts RGB to QBColor. Very fast. Doesn't use any API, DLL, or OCX!

Rate Converts RGB to QBColor. Very fast. Doesn't use any API, DLL, or OCX!



    Dim R2 As Integer, G2 As Integer, B2 As Integer
    Dim Num1 As Integer, Num2 As Integer
    R2 = R
    G2 = G
    B2 = B
    If Abs(R2 - G2) > 40 Then GoTo Color
    If Abs(R2 - B2) > 40 Then GoTo Color
    If Abs(B2 - G2) > 40 Then GoTo Color
    Select Case (R + G + B) \ 3
    Case Is < 64
        RGB2QBC = 0
    Case Is < 160
        RGB2QBC = 8
    Case Is < 224
        RGB2QBC = 7
    Case Else
        RGB2QBC = 15
    End Select
    Exit Function
Color:
    If B2 > 85 Then RGB2QBC = 1: Num1 = 1: Num2 = B2
    If G2 > 85 Then RGB2QBC = RGB2QBC + 2: Num1 = Num1 + 1: Num2 = Num2 + G2
    If R2 > 85 Then RGB2QBC = RGB2QBC + 4: Num1 = Num1 + 1: Num2 = Num2 + R2
    If Num1 > 0 Then If Num2 \ Num1 > 169 Then RGB2QBC = RGB2QBC + 8
End Function

Download this snippet    Add to My Saved Code

Converts RGB to QBColor. Very fast. Doesn't use any API, DLL, or OCX! Comments

No comments have been posted about Converts RGB to QBColor. Very fast. Doesn't use any API, DLL, or OCX!. Why not be the first to post a comment about Converts RGB to QBColor. Very fast. Doesn't use any API, DLL, or OCX!.

Post your comment

Subject:
Message:
0/1000 characters