开发者

Problem dealing with large bitmaps

The error is the following:

08-24 15:03:59.998: ERROR/AlarmManager(2130): set: Alarm{47792078 type 1 android} package:android
08-24 15:04:00.455: ERROR/dalvikvm-heap(13274): 12582912-byte external allocation too large for this process.
08-24 15:04:00.455: ERROR/GraphicsJNI(13274): VM won't let us allocate 12582912 bytes
08-24 15:04:06.678: WARN/ActivityManager(2130): Launch timeout has expired, giving up wake lock!
08-24 15:04:06.697: WARN/ActivityManager(2130): Activity idle timeout for  HistoryRecord{47854538 com.ibssistemas.ibs/.gallery}
08-24 15:04:57.322: WARN/dalvikvm(13274): threadid=1: thread exiting with uncaught exception (group=0x3d5737d0)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274): FATAL EXCEPTION: main
08-24 15:04:57.365: ERROR/AndroidRuntime(13274): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at  android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:459)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:271)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at com.ibssistemas.ibs.gallery.openImage(gallery.java:69)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at com.ibssistemas.ibs.gallery$ImageAdapter.getView(gallery.java:91)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.widget.AbsSpinner.onMeasure(AbsSpinner.java:192)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.view.View.measure(View.java:8171)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at  android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:696)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:306)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.view.View.measure(View.java:8171)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at  android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:381)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.view.View.measure(View.java:8171)
开发者_运维技巧08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at  android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.view.View.measure(View.java:8171)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:526)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at  android.widget.LinearLayout.onMeasure(LinearLayout.java:304)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.view.View.measure(View.java:8171)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.view.View.measure(View.java:8171)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.view.ViewRoot.performTraversals(ViewRoot.java:801)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.os.Looper.loop(Looper.java:123)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at android.app.ActivityThread.main(ActivityThread.java:4627)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at java.lang.reflect.Method.invokeNative(Native Method)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at java.lang.reflect.Method.invoke(Method.java:521)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-24 15:04:57.365: ERROR/AndroidRuntime(13274):     at dalvik.system.NativeStart.main(Native Method)

Caused by 'too big image you dumb'.... lol..

Is there anyway to avoid this when the image is too big? :(


You must pass options to the decode function to reduce the size of the bitmap as it reads by adding a BitmapFactory.Options argument in your code. This is because the VM has limited memory space for your process.

The prototype for the relevant BitmapFactory.decodeFile function is documented as:

BitmapFactory.decodeFile(String pathName, BitmapFactory.Options opts)

You will need to read the BitmapFactory.Options section of the documentation to set the values appropriate to your situation.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜