@Test public void testCerealize() throws IOException, CerealException { BufferedImageCerealizer cerealizer = new BufferedImageCerealizer(); BufferedImage image = ImageIO.read(BufferedImageCerealizerTest.class.getResourceAsStream("comcast.jpg")); String base64 = cerealizer.cerealize(image, new ObjectCache()); BufferedImage image2 = cerealizer.deCerealize(base64, new ObjectCache()); Assert.assertEquals(image.getWidth(), image2.getWidth()); Assert.assertEquals(image.getHeight(), image2.getHeight()); }
@Override public String cerealize(BufferedImage object, ObjectCache objectCache) throws CerealException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { try { ImageIO.write(object, "jpg", baos); } catch (IOException e) { throw new CerealException("Failed to cerealize BufferedImage", e); } return Base64.encodeBase64String(baos.toByteArray()); } finally { IOUtils.closeQuietly(baos); } }
BufferedImageCerealizer implements Cerealizer<BufferedImage, String> { @Override public String cerealize(BufferedImage object, ObjectCache objectCache) throws CerealException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { try { ImageIO.write(object, "jpg", baos); } catch (IOException e) { throw new CerealException("Failed to cerealize BufferedImage", e); } return Base64.encodeBase64String(baos.toByteArray()); } finally { IOUtils.closeQuietly(baos); } } }
BufferedImageCerealizer implements Cerealizer<BufferedImage, String> { @Override public String cerealize(BufferedImage object, ObjectCache objectCache) throws CerealException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { try { ImageIO.write(object, "jpg", baos); } catch (IOException e) { throw new CerealException("Failed to cerealize BufferedImage", e); } return Base64.encodeBase64String(baos.toByteArray()); } finally { IOUtils.closeQuietly(baos); } }  }
BufferedImageCerealizer implements Cerealizer<BufferedImage, String> { @Override public String cerealize(BufferedImage object, ObjectCache objectCache) throws CerealException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { try { ImageIO.write(object, "jpg", baos); } catch (IOException e) { throw new CerealException("Failed to cerealize BufferedImage", e); } return Base64.encodeBase64String(baos.toByteArray()); } finally { IOUtils.closeQuietly(baos); } }  @Override BufferedImage deCerealize(String cereal, ObjectCache objectCache); @Override String cerealize(BufferedImage object, ObjectCache objectCache); }
BufferedImageCerealizer implements Cerealizer<BufferedImage, String> { @Override public String cerealize(BufferedImage object, ObjectCache objectCache) throws CerealException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { try { ImageIO.write(object, "jpg", baos); } catch (IOException e) { throw new CerealException("Failed to cerealize BufferedImage", e); } return Base64.encodeBase64String(baos.toByteArray()); } finally { IOUtils.closeQuietly(baos); } }  @Override BufferedImage deCerealize(String cereal, ObjectCache objectCache); @Override String cerealize(BufferedImage object, ObjectCache objectCache);  }