docs: public static ByteBuffer convertImageData(BufferedImage bi) {
          DataBuffer buff = bi.getRaster().getDataBuffer();
          // ClassCastException thrown if buff not instanceof DataBufferByte because raster data is not necessarily bytes.
          // Convert the original buffered image to grayscale.
          if (!(buff instanceof DataBufferByte)) {
              BufferedImage grayscaleImage = ImageHelper.convertImageToGrayscale(bi);
              buff = grayscaleImage.getRaster().getDataBuffer();
          }
          byte[] pixelData = ((DataBufferByte) buff).getData();
          //        return ByteBuffer.wrap(pixelData);
          ByteBuffer buf = ByteBuffer.allocateDirect(pixelData.length);
          buf.order(ByteOrder.nativeOrder());
          buf.put(pixelData);
          ((Buffer) buf).flip();
          return buf;
      }