我想围绕特定像素位置而不是围绕图像中心旋转图像。我想将图像旋转小于 90 度。我使用了图形类的旋转功能,但是旋转时图像变得模糊。如何去除这种模糊?有没有特定的功能?这是我现在使用的代码:
BufferedImage oldImage = ImageIO.read(new File("C:/omr/OMR_Rotation_1.jpg"));
BufferedImage newImage = new BufferedImage(oldImage.getWidth(), oldImage.getHeight(),oldImage.getType());
Graphics2D graphics = (Graphics2D) newImage.getGraphics();
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_DEFAULT);
graphics.rotate(Math.toRadians(-2.3), newImage.getWidth() / 2, newImage.getHeight() / 2);
graphics.translate((newImage.getWidth() - oldImage.getWidth()) / 2, (newImage.getHeight() - oldImage.getHeight()) / 2);
//graphics.drawImage(oldImage, 0, 0, oldImage.getWidth(), oldImage.getHeight(), null);
graphics.drawImage(oldImage, null, 0, 0);
ImageIO.write(newImage, "JPG", new File("C:/omr/OMR_Rotation_2.jpg"));
graphics.translate((newImage.getWidth() - oldImage.getWidth()) / 2, (newImage.getHeight() - oldImage.getHeight()) / 2);