From a903c4d713f019949881522bae6a02ac652d3429 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Sexenian?= <99925035+tomas-sexenian@users.noreply.github.com> Date: Thu, 29 Aug 2024 11:33:07 -0300 Subject: [PATCH] Remove rectangle drawing from rotated image --- java/src/main/java/com/genexus/GxImageUtil.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/java/src/main/java/com/genexus/GxImageUtil.java b/java/src/main/java/com/genexus/GxImageUtil.java index 2c55d5fae..f46d953a6 100644 --- a/java/src/main/java/com/genexus/GxImageUtil.java +++ b/java/src/main/java/com/genexus/GxImageUtil.java @@ -308,18 +308,23 @@ private static BufferedImage rotateImage(BufferedImage buffImage, double angle) int width = buffImage.getWidth(); int height = buffImage.getHeight(); - int nWidth = (int) Math.floor((double) width * cos + (double) height * sin); - int nHeight = (int) Math.floor((double) height * cos + (double) width * sin); + int nWidth = (int) Math.floor(width * cos + height * sin); + int nHeight = (int) Math.floor(height * cos + width * sin); BufferedImage rotatedImage = new BufferedImage(nWidth, nHeight, BufferedImage.TYPE_INT_ARGB); Graphics2D graphics = rotatedImage.createGraphics(); + + graphics.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR); + graphics.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); + graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + AffineTransform at = new AffineTransform(); - at.translate((nWidth - width) / 2, (nHeight - height) / 2); - at.rotate(radian, (double) (width / 2), (double) (height / 2)); + at.translate((double) (nWidth - width) / 2, (double) (nHeight - height) / 2); + at.rotate(radian, width / 2.0, height / 2.0); + graphics.setTransform(at); graphics.drawImage(buffImage, 0, 0, null); - graphics.drawRect(0, 0, nWidth - 1, nHeight - 1); graphics.dispose(); return rotatedImage;