Tools Links Login

Color RGB from a Long Using "Point" method

After using the POINT method the computer returns a long value like 16711680 but with this function it will return the color in the RGB(R,G,B)
format.

Original Author: Brandon Brownlee

Assumptions

Start a new project and make any picture you have the background for your form.
Then start it and move the mouse on the form and look at the caption of the form.

Returns

Returns Rgb(R,G,B) format from a Long Value

Code

Public Blue As Double
Public Green As Double
Public Red As Double
Public BlueS As Double
Public GreenS As Double
Public RGBs As String
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, _
Y As Single)
Call ConvertRGB(Form1.Point(X, Y))
Form1.Caption = RGBs
End Sub
Public Function ConvertRGB(P)
  Blue = Fix((P / 256) / 256)
  BlueS = (Blue * 256) * 256
  Green = Fix((P - BlueS) / 256)
  GreenS = Green * 256
  Red = Fix(P - BlueS - GreenS)
  RGBs = "RGB(" & Red & ", " & Green & ", " & Blue & ")"
End Function

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 87 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.