@@ -308,18 +308,23 @@ private static BufferedImage rotateImage(BufferedImage buffImage, double angle)
308308 int width = buffImage .getWidth ();
309309 int height = buffImage .getHeight ();
310310
311- int nWidth = (int ) Math .floor (( double ) width * cos + ( double ) height * sin );
312- int nHeight = (int ) Math .floor (( double ) height * cos + ( double ) width * sin );
311+ int nWidth = (int ) Math .floor (width * cos + height * sin );
312+ int nHeight = (int ) Math .floor (height * cos + width * sin );
313313
314314 BufferedImage rotatedImage = new BufferedImage (nWidth , nHeight , BufferedImage .TYPE_INT_ARGB );
315315
316316 Graphics2D graphics = rotatedImage .createGraphics ();
317+
318+ graphics .setRenderingHint (RenderingHints .KEY_INTERPOLATION , RenderingHints .VALUE_INTERPOLATION_BILINEAR );
319+ graphics .setRenderingHint (RenderingHints .KEY_RENDERING , RenderingHints .VALUE_RENDER_QUALITY );
320+ graphics .setRenderingHint (RenderingHints .KEY_ANTIALIASING , RenderingHints .VALUE_ANTIALIAS_ON );
321+
317322 AffineTransform at = new AffineTransform ();
318- at .translate ((nWidth - width ) / 2 , (nHeight - height ) / 2 );
319- at .rotate (radian , (double ) (width / 2 ), (double ) (height / 2 ));
323+ at .translate ((double ) (nWidth - width ) / 2 , (double ) (nHeight - height ) / 2 );
324+ at .rotate (radian , width / 2.0 , height / 2.0 );
325+
320326 graphics .setTransform (at );
321327 graphics .drawImage (buffImage , 0 , 0 , null );
322- graphics .drawRect (0 , 0 , nWidth - 1 , nHeight - 1 );
323328 graphics .dispose ();
324329
325330 return rotatedImage ;
0 commit comments