cpp implementation of Rotate Image