Bitmap loses data when transferred into Allegro datafile?


I was having some problems with a game I was making after I tried to implement Allegro datafiles instead of separate files for all the sprites and sounds. I then made a test program to test and see if everything was being transferred fine. The bitmaps with one single frame/sprite were transferred fine and retained all data. However, I have two bitmaps that have several frames of a tank in them and it seems that when they are transferred into the datafile, it just becomes all black and that is what is copied to the datafile. Can anybody help me?

Steve Terry

I'm assuming those bitmaps were gifs and the datafile utility doesn't support gifs natively, though it will still import them as binary data.


Actually, the bitmaps were really BMP files...that's why almost all of them worked. Allegro datafiles support the BMP filetype. But for some reason the two tank BMPs that have several frames right next to each other turned into just a black strip when transferred into the datafile. It's very strange. All the other bitmaps work, but these two don't...

I can also import them into the datafile through binary data? Maybe I should try see if the tank bitmaps will retain the data..if that's an alternative method.

Matthew Dalrymple

I probably can't help you, but to those who are very familiar with your topic... you might want to supply them with some source and the images. But that is just a suggestion.

Steve Terry

What is the bit depth of the tank images?


Good idea, I had actually not thought of that. I think this will be very helpful for any willing to help me out.! Anything like explode.bmp (attached), where there is but a single frame of the object, is transferred fine and by using my test program..I can retrieve and save the exact same thing from the data file. Now, for something like tank1.bmp (attached), with multiple frames and such, it turns into tank1saved.bmp (attached) after I run my test program. This is the code that I basically use for the test program:

set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0);
data = load_datafile("test.dat");
sprite = (BITMAP *)data[TANK1_BMP].dat;
//sprite = (BITMAP *) load_datafile_object("test.dat", "EXPLODE_BMP");
//sprite = load_bitmap("tank2.bmp", NULL);
save_bitmap("tank1saved.bmp", sprite, NULL);
//while (!key[KEY_ESC]) {}

Oh, and the color depth of the tanks and all the sprites/images that I use is 16-bit. Dunno..just a default thing I guess...I'm only learning with a book so..heh..


Can you also attach the smallest .dat file that the problem occurs with?

edit: I Just noticed that tank1.bmp is a 8bit image, but you have no palette information. The rest of the images you supplied are 24bit.


Mmmmmmmm...8-bit....wonder when I did that..

Ahh..the datafile...ok I've attached the only one I use..with compression, it's small enough.

Well if the others are 24-bit and they are transferred fine...then I...meh...I dunno..maybe the 8-bit just doesn't work with my 16-bit setting...probably should do a conversion to 8-bit at the beginning of the test program or something.....hmmmm...


Ahh..the datafile...ok I've attached the only one I use..with compression, it's small enough.

No, you haven't. But just try converting the 8bit images to 24bit (or even better 16bit, since it's the depth you set the screen to). That should fix the problem.

edit: hey, you cheated. :P


Sheesh..well, I'm not too sure how I can change the depth of those bitmaps..

you cheat more than I do =P, my computer takes 5 mins to load each of these pages..


Well, if you're using windows, just load the 8bit images into Paint and save them as 24bit bitmaps.

edit: I'm not sure how you managed to do what you did, but I saved your 8bit image to my machine and made a new .dat file with the grabber. I then used the grabber to convert the image to 16bit, and it works fine.

I've attached the .dat file with the single bitmap.



Err... that's not how you do things.


actually that call to the conversion was pointless...after trying a lot of different things, I thought I might throw that in..but it didn't change anything..=/


actually that call to the conversion was pointless...

No, it's wrong. Check the manual entry for set_color_conversion().


Here's a link even:


Thread #589559. Printed from