Quote:
1 2 3 4 5 6 7 8 9 <- top
9 2 3 4 5 6 7 8 1 <- exchanging the top spot with the last
9 8 3 4 5 6 7 2 1 <- change the second position with the penultimate
9 8 7 4 5 6 3 2 1 and so on
9 8 7 6 5 4 3 2 1
9 8 7 6 5 4 3 2 1 <- should stop: arrived in the middle
You need a temporary variable that stores the value of the pixel you are going to modify, then as that has the pixel color pixel corresponding to the opposite side, and while you lack: replace the pixel on the side opposite the temporary variable that has pixel value of the original.