MCPcopy Create free account
hub / github.com/KAlO2/PerfectShow / decodeImage

Method decodeImage

src/com/cloudream/ishow/util/BitmapUtils.java:355–376  ·  view source on GitHub ↗

Decode image from uri using given "inSampleSize", but if failed due to out-of-memory then raise the inSampleSize until success.

(ContentResolver resolver, Uri uri, BitmapFactory.Options options)

Source from the content-addressed store, hash-verified

353 * raise the inSampleSize until success.
354 */
355 private static Bitmap decodeImage(ContentResolver resolver, Uri uri, BitmapFactory.Options options)
356 throws FileNotFoundException
357 {
358 do
359 {
360 InputStream stream = null;
361 try
362 {
363 stream = resolver.openInputStream(uri);
364 return BitmapFactory.decodeStream(stream, EMPTY_RECT, options);
365 }
366 catch(OutOfMemoryError e)
367 {
368 options.inSampleSize *= 2;
369 }
370 finally
371 {
372 closeSafe(stream);
373 }
374 } while(options.inSampleSize <= 512);
375 throw new RuntimeException("Failed to decode image: " + uri);
376 }
377
378 /**
379 * Decode specific rectangle bitmap from stream using sampling to get bitmap with the requested

Callers 2

decodeSampledBitmapMethod · 0.95
cropBitmapMethod · 0.95

Calls 1

closeSafeMethod · 0.95

Tested by

no test coverage detected