code: @Override
    public CloseableReference<Bitmap> decodeFromEncodedImageWithColorSpace(
        final EncodedImage encodedImage,
        Bitmap.Config bitmapConfig,
        @Nullable Rect regionToDecode,
        @Nullable final ColorSpace colorSpace) {
      BitmapFactory.Options options = getBitmapFactoryOptions(
          encodedImage.getSampleSize(),
          bitmapConfig);
      if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        OreoUtils.setColorSpace(options, colorSpace);
      }
      CloseableReference<PooledByteBuffer> bytesRef = encodedImage.getByteBufferRef();
      Preconditions.checkNotNull(bytesRef);
      try {
        Bitmap bitmap = decodeByteArrayAsPurgeable(bytesRef, options);
        return pinBitmap(bitmap);
      } finally {
        CloseableReference.closeSafely(bytesRef);
      }
    }
docs: Creates a bitmap from encoded bytes.
  
  @param encodedImage the encoded image with reference to the encoded bytes
  @param bitmapConfig the {@link android.graphics.Bitmap.Config} used to create the decoded
  Bitmap
  @param regionToDecode optional image region to decode. currently not supported.
  @param colorSpace the target color space of the decoded bitmap, must be one of the named color
  space in {@link android.graphics.ColorSpace.Named}. If null, then SRGB color space is
  assumed if the SDK version >= 26.
  @return the bitmap
  @throws TooManyBitmapsException if the pool is full
  @throws java.lang.OutOfMemoryError if the Bitmap cannot be allocated