Skip to content

Commit

Permalink
Remove rectangle drawing from rotated image (#896)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas-sexenian authored Nov 18, 2024
1 parent a756677 commit 3620111
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions java/src/main/java/com/genexus/GxImageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3620111

Please sign in to comment.