/*
Bryce Metz
11/17/22
Section 001
Lab #11
*/

#include<stdio.h>
#include"defs.h"
#include<stdlib.h>

int main (void){

//  int width;
//  int height;
//  char type[4];
//  colors colorInfo;
   info headerInfo;

	FILE * inFile;
   FILE * outFile;

   inFile = fopen("Disney.pnm", "r");

/*   if (inFile == NULL) {
      fprintf(stderr, “File open error. Exiting program\n”);
      exit(1);
   }*/
	outFile=fopen("smallerDisney.pnm", "w");

	headerInfo = getHeader(inFile);

   fprintf(stderr, "\n\nMaking the flag with width %d & height %d ...",
      headerInfo.width, headerInfo.height);
   fprintf(stderr, "\n\n");

   // 3. declare an array of type:  unsigned int
   // * it will need to be big enough to hold all the color values:
   // * each pixel is made up of red, green, and blue values
   //   so each pixel has 3 things in it
   // * therefore (HINT):  the width is actually 3 times bigger
   const int  colorInfo = headerInfo.width*headerInfo.height;

	colors *header = (colors*)malloc(colorInfo * sizeof(colors));

   writeHeader(headerInfo, outFile);

   fillImageArray (header, inFile, headerInfo.width, headerInfo.height);

   // 5. print the contents of the array to stdout, so with redirection,
   //    the pixels will be written to the .ppm file
   //    * with P3, the unsigned int values must be written so that
   //      the values are 3 to a line (see lab write-up)
   // pseudocode:

   halfSizeWritePixels(header, outFile, headerInfo.width, headerInfo.height);

   return 0;
}


