summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/util/BitmapDecoder.java
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2012-08-03 19:48:59 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2012-08-03 19:48:59 +0200
commite170605ebc8c6cc1574054074481bb778902b409 (patch)
tree7a8d25bc44a34876985bef6638a3529b4876cf37 /src/de/danoeh/antennapod/util/BitmapDecoder.java
parent93812142dafac72b773573f7474033ae241ae348 (diff)
downloadAntennaPod-e170605ebc8c6cc1574054074481bb778902b409.zip
Thumbnail download is now partly working
Diffstat (limited to 'src/de/danoeh/antennapod/util/BitmapDecoder.java')
-rw-r--r--src/de/danoeh/antennapod/util/BitmapDecoder.java28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/de/danoeh/antennapod/util/BitmapDecoder.java b/src/de/danoeh/antennapod/util/BitmapDecoder.java
index 8cd0bd910..f4b902c6f 100644
--- a/src/de/danoeh/antennapod/util/BitmapDecoder.java
+++ b/src/de/danoeh/antennapod/util/BitmapDecoder.java
@@ -6,8 +6,9 @@ import android.util.Log;
public class BitmapDecoder {
private static final String TAG = "BitmapDecoder";
-
- private static int calculateSampleSize(int preferredLength, int width, int height) {
+
+ private static int calculateSampleSize(int preferredLength, int width,
+ int height) {
int max = Math.max(width, height);
if (max < preferredLength) {
return 1;
@@ -27,18 +28,23 @@ public class BitmapDecoder {
}
}
}
-
+
public static Bitmap decodeBitmap(int preferredLength, String fileUrl) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(fileUrl, options);
- int sampleSize = calculateSampleSize(preferredLength, options.outWidth,
- options.outHeight);
+ int srcWidth = options.outWidth;
+ int srcHeight = options.outHeight;
+ int sampleSize = calculateSampleSize(preferredLength, srcWidth,
+ srcHeight);
options.inJustDecodeBounds = false;
options.inSampleSize = sampleSize;
- Bitmap decodedBitmap = BitmapFactory.decodeFile(fileUrl,
- options);
+ options.inPreferredConfig = Bitmap.Config.ARGB_8888;
+ options.inDither = false;
+ options.inScaled = false;
+
+ Bitmap decodedBitmap = BitmapFactory.decodeFile(fileUrl, options);
if (decodedBitmap == null) {
Log.i(TAG,
"Bitmap could not be decoded in custom sample size. Trying default sample size (path was "
@@ -46,8 +52,12 @@ public class BitmapDecoder {
decodedBitmap = BitmapFactory.decodeFile(fileUrl);
}
if (decodedBitmap != null) {
- return Bitmap.createScaledBitmap(decodedBitmap,
- preferredLength, preferredLength, false);
+ if (preferredLength > srcWidth || preferredLength > srcHeight) {
+ return decodedBitmap;
+ } else {
+ return Bitmap.createScaledBitmap(decodedBitmap,
+ preferredLength, preferredLength, false);
+ }
} else {
return null;
}