byte[] pngBytes = encodeImage(image);
//
// Now, convert PNG data to Base64
//
Base64Encoder b64Encoder = new Base64Encoder();
ByteArrayInputStream is = new ByteArrayInputStream(pngBytes);
ByteArrayOutputStream os = new ByteArrayOutputStream();
try {
b64Encoder.encodeBuffer(new ByteArrayInputStream(pngBytes),
os);
} catch (IOException e) {
// Should not happen because we are doing in-memory processing
throw new SVGGraphics2DIOException(ERR_UNEXPECTED, e);
}