code: public static ByteBuffer getImageByteBuffer(RenderedImage image) {
          ColorModel cm = image.getColorModel();
          WritableRaster wr = image.getData().createCompatibleWritableRaster(image.getWidth(), image.getHeight());
          image.copyData(wr);
          BufferedImage bi = new BufferedImage(cm, wr, cm.isAlphaPremultiplied(), null);
          return convertImageData(bi);
      }
docs: Gets pixel data of an <code>RenderedImage</code> object.
  
  @param image an <code>RenderedImage</code> object
  @return a byte buffer of pixel data