首页 > 解决方案 > 使用 Glide 下载位图时会失去透明度

问题描述

我正在尝试使用 Glide 库(版本 4)在 android 应用程序中下载位图图像,但是当我这样做时,图像的透明度会丢失,并被白色背景取代。
我尝试使用以下命令:

Glide.with(this).load(url).into(imageView);


Glide.with(this).asBitmap().load(url).into(imageView);

Glide.with(this).load(url).apply( new RequestOptions().format(DecodeFormat.PREFER_ARGB_8888).encodeFormat(Bitmap.CompressFormat.PNG)).into(imageView);

但是似乎没有任何效果。

图片网址为:https ://s151.convertio.me/p/HwxwbAP4nbAyKsEmdn7ORw/1dc5e4a91d3de94ef6c5fcd51b0fb79d/yellow_circle_1.bmp

以下是该应用程序的一些屏幕截图:
这就是它的外观。 这就是它应该的样子。(貌似我用png图片的时候,红色背景是ImageView的背景,图片背景是透明的。)

这是位图 这是位图的样子的样子(透明背景变成白色。)

非常感谢。

标签: androidandroid-glidebitmapimage

解决方案


据我所知,没有 BMP 格式的 alpha 通道 https://en.wikipedia.org/wiki/BMP_file_format


推荐阅读