if I remove this line (*a = temp2) the left image only reflects and if I remove this line (*b = temp ) the right image only reflects but if I write both the image return into the original one no reflect.
1 Answer
If you swap the first pixel with the last, and then the last with the first, you are reflecting twice.
Make your horizontal loop run width / 2
times instead of width
.