From: patkwee@web.de (Pat)
Subject: Re: Color components and fixed point numbers
Date: 2 Mar 2004 02:58:09 -0800
Date: 2004-03-02T02:58:09-08:00 [thread overview]
Message-ID: <fc19748c.0403020258.603103da@posting.google.com> (raw)
In-Reply-To: uZ6dnZ7RmvRM_t7dRVn-uA@comcast.com
Thank you very much for your answer.
> First fix your type declarations ... Besides, you also omitted the semicolons.
Sorry, was just too lazy...
> Second, you got the numbers wrong, or you want something that many
> compilers would not support as a value for 'Small, even with a rep
> clause. You should use:
I'm very new to Ada, so what is rep clause?
> Since that is how the hardware works, that should be what you expect. So
> Small_RGB'(1.0,1.0,1.0) and Wide_RGB'(1.0,1.0,1.0) are different colors.
> Or better stated: Small_RGB(255.0/256, 255.0/256. 255.0/256) is not
> equal to Wide_RGB(65535.0/65536, 65535.0/65536, 65535.0/65536), and you
> should not expect them to be equal.
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.
If I would use integer arithmetic I would do it like this:
type Small_Comp is range 0 .. 255;
type Wide_Comp is range 0 .. 65535;
-- Small_Comp'Last and Wide_Comp'Last should represent the same
brightest color
-- Small_COmp'First and Wide_Comp'Last should represent the same
darkest color
w : Wide_Comp;
s : Small_Comp:=?;
w := s*65535 / 255; -- equals w:=s*257
s := w / 257;
I though the reason why 1.0/255 is not working may be that there is no
exact
floating point representation of 1.0/255 and so due to rounding 255 *
(1.0/255) < 1.0 .
> Can you force an implementation to make the two brightest whites equal?
> It is not too difficult. Most compilers will give the expected result
> for:
>
> type Small_Component is delta 1.0/256 range 1.0/256 .. 1.0;
> type Wide_Component is delta 1.0/65536 range 1.0/65536 .. 1.0;
I think this will only move my problem, so that now the darkest colors
are
not identical.
Thank you very much, Pat
next prev parent reply other threads:[~2004-03-02 10:58 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 [this message]
2004-03-02 16:39 ` Robert I. Eachus
2004-03-02 22:23 ` tmoran
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