/*
Bryce Getsinger
CPSC 1011, Section 004, 11/13/2022
Lab 10B, a lab which compresses an HD prohograph using pointers,
structures, and functions in a multi-file program.
*/

#include "defs.h"

void halfSizeWritePixels(pixelInfo printArray[], int printWidth, int printHeight) {
	for (int j = 0; j < printHeight; j+=2) {
		for (int k = 0; k < printWidth; k+=2) {
			printArray[k].r = (printArray[k].r + printArray[k+1].r + printArray[k+printWidth].r + printArray[k+printWidth+1].r) / 4;
			printArray[k].r = (printArray[k].g + printArray[k+1].g + printArray[k+printWidth].g + printArray[k+printWidth+1].g) / 4;
			printArray[k].r = (printArray[k].b + printArray[k+1].b + printArray[k+printWidth].b + printArray[k+printWidth+1].b) / 4;
		}
	}
}

void writePixels(pixelInfo printArray[], int printWidth, int printHeight) {
	int printSize = printWidth * printHeight;
	for (int i = 0; i < printSize; i++) {                                        
		fprintf(stdout, "%i \n", printArray[i].r);
		fprintf(stdout, "%i \n", printArray[i].g);
		fprintf(stdout, "%i\n", printArray[i].b);
		fprintf(stdout, "\n");
     }    
}
