I'm having trouble with the vertical scaling. I've reviewed my code and it seems like it should scale correctly, but instead I get the following picture.
My pseudocode for vertically scaling goes as follows:
for each row
for each pixel
copy each pixel (RGBTRIPLE value) "n" times to an array
for n times
write array to outfile
write outfile padding
skip infile padding
Below is my actual code. Any hints on what I'm doing wrong?
// VERTICAL SCALING
// iterate over infile's scanlines
for (int i = 0, biHeight = abs(bi.biHeight); i < biHeight; i++)
{
// create array
RGBTRIPLE array[n];
// create pointer to array
RGBTRIPLE *a;
a = array;
// iterate over pixels in scanline
for (int j = 0; j < bi.biWidth; j++)
{
// temporary storage
RGBTRIPLE triple;
// read RGB triple from infile
fread(&triple, sizeof(RGBTRIPLE), 1, inptr);
// write RGB triple to outfile
for(int k = 0; k<n; k++)
{
// write each pixel "n" times to the array
array[k].rgbtBlue = triple.rgbtBlue;
array[k].rgbtGreen = triple.rgbtGreen;
array[k].rgbtRed = triple.rgbtRed;
}
}
for(int b=0;b<n;b++)
{
// write array to outfile
fwrite(&array, sizeof(RGBTRIPLE), 1, outptr);
// write outfile padding
for (int k = 0; k < outPadding; k++)
{
fputc(0x00, outptr);
}
}
// skip infile padding
fseek(inptr, inPadding, SEEK_CUR);
}