Algorithm to rotate an image 90 degrees in place? (No extra memory)

前端 未结 9 901
囚心锁ツ
囚心锁ツ 2020-11-29 06:26

In an embedded C app, I have a large image that I\'d like to rotate by 90 degrees. Currently I use the well-known simple algorithm to do this. However, this algorithm requi

9条回答
  •  执念已碎
    2020-11-29 06:57

    Here is a simple method in java,

        public static void rotateMatrix(int[][] a) {                                                                            
        int m =0;
        for(int i=0; i=end)
                    break;
                int tmp = a[i][j];
                a[i][j] = a[i][end];
                a[i][end] = tmp;
                end--;
            }
        }
    }
    

提交回复
热议问题