private static byte [ ] getByteArray ( BufferedImage image ) { checkNotNull ( image ) ; ByteArrayOutputStream stream = new ByteArrayOutputStream ( ) ; try { ImageIO . write ( image , "png" , stream ) ; } catch ( IOException e ) { throw new IllegalStateException ( e ) ; } return stream . toByteArray ( ) ; }
Get a byte array of the data of a buffered image .