Add 'src/be/nikiroo/utils/' from commit '46add0670fdee4bd936a13fe2448c5e20a7ffd0a'
[fanfix.git] / src / be / nikiroo / utils / android / ImageUtilsAndroid.java
index f50af005316c3fdc169aabfe8d11269171db8458..c2e269cc58291cfbcb32d2e105c7d63938c6e136 100644 (file)
@@ -45,7 +45,7 @@ public class ImageUtilsAndroid extends ImageUtils {
                        }
 
                        // Some formats are not reliable
-                       // Second change: PNG
+                       // Second chance: PNG
                        if (!ok && !format.equals("png")) {
                                ok = image.compress(Bitmap.CompressFormat.PNG, 90, fos);
                        }
@@ -76,9 +76,19 @@ public class ImageUtilsAndroid extends ImageUtils {
                try {
                        Bitmap image = BitmapFactory.decodeStream(stream);
                        if (image == null) {
+                               String extra = "";
+                               if (img.getSize() <= 2048) {
+                                       try {
+                                               extra = ", content: "
+                                                               + new String(img.getData(), "UTF-8");
+                                       } catch (Exception e) {
+                                               extra = ", content unavailable";
+                                       }
+                               }
                                String ssize = StringUtils.formatNumber(img.getSize());
                                throw new IOException(
-                                               "Failed to convert input to image, size was: " + ssize);
+                                               "Failed to convert input to image, size was: " + ssize
+                                                               + extra);
                        }
 
                        return image;