2011-04-30 78 views
1

我通过我的图像转换成XML,通过调整图片的大小尺寸:位图大小超过VM预算

scaled = Bitmap.createScaledBitmap(bp, h, w, true); 
    imgV.setImageBitmap(scaled); 

,但我得到的位图的大小超过VM预算。

04-30 18:36:16.552: ERROR/AndroidRuntime(7164): FATAL EXCEPTION: main 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): java.lang.OutOfMemoryError: bitmap size exceeds VM budget 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:525) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at com.webrich.bachflower.TopicController.getImageBitmap(TopicController.java:103) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at com.webrich.bachflower.TopicController.onCreate(TopicController.java:73) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at android.app.ActivityThread.access$1500(ActivityThread.java:117) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at android.os.Handler.dispatchMessage(Handler.java:99) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at android.os.Looper.loop(Looper.java:123) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at android.app.ActivityThread.main(ActivityThread.java:3683) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at java.lang.reflect.Method.invokeNative(Native Method) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at java.lang.reflect.Method.invoke(Method.java:507) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 04-30 18:36:16.552: ERROR/AndroidRuntime(7164): at dalvik.system.NativeStart.main(Native Method) 04-30 18:36:16.602: WARN/ActivityManager(63): Force finishing activity com.webrich.bachflower/.TopicController 04-30 18:36:17.132: WARN/ActivityManager(63): Activity pause timeout for HistoryRecord{407ff648 com.webrich.bachflower/.TopicController} 04-30 18:36:19.762: DEBUG/SntpClient(63): request time failed: java.net.SocketException: Address family not supported by protocol 04-30 18:36:20.212: INFO/Process(7164): Sending signal. PID: 7164 SIG: 9 04-30 18:36:20.302: INFO/ActivityManager(63): Process com.webrich.bachflower (pid 7164) has died. 04-30 18:36:20.302: INFO/WindowManager(63): WIN DEATH: Window{407e6b88 com.webrich.bachflower/com.webrich.bachflower.FlowerController paused=false} 04-30 18:36:20.362: ERROR/InputDispatcher(63): channel '407fcdb8 com.webrich.bachflower/com.webrich.bachflower.Topics (server)' ~ Consumer closed input channel or an error occurred. events=0x8 04-30 18:36:20.362: ERROR/InputDispatcher(63): channel '407fcdb8 com.webrich.bachflower/com.webrich.bachflower.Topics (server)' ~ Channel is unrecoverably broken and will be disposed! 04-30 18:36:20.412: INFO/WindowManager(63): WIN DEATH: Window{407fcdb8 com.webrich.bachflower/com.webrich.bachflower.Topics paused=false} 04-30 18:36:20.882: WARN/InputManagerService(63): Got RemoteException sending setActive(false) notification to pid 7164 uid 10034

回答

1

这是不是这个问题的一个副本: Strange out of memory issue while loading an image to a Bitmap object

尤其是你正在寻找的答案是(#COMMENT链接): Strange out of memory issue while loading an image to a Bitmap object

+0

不...你能引导解决此问题的方法 – bamini 2011-05-03 05:19:53

+0

请执行#comment“private Bitmap decodeFile(){...}”的说法。我使用过这些代码,处理的文件远远超过了内存中的内容。 – dpjanes 2011-05-03 22:44:05

相关问题