/*=========================================================
Owen Dover
C20224779
11/10/2022
CPSC 1011 Section 005
Lab 10B

Driver code to scale inputted .pnm file image by
1/2 then output it
=========================================================*/

#include"defs.h"

int main (){

	//declaring header struct
	info_t headerInfo;
	
	//function call to get header
	headerInfo = getHeader();

	//size needed to hold all rbg values
	int max = (headerInfo.width)*(headerInfo.height);
	int max2 = max*3;

	//declaring pixel struct and allocating necessary memory
	rgb_t *pixels;
	pixels = (rgb_t *) malloc(max2 * sizeof(int));


	//function call to fill pixel struct with proper rbg values
	fillImageArray(pixels, max);
	//function call to write scaled header info
	writeHeader(headerInfo);	

	//function call to output scaled image
	halfSizeWritePixels(pixels, headerInfo.height, headerInfo.width);

	free(pixels);
	
	
//end of program
return 0;
}