gpt4 book ai didi

安卓消息 "Cannot generate texture from bitmap"

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:01:10 25 4
gpt4 key购买 nike

我正在使用 Gallery-widget 和大量位图。我使用 Bitmap.recycle() 删除位图。结果我在 logcat 上看到了下一条消息:

08-18 17:49:26.020: INFO/dalvikvm-heap(13847): Grow heap (frag case) to 22.373MB for 2457616-byte allocation
08-18 17:49:26.060: DEBUG/dalvikvm(13847): GC_FOR_ALLOC freed 1K, 36% free 22835K/35143K, paused 27ms
08-18 17:49:26.230: DEBUG/dalvikvm(13847): GC_CONCURRENT freed <1K, 36% free 22835K/35143K, paused 2ms+3ms
08-18 17:49:28.070: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.080: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.110: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.120: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.140: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.160: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.180: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.190: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.210: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.230: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.240: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.260: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.280: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.290: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.310: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.330: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.350: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.360: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.380: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.400: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.410: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.430: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.450: ERROR/OpenGLRenderer(13847): Cannot generate texture from bitmap
08-18 17:49:28.500: INFO/System.out(13847): Image width: 144; height: 108
08-18 17:49:28.570: DEBUG/dalvikvm(13847): GC_FOR_ALLOC freed 4094K, 42% free 20449K/35143K, paused 27ms
08-18 17:49:28.620: INFO/dalvikvm-heap(13847): Grow heap (frag case) to 22.385MB for 2457616-byte allocation

Gallery-widget 上的项目是黑色的。但应用程序有效。

你对这个问题有什么想法吗?

最佳答案

我刚刚遇到了同样的问题。问题是通过调用 recycle() 你销毁了引用图像像素数据的本地对象,并且对象本身(位图)被标记为“死”。如果没有其他对象引用这些数据,它们将被 GC 释放。所以有两种可能发生在你身上的事情:

  1. 位图只是由 GC 收集,因此渲染器没有数据可供使用。
  2. 由于位图本身被标记为无效,因此您无法从中读取/写入像素

因此,如果您正在使用/引用此位图并回收它,您只是拒绝所有人访问它。至少我是这样理解的。仔细阅读:

http://developer.android.com/reference/android/graphics/Bitmap.html#recycle%28%29

因此只有当您确定没有人在使用/引用位图对象时才应该使用回收。希望对您有所帮助。

关于安卓消息 "Cannot generate texture from bitmap",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7109555/

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