gpt4 book ai didi

android - Drawable 在转换为位图后失去滤色器

转载 作者:太空狗 更新时间:2023-10-29 14:53:35 26 4
gpt4 key购买 nike

我正在尝试在可绘制对象中添加颜色过滤器,然后将其转换为位图。问题是当将 drawable 转换为位图时,它会失去它的滤色器。我在 imageview 中使用了 drawable 并且它具有滤色器但是在 imageview 中使用位图没有任何颜色效果。为什么会这样?提前致谢。

最佳答案

使用 Canvas 将 Drawable 位 block 传输回位图:

    Canvas canvas;
Drawable drawable = <yourDrawable created from wherever>;
Bitmap bmp = <your Bitmap which is the same width/height as the drawable>

// blit the drawable onto the bitmap using a Canvas
canvas = new Canvas(bmp);
drawable.draw(canvas);

http://developer.android.com/guide/topics/graphics/2d-graphics.html

关于android - Drawable 在转换为位图后失去滤色器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33287510/

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