【发布时间】:2016-05-23 05:12:38
【问题描述】:
这是我编写的一些代码,用于将图像顺时针旋转 90 度。当图像的高度与其宽度匹配时,这可以正常工作。但是,如果不是这种情况,则图像在图像的其余部分应该在的末端有一个黑色边缘。任何帮助表示赞赏
public void rotate(){
int y = this.image.length;
int x = this.image[0].length;
int[][] rotate = new int[x][y];
UI.println(y);
UI.println(x);
for(int row = 0; row<x/2; row++){
for(int col = 0; col < ((y+1)/2); col++){
int temp = this.image[row][col];
rotate[row][col] = this.image[y-1-col][row];
rotate[y-1-col][row] = this.image[y-1-row][y-1-col];
rotate[y-1-row][y-1-col] = this.image[col][y-1-row];
rotate[col][y-1-row] = temp;
}
}
int[][] image = new int[x][y];
this.image = rotate;
【问题讨论】:
-
标记为重复的问题是错误的。在这里 op 想要编程来旋转图像。不要使用 awt 提供的任何实用方法。
-
我不确定你是否理解它 - 你能绕开它吗?