Java で小さなゲームを作成していますが、回転する画像があります。
下の 2 つの画像でわかるように、ゲーム内でゆっくりと回転する巨大な船がありますが、特定のポイントに達すると (独自の小さな BufferedImage により) 切断されます。
私のレンダリングコードは次のとおりです。
public void drawImageRotated(BufferedImage img, double x, double y, double scale, double angle) {
x -= xScroll;
y -= yScroll;
BufferedImage image = new BufferedImage((int)(img.getWidth() * 1.5D), (int)(img.getHeight() * 1.5D), 2);
Graphics2D g = (Graphics2D)image.getGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.rotate(Math.toRadians(angle), image.getWidth() / 2, image.getHeight() / 2);
g.drawImage(img, image.getWidth() / 2 - img.getWidth() / 2, image.getHeight() / 2 - image.getHeight() / 2, null);
g2d.drawImage(image, (int)(x-image.getWidth()*scale/2), (int)(y-image.getHeight()*scale/2), (int)(image.getWidth()*scale), (int)(image.getHeight()*scale), null);
g.dispose();
}
手元の問題に戻りますが、バッファリングされた画像のサイズで補正できるように、回転中に画像の最大 x および y サイズを計算するにはどうすればよいですか?