git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
lib: sort fixes
[fanfix.git]
/
src
/
be
/
nikiroo
/
utils
/
android
/
ImageUtilsAndroid.java
diff --git
a/src/be/nikiroo/utils/android/ImageUtilsAndroid.java
b/src/be/nikiroo/utils/android/ImageUtilsAndroid.java
index d55e602cb89d247e6056caec1f49c9b484de7ed4..c2e269cc58291cfbcb32d2e105c7d63938c6e136 100644
(file)
--- a/
src/be/nikiroo/utils/android/ImageUtilsAndroid.java
+++ b/
src/be/nikiroo/utils/android/ImageUtilsAndroid.java
@@
-10,8
+10,6
@@
import java.io.IOException;
import java.io.InputStream;
import java.util.stream.Stream;
import java.io.InputStream;
import java.util.stream.Stream;
-import javax.imageio.ImageIO;
-
import be.nikiroo.utils.Image;
import be.nikiroo.utils.ImageUtils;
import be.nikiroo.utils.StringUtils;
import be.nikiroo.utils.Image;
import be.nikiroo.utils.ImageUtils;
import be.nikiroo.utils.StringUtils;
@@
-26,7
+24,7
@@
public class ImageUtilsAndroid extends ImageUtils {
@Override
protected boolean check() {
// If we can get the class, it means we have access to it
@Override
protected boolean check() {
// If we can get the class, it means we have access to it
- Config.ALPHA_8;
+ Config
c = Config
.ALPHA_8;
return true;
}
return true;
}
@@
-47,7
+45,7
@@
public class ImageUtilsAndroid extends ImageUtils {
}
// Some formats are not reliable
}
// Some formats are not reliable
- // Second chan
g
e: PNG
+ // Second chan
c
e: PNG
if (!ok && !format.equals("png")) {
ok = image.compress(Bitmap.CompressFormat.PNG, 90, fos);
}
if (!ok && !format.equals("png")) {
ok = image.compress(Bitmap.CompressFormat.PNG, 90, fos);
}
@@
-78,14
+76,24
@@
public class ImageUtilsAndroid extends ImageUtils {
try {
Bitmap image = BitmapFactory.decodeStream(stream);
if (image == null) {
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(
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;
} finally {
stream.close();
}
} finally {
stream.close();
}
-
- return image;
}
}
}
}