Creating an array of TImage 

Most often, when a developer needs an array of bitmaps, the easiest thing to do is to use a TImageList.  There are times however, when is it neccessary to create an arrray of TImages, especially if your images are of different dimensions.  The following code illustrates how to create and destroy an array of TImages. 

KEYWORDS: TImage, new [], delete [] 
 

 

//in header file 
TImage **MyImageArray; 
 

 
 

//---------------------------------------------------------------------------
//in source... 
const int num_of_images = 100; 

//create 100 TImages... 
MyImageArray = new TImage *[num_of_images]; 
for (int frame = 0; frame < num_of_images; frame++) 

    MyImageArray[frame] = new TImage(this); 
    MyImageArray[frame]->Parent = this; 
    //set other properties accordingly 

  

//later delete the array... 
for (int dframe = 0; dframe < num_of_images; dframe++) 

    MyImageArray[dframe]->Picture = NULL; 
    delete MyImageArray[dframe]; 

delete [] MyImageArray;