private @Nullable Rect computeRegionToDecode(
      EncodedImage encodedImage, ImageDecodeOptions options) {
    if (!(options instanceof FrescoVitoImageDecodeOptions)) {
      return null;
    }
    FrescoVitoImageDecodeOptions frescoVitoOptions = (FrescoVitoImageDecodeOptions) options;

    Rect regionToDecode = new Rect();
    Matrix matrix = new Matrix();
    frescoVitoOptions.scaleType.getTransform(
        matrix,
        frescoVitoOptions.parentBounds,
        encodedImage.getWidth(),
        encodedImage.getHeight(),
        frescoVitoOptions.focusPoint.x,
        frescoVitoOptions.focusPoint.y);
    matrix.invert(matrix);

    RectF tempRectangle = new RectF(frescoVitoOptions.parentBounds);
    matrix.mapRect(tempRectangle);

    tempRectangle.round(regionToDecode);
    return regionToDecode;
  }
Decodes a partial jpeg.

@param encodedImage input image (encoded bytes plus meta data)
@param length if image type supports decoding incomplete image then determines where the image
    data should be cut for decoding.
@param qualityInfo quality information for the image
@param options options that can change decode behavior
samples/showcase/src/main/java/com/facebook/fresco/samples/showcase/vito/FrescoVitoRegionDecoder.java