/* 
	Abigail Thornton 
	November 13, 2022 Section 101
	Lab 10B
	This the main function of the program that takes a value of the width and height from an image. Then uses it to find a the correct proportional size of the image. This program then makes the image half the size without distorting it. This program is structured using functions.
*/
#include <stdlib.h>
#include <stdio.h>
#include "defs.h"

int main (void){

	header_t info;

	// 3. declare an array of type:  unsigned int
	
	info = getHeader();
	pixel_t *pixelPtr = (pixel_t *) malloc((info.width*info.height)*sizeof(pixel_t));

	if (pixelPtr == NULL) {
		printf("Unable to allocaate array. Exiting program.\n");
		exit (1);
	}
	
	// write to stdout the ppm header values 
	// * with redirection, these outputs will be written to the file
	
	fillImageArray(pixelPtr, info.width, info.height);
	writeHeader(info);

	// 4. nested for loops for writing the pixel data:
	
	//fillImageArray(pixelPtr, info.width, info.height);


	// 5. print the contents of the array to stdout, so with redirection,
	//    the pixels will be written to the .ppm file

	writeHalfSizePixels(pixelPtr, info.width, info.height);


	return 0;
}
