AffineTransformを使用してイメージを回転させるサンプルです。
int x = 中心点X int y = 中心点Y int w = イメージの幅 int h = イメージの幅 double angle = 角度 Image image = イメージは取得できているものとする。
AffineTransform affin = new AffineTransform(); //イメージの移動 affin.translate(x-w/2, y-h/2); //イメージを中心位置で回転 affin.rotate(Math.toRadians(-1.0*angle), w/2, h/2); //イメージの描画 g2.drawImage(image, affin, null);
|