Load bitmap resources entirely from native code.

Change-Id: I6660baec241794c40611bce79b7f9ce9479e52ba
This commit is contained in:
Romain Guy
2009-08-31 14:06:43 -07:00
parent de5cd3d864
commit 650a3eb7d6
4 changed files with 76 additions and 18 deletions

View File

@@ -337,19 +337,26 @@ public class BitmapFactory {
*/
public static Bitmap decodeResource(Resources res, int id, Options opts) {
Bitmap bm = null;
InputStream is = null;
try {
final TypedValue value = new TypedValue();
final InputStream is = res.openRawResource(id, value);
is = res.openRawResource(id, value);
bm = decodeResourceStream(res, value, is, null, opts);
is.close();
} catch (java.io.IOException e) {
} catch (Exception e) {
/* do nothing.
If the exception happened on open, bm will be null.
If it happened on close, bm is still valid.
*/
} finally {
try {
if (is != null) is.close();
} catch (IOException e) {
// Ignore
}
}
return bm;
}