## Picture1.Point RGB Value

### Picture1.Point RGB Value

How do I extract the R, G, B, values separately from a Picture in a picture
box.

### Picture1.Point RGB Value

Function GetRGB(ByVal RGBval, ByVal Num) As Integer
If Num > 0 And Num < 4 And RGBval > -1 And RGBval < 16777216 Then
GetRGB = RGBval \ 256 ^ (Num - 1) And 255
Else
'Num or RGBval invalid
GetRGB = True
End If
End Function

Sub foo
'sample code retrieving rgb value for pixel in position 10, 10 of
Picture1
Dim r%, g%, b%, color&
color = Picture1.Point(10, 10)
r = GetRGB(color, 1)
g = GetRGB(color, 2)
b = GetRGB(color, 3)
Msgbox "RGB values are " & cstr(r) & ", " & cstr(g) & ", " & cstr(b) &
". "
'Haven't actually tested this(written in outlook express, so expect some
'minor syntax errors
'The GetRGB should work fine
End Sub

>How do I extract the R, G, B, values separately from a Picture in a picture
>box.

### Picture1.Point RGB Value

> How do I extract the R, G, B, values separately from a Picture in a picture
> box.

Hi,
This is a 'non-mathematical' approach :-)

c&=picture1.point(x,y) 'color

blue=val("&H"+mid\$(n\$,1,2))
green=val("&H"+mid\$(n\$,3,2))
red=val("&H"+mid\$(n\$,5,2))

Michaela

Hello,

I coded long time in VisualBasic and want to switch
now to Borland Bulider 6.

I paint an picture using "SetDIBitsToDevice(..)"
this works great but

*) when I move the form out of Screen the picture
is deleted

*) I can't save the picture into an bmp file

in vb the solution of this Problem was:

Picture1.AutoRedraw=True
SetDIBitsToDevice(..)
Set Picture1.Picture = Picture1.Image

how can I do this in BorlandBuilder 6?

And an secound question:
is GetDC(Image1->Picture->Bitmap->Handle) the right
handel to an picture? The Data is not printed in the
picture box but on the screen.
I have to use Form1->Left + Image1->Left as an x-offset
and Form1->Top + Image1->Top as an y-offset. Is this
correct?

best regards,
Philipp Arndt