我已经成功将一张图片旋转了180度
,但是我希望将其顺时针90度
旋转,请问有谁能编辑我的代码并解释一下。谢谢。
private void rotateClockwise()
{
if(currentImage != null){
int width = currentImage.getWidth();
int height = currentImage.getHeight();
OFImage newImage = new OFImage(width, height);
for(int y = 0; y < height; y++) {
for(int x = 0; x < width; x++) {
newImage.setPixel( x, height-y-1, currentImage.getPixel(x, y));
}
}
currentImage = newImage;
imagePanel.setImage(currentImage);
frame.pack();
}
}