git://git.nikiroo.be
/
nikiroo-utils.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into streamify
[nikiroo-utils.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 b2359e66338d9d0d7959b6fae56fa3ea6b0c7b72..f198862437754f0883d6ecc77dbacf03c55d4eb7 100644
(file)
--- a/
src/be/nikiroo/utils/android/ImageUtilsAndroid.java
+++ b/
src/be/nikiroo/utils/android/ImageUtilsAndroid.java
@@
-9,6
+9,7
@@
import java.io.IOException;
import be.nikiroo.utils.Image;
import be.nikiroo.utils.ImageUtils;
import be.nikiroo.utils.Image;
import be.nikiroo.utils.ImageUtils;
+import be.nikiroo.utils.StringUtils;
/**
* This class offer some utilities based around images and uses the Android
/**
* This class offer some utilities based around images and uses the Android
@@
-61,23
+62,11
@@
public class ImageUtilsAndroid extends ImageUtils {
* in case of IO error
*/
static public Bitmap fromImage(Image img) throws IOException {
* in case of IO error
*/
static public Bitmap fromImage(Image img) throws IOException {
- Bitmap image = BitmapFactory.decodeByteArray(img.getData(), 0,
- img.getData().length);
+ byte[] array = img.getData();
+ int size = array.length;
+ Bitmap image = BitmapFactory.decodeByteArray(array, 0, size);
if (image == null) {
if (image == null) {
- int size = img.getData().length;
- String ssize = size + " byte";
- if (size > 1) {
- ssize = size + " bytes";
- if (size >= 1000) {
- size = size / 1000;
- ssize = size + " kb";
- if (size > 1000) {
- size = size / 1000;
- ssize = size + " MB";
- }
- }
- }
-
+ String ssize = StringUtils.formatNumber(size);
throw new IOException(
"Failed to convert input to image, size was: " + ssize);
}
throw new IOException(
"Failed to convert input to image, size was: " + ssize);
}