Пример #1
0
 /**
  * translate a binary array to a buffered image
  *
  * @param binary
  * @return
  * @throws IOException
  */
 @Override
 public final BufferedImage toBufferedImage(byte[] bytes, String format) throws IOException {
   try {
     return Sanselan.getBufferedImage(new ByteArrayInputStream(bytes));
   } catch (ImageReadException e) {
     throw ExceptionUtil.toIOException(e);
   }
 }
Пример #2
0
 /**
  * translate a file resource to a buffered image
  *
  * @param res
  * @return
  * @throws IOException
  */
 @Override
 public final BufferedImage toBufferedImage(Resource res, String format) throws IOException {
   InputStream is = null;
   try {
     return Sanselan.getBufferedImage(is = res.getInputStream());
   } catch (ImageReadException e) {
     throw ExceptionUtil.toIOException(e);
   } finally {
     IOUtil.closeEL(is);
   }
 }