Skip to content

Instantly share code, notes, and snippets.

@mdeterman
Created December 6, 2015 18:26
Show Gist options
  • Save mdeterman/c32adbb0913eefb0da1e to your computer and use it in GitHub Desktop.
Save mdeterman/c32adbb0913eefb0da1e to your computer and use it in GitHub Desktop.
getImage
protected CImage getImage(String path) throws Exception {
BufferedImage image = ImageIO.read(new File(path));
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(image, "bmp", baos );
baos.flush();
byte[] imageInByte = baos.toByteArray();
baos.close();
return new CImage(imageInByte,image.getWidth(),image.getHeight());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment