@Test public void rorate90ImageTest(){ BufferedImage img = new BufferedImage(256, 128, BufferedImage.TYPE_INT_ARGB); BufferedImage newimg = ImageHelper.rotate90DegreeRight(img); assertEquals(128, newimg.getWidth()); assertEquals(256, newimg.getHeight()); }
public static BufferedImage rotate90DegreeRight(BufferedImage img) { int w = img.getWidth(); int h = img.getHeight(); BufferedImage rot = new BufferedImage(h, w, BufferedImage.TYPE_INT_RGB); double theta = Math.PI / 2; AffineTransform xform = new AffineTransform(); xform.translate(0.5*h, 0.5*w); xform.rotate(theta); xform.translate(-0.5*w, -0.5*h); Graphics2D g = (Graphics2D) rot.createGraphics(); g.drawImage(img, xform, null); g.dispose(); return rot; }
ImageHelper { public static BufferedImage rotate90DegreeRight(BufferedImage img) { int w = img.getWidth(); int h = img.getHeight(); BufferedImage rot = new BufferedImage(h, w, BufferedImage.TYPE_INT_RGB); double theta = Math.PI / 2; AffineTransform xform = new AffineTransform(); xform.translate(0.5*h, 0.5*w); xform.rotate(theta); xform.translate(-0.5*w, -0.5*h); Graphics2D g = (Graphics2D) rot.createGraphics(); g.drawImage(img, xform, null); g.dispose(); return rot; } }
ImageHelper { public static BufferedImage rotate90DegreeRight(BufferedImage img) { int w = img.getWidth(); int h = img.getHeight(); BufferedImage rot = new BufferedImage(h, w, BufferedImage.TYPE_INT_RGB); double theta = Math.PI / 2; AffineTransform xform = new AffineTransform(); xform.translate(0.5*h, 0.5*w); xform.rotate(theta); xform.translate(-0.5*w, -0.5*h); Graphics2D g = (Graphics2D) rot.createGraphics(); g.drawImage(img, xform, null); g.dispose(); return rot; }  }
ImageHelper { public static BufferedImage rotate90DegreeRight(BufferedImage img) { int w = img.getWidth(); int h = img.getHeight(); BufferedImage rot = new BufferedImage(h, w, BufferedImage.TYPE_INT_RGB); double theta = Math.PI / 2; AffineTransform xform = new AffineTransform(); xform.translate(0.5*h, 0.5*w); xform.rotate(theta); xform.translate(-0.5*w, -0.5*h); Graphics2D g = (Graphics2D) rot.createGraphics(); g.drawImage(img, xform, null); g.dispose(); return rot; }  static void convertImage(RawImage rawImage, BufferedImage image); static BufferedImage resize(BufferedImage image, int targetWidth, int targetHeight); static BufferedImage getImageFromByte(byte[] array); static String getImageType(byte[] array); static BufferedImage convertRenderedImage(RenderedImage img); static BufferedImage rorateImage(BufferedImage image, int angle); static BufferedImage rotate90DegreeRight(BufferedImage img); static BufferedImage createImage(int width, int height); static String extractFullNameFromRRInfo(HttpRequestResponseInfo hrri); static boolean isImageDecoderStatus(); static void setImageDecoderStatus(boolean imageDecoderStatus); }
ImageHelper { public static BufferedImage rotate90DegreeRight(BufferedImage img) { int w = img.getWidth(); int h = img.getHeight(); BufferedImage rot = new BufferedImage(h, w, BufferedImage.TYPE_INT_RGB); double theta = Math.PI / 2; AffineTransform xform = new AffineTransform(); xform.translate(0.5*h, 0.5*w); xform.rotate(theta); xform.translate(-0.5*w, -0.5*h); Graphics2D g = (Graphics2D) rot.createGraphics(); g.drawImage(img, xform, null); g.dispose(); return rot; }  static void convertImage(RawImage rawImage, BufferedImage image); static BufferedImage resize(BufferedImage image, int targetWidth, int targetHeight); static BufferedImage getImageFromByte(byte[] array); static String getImageType(byte[] array); static BufferedImage convertRenderedImage(RenderedImage img); static BufferedImage rorateImage(BufferedImage image, int angle); static BufferedImage rotate90DegreeRight(BufferedImage img); static BufferedImage createImage(int width, int height); static String extractFullNameFromRRInfo(HttpRequestResponseInfo hrri); static boolean isImageDecoderStatus(); static void setImageDecoderStatus(boolean imageDecoderStatus); static boolean imageDecoderStatus; }