Re: [AD] native image loaders

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


On 9 Apr 2010, at 21:01 , Matthew Leverton wrote:
> You would need it if there were no explicit al_load_type()
> 
> al_load_bitmap("foo"); // which handler to call?
> al_load_bitmap("foo.dat"); // extension changed
> 
> But in real usage that would rarely happen because most common image
> types will have extensions,

Right. Those examples are a little contrived in the sense that I don't think anyone would or should do that (why would you try to hide the file extension in that way? Security through obscurity? Doesn't even work in this case).

> It's a convenience method for:
> 
> ALLEGRO_FILE *f = al_fopen("foo", "rb");
> ALLEGRO_BITMAP *bmp = al_load_bitmap_f(f, ".png");
> al_fclose(f);

Yup.
We can always opt to include that in an example, or in the documentation for someone who really wants it. Although I don't really have real objections to including an "al_load_bitmap_type()" function as proposed.

> The purpose of getting rid of explicit functions is to make sure the
> image add-on always has the same public API, regardless of what is
> loaded into it. I also think it simply looks ugly to have all of those
> functions when they aren't really needed.

Yes, I agree 100%.
I always want to shout at people who use "load_bmp()" in Allegro 4.

> * no explicit functions (e.g., load_bmp, load_pcx, load_ogg)

Agreed.
Which reminds me: does the audio addon have the equivalent register_sample_filetype() functionality to register_bitmap_filetype() for the image addon? (Sorry, if that sentence came out a bit warped).

> * everything supported at compile time is part of the acodec/image addon

Agreed, with the caveat that we should specify a list of formats that are "always" supported.

> * [optional] some way to query which formats are supported (probably a
> list of registered handlers by extension)

Oh, forgot to mention that. Yes, we need this if we don't have it already.

> * the docs mention which platforms support which formats

I think we should have a core set of formats that are always supported on all platforms.
For images, that's probably bmp/png/jpg/tga/pcx. The last of those only because we have our own loader for it, I'm not sure who would use it these days (coming from someone who used PCX files almost exclusively while using vanilla Allegro 4).
No clue for audio, some form of .wav file probably. Ogg/Vorbis would be nice, but I'm not sure we should require that.

Evert



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