@@ -321,18 +321,23 @@ private static BufferedImage rotateImage(BufferedImage buffImage, double angle)
321321 int width = buffImage .getWidth ();
322322 int height = buffImage .getHeight ();
323323
324- int nWidth = (int ) Math .floor (( double ) width * cos + ( double ) height * sin );
325- int nHeight = (int ) Math .floor (( double ) height * cos + ( double ) width * sin );
324+ int nWidth = (int ) Math .floor (width * cos + height * sin );
325+ int nHeight = (int ) Math .floor (height * cos + width * sin );
326326
327327 BufferedImage rotatedImage = new BufferedImage (nWidth , nHeight , BufferedImage .TYPE_INT_ARGB );
328328
329329 Graphics2D graphics = rotatedImage .createGraphics ();
330+
331+ graphics .setRenderingHint (RenderingHints .KEY_INTERPOLATION , RenderingHints .VALUE_INTERPOLATION_BILINEAR );
332+ graphics .setRenderingHint (RenderingHints .KEY_RENDERING , RenderingHints .VALUE_RENDER_QUALITY );
333+ graphics .setRenderingHint (RenderingHints .KEY_ANTIALIASING , RenderingHints .VALUE_ANTIALIAS_ON );
334+
330335 AffineTransform at = new AffineTransform ();
331- at .translate ((nWidth - width ) / 2 , (nHeight - height ) / 2 );
332- at .rotate (radian , (double ) (width / 2 ), (double ) (height / 2 ));
336+ at .translate ((double ) (nWidth - width ) / 2 , (double ) (nHeight - height ) / 2 );
337+ at .rotate (radian , width / 2.0 , height / 2.0 );
338+
333339 graphics .setTransform (at );
334340 graphics .drawImage (buffImage , 0 , 0 , null );
335- graphics .drawRect (0 , 0 , nWidth - 1 , nHeight - 1 );
336341 graphics .dispose ();
337342
338343 return rotatedImage ;
0 commit comments