我有这个功能用于旋转图像。尽管我失去了质量。任何可以改善它的变化?Java旋转图像丢失质量
public BufferedImage RotateImage(String imagePath,int degrees) throws IOException{
File file = new File(imagePath);
Image image = ImageIO.read(file);
BufferedImage img=bufferImage(image, BufferedImage.TYPE_INT_RGB);
AffineTransform tx = new AffineTransform();
double radians = (Math.PI/180) * degrees;
double width = img.getWidth()/2;
double height = img.getHeight()/2;
if(degrees != 180){
tx.translate(height,width);
tx.rotate(radians);
tx.translate(-width,-height);
}else{
tx.rotate(radians,width, height);
}
AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
img = op.filter(img, null);
return img;
}
请注意,如果您发布了[SSCCE](http://pscode.org/sscce.html),**我们**可以“尝试”其他调整大小技巧。对于具有图像的SSCCE,生成一个代码或热链接到直接离开网络的图像,例如,我的[媒体页面](http://pscode.org/media/#image)上提供的图像之一。 – 2011-03-25 18:06:42