@Override
  public @Nullable CloseableImage decode(
      EncodedImage encodedImage, int length, QualityInfo qualityInfo, ImageDecodeOptions options) {

    Rect regionToDecode = computeRegionToDecode(encodedImage, options);

    CloseableReference<Bitmap> decodedBitmapReference =
        mPlatformDecoder.decodeJPEGFromEncodedImageWithColorSpace(
            encodedImage, options.bitmapConfig, regionToDecode, length, options.colorSpace);
    try {
      boolean didApplyTransformation =
          TransformationUtils.maybeApplyTransformation(
              options.bitmapTransformation, decodedBitmapReference);

      CloseableStaticBitmap closeableStaticBitmap =
          CloseableStaticBitmap.of(
              decodedBitmapReference,
              ImmutableQualityInfo.FULL_QUALITY,
              encodedImage.getRotationAngle(),
              encodedImage.getExifOrientation());

      closeableStaticBitmap.putExtra(
          HasExtraData.KEY_IS_ROUNDED,
          didApplyTransformation && options.bitmapTransformation instanceof CircularTransformation);

      return closeableStaticBitmap;
    } finally {
      CloseableReference.closeSafely(decodedBitmapReference);
    }
  }
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