Stuck on PSET4 resize: the file I'm writing is going into overflow and I'm not sure why. I've designed it using nested for loops as you'll see.
It compiles and runs, but then it says the file is too big and the resulting image is 'unsupported'
FWIW, I'd love an invite to the slack channel as it's pretty hard to learn coding in a bubble.
Onto the problems...
My approach is to store each line in an array of RGB Triples, and then print each triple SCALE times horizontally, add padding, and then print each row SCALE times, where SCALE is the scaling argument passed to resize.
I'm pretty sure you can do an array of structs. However, I'm having trouble understanding how you access and point to these structures--a little explanation would be helpful. I've done a nested for loop as described below:
FOR - (The Height of the Original Image)
FOR (Each Line, up to the width of the image)
// create a story for the triple
RGBTRIPLE triple;
// read the triple from the inptr
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
// make the triple the jth element of the array
line_array[j] = triple;
Is this correct to story the elements in the triple?
Later, I try to grab the elements in the array and print them a number of times.
My control flow may be wrong (to avoid 'fishing for a solution', I'm not pasting my entire code), but I'd first like to check if my data structure and access is roughly correct.
I try to write the data referencing the array here:
for (int m = 0; m < scale; m++)
{
fwrite(&line_array[l], sizeof(RGBTRIPLE), 1, outptr);
}
I chose an array because we can go line by line, and just overwrite the values in the array and it solves the referencing problem more easily.... or so I thought.
Any help much appreciated!
Full Code (Reference Only): http://pastebin.com/Pvu4vpSf
bi.new = bi.old;