Figure 5: A portion of the program that performs the first isometric transform

#include "cips.h"

#define FILL     200
#define FILL2    150
#define MOREROWS 100
#define DEGREESPERRADIAN 57.29577952

short **the_image;
short **out_image;

main(argc, argv)
   int argc;
   char *argv[];
{
   ...

   get_image_size(in_name, &length1, &width1);
   tantheta = tan((double)(theta)/DEGREESPERRADIAN);
   bigxshift  = tantheta*(double)(length1);
   if(bigxshift < 0) bigxshift  = bigxshift * (-1);
   length2 = length1 + MOREROWS + MOREROWS;
   width2  = width1 + bigxshift;
   
   create_resized_image_file(in_name, out_name, 
                             length2, width2);

   ...

   for(i=0; i<length2; i++)
      for(j=0; j<width2; j++)
         out_image[i][j] = FILL;

   read_image_array(in_name, the_image);

   max = 0;
   for(i=0; i<length1; i++){
      for(j=0; j<width1; j++){
         if(the_image[i][j] > max)
            max = the_image[i][j];
      }  /* ends loop over j */
   }  /* ends loop over i */


   if(max > MOREROWS)
      scale = (float)(max)/(float)(MOREROWS);
   else
      scale = max;

   if(scale < 1.0)
      scale = 1.0;

   for(i=0; i<length1; i++){
      for(j=0; j<width1; j++){

         if(i%space == 0){
            ii      = i + MOREROWS;
            xshift  = tantheta*(double)(i);

            if(i == 0  &&  theta <= 0)
               jj = j + bigxshift + xshift;
            if(i == 0  &&  theta >  0)
               jj = j + xshift;
            if(i != 0  &&  theta <= 0)
               jj = j + bigxshift + xshift;
            if(i != 0  &&  theta >  0)
               jj = j + xshift;

            out_image[ii][jj] = the_image[i][j];

            height = the_image[i][j]/scale;
            lineup(out_image, ii, ii-height, jj);
            if(value == 0)
               out_image[ii-height][jj] = 0;
            else
               out_image[ii-height][jj] = 
                  the_image[i][j];
         }  /* ends if j%space  */

      }  /* ends loop over j */
   }  /* ends loop over i */


   write_image_array(out_name, out_image);

   ...

}  /* ends main  */



lineup(image, start_row, end_row, column)
   int   start_row, end_row, column;
   short **image;
{
   int i; 
   for(i=start_row; i>end_row; i--)
      image[i][column] = FILL2;
}  /* ends lineup */