/*
Rowan Froeschner
11/13/2022
CPSC-1011 Section 007 Fall Semester 2022
Lab #10B
This section just takes the large array with all of the pixel values in it and prints
them to create a large list that can be converted into a gimp file and will be printed,
but this time, it this image is only half the size.
*/
#include"defs.h"
void writePixels(Pixel im[], int width, int height) {
    int k = 0;
    for (; k<(width*height); k+=1) {
        fprintf(stdout, "%i %i %i\n", im[k].r, im[k].g, im[k].b); 
    }
}
void halfSizeWritePixels(Pixel im[], int width, int height) {
    int l;
    int m = 0;
    int counter = 0;
    Pixel newPixel[width*height/4];
    for (l=0; l < (width*height); l+=2) {
        if (counter<width) {
            l = l + width;
            counter = -2;
        counter += 2;
        }
        newPixel[m].r = (im[l].r + im[l+1].r + im[l+width].r + im[l+1+width].r)/4;
        newPixel[m].g = (im[l].g + im[l+1].g + im[l+width].g + im[l+1+width].g)/4;
        newPixel[m].b = (im[l].b + im[l+1].b + im[l+width].b + im[l+1+width].b)/4;
        m += 1;
    }
    int k = 0;
    for (; k<(width*height/4); k+=1) {
        fprintf(stdout, "%i %i %i\n", newPixel[k].r, newPixel[k].g, newPixel[k].b); 
    }
}
