comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@acm.org
Subject: Re: Color components and fixed point numbers
Date: Tue, 02 Mar 2004 22:23:21 GMT
Date: 2004-03-02T22:23:21+00:00	[thread overview]
Message-ID: <tP71c.29732$PR3.512648@attbi_s03> (raw)
In-Reply-To: fc19748c.0403020258.603103da@posting.google.com

>Yes, this is the reason why I used 255 and 65535 as denominator. I am
>not a
>expert on color conversion or representation, but I think 0.0 should
>represent
>the darkest and 1.0 the brigthest color independent from the
>representation as
>integers. So 255 and 65535 should be the same brightness.

  You are expanding 8 bits into 16 bits so the question is what to
use to pad out the extra 8 bits.  Using 1.0/256 and 1.0/65536 pads
with zeros.
Declaring
  type Small_Comp is delta 1.0 / 255 range 0.0 .. 1.0;
  for Small_Comp'small use 1.0/255;
  for Small_Comp'Size use 8;

  type Wide_Comp is delta 1.0 / 65535 range 0.0 .. 1.0;
  for Wide_Comp'small use 1.0/65535;
  for Wide_Comp'Size use 16;

pads with greater than zero.

Note that 0.5 is then not exactly representable since 0.5*255= 127.5 I
have one compiler that truncates to 7F and another that rounds to 80.  In
the first case doubling 0.5 will give a value less than 1.0, in the second
case it's greater than 1.0 (and raises Constraint_Error), so the
finiteness of the arithmetic shows up anyway.  OTOH, with power-of-two
deltas, neither range will include 1.0 (Small_Comp'last= 0.996 and
Wide_Comp'last = 0.99609), and Small_Comp(Wide_Comp'last) will overflow.

IMO, black is black, ie 00 = 0000, but "brightest" is not really fixed.
Is the brightness of the screen using 8 bit color and Small_Comp'last the
same as, or slightly less than, the brightness using Wide_Comp'last?  And
what happens if you turn up the monitor's brightness control?  "1.0" is a
very artifical value.

As Robert Eachus pointed out, NTSC has other problems, like "blacker
than black", which you may or may not have to take account of in your
programming.

The bottom line is that you need to make sure your graphics algorithms
stay safely away from 1.0.  As Robert Eachus pointed out, NTSC has other
problems (like "blacker than black") so you better stay away from 0.0
also.  Given those facts, the difference between a power-of-two delta and
a power-of-two-minus-one is a minor point.



  parent reply	other threads:[~2004-03-02 22:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-01 11:49 Color components and fixed point numbers Pat
2004-03-01 16:24 ` Robert I. Eachus
2004-03-02 10:58   ` Pat
2004-03-02 16:39     ` Robert I. Eachus
2004-03-02 22:23     ` tmoran [this message]
2004-03-04 13:31       ` Pat
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox