code: public static Bitmap cropBitmap(Bitmap sourceBitmap, int left, int top, int width, int height) {
          if (sourceBitmap == null) {
              return null;
          }
  
          try {
              return Bitmap.createBitmap(sourceBitmap, left, top, width, height);
          } catch (IllegalArgumentException ex) {
              // Can throw exception if cropping arguments are out of bounds.
              LogUtils.log(ScreenshotUtils.class, Log.ERROR, Log.getStackTraceString(ex));
              return null;
          }
      }
docs: Creates a new {@link Bitmap} object with a rectangular region of pixels
  from the source bitmap.
  <p>
  The source bitmap is unaffected by this operation.
  
  @param sourceBitmap The source bitmap to crop.
  @param left The leftmost coordinate to include in the cropped image
  @param top The toptmost coordinate to include in the cropped image
  @param width The width of the cropped image
  @param height The height of the cropped image
  @return A new bitmap of the cropped area, or {@code null} if the source
  was {@code null} or the crop parameters were out of bounds.