Bubble sort seems quite an inefficient way to go about reflecting the image. I suggest that, for the problem set, you try to think of a more direct way to achieve the same thing.
But regarding your code:
note that you define temp, but then don't use it. Look at your code and see where it should be used;
there is a problem in your for loop declarations. ...