Hi.
I'm using VB 6.0. I am using the POINT method to get the colour of a
specific point in one of my pictureboxes. How can I change the data that
POINT returns to the 3 RGB values of that colour?
Thanks in advance,
Rob.
PS:
picturebox1.backcolor=rgb(100,100,100)
msgbox picturebox1.point(1,1) //it returns 6579300 :(
Norm Cook - 26 Sep 2005 13:55 GMT
Something along these lines:
Dim clr As Long
Dim Red As Byte, Green As Byte, Blue As Byte
clr = vbWhite
Red = clr And &HFF&
Green = (clr And &HFF00&) \ 256
Blue = (clr And &HFF0000) \ 65536
Debug.Print Red, Green, Blue
> Hi.
>
[quoted text clipped - 8 lines]
> picturebox1.backcolor=rgb(100,100,100)
> msgbox picturebox1.point(1,1) //it returns 6579300 :(
Karl E. Peterson - 27 Sep 2005 20:05 GMT
Hi Rob --
> I'm using VB 6.0. I am using the POINT method to get the colour of a
> specific point in one of my pictureboxes. How can I change the data
> that POINT returns to the 3 RGB values of that colour?
I think the easiest way is to just ask for it, directly.
Public Declare Function GetPixelRGB Lib "gdi32" Alias "GetPixel" (ByVal hDC As
Long, ByVal x As Long, ByVal y As Long) As RGB32
Public Type RGB32
Red As Byte
Green As Byte
Blue As Byte
Pad As Byte
End Type
See http://vb.mvps.org/samples/RGB for complete implementation.
> PS:
> picturebox1.backcolor=rgb(100,100,100)
> msgbox picturebox1.point(1,1) //it returns 6579300 :(
Yep, that's how VB encodes colors into a Long. You can break it apart with math as
Norm shows, or like this:
Public Function SplitColors(ByVal Value As Long) As RGB32
Call CopyMemory(SplitColors, Value, 4)
End Function
Later... Karl

Signature
Working Without a .NET?
http://classicvb.org/petition