Grabber and png
APrince

Hi, is there a way to grab png images to a datafile or do I have to convert all of my images to targa first?

LennyLen

You can add files of any type, even if they're not one that Allegro supports natively (such as PNG).

Just select "Other" as the type of object you want, and then grab as you would normally.

Johan Halmén

Yes. You won't see the image in Grabber, but that's not important, is it? And if it is, I guess you can rebuild Grabber and add png as a known image format. Grabber won't convert it to a BITMAP* object. It comes as a png chunk into your program's DATAFILE* object. And you use load_memory_png() to create the BITMAP* object.

APrince

Thank's - I'll try that.

//edit: This load_memory_png is a function from loadpng and I have to download that separately, i take it... Right?

LennyLen

If you're using loadpng, look at the exdata.c example for the recommended way of loading a PNG from a datafile.

Edgar Reynaldo

loadpng comes with Allegro 4.4, you just have to include its headers and link to it like any other library.

APrince

"loadpng comes with Allegro 4.4, you just have to include its headers and link to it like any other library."

It seemed strange to me, because I didn't have to do anything extra to use png images (AL 5.0.1).

Thank's very much, I'm going to try that.

Thomas Fjellstrom
APrince said:

It seemed strange to me, because I didn't have to do anything extra to use png images (AL 5.0.1).

Yeah, allegro 5 is a new API and library. It's image loader addon includes PNG support.

Allegro 4.4 has a png loader addon included, 4.2 and before do not include a png loader addon, but there is an older version of loadpng available for them.

APrince

Thank's.

I have two more questions...

1) I cannot find loadpng in Allegro 5. In Allegro 4.4 it is in Allegro/addons but I really don't know, where to find it in A5.

2) I need to grab about 100 png images... Is there a way to select them somehow all at once, or do I have to do that manually? The problems is I don't really understand the grabber and documentation doesn't help much. What I do, is that I select Object->new->other then fill in type as PNG and whatever name and then Object->grab and select the corresponding file. I can't imagine doing this for a hundred files...

Thank's a lot.

LennyLen
APrince said:

1) I cannot find loadpng in Allegro 5. In Allegro 4.4 it is in Allegro/addons but I really don't know, where to find it in A5.

A5 does not use loadpng. Instead, you use the image IO addon routines in conjunction with al_load_bitmap or al_load_bitmap_f

Quote:

2) I need to grab about 100 png images... Is there a way to select them somehow all at once, or do I have to do that manually? The problems is I don't really understand the grabber and documentation doesn't help much. What I do, is that I select Object->new->other then fill in type as PNG and whatever name and then Object->grab and select the corresponding file. I can't imagine doing this for a hundred files...

The datafile format (and therefore the grabber tool) are not supported by A5. If you want to use the grabber, you will need to write your own routines for extracting the data from them.

But to answer the question anyway, to add multiple files like that, don't use the grabber, use the command line dat utility instead.

Luiji99

Does anybody actually want to use Allegro 4 DATAFILEs with Allegro 5, or is everyone comfortable with PhysicsFS's archive formats? (Personally I like a PAK/ZIP mixture.)

APrince

Well now I'm really confused... If I get this right, I suppose that everything to this point was irrelevant, because somehow everyone assumed I use Allegro 4. Now that there's the knowledge I use Allegro 5, everyrhing changes... Right? I don't really want to bother you, if there is any tutorial on how to solve this thing I would really appreciate it...

Where can I get the tool you mentioned (command line dat utility)? I cannot find it amongst the Allegro utilities.

Audric

It's the word "datafile" that everybody understands as the specific file format that was supported in Allegro 4.
Allegro 5 cannot read this format (and even the structs stored inside: BITMAP, RLE_SPRITE etc. are different from Allegro 5's AL_BITMAP)
so you shouldn't bother anymore with the grabber.exe and dat.exe, they are all for Allegro 4.

In Allegro 5, if you want to store all resources in a single file, the handy way is to make a zip archive (using any standard tools, the zip can even use sub-directories) and in your program, use the PhysicsFS addon to access the individual items.
The idea is that you call:

PHYSFS_init();
PHYSFS_addToSearchPath("mydata.zip", 1);
al_set_physfs_file_interface();

and then any call to al_load_bitmap() will read items in the zip.

See the complete example ex_physfs.c in the distribution.

APrince

It's not really about storing everything in one file. The point is to prevent a "common user" from overriding those images with something else and thus defacing the program... Common zip will not solve this (niether datafile would, I suppose, but it would surely make it much more difficult). Maybe if the zip archive was password protected...

Thomas Fjellstrom

Or just don't use the .zip file ending. call it .dat or something. Most people would be confused. A lot of games do that.

APrince

Thank's a lot, that may work... :-)

//edit: Thank's to all of you, it works perfectly...

Thread #609490. Printed from Allegro.cc