public Bitmap run(ThreadPool.JobContext paramJobContext) {
   ImageCacheService localImageCacheService = this.mApplication.getImageCacheService();
   BytesBufferPool.BytesBuffer localBytesBuffer = MediaItem.getBytesBufferPool().get();
   Bitmap localBitmap1;
   try {
     boolean bool1 = localImageCacheService.getImageData(this.mPath, this.mType, localBytesBuffer);
     boolean bool2 = paramJobContext.isCancelled();
     if (bool2) return null;
     if (bool1) {
       BitmapFactory.Options localOptions = new BitmapFactory.Options();
       localOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
       if (this.mType == 2) ;
       Bitmap localBitmap3;
       for (Object localObject2 =
               DecodeUtils.decode(
                   paramJobContext,
                   localBytesBuffer.data,
                   localBytesBuffer.offset,
                   localBytesBuffer.length,
                   localOptions,
                   MediaItem.getMicroThumbPool());
           ;
           localObject2 = localBitmap3) {
         if ((localObject2 == null) && (!paramJobContext.isCancelled()))
           Log.w("ImageCacheRequest", "decode cached failed " + debugTag());
         return localObject2;
         localBitmap3 =
             DecodeUtils.decode(
                 paramJobContext,
                 localBytesBuffer.data,
                 localBytesBuffer.offset,
                 localBytesBuffer.length,
                 localOptions,
                 MediaItem.getThumbPool());
       }
     }
     MediaItem.getBytesBufferPool().recycle(localBytesBuffer);
     localBitmap1 = onDecodeOriginal(paramJobContext, this.mType);
     return null;
   } finally {
     MediaItem.getBytesBufferPool().recycle(localBytesBuffer);
   }
   if (localBitmap1 == null) {
     Log.w("ImageCacheRequest", "decode orig failed " + debugTag());
     return null;
   }
   if (this.mType == 2) ;
   for (Bitmap localBitmap2 =
           BitmapUtils.resizeAndCropCenter(localBitmap1, this.mTargetSize, true);
       paramJobContext.isCancelled();
       localBitmap2 = BitmapUtils.resizeDownBySideLength(localBitmap1, this.mTargetSize, true))
     return null;
   byte[] arrayOfByte = BitmapUtils.compressToBytes(localBitmap2);
   if (paramJobContext.isCancelled()) return null;
   localImageCacheService.putImageData(this.mPath, this.mType, arrayOfByte);
   return (Bitmap) localBitmap2;
 }
  public static Bitmap decodeThumbnail(
      JobContext jc, FileDescriptor fd, Options options, int targetSize, int type) {
    if (options == null) options = new Options();
    jc.setCancelListener(new DecodeCanceller(options));

    options.inJustDecodeBounds = true;
    BitmapFactory.decodeFileDescriptor(fd, null, options);
    if (jc.isCancelled()) return null;

    int w = options.outWidth;
    int h = options.outHeight;

    if (type == MediaItem.TYPE_MICROTHUMBNAIL) {
      // We center-crop the original image as it's micro thumbnail. In this case,
      // we want to make sure the shorter side >= "targetSize".
      float scale = (float) targetSize / Math.min(w, h);
      options.inSampleSize = BitmapUtils.computeSampleSizeLarger(scale);

      // For an extremely wide image, e.g. 300x30000, we may got OOM when decoding
      // it for TYPE_MICROTHUMBNAIL. So we add a max number of pixels limit here.
      final int MAX_PIXEL_COUNT = 640000; // 400 x 1600
      if ((w / options.inSampleSize) * (h / options.inSampleSize) > MAX_PIXEL_COUNT) {
        options.inSampleSize =
            BitmapUtils.computeSampleSize(FloatMath.sqrt((float) MAX_PIXEL_COUNT / (w * h)));
      }
    } else {
      // For screen nail, we only want to keep the longer side >= targetSize.
      float scale = (float) targetSize / Math.max(w, h);
      options.inSampleSize = BitmapUtils.computeSampleSizeLarger(scale);
    }

    options.inJustDecodeBounds = false;
    setOptionsMutable(options);

    Bitmap result = BitmapFactory.decodeFileDescriptor(fd, null, options);
    if (result == null) return null;

    // We need to resize down if the decoder does not support inSampleSize
    // (For example, GIF images)
    float scale =
        (float) targetSize
            / (type == MediaItem.TYPE_MICROTHUMBNAIL
                ? Math.min(result.getWidth(), result.getHeight())
                : Math.max(result.getWidth(), result.getHeight()));

    if (scale <= 0.5) result = BitmapUtils.resizeBitmapByScale(result, scale, true);
    return ensureGLCompatibleBitmap(result);
  }
 @Override
 public int getSupportedOperations() {
   int supported = SUPPORT_EDIT | SUPPORT_SETAS;
   if (isSharable()) supported |= SUPPORT_SHARE;
   if (BitmapUtils.isSupportedByRegionDecoder(mContentType)) {
     supported |= SUPPORT_FULL_IMAGE;
   }
   return supported;
 }
 @Override
 public Bitmap run(JobContext jc) {
   Bitmap bitmap = mItem.requestImage(MediaItem.TYPE_THUMBNAIL).run(jc);
   if (jc.isCancelled()) return null;
   if (bitmap != null) {
     bitmap =
         BitmapUtils.rotateBitmap(
             bitmap, mItem.getRotation() - mItem.getFullImageRotation(), true);
   }
   return bitmap;
 }
    @Override
    public Bitmap run(JobContext jc) {
      if (!prepareInputFile(jc)) return null;
      int targetSize = MediaItem.getTargetSize(mType);
      Options options = new Options();
      options.inPreferredConfig = Config.ARGB_8888;
      Bitmap bitmap =
          DecodeUtils.decodeThumbnail(
              jc, mFileDescriptor.getFileDescriptor(), options, targetSize, mType);

      if (jc.isCancelled() || bitmap == null) {
        return null;
      }

      if (mType == MediaItem.TYPE_MICROTHUMBNAIL) {
        bitmap = BitmapUtils.resizeAndCropCenter(bitmap, targetSize, true);
      } else {
        bitmap = BitmapUtils.resizeDownBySideLength(bitmap, targetSize, true);
      }
      return bitmap;
    }
  /**
   * Decodes the bitmap from the given byte array if the image size is larger than the given
   * requirement.
   *
   * <p>Note: The returned image may be resized down. However, both width and height must be larger
   * than the <code>targetSize</code>.
   */
  public static Bitmap decodeIfBigEnough(
      JobContext jc, byte[] data, Options options, int targetSize) {
    if (options == null) options = new Options();
    jc.setCancelListener(new DecodeCanceller(options));

    options.inJustDecodeBounds = true;
    BitmapFactory.decodeByteArray(data, 0, data.length, options);
    if (jc.isCancelled()) return null;
    if (options.outWidth < targetSize || options.outHeight < targetSize) {
      return null;
    }
    options.inSampleSize =
        BitmapUtils.computeSampleSizeLarger(options.outWidth, options.outHeight, targetSize);
    options.inJustDecodeBounds = false;
    setOptionsMutable(options);

    return ensureGLCompatibleBitmap(BitmapFactory.decodeByteArray(data, 0, data.length, options));
  }