Re: [AD] small bug in 15 and 16 bit asm color converters

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


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.




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/