/*
*Madison Noyce
*11/17/22
*Lab Section 1011-007
*Lab 11
*This program will take pixels from a source and send them along with an
*image header to an outside source such as Gimp but in a smaller size with
*file pointers.
*/

#include "defs.h"

//This is the main function containing all the other function info.
int main(int argc, int *argv[]) {
	int arraySize;
	FILE *inFile;
	inFile = fopen(argv[1], "r");
	FILE *outFile;
	outFile = fopen(argv[2], "w");
	if (inFile == NULL) {
		fprintf(stderr, "File open error. Existing program\n");
		exit(1);
	}
	if (outFile == NULL) {
                fprintf(stderr, "File open error. Existing program\n");
                exit(1);
        }
	headerInfo header = getHeader(inFile);
	writeHeader(header, outFile);
	pixelValues* colors = NULL;
	arraySize = header.width * header.height;	
	colors = (pixelValues*) calloc(arraySize, sizeof(pixelValues));
	fillImageArray(colors, header.width, header.height, inFile);
	halfSizeWritePixels(colors, header.width, header.height, outFile);
	return 0; 
}
