code: protected void setImage(int xsize, int ysize, ByteBuffer buf, Rectangle rect, int bpp) {
          int bytespp = bpp / 8;
          int bytespl = (int) Math.ceil(xsize * bpp / 8.0);
          api.TessBaseAPISetImage(handle, buf, xsize, ysize, bytespp, bytespl);
  
          if (rect != null && !rect.isEmpty()) {
              api.TessBaseAPISetRectangle(handle, rect.x, rect.y, rect.width, rect.height);
          }
      }
docs: Sets image to be processed.
  
  @param xsize width of image
  @param ysize height of image
  @param buf pixel data
  @param rect the bounding rectangle defines the region of the image to be
  recognized. A rectangle of zero dimension or <code>null</code> indicates
  the whole image.
  @param bpp bits per pixel, represents the bit depth of the image, with 1
  for binary bitmap, 8 for gray, and 24 for color RGB.