Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Bitmap loses data when transferred into Allegro datafile?

This thread is locked; no one can reply to it. rss feed Print
Bitmap loses data when transferred into Allegro datafile?
XcronZ3X
Member #8,222
January 2007

Hello.

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
Member #1,989
March 2002
avatar

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.

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

XcronZ3X
Member #8,222
January 2007

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 that...to see if the tank bitmaps will retain the data..if that's an alternative method.

Matthew Dalrymple
Member #7,922
October 2006
avatar

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.

=-----===-----===-----=
I like signatures that only the signer would understand. Inside jokes are always the best, because they exclude everyone else.

Steve Terry
Member #1,989
March 2002
avatar

What is the bit depth of the tank images?

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

XcronZ3X
Member #8,222
January 2007

Good idea, I had actually not thought of that. I think this will be very helpful for any willing to help me out. Ok..so! 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:

allegro_init();
install_keyboard();
set_color_depth(16);
set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0);
text_mode(-1);
set_color_conversion(16);
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]) {}
//unload_datafile_object(sprite);
unload_datafile(data);
allegro_exit();

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..

LennyLen
Member #5,313
December 2004
avatar

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.

XcronZ3X
Member #8,222
January 2007

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...

LennyLen
Member #5,313
December 2004
avatar

Quote:

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

XcronZ3X
Member #8,222
January 2007

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..

LennyLen
Member #5,313
December 2004
avatar

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.

gnolam
Member #2,030
March 2002
avatar

Quote:

set_color_conversion(16);

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

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

XcronZ3X
Member #8,222
January 2007

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..=/

Evert
Member #794
November 2000
avatar

Quote:

actually that call to the conversion was pointless...

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

LennyLen
Member #5,313
December 2004
avatar

Here's a link even:

set_color_conversion()

Go to: