@Test public void testGetImageFromByte() throws IOException{ BufferedImage image = ImageHelper.getImageFromByte(imagedata); assertEquals(10, image.getWidth()); assertEquals(10, image.getWidth()); }
public static BufferedImage getImageFromByte(byte[] array){ InputStream instream = new ByteArrayInputStream(array); String imageType = getImageType(array); ImageDecoder dec = ImageCodec.createImageDecoder(imageType, instream, null); BufferedImage image = null; FileOutputStream fos=null; try { File logFile = new File(Util.getVideoOptimizerLibrary() + Util.FILE_SEPARATOR +THIRDP_LOG); logFile.createNewFile(); fos = new FileOutputStream(logFile,false); } catch (IOException ioe) { Logger.error("Failed to create a log file", ioe); } System.setErr(new PrintStream(fos)); try { RenderedImage renderedImg; renderedImg = dec.decodeAsRenderedImage(0); RenderedImage rendering = new NullOpImage(renderedImg, null, null, OpImage.OP_IO_BOUND); image = convertRenderedImage(rendering); } catch (ImagingException exp) { setImageDecoderStatus(false); } catch (EOFException eof) { setImageDecoderStatus(false); } catch (IOException ioe) { setImageDecoderStatus(false); } System.setErr(System.err); return image; }
ImageHelper { public static BufferedImage getImageFromByte(byte[] array){ InputStream instream = new ByteArrayInputStream(array); String imageType = getImageType(array); ImageDecoder dec = ImageCodec.createImageDecoder(imageType, instream, null); BufferedImage image = null; FileOutputStream fos=null; try { File logFile = new File(Util.getVideoOptimizerLibrary() + Util.FILE_SEPARATOR +THIRDP_LOG); logFile.createNewFile(); fos = new FileOutputStream(logFile,false); } catch (IOException ioe) { Logger.error("Failed to create a log file", ioe); } System.setErr(new PrintStream(fos)); try { RenderedImage renderedImg; renderedImg = dec.decodeAsRenderedImage(0); RenderedImage rendering = new NullOpImage(renderedImg, null, null, OpImage.OP_IO_BOUND); image = convertRenderedImage(rendering); } catch (ImagingException exp) { setImageDecoderStatus(false); } catch (EOFException eof) { setImageDecoderStatus(false); } catch (IOException ioe) { setImageDecoderStatus(false); } System.setErr(System.err); return image; } }
ImageHelper { public static BufferedImage getImageFromByte(byte[] array){ InputStream instream = new ByteArrayInputStream(array); String imageType = getImageType(array); ImageDecoder dec = ImageCodec.createImageDecoder(imageType, instream, null); BufferedImage image = null; FileOutputStream fos=null; try { File logFile = new File(Util.getVideoOptimizerLibrary() + Util.FILE_SEPARATOR +THIRDP_LOG); logFile.createNewFile(); fos = new FileOutputStream(logFile,false); } catch (IOException ioe) { Logger.error("Failed to create a log file", ioe); } System.setErr(new PrintStream(fos)); try { RenderedImage renderedImg; renderedImg = dec.decodeAsRenderedImage(0); RenderedImage rendering = new NullOpImage(renderedImg, null, null, OpImage.OP_IO_BOUND); image = convertRenderedImage(rendering); } catch (ImagingException exp) { setImageDecoderStatus(false); } catch (EOFException eof) { setImageDecoderStatus(false); } catch (IOException ioe) { setImageDecoderStatus(false); } System.setErr(System.err); return image; }  }
ImageHelper { public static BufferedImage getImageFromByte(byte[] array){ InputStream instream = new ByteArrayInputStream(array); String imageType = getImageType(array); ImageDecoder dec = ImageCodec.createImageDecoder(imageType, instream, null); BufferedImage image = null; FileOutputStream fos=null; try { File logFile = new File(Util.getVideoOptimizerLibrary() + Util.FILE_SEPARATOR +THIRDP_LOG); logFile.createNewFile(); fos = new FileOutputStream(logFile,false); } catch (IOException ioe) { Logger.error("Failed to create a log file", ioe); } System.setErr(new PrintStream(fos)); try { RenderedImage renderedImg; renderedImg = dec.decodeAsRenderedImage(0); RenderedImage rendering = new NullOpImage(renderedImg, null, null, OpImage.OP_IO_BOUND); image = convertRenderedImage(rendering); } catch (ImagingException exp) { setImageDecoderStatus(false); } catch (EOFException eof) { setImageDecoderStatus(false); } catch (IOException ioe) { setImageDecoderStatus(false); } System.setErr(System.err); return image; }  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 getImageFromByte(byte[] array){ InputStream instream = new ByteArrayInputStream(array); String imageType = getImageType(array); ImageDecoder dec = ImageCodec.createImageDecoder(imageType, instream, null); BufferedImage image = null; FileOutputStream fos=null; try { File logFile = new File(Util.getVideoOptimizerLibrary() + Util.FILE_SEPARATOR +THIRDP_LOG); logFile.createNewFile(); fos = new FileOutputStream(logFile,false); } catch (IOException ioe) { Logger.error("Failed to create a log file", ioe); } System.setErr(new PrintStream(fos)); try { RenderedImage renderedImg; renderedImg = dec.decodeAsRenderedImage(0); RenderedImage rendering = new NullOpImage(renderedImg, null, null, OpImage.OP_IO_BOUND); image = convertRenderedImage(rendering); } catch (ImagingException exp) { setImageDecoderStatus(false); } catch (EOFException eof) { setImageDecoderStatus(false); } catch (IOException ioe) { setImageDecoderStatus(false); } System.setErr(System.err); return image; }  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; }