我已经设法旋转图像180 degrees
,但希望旋转它90 degrees
clockwise
可以有人编辑我的代码,以便它通过解释来做到这一点。谢谢。
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();
}
}