gpt4 book ai didi

android - 位图大小超出 VM 预算

转载 作者:行者123 更新时间:2023-11-30 04:41:55 25 4
gpt4 key购买 nike

我正在将我的图像传递到 xml,通过使用以下方法调整我的图像大小:

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

最佳答案

这不是这个问题的重复: 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

关于android - 位图大小超出 VM 预算,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5840753/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com