@Test public void convertRenderedImageTest(){ RenderedImage renderimage = new BufferedImage(100,100,BufferedImage.TYPE_INT_ARGB); BufferedImage newimage = ImageHelper.convertRenderedImage(renderimage); assertTrue(newimage instanceof BufferedImage); }
public static BufferedImage convertRenderedImage(RenderedImage img) { if (img instanceof BufferedImage) { return (BufferedImage)img; } ColorModel cm = img.getColorModel(); int width = img.getWidth(); int height = img.getHeight(); WritableRaster raster = cm.createCompatibleWritableRaster(width, height); boolean isAlphaPremultiplied = cm.isAlphaPremultiplied(); Hashtable<String, Object> properties = new Hashtable<>(); String[] keys = img.getPropertyNames(); if (keys!=null) { for (int i = 0; i < keys.length; i++) { properties.put(keys[i], img.getProperty(keys[i])); } } BufferedImage result = new BufferedImage(cm, raster, isAlphaPremultiplied, properties); img.copyData(raster); return result; }
ImageHelper { public static BufferedImage convertRenderedImage(RenderedImage img) { if (img instanceof BufferedImage) { return (BufferedImage)img; } ColorModel cm = img.getColorModel(); int width = img.getWidth(); int height = img.getHeight(); WritableRaster raster = cm.createCompatibleWritableRaster(width, height); boolean isAlphaPremultiplied = cm.isAlphaPremultiplied(); Hashtable<String, Object> properties = new Hashtable<>(); String[] keys = img.getPropertyNames(); if (keys!=null) { for (int i = 0; i < keys.length; i++) { properties.put(keys[i], img.getProperty(keys[i])); } } BufferedImage result = new BufferedImage(cm, raster, isAlphaPremultiplied, properties); img.copyData(raster); return result; } }
ImageHelper { public static BufferedImage convertRenderedImage(RenderedImage img) { if (img instanceof BufferedImage) { return (BufferedImage)img; } ColorModel cm = img.getColorModel(); int width = img.getWidth(); int height = img.getHeight(); WritableRaster raster = cm.createCompatibleWritableRaster(width, height); boolean isAlphaPremultiplied = cm.isAlphaPremultiplied(); Hashtable<String, Object> properties = new Hashtable<>(); String[] keys = img.getPropertyNames(); if (keys!=null) { for (int i = 0; i < keys.length; i++) { properties.put(keys[i], img.getProperty(keys[i])); } } BufferedImage result = new BufferedImage(cm, raster, isAlphaPremultiplied, properties); img.copyData(raster); return result; }  }
ImageHelper { public static BufferedImage convertRenderedImage(RenderedImage img) { if (img instanceof BufferedImage) { return (BufferedImage)img; } ColorModel cm = img.getColorModel(); int width = img.getWidth(); int height = img.getHeight(); WritableRaster raster = cm.createCompatibleWritableRaster(width, height); boolean isAlphaPremultiplied = cm.isAlphaPremultiplied(); Hashtable<String, Object> properties = new Hashtable<>(); String[] keys = img.getPropertyNames(); if (keys!=null) { for (int i = 0; i < keys.length; i++) { properties.put(keys[i], img.getProperty(keys[i])); } } BufferedImage result = new BufferedImage(cm, raster, isAlphaPremultiplied, properties); img.copyData(raster); 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 convertRenderedImage(RenderedImage img) { if (img instanceof BufferedImage) { return (BufferedImage)img; } ColorModel cm = img.getColorModel(); int width = img.getWidth(); int height = img.getHeight(); WritableRaster raster = cm.createCompatibleWritableRaster(width, height); boolean isAlphaPremultiplied = cm.isAlphaPremultiplied(); Hashtable<String, Object> properties = new Hashtable<>(); String[] keys = img.getPropertyNames(); if (keys!=null) { for (int i = 0; i < keys.length; i++) { properties.put(keys[i], img.getProperty(keys[i])); } } BufferedImage result = new BufferedImage(cm, raster, isAlphaPremultiplied, properties); img.copyData(raster); 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; }