1
for(int i = 0; i < hdr.getHeight(); i++){
    for(int j = 0; j < hdr.getWidth(); j++){
        Pixel temp = vec.at(i * hdr.getWidth()  + j);
        vec.at(i * hdr.getWidth() + j) = vec.at(i * hdr.getWidth() + ((i * hdr.getWidth()) - j));
        vec.at(i * hdr.getWidth() + ((i * hdr.getWidth()) - j)) = temp;

     }
}

I've been working on this class assignment pretty much all day, and all sense and reason and critical thinking abilities have absolutely left me. I understand the concept of iterating through a 1D vector as a 2D, in that

i * # of cols + j

Basically bypasses an entire row and references the first element in a "column," but trying to do that, and replacing the original pixel with the pixel at the mirrored position is absolutely escaping me.

Paul Floyd
  • 5,530
  • 5
  • 29
  • 43
  • You should give things names. For example the x or y coordinate of the pixel you want to mirror, and the x or y coordinate of its mirrored sibling. Then check the value of those coordinates while your program is running, and think about whether the values you see are what you expect for a successful mirroring operation. – Timbo Jun 08 '20 at 07:42
  • 1
    Are you trying to flip the image horizontally or vertically? In any case, you should limit the swaps to only *half* the image, otherwise you are flipping back the pixels to their original position. – Bob__ Jun 08 '20 at 07:49

0 Answers0