delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/25/09:56:27

From: Dave Peterson <dave_r_peterson AT yahoo DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Dynamically creating BITMAP arrays with C and Allegro.
Date: Fri, 25 Jun 1999 13:52:06 +0100
Organization: Customer of Planet Online
Message-ID: <37737B76.E907AD88@yahoo.com>
NNTP-Posting-Host: modem-23.phenytoin.dialup.pol.co.uk
Mime-Version: 1.0
X-Trace: news7.svr.pol.co.uk 930316937 19717 62.136.83.151 (25 Jun 1999 13:22:17 GMT)
NNTP-Posting-Date: 25 Jun 1999 13:22:17 GMT
X-Complaints-To: abuse AT theplanet DOT net
X-Mailer: Mozilla 4.05 [en] (Win95; I)
Lines: 31
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

I am attempting to dynamically create an array of BITMAPs that can have
its size set during execution of the program and I am confused on how
exactly this should be done.

I initialize it like this:
BITMAP *bitmapArray;
bitmapArray=(BITMAP *) malloc(3*sizeof(BITMAP));

This step seems to work fine.

I load in the data to the array like this:
bitmapArray=load_bitmap("pe.bmp",*pal);

Again, this works fine until I try to do any pointer arithmetic with it
(to refer to the other bitmaps that I would like to store).  I always
manage to screw it up and my program crashes.

I realize that I am probably doing totally the wrong thing here, but
there must be a way to create an array of bitmaps dynamically and refer
to each one individually.  Any help on this would be greatly
appreciated.

Also, I was looking at a tutorial which claimed that if you created a
dynamic data structure you could refer to each element like you could an
array.  I have been unable to do this for myself, so if anyone knows how
to do this, could you please let me into the secret?  Also, would it
work with bitmaps?

Thanks for your time,
Dave Peterson.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019