diff options
Diffstat (limited to 'src/com/android/gallery3d/glrenderer/ResourceTexture.java')
-rw-r--r-- | src/com/android/gallery3d/glrenderer/ResourceTexture.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/glrenderer/ResourceTexture.java b/src/com/android/gallery3d/glrenderer/ResourceTexture.java index eb8e8a517..d60a16c5a 100644 --- a/src/com/android/gallery3d/glrenderer/ResourceTexture.java +++ b/src/com/android/gallery3d/glrenderer/ResourceTexture.java @@ -19,6 +19,7 @@ package com.android.gallery3d.glrenderer; import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; +import android.util.Log; import junit.framework.Assert; @@ -26,6 +27,7 @@ import junit.framework.Assert; // By default ResourceTexture is not opaque. public class ResourceTexture extends UploadedTexture { + private static final String TAG = "ResourceTexture"; protected final Context mContext; protected final int mResId; @@ -40,8 +42,15 @@ public class ResourceTexture extends UploadedTexture { protected Bitmap onGetBitmap() { BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; - return BitmapFactory.decodeResource( - mContext.getResources(), mResId, options); + Bitmap bitmap = null; + try { + bitmap = BitmapFactory.decodeResource(mContext.getResources(), mResId, options, false); + } catch (OutOfMemoryError ex) { + Log.e(TAG, "BitmapFactory decode resource out of memory"); + ex.printStackTrace(); + return null; + } + return bitmap; } @Override |