Re: [AD] small bug in 15 and 16 bit asm color converters |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: alleg-developers@xxxxxxxxxx
- Subject: Re: [AD] small bug in 15 and 16 bit asm color converters
- From: Elias Pschernig <allefant@xxxxxxxxxx>
- Date: Sat, 23 Oct 2004 16:23:44 +0200
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=fj1uGO7IanRmnonFC2xUBw3Znd6g6jfnc01C6oeSGaO3M5M3FdF4hY24mamrAyR+vDR7qzo3RR9GCGZL4QbNvNLzlbvptD6Yece2TMHxC9loULOj/ZTvKu+QoPE9VnZWrkIvRNCBqqmc7Yq0VwoBF4HbLzODyXGhMDEdPqeB3P0=
On Sat, 2004-10-23 at 15:25 +0200, Elias Pschernig wrote:
> Thinking about this.. now color 0/0/0 gets 7/3/7. This needs a better
> soltuion - but my asm skills aren't good enough for that :| And it will
> probably get slower, since it will need a lookup table (like the C
> version). Or maybe there's some clever trick to get this "almost" right?
> Like, use some clever shift-rotate instructions which will leave the 0
> bits as 0 for small color components, and only fill the 1 bits in for
> high ones?
>
> So rgb -> r000g00b000 for colors < 80/80/80, and rgb -> r111g11b111 for
> other colors? Or even better, if it could be per-component.
>
Ok, problem solved. My patch is ok. Quoting #allegro:
"<allefant> so e.g. 255/255/255 gets 248/251/248, which is a greenish
gray on this monitor
<allefant> instead of white
<M> i would fill all unused bits with 1
<allefant> yes, i sent a patch for tha to [AD] before :)
<M> 080808 is v v near to 000000
<allefant> but now 0/0/0 gets 7/3/7
<M> it's still blackest blacky black"
And doing some testing, I agree to this. I set this monitor from the
standard 10% brightness 10% contrast to blinding 100% 100%, and still,
color 7/3/7 is not to be distinguished from 0/0/0.
The proof is this testcase:
#include <allegro.h>
int
main (void)
{
allegro_init ();
set_color_depth (32);
set_gfx_mode (GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
int i;
for (i = 0; i < 640 * 240; i++)
putpixel (screen, i % 640, i / 640,
(i / 640) < 120 ? makecol (0, 0, 0)
: makecol (7, 7, 7));
for (i = 0; i < 640 * 240; i++)
putpixel (screen, i % 640, 240 + i / 640,
(i / 640) < 120 ? makecol (255, 255, 255)
: makecol (248, 248, 248));
install_keyboard ();
install_mouse ();
show_mouse (screen);
readkey ();
return 0;
}
END_OF_MAIN ()
There is no way the discontinuity in the upper half can be seen.. 0/0/0
and 7/3/7 *is* the same color for what out eyes are concernted,
apparently.
The discontinuity on the lower half OTOH is there. Even when using
254/254/254 it can clearly be seen. On the upper half, I can easily go
to 8/8/8 and still - it's pitch black. This may be only true for an LCD
display though - with my old monitor, I never noticed any problems.