位图大小超过虚拟机预算

我通过使用以下命令调整图像大小来将图像传递到xml:

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

但得到的位图大小超过Vm预算。

04-30 18:36:16.552:ERROR / AndroidRuntime(7164):致命例外:main 04-30 18:36:16.552:ERROR / AndroidRuntime(7164):java.lang.OutOfMemoryError:位图大小超过VM预算04-30 18:36:16.552:错误/ AndroidRuntime(7164):在android.graphics.BitmapFactory.nativeDecodeAsset(本地方法)04-30 18:36:16.552:错误/ AndroidRuntime(7164):在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):在android.app.ActivityThread.performLaun chActivity(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):在android.app.ActivityThread.access $ 1500(ActivityThread.java:117)04-30 18:36:16.552:错误/ AndroidRuntime(7164):在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 $ MethodAndAr gsCaller.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):强制整理活动com.webrich.bachflower / .TopicController 04-30 18:36:17.132:WARN / ActivityManager(63):HistoryRecord的活动暂停超时{407ff648 com.webrich.bachflower / .TopicController} 04-30 18:36:19.762:DEBUG / SntpClient(63):请求时间失败:java.net.SocketException:协议不支持的地址族04-30 18:36:20.212:INFO / Process(7164):发送信号。 PID:7164 SIG:9 04-30 18:36:20.302:INFO / ActivityManager(63):进程com.webrich.bachflower(pid 7164)已经死亡。 04-30 18:36:20.302:INFO / WindowManager(63):WIN DEATH:窗口{407e6b88 com.webrich.bachflower / com.webrich.bachflower.FlowerController paused = false} 04-30 18:36:20.362:ERROR / InputDispatcher(63):频道'407fcdb8 com.webrich.bachflower / com.webrich.bachflower.Topics(服务器)'〜消费者关闭的输入频道或发生错误。 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 dispos! 04-30 18:36:20.412:INFO / WindowManager(63):WIN DEATH:窗口{407fcdb8 com.webrich.bachflower / com.webrich.bachflower.Topics paused = false} 04-30 18:36:20.882:WARN / InputManagerService(63):得到RemoteException发送setActive(false)通知给pid 7164 uid 10034


这是不是这个问题的重复:在将图像加载到Bitmap对象时出现内存不足的问题

特别是,您正在寻找的答案是(#comment link):将图像加载到Bitmap对象时出现内存不足的问题

链接地址: http://www.djcxy.com/p/33651.html

上一篇: Bitmap size exceeds VM budget

下一篇: Factory updating the created objects, any design pattern fulfilling this?