I have an array of pixel data for an image. The image I am getting is already rotated to 270 degrees. So I am trying to rotate it again by 90 degrees to have the correct image. I've tried a transpose algorithm, by changing data[x][y] to data[y][x], but I don't think that's the correct way. Can anyone guide me what can I do to have it rotated?
data[x][y]
data[y][x]
You have old_data[rows][cols] and new_data[cols][rows], then:
old_data[rows][cols]
new_data[cols][rows]
for(int i=0; i<cols; i++) { for(int j=0; j<rows; j++) { new_data[i][j] = old_data[rows-1-j][i]; } }
This should rotate old_data by 90 degrees CW.
1.4m articles
1.4m replys
5 comments
57.0k users