You've already forked FrameTour-BE
fix(utils): 修正图片旋转角度参数
- 将旋转角度从270度更正为90度 - 保持旋转后宽高的正确计算逻辑 - 确保测试场景覆盖正确的旋转角度
This commit is contained in:
@@ -336,7 +336,7 @@ public class ImageUtils {
|
||||
// 测试两种情况: 不旋转、旋转270度
|
||||
int[][] scenarios = {
|
||||
{0, srcWidth, srcHeight}, // 不旋转
|
||||
{270, srcHeight, srcWidth} // 旋转270度
|
||||
{90, srcHeight, srcWidth} // 旋转270度
|
||||
};
|
||||
|
||||
for (int[] scenario : scenarios) {
|
||||
@@ -379,7 +379,7 @@ public class ImageUtils {
|
||||
int width = source.getWidth();
|
||||
int height = source.getHeight();
|
||||
|
||||
// 270度会交换宽高
|
||||
// 90度会交换宽高
|
||||
BufferedImage rotated = new BufferedImage(height, width, source.getType());
|
||||
Graphics2D g2d = null;
|
||||
|
||||
@@ -388,7 +388,7 @@ public class ImageUtils {
|
||||
|
||||
AffineTransform transform = new AffineTransform();
|
||||
transform.translate(height / 2.0, width / 2.0);
|
||||
transform.rotate(-Math.PI / 2);
|
||||
transform.rotate(Math.PI / 2);
|
||||
transform.translate(-width / 2.0, -height / 2.0);
|
||||
|
||||
g2d.setTransform(transform);
|
||||
|
||||
Reference in New Issue
Block a user