在Android上组合位图

发布于 2024-12-11 23:22:08 字数 2217 浏览 0 评论 0原文

我想将两个位图组合在一起。但是,它无法合并 2 张超过 1600X1200 的图像。有人可以帮我解决这个问题吗?有人告诉我,它可以扩大应用程序的已用内存。 这是错误日志

> 10-26 12:07:16.492: ERROR/AndroidRuntime(3221): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.graphics.Bitmap.nativeCreate(Native Method)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.graphics.Bitmap.createBitmap(Bitmap.java:423)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.graphics.Bitmap.createBitmap(Bitmap.java:374)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at com.org.testing.TestingActivity.crop(TestingActivity.java:102)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at com.org.testing.TestingActivity.access$0(TestingActivity.java:97)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at com.org.testing.TestingActivity$2.onClick(TestingActivity.java:54)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.view.View.performClick(View.java:2428)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.view.View$PerformClick.run(View.java:8939)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.os.Handler.handleCallback(Handler.java:587)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.os.Looper.loop(Looper.java:123)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.app.ActivityThread.main(ActivityThread.java:4668)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at java.lang.reflect.Method.invokeNative(Native Method)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at java.lang.reflect.Method.invoke(Method.java:521)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at dalvik.system.NativeStart.main(Native Method)

I want to combine two bitmap together. However, it can not combine 2 image that exceed 1600X1200.Can anyone help me to solve this problem? Someone tells me that it can enlarge the used memory of the apps.
Here's the error log

> 10-26 12:07:16.492: ERROR/AndroidRuntime(3221): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.graphics.Bitmap.nativeCreate(Native Method)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.graphics.Bitmap.createBitmap(Bitmap.java:423)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.graphics.Bitmap.createBitmap(Bitmap.java:374)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at com.org.testing.TestingActivity.crop(TestingActivity.java:102)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at com.org.testing.TestingActivity.access$0(TestingActivity.java:97)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at com.org.testing.TestingActivity$2.onClick(TestingActivity.java:54)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.view.View.performClick(View.java:2428)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.view.View$PerformClick.run(View.java:8939)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.os.Handler.handleCallback(Handler.java:587)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.os.Looper.loop(Looper.java:123)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at android.app.ActivityThread.main(ActivityThread.java:4668)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at java.lang.reflect.Method.invokeNative(Native Method)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at java.lang.reflect.Method.invoke(Method.java:521)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
10-26 12:07:16.492: ERROR/AndroidRuntime(3221):     at dalvik.system.NativeStart.main(Native Method)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自在安然 2024-12-18 23:22:08

您有三个选择:

  1. 缩小图像。有 16 MB 堆限制
  2. 使用 ndk 执行此操作,此限制不适用
  3. 在服务器端执行此操作。

You have three options :

  1. Scale down the image. There is a 16 MB heap restriction
  2. Use the ndk to do this, where this restriction does not apply
  3. Do it server side.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文