- byte[] array = img.getData();
- int size = array.length;
- // TODO: check if we can use a stream, too
- Bitmap image = BitmapFactory.decodeByteArray(array, 0, size);
- if (image == null) {
- String ssize = StringUtils.formatNumber(size);
- throw new IOException(
- "Failed to convert input to image, size was: " + ssize);
- }
+ InputStream stream = img.newInputStream();
+ try {
+ Bitmap image = BitmapFactory.decodeStream(stream);
+ if (image == null) {
+ String ssize = StringUtils.formatNumber(img.getSize());
+ throw new IOException(
+ "Failed to convert input to image, size was: " + ssize);
+ }