|
-
Aug 21st, 2000, 02:41 PM
#1
Thread Starter
Lively Member
Now then, I know how to convert from RGB to long by using RGB(Red As Integer, Green As Integer, Blue As Integer), but how can I convert from a long value back to RGB?
It's puzzled me for a while and the only way I can think to do it is like this:
Code:
Dim redVal As Integer, greenVal As Integer, blueVal As Integer
Dim lngColour As Long
For redVal = 0 To 255
For greenVal = 0 To 255
For blueVal = 0 To 255
If RGB(redVal, greenVal, blueVal) = lngColour Then
'the RGB version of lngColour is redVal, greenVal, blueVal
Exit Sub
Else:
'wrong colour, keep trying
End If
Next blueVal
Next greenVal
Next redVal
This will work, but surely there's an easier way of doing it - this loops through 16 and a half million colours, and checks each one, and my computer crashes every time I try. I need to find it at the click of a mouse button, otherwise the purpose of the application is defied.
Anybody?
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
|