This is some code that I have written to rotate an image 90 degrees clockwise. This works fine when the image's height matches its width. But when this is not the case, the image has a black edge at the end where the rest of the image is supposed to be. Any help is appreciated
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;