[AD] palette_color[] in 8 bit modes

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


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

The docs for the palette_color[] array (alleg012.html#palette_color) 
state that in 8 bit mode the array indices map onto theirselves (ie. 
palette_color[i] = i for 0 <= i < 256).

The attached test program, for me at least, shows that the palette_color 
array is all 0 in 8 bit mode, which is nasty :-(

Please confirm whether this is either a bug in the library, the 
documentation, or my interpretation thereof. Thanks!

Bye for now,
- -- 
Laurence Withers,  lwithers@xxxxxxxxxx
(GnuPG 04A646EA) http://www.lwithers.demon.co.uk/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE9ginrUdhclgSmRuoRAooYAJ9d9nWirXycKzicFzIvgCfIlKIkYgCfQkWS
0tNtt8YMDBNNqjRPeeXrav0=
=Oxxv
-----END PGP SIGNATURE-----
/* test-palette_color.c
 *
 *  A quick test program for seeing if the 'palette_color' array is
 *  working.
 */

#include <allegro.h>
#include <stdio.h>

int color_depth_list[] = {
    8,
    15,
    16,
    24,
    32,
    0
};

int main(void)
{
    int* color_depth = 0;
    int i;
    PALETTE pal;
    
    if(install_allegro(SYSTEM_NONE, &errno, atexit)) {
        fprintf(stderr, "Failed to install Allegro.\n");
        return 1;
    }
    
    printf("Palette (RGB is decimal VGA, 0-63):\n");
    generate_332_palette(pal);
    for(i = 0; i < 256; i++)
        printf("  %03d: r%02d g%02d b%02d\n",
            i, pal[i].r, pal[i].g, pal[i].b);
    printf("\n\n\n");

    printf("palette_color[] listings (RGB is hex, 0-255):\n");
    
    for(color_depth = color_depth_list; *color_depth; color_depth++) {
        
        printf("  Color depth %d\n", *color_depth);
        set_color_depth(*color_depth);
        set_palette(pal);
        
        for(i = 0; i < 256; i++) {
            
            int x = palette_color[i];
            printf("    palette_color[%03d] = %8d "
            "(r%02X g%02X b%02X)\n",
                i, x,
                getr(x), getg(x), getb(x));
        }
        
        printf("\n\n\n");
    }
    
    return 0;
}
END_OF_MAIN()



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