Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove rectangle drawing from rotated image #896

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading