[futurebasic] Re: [FB] RGB Color

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : May 2001 : Group Archive : Group : All Groups

From: Alain Pastor <apastor@...>
Date: Wed, 16 May 2001 17:14:02 +0200

Marc Girondot wrote:
> 
> Hye,
> 
> I try to get the color of the pixel of an image but there are some
> inconstancies that I don't understand.
> I define the RGB variable as
> DIM AS RGBCOLOR rgb
> 
> and I obtain the color of the pixel by
> 
> call getcpixel(xh%, yh%, RGB)
> with xh% and yh% the x and y position in the current window.
> 
> Then I obtain the color in
> RGB.red%, RGB.blue% and RGBbg.green%
> 
> But what is the range of the color... sometimes I obtain negative
> value... then I suspect that it ranges for -32767 to 32768, but
> sometimes I obtain 65535... then I suspect that it ranges for 0  to
> 65535.
> 
> Furthermore, if I use:
> long color RGB.blue%, RGB.green%, RGB.red%
> 
> The selected color is correct according to the RGB.blue%, RGB.green%,
> RGB.red% even if they are negative whereas the reference manual
> indicated that each parameter of long color should be from 0 to 65535
> (it is the french manual).
> 
> I suspect that sometimes it shows the results in 2 bytes signed
> (-32767 to 32768) or unsigned  (0 to 65535), but how to know if you
> are in sign or unsign for a value between 0 and 32768 ?
> 
> Thanks a lot
> 
> Marc Girondot
> 

Hi Marc,

I think it is not totally correct to write the following (it comes
from FBII): RGB.blue%, etc.
You should use an unsigned integer like so (available in FB^3):
RGB.blue%`, etc.
But the best is to remove the type identifier suffix since you are
using an RGBColor record: RGB.blue, etc.

The RGBColor record is defined in the header like so:
begin record RGBColor
dim red       as unsigned short
dim green     as unsigned short
dim blue      as unsigned short
end record

-- 

Cheers

Alain

-----------------------------------------------------
FB^3 in Europe:  http://euro.futurebasic.com/
FB II Pouch:     http://www.pixmix.com/FB/outils.html
-----------------------------------------------------