[fpc-devel] Correlation between TFPColor and RGB values (possible inconsistencies)
Graeme Geldenhuys
graemeg.lists at gmail.com
Wed Feb 17 13:27:30 CET 2010
Michael Van Canneyt wrote:
>> As defined by fpImage unit.
>>
>> colMaroon : TFPColor = (Red: $8000; Green: $0000; Blue: $0000; Alpha:
>> alphaOpaque);
>>
>>
>> This is *incorrect*. It should be:
>>
>> colMaroon : TFPColor = (Red: $8080; Green: $0000; Blue: $0000; Alpha:
>> alphaOpaque);
>
> This is not so.
>
> Both definitions are - within the 256-bit color plane - 100% equivalent.
I'm no color expert (maybe that shows), but I based the calculation on
ratio information only. Maroon has a red channel value in 24-bit color set
to $80. That's 128/256 giving you a 0.5 ratio. Using that ratio and the max
value per 48-bit color channel (65536) I calculated the same 48-bit red
channel color. 65536 * 0.5 = 32768 = in hex $8080.
128/255 = 32896/65536 = red channel $80 (in RGB 24-bit) or $8080 (in
48-bit) color.
So using the same ratio for both 24-bit and 48-bit color, colMaroon is
incorrectly defined in fpImage.
Now lets apply the same ratio math to colDkGray.
colDkGray : TFPColor = (Red: $4000; Green: $4000; Blue: $4000; Alpha:
alphaOpaque);
I know the RGB (24-bit color) of DarkGray is $40 for the Red channel. So
lets calculate the ratio or the Red channel and upscale it to 48-bit color.
$40 hex = 64 decimal.
64/256 = 0.25 ratio
0.25 * 65536 max color per 48-bit channel = 16384 decimal
16384 dec = $4000 hex.
So based on the definition of colDkGray, the ratio of the red channel is
equivalent to the known 24-bit color ratio. So colDrGray is correctly
defined in fpImage, but colMaroon is not.
I worked with values I know. I only know the hex values of Maroon and
DarkGray in 24-bit color. I tried to use Google to find the exact hex
values in 48-bit color, but couldn't find any clear information. Hence the
reason I upscaled the 24-bit color channel ratios to 48-bit. So having the
same color channel ratios in both 24-bit and 48-bit should equate to the
same color.
> Even the following would be maroon in the 256-bit color plane.
>
> colMaroon : TFPColor = (Red: $80FF; Green: $0000; Blue: $0000; Alpha: alphaOpaque);
Yes, but I'm not limiting my calculation based 24-bit color only. I'm
working with the ratio of red in 24-bit color and applying that same ration
to 48-bit color. That should mean the two colors are the same. Now using
such a ratio with the known 24-bit colors does not equate in all cases to
the 48-bit color definitions in fpImage. They are close, but not equal.
Regards,
- Graeme -
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/
More information about the fpc-devel
mailing list