【发布时间】:2020-07-06 09:21:09
【问题描述】:
我希望将从文件加载的图像旋转 90 度。我有代码,但是当我使用它时,我收到一条错误消息,指出坐标超出范围。任何帮助将不胜感激。
这是我目前写的方法:
public void rotateImage(OFImage image) {
if (currentImage != null) {
int width = image.getWidth();
int height = image.getHeight();
OFImage newImage = new OFImage(width, height);
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
Color col = image.getPixel(i, j);
newImage.setPixel(height - j - 2, i, col);
}
}
image = newImage;
}
}
【问题讨论】:
标签: java image rotation bufferedimage graphics2d