简体   繁体   English

RenderScript模糊破坏了Glide加载的位图

[英]RenderScript blur breaks bitmap loaded by Glide

So, the thing is that I am fetching some images using Glide. 所以,问题是我正在使用Glide获取一些图像。 I fetch them directly into bitmap, and then I blur that bitmap using RenderScript and than show on UI blurred one. 我直接将它们提取到位图中,然后使用RenderScript模糊该位图,然后在UI上显示模糊的位图。

UI itself has "All Images" activity and "Single Image" activity. UI本身具有“所有图像”活动和“单个图像”活动。 User clicks on the image on the first activity, and the blurred version is showed on the second one, so it is possible to go back and forth opening and closing the same image. 用户单击第一个活动上的图像,然后在第二个活动上显示模糊的版本,因此可以前后打开和关闭同一图像。

The issue is that this cause image to become broken, and there is no way to fix it unless you clear all app data. 问题在于,这会导致图像损坏,除非清除所有应用程序数据,否则无法修复它。

The issue even survives app reinstall (using Android Studio). 该问题甚至在重新安装应用程序(使用Android Studio)后仍然存在。 So, if I open image, and it is displayed as it should, than make some changes in code, and install the app again, image would show broken immediately after installation, unless I clear data. 因此,如果我打开图像并按原样显示它,而不是对代码进行一些更改,然后再次安装该应用程序,则除非我清除数据,否则图像在安装后会立即显示为损坏。

It happens only with bitmaps loaded using glide. 它仅在使用glide加载的位图时发生。 If I get some drawable resource as bitmap, everything works well. 如果我得到一些可绘制的资源作为位图,则一切正常。

UPDATE: This is the code used here; 更新:这是这里使用的代码;

Bitmap logo = Glide.with(context)
                        .load(url)
                        .asBitmap()
                        .into(80, 80)
                        .get();
return BlurBuilder.blur(context, logo);

And BlurBuilder is the class copied from here: Create blurry transparent background effect 并且BlurBuilder是从此处复制的类: 创建模糊的透明背景效果

图像破裂

Had the same problem. 有同样的问题。 Solved it by setting the Glide decode format to ARGB_8888 https://github.com/bumptech/glide/wiki/Configuration#bitmap-format 通过将Glide解码格式设置为ARGB_8888来解决此问题https://github.com/bumptech/glide/wiki/Configuration#bitmap-format

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM