- Online Community Forums » Programming Questions » [A5] Load indexed bitmap

This thread is locked; no one can reply to it. rss feed Print
[A5] Load indexed bitmap
Member #8,794
July 2007

Is it possible to load an indexed/paletted bitmap using Allegro 5 while keeping the index information? I've tried using ALLEGRO_KEEP_INDEX but then how do I access the bitmap data? al_get_pixel() returns an ALLEGRO_COLOR, not an index. I've also tried locking the bitmap to access the data pointer but I can't get the index data either.

Erin Maus
Member #7,537
July 2006

Have you tried locking it with ALLEGRO_PIXEL_FORMAT_SINGLE_CHANNEL_8?

See the bitmap loading code:

It's also in the docs on pixel formats:

ItsyRealm, a quirky 2D/3D RPG where you fight, skill, and explore in a medieval world with horrors unimaginable.
they / she

Member #8,794
July 2007

I have tried that, yes. After doing that, the data pointer of the locked region represents the red component of the image, as stated in the docs, but not the color index of the original bitmap.

[EDIT:] Nevermind, it seems the right way to do it is to load the bitmap with al_load_bitmap_flags() using the ALLEGRO_KEEP_INDEX flag and then locking the bitmap with the ALLEGRO_PIXEL_FORMAT_SINGLE_CHANNEL_8 format.


Edgar Reynaldo
Major Reynaldo
May 2007

Go to: