RGB Values from a picturebox

tblakemore
04-02-2005, 09:54 PM
Hello,

I have a simple question. I have a form and a picturebox. All I want to do is when I mouseover the picturebox, have the pixels RGB value that is under the cursor displayed in a textbox.

However, I cannot find any documentation to do this.

I have tried --> picture1.point(X,Y) <-- to retrieve the color but it returns the result as a long number.

Does anyone know how to convert this number to an RGB or if there is another function to retrieve the RGB of an image a cursor is under.

Gruff
04-02-2005, 10:12 PM
Option Explicit

Dim Color As Long
Dim Red As Byte
Dim Green As Byte
Dim Blue As Byte

Color = Picture1.Point(X, Y)

Red = Color And &HFF
Green = (Color And &HFF00&) \ &H100&
Blue = (Color And &HFF0000) \ &H10000

Msgbox Red & "//" & Green & "//" & Blue

tblakemore
04-02-2005, 11:32 PM
Thank you very much Gruff. The code works perfectly!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum