Re: [AD] Another GFX_SAFE patch, now the demo |
[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]
In reply to Grzegorz Adam Hankiewicz <gradha@xxxxxxxxxx>: >True, Allegro converts the datafile. You only have to be careful to load >the palette before the datafile. The routine I was thinking about was >something more complex, where a single datafile contains images with >different palettes, and were you mix different color depth graphics, and >all of them would use the actual color depth at the end. It doesn't have to be that complicated. For instance (untested): DATAFILE* load_demo_data(const char* filename) { DATAFILE* dat = 0; DATAFILE* default_pal_dat = 0; RGB* default_pal = 0; set_color_conversion(COLORCONV_NONE); dat = load_datafile(filename); if(!dat) return 0; default_pal_dat = find_datafile_object(dat, "GAME_PAL"); if(!default_pal_dat) { unload_datafile(dat); return 0; } default_pal = default_pal_dat->dat; convert_datafile(dat, default_pal); return dat; } void convert_datafile(DATAFILE* dat, RGB* default_pal) { DATAFILE* iter = 0; DATAFILE* pal_dat = 0; RGB* pal = 0; char* pal_name = 0; for(iter = dat; iter->type != DAT_END; iter++) { pal_name = get_datafile_property(iter, DAT_ID('P','A','L',0)); if(pal_name) { pal_dat = find_datafile_object(dat, pal_name); if(pal_dat) pal = pal_dat->dat; else pal = default_pal; } else { pal = default_pal; } switch(iter->type) { case DAT_BITMAP: iter->dat = convert_datafile_bitmap(iter->dat, pal); break; case DAT_RLE_SPRITE: iter->dat = convert_datafile_rle(iter->dat, pal); break; /* and so on */ } } } /* convert_datafile_bitmap et al. are not included, but are easy enough to code. */ From this code, it can be seen that such a convert_datafile function would not be overly difficult to write; whether or not it is useful enough to integrate into the core library is another thing altogether, of course. If it is deemed useful, I will finish the implementation. Bye for now, -- Laurence Withers, lwithers@xxxxxxxxxx http://www.lwithers.demon.co.uk/
Attachment:
signature.asc
Description: PGP signature
Mail converted by MHonArc 2.6.19+ | http://listengine.tuxfamily.org/ |