@Test public void resizeTest(){ BufferedImage img = new BufferedImage(256, 128, BufferedImage.TYPE_INT_ARGB); BufferedImage newimg = ImageHelper.resize(img, 50, 40); assertEquals(50, newimg.getWidth()); assertEquals(40, newimg.getHeight()); }
public static BufferedImage resize(BufferedImage image, int targetWidth, int targetHeight){ int imageType = BufferedImage.TYPE_INT_ARGB; BufferedImage result = image; BufferedImage tmp = new BufferedImage(targetWidth, targetHeight, imageType); Object hint = RenderingHints.VALUE_INTERPOLATION_BILINEAR; Graphics2D g2 = tmp.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint); g2.drawImage(image, 0, 0, targetWidth, targetHeight, 0, 0, image.getWidth(), image.getHeight(), null); g2.dispose(); result = tmp; return result; }
ImageHelper { public static BufferedImage resize(BufferedImage image, int targetWidth, int targetHeight){ int imageType = BufferedImage.TYPE_INT_ARGB; BufferedImage result = image; BufferedImage tmp = new BufferedImage(targetWidth, targetHeight, imageType); Object hint = RenderingHints.VALUE_INTERPOLATION_BILINEAR; Graphics2D g2 = tmp.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint); g2.drawImage(image, 0, 0, targetWidth, targetHeight, 0, 0, image.getWidth(), image.getHeight(), null); g2.dispose(); result = tmp; return result; } }
ImageHelper { public static BufferedImage resize(BufferedImage image, int targetWidth, int targetHeight){ int imageType = BufferedImage.TYPE_INT_ARGB; BufferedImage result = image; BufferedImage tmp = new BufferedImage(targetWidth, targetHeight, imageType); Object hint = RenderingHints.VALUE_INTERPOLATION_BILINEAR; Graphics2D g2 = tmp.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint); g2.drawImage(image, 0, 0, targetWidth, targetHeight, 0, 0, image.getWidth(), image.getHeight(), null); g2.dispose(); result = tmp; return result; }  }
ImageHelper { public static BufferedImage resize(BufferedImage image, int targetWidth, int targetHeight){ int imageType = BufferedImage.TYPE_INT_ARGB; BufferedImage result = image; BufferedImage tmp = new BufferedImage(targetWidth, targetHeight, imageType); Object hint = RenderingHints.VALUE_INTERPOLATION_BILINEAR; Graphics2D g2 = tmp.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint); g2.drawImage(image, 0, 0, targetWidth, targetHeight, 0, 0, image.getWidth(), image.getHeight(), null); g2.dispose(); result = tmp; return result; }  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 resize(BufferedImage image, int targetWidth, int targetHeight){ int imageType = BufferedImage.TYPE_INT_ARGB; BufferedImage result = image; BufferedImage tmp = new BufferedImage(targetWidth, targetHeight, imageType); Object hint = RenderingHints.VALUE_INTERPOLATION_BILINEAR; Graphics2D g2 = tmp.createGraphics(); g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION, hint); g2.drawImage(image, 0, 0, targetWidth, targetHeight, 0, 0, image.getWidth(), image.getHeight(), null); g2.dispose(); result = tmp; return result; }  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; }