From: Einar <"eincar"@[EINAR]vip.cybercity.dk> Newsgroups: comp.os.msdos.djgpp Subject: Re: Retrieving BMP from datafile? Date: Sun, 23 Aug 1998 11:30:30 +0200 Organization: CyberCity Internet Lines: 112 Message-ID: <6ron2n$rvh$1@news.cybercity.dk> References: <6r776u$snn$1 AT news DOT cybercity DOT dk> NNTP-Posting-Host: 212.242.3.204 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Thanks for the help I've gotten on this question. I now able to get the BMP files out of the data file with a warying degree of success, that leaves me puzzled. In the following lines I'll show you two examples of the same code, that gives hugely different results. ///////////// First example of my test program /////////////// #include #include "othello.h" DATAFILE *datafile; BITMAP *back, *player1; RGB *palette; int main() { allegro_init(); install_keyboard(); datafile=load_datafile("data.dat"); set_palette((RGB*)datafile[othello].dat); set_gfx_mode(GFX_AUTODETECT,640,480,0,0); back=(BITMAP*)datafile[backgr].dat; player1=(BITMAP*)datafile[black].dat; blit(back,screen,0,0,0,0,back->w,back->h); readkey(); clear(screen); blit(player1,screen,0,0,0,0,player1->w,player1->h); readkey(); allegro_exit(); destroy_bitmap(back); destroy_bitmap(player1); return 0; } This example worked fine, with the exception that the color scheme of the BMP pictures where wrong. //////////// Second example of my test program /////////////// Here I've changed the second BITMAP variable player1 to black. #include #include "othello.h" DATAFILE *datafile; BITMAP *back, *black; RGB *palette; int main() { allegro_init(); install_keyboard(); datafile=load_datafile("data.dat"); set_palette((RGB*)datafile[othello].dat); set_gfx_mode(GFX_AUTODETECT,640,480,0,0); back=(BITMAP*)datafile[backgr].dat; black=(BITMAP*)datafile[black].dat; blit(back,screen,0,0,0,0,back->w,back->h); readkey(); clear(screen); blit(black,screen,0,0,0,0,black->w,black->h); readkey(); allegro_exit(); destroy_bitmap(back); destroy_bitmap(black); return 0; } And this change seems to create havoc inside the program, here are the error messages I get when trying to compile the program: Compiling: test.cc test.cc (7) Error: parse error before `1' In function `int main()': test.cc (20) Error: non-lvalue in assignment test.cc (24) Error: base operand of `->' is not a pointer test.cc (24) Error: base operand of `->' is not a pointer test.cc (24) Warning: passing `int' to argument 1 of `blit(BITMAP *, BITMAP *, int, int, int, int, int, int)' lacks a cast test.cc (28) Warning: passing `int' to argument 1 of `destroy_bitmap(BITMAP *)' lacks a cast There where some errors. I do not understand that because the variables back and black should be just as different as back and player1 or what??? Finally I tried my luck on my Othello game, changing all the bitmap variables to *a, *b, *c, *d etc. to be certain that the variables had no similarities in their wording. This worked wonders, and I even got the game to show the BMP's with the right color scheme, so it was a great success, but as a final test I changed the test program above in the same way, using *a, *b as variables for the bitmaps, but then it showed the test with a wrong color scheme????. All these different results keep me perplexed as to what criteria's Allegro is working with, when it comes to the dat file? I would be interested in hearing any comments on this phenomena. Sorry for this long posting. Einar. ------------------------------------------------------- Remove [EINAR] from e-mail address when replying