【发布时间】:2012-10-09 20:25:45
【问题描述】:
我正在尝试使用此代码旋转图像:
File imgPath = new File("c:\\tmp\\7.jpg");
BufferedImage src = ImageIO.read(imgPath);
AffineTransform tx = new AffineTransform();
int width = src.getWidth();
int height = src.getHeight();
tx.rotate(radiant ,width, height);
AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BICUBIC);
BufferedImage out = op.filter(src, null);
File outFile = new File("c:\\tmp\\out.jpg");
ImageIO.write(out, "jpg", outFile);
由于某种原因,旋转后的背景是黑色的。 怎样才能让背景变白或透明?
【问题讨论】:
-
背景在为黑色之前是什么颜色?
-
你把它旋转多少度?我无法从您的代码中看出,因为没有提到辐射值。
-
没有背景,旋转后旋转前不存在的区域为黑色,
-
旋转的值为0.02050493823247637
-
黑色背景和你的图片形状一样吗?