diff options
Diffstat (limited to 'src/de/danoeh/antennapod/util/BitmapDecoder.java')
-rw-r--r-- | src/de/danoeh/antennapod/util/BitmapDecoder.java | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/src/de/danoeh/antennapod/util/BitmapDecoder.java b/src/de/danoeh/antennapod/util/BitmapDecoder.java deleted file mode 100644 index 5296d675a..000000000 --- a/src/de/danoeh/antennapod/util/BitmapDecoder.java +++ /dev/null @@ -1,50 +0,0 @@ -package de.danoeh.antennapod.util; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Rect; -import android.util.Log; -import de.danoeh.antennapod.BuildConfig; -import de.danoeh.antennapod.asynctask.ImageLoader; -import org.apache.commons.io.IOUtils; - -import java.io.InputStream; - -public class BitmapDecoder { - private static final String TAG = "BitmapDecoder"; - - private static int calculateSampleSize(int preferredLength, int length) { - int sampleSize = 1; - if (length > preferredLength) { - sampleSize = Math.round(((float) length / (float) preferredLength)); - } - return sampleSize; - } - - public static Bitmap decodeBitmapFromWorkerTaskResource(int preferredLength, - ImageLoader.ImageWorkerTaskResource source) { - InputStream input = source.openImageInputStream(); - if (input != null) { - BitmapFactory.Options options = new BitmapFactory.Options(); - options.inJustDecodeBounds = true; - BitmapFactory.decodeStream(input, new Rect(), options); - int srcWidth = options.outWidth; - int srcHeight = options.outHeight; - int length = Math.max(srcWidth, srcHeight); - int sampleSize = calculateSampleSize(preferredLength, length); - if (BuildConfig.DEBUG) - Log.d(TAG, "Using samplesize " + sampleSize); - options.inJustDecodeBounds = false; - options.inSampleSize = sampleSize; - options.inPreferredConfig = Bitmap.Config.ARGB_8888; - Bitmap decodedBitmap = BitmapFactory.decodeStream(source.reopenImageInputStream(input), - null, options); - if (decodedBitmap == null) { - decodedBitmap = BitmapFactory.decodeStream(source.reopenImageInputStream(input)); - } - IOUtils.closeQuietly(input); - return decodedBitmap; - } - return null; - } -} |