コード例 #1
0
 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;
 }
コード例 #2
0
 @Override
 public BitmapRegionDecoder run(JobContext jc) {
   if (!prepareInputFile(jc)) return null;
   BitmapRegionDecoder decoder =
       DecodeUtils.createBitmapRegionDecoder(jc, mFileDescriptor.getFileDescriptor(), false);
   mWidth = decoder.getWidth();
   mHeight = decoder.getHeight();
   return decoder;
 }
コード例 #3
0
    @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;
    }
コード例 #4
0
  // This is the same as the method above except the source data comes
  // from a file descriptor instead of a byte array.
  @TargetApi(Build.VERSION_CODES.HONEYCOMB)
  public static Bitmap decodeUsingPool(
      JobContext jc, FileDescriptor fileDescriptor, Options options) {
    if (options == null) options = new BitmapFactory.Options();
    if (options.inSampleSize < 1) options.inSampleSize = 1;
    options.inPreferredConfig = Bitmap.Config.ARGB_8888;
    options.inBitmap =
        (options.inSampleSize == 1) ? findCachedBitmap(jc, fileDescriptor, options) : null;
    try {
      Bitmap bitmap = DecodeUtils.decode(jc, fileDescriptor, options);
      if (options.inBitmap != null && options.inBitmap != bitmap) {
        GalleryBitmapPool.getInstance().put(options.inBitmap);
        options.inBitmap = null;
      }
      return bitmap;
    } catch (IllegalArgumentException e) {
      if (options.inBitmap == null) throw e;

      Log.w(TAG, "decode fail with a given bitmap, try decode to a new bitmap");
      GalleryBitmapPool.getInstance().put(options.inBitmap);
      options.inBitmap = null;
      return decode(jc, fileDescriptor, options);
    }
  }