I have written the function to reflect an images that were provided in the zip file as .bmps.
Upon some research, I've seen that many people who have solved this problem divided the width in the image by 2. However, I felt this wasn't applicable to my code.
The code does reflect the image as seen by eye but it does not meet any of the criteria provided by check50.
If width/2 is indeed necessary, even in my code, please do explain the logic behind implementing this in my instance of code:
void reflect(int height, int width, RGBTRIPLE image[height][width])
{
RGBTRIPLE coloursofaddress[width];
for (int i = 0; i < height; i++)
{
for (int j = 0; j < width; j++)
{
// Step 3
coloursofaddress[width - 1 - j].rgbtRed = image[i][j].rgbtRed;
coloursofaddress[width - 1 - j].rgbtGreen = image[i][j].rgbtGreen;
coloursofaddress[width - 1 - j].rgbtBlue = image[i][j].rgbtBlue;
// Step 4
image[i][j].rgbtRed = coloursofaddress[j].rgbtRed;
image[i][j].rgbtGreen = coloursofaddress[j].rgbtGreen;
image[i][j].rgbtBlue = coloursofaddress[j].rgbtBlue;
}
}
return;
}
The following are the error messages:
:( reflect correctly filters 1x2 image
expected "0 0 255\n255 0...", not "5 0 0\n255 0 0..."
:( reflect correctly filters 1x3 image
expected "0 0 255\n0 255...", not "5 0 0\n0 255 0..."
:( reflect correctly filters image that is its own mirror image
expected "255 0 0\n255 0...", not "5 0 0\n255 0 0..."
:( reflect correctly filters 3x3 image
expected "70 80 90\n40 5...", not "5 0 0\n40 50 6..."
:( reflect correctly filters 4x4 image
expected "100 110 120\n7...", not "5 0 0\n0 0 0\n..."
EDIT: Upon close further examination of the reflected image output by the above code, everything seems to be perfect except for a thin additional row(s?) of pixels with random colours - not sure why. It was visible by zooming in on the bottom part of the picture, but is not visible in the input .bmp.
EDIT 2: Upon even closer examination of the reflected image output, the line of "stray" pixels at the bottom seem to end smack in the middle. It seems to be the entire left half of the reflected image is 1 pixel unit higher than it's supposed to be, and the right half is just fine. A line showing this clear height division is faintly visible going down the center of the picture. This is starting to get funny.