/*
 * =====================================================================================
 *         Name:  Mac Howe, Pmhowe@clemson.edu
 *         Date:  11/15/2022
 *  Lab Section:  7
 *         Lab#:  lab 11
 *  Description:  This lab will take in an image and wright a new one with 1/4 the pixles 
 * =====================================================================================
 */

#include "defs.h"

int main (void){
	FILE *inFile = fopen("Disney.pnm", "r");
	if (inFile == NULL){
		fprintf(stderr, "File open error.  Exiting program\n");
		exit(1);
	}
	FILE *outFile = fopen("smallerDisney.pnm", "w");
	if (outFile == NULL){
      fprintf(stderr, "File open error.  Exiting program\n");
      exit(1);
	}
	pixel_t *pixelPtr = NULL;
	
	header_t header = getHeader(inFile); //gets the header from file read in
//alocates the memory 
	pixelPtr = (pixel_t *) malloc(header.width *  header.height * sizeof(pixel_t));

	fillImageArray(pixelPtr, header.height, header.width, inFile);
	
	writeHeader(header, outFile);
//	writePixels(pixelPtr,  header.height, header.width);
	
	halfSizeWritePixels(pixelPtr, header.height, header.width, outFile);

	return 0;
}



