Reputation: 119
In my Android app I'm using the following code:
BitmapRegionDecoder decoder;
...
decoder = BitmapRegionDecoder.newInstance(myStream, false);
...
int width = -1, height = -1, left = -1, top = -1;
...
Log.d("GDA", left + " " + top + " " + width + " " + height);
Rect re = new Rect(left, top, width, height);
Log.d("GDA", re.toString());
if(decoder != null)
region = decoder.decodeRegion(re, null);
everything work well on smartphones and 7" tablets but in 10" tablets (I tested it on a Samsung GT10.1 and an Acer A501) I got this error:
1152 1728 2304 2592
Rect(1152, 1728 - 2304, 2592)
java.lang.NullPointerException
at android.graphics.BitmapRegionDecoder.decodeRegion(BitmapRegionDecoder.java:399)
I can't find a solution. Has anyone had the same issue? Any suggestions?
Upvotes: 2
Views: 2419
Reputation: 86
Solution:
Don't use "region = decoder.decodeRegion(re, null);", use for example:
BitmapFactory.Options options = new BitmapFactory.Options();
region = decoder.decodeRegion(re, options);
It's work, checked for Galaxy Tab 10.1 Android 4.0.x
Upvotes: 6