I am working through CS50's PSET #4, specifically filter -> reflect. I can get the image to present correctly (i.e., it is mirrored), but it is not exact enough to pass the CS50 Check.
My code is as follows:
void reflect(int height, int width, RGBTRIPLE image[height][width])
{
for (int i = 0; i < height; i++) // Loop over every line
{
for (int j = 0; j < width / 2.00; j++) // Loop over every pixel in line
{
RGBTRIPLE tmp = image[i][j]; // tmp = pix[0]
image[i][j] = image[i][width - j]; // make pix[0] = pix[n]
image[i][width - j] = tmp; // make pix[n] = tmp
}
}
}
My results are on this page (link). It looks like my array is swapping beyond the array, and seems to be misaligned by one. For example, the below shows the blocks of code that are misaligned (by one row, it appears).
Any help is appreciated!