I added a function to Allegro SVN today called al_create_user_bitmap(). It allows you to load custom texture format images (only tested with OpenGL) like say PVR or ETC1, but in my case I'm using it to load 8 bit paletted images on Android (should work on iOS too) with the OES_compressed_paletted_texture extension (which Allegro loads itself.)
The images save some memory (though that can depend on the device/drivers as some may just convert to a 32 bit image internally.) The code is C++ but the interface can be used from C. Loading a paletted image is a little bit round-about because you have to have created or loaded the image you want to convert to paletted beforehand, but it doesn't seem to slow my game down during loading much.
This is basically all there is to it:
Make a function with that and you can load, then convert to 8 bit. I don't know if and how palette effects are possible with this. I don't know if you can modify the palette. I didn't make it for that purpose but it would be neat if you can. The code is attached, may require a tiny bit of work to get compiled and working as I ripped it from my game and removed anything specific to my game from it.
NOTE: You can lock these images READONLY but not for writing.
NOTE2: I haven't tried this with ANY images with a lot of colors. For all I know, and it's highly probably that I've only used images with < 256 colors, so the quantization isn't tested. I based it off reading the description of how the Allegro 4 quantization works from the source code (I was going to copy the code but it seemed like it'd be simpler to do it myself.)
EDIT: I've been working on it, since I tested with higher color images and it didn't work. It works pretty good now and is a lot faster. Still not super fast, but on my fairly slow tablet it takes 0.87 seconds to convert the 800x600 image below. The results aren't bad.
Before:
{"name":"8urcat.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/6\/a660ad12066301ca7617dbc3c37c915c.png","w":800,"h":600,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/a\/6\/a660ad12066301ca7617dbc3c37c915c"}
After:
{"name":"8urcat-quantized.png","src":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/9\/9940c6f9a09930e0da2a2842e53fdffc.png","w":800,"h":600,"tn":"\/\/djungxnpq2nug.cloudfront.net\/image\/cache\/9\/9\/9940c6f9a09930e0da2a2842e53fdffc"}
The bright light in the window is the worst part. If anyone wants me to post the new source I will.
Hmm, I can't say I understood it. Doesn't this API pretty much require the use to dig into Allegro internals? Can you post the example?
The example is identical to the code block I pasted. I have that in my game which is exactly what I used to generate that image. Well, exactly as in I made some minor modifications to the api, but those are minor (I just removed the need for the "exact" parameter.)
Oh, I didn't see the attachment. I was looking for the upload_paletted_image function.
Indeed it casts the bitmap to ALLEGRO_BITMAP_EXTRA_OPENGL and works with the internals. I think we need to find another way. Maybe an OpenGL-specific function that creates a bitmap out of an existing texture?
All it would need is an al_set_opengl_texture really.