ImageUtil { public static byte[] getEmbeddedBase64Image(String imageDataUri) { int b64Index = imageDataUri.indexOf("base64,"); if (b64Index != -1) { String b64encoded = imageDataUri.substring(b64Index + "base64,".length()); return Base64.getMimeDecoder().decode(b64encoded); } else { XRLog.log(Level.SEVERE, LogMessageId.LogMessageId0Param.LOAD_EMBEDDED_DATA_URI_MUST_BE_ENCODED_IN_BASE64); } return null; }  static BufferedImage makeCompatible(BufferedImage bimg); static BufferedImage createCompatibleBufferedImage(int width, int height, int biType); static BufferedImage createCompatibleBufferedImage(int width, int height); static BufferedImage getScaledInstance(ScalingOptions opt, BufferedImage orgImage); static BufferedImage getScaledInstance(BufferedImage orgImage, int targetWidth, int targetHeight); static BufferedImage convertToBufferedImage(Image awtImg, int type); static BufferedImage createTransparentImage(int width, int height); static boolean isEmbeddedBase64Image(String uri); static boolean isDataUri(String uri); static byte[] getEmbeddedBase64Image(String imageDataUri); static byte[] getEmbeddedDataUri(String dataUri); static BufferedImage loadEmbeddedBase64Image(String imageDataUri);  }
@Test public void testGetEmbeddedBase64Image() { String onePixel = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAIAAACQd1PeAAAACXBIWXMAAC4jAAAuIwF4pT92AAAADElEQVQI12P4 byte[] result = ImageUtil.getEmbeddedBase64Image(onePixel); Assert.assertThat(result, notNullValue()); }