LayerDrawable位图 [英] LayerDrawable to bitmap
本文介绍了LayerDrawable位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是LayerDrawable合并多个可绘制。现在,想我对我的LayerDrawable导出到文件中。
I'm using a LayerDrawable to merge multiple Drawable. Now, I'd like to export my LayerDrawable to a file.
我试过这样:
Bitmap b = ((BitmapDrawable)myLayerDrawable).getBitmap();
--> ClassCastException...
我该怎么办?
推荐答案
你试过绘制绘制对象为位图印刷品吗?我想调用顺序会去是这样的:
Have you tried drawing the Drawable to a Bitmap Canvas? I think the call order would go something like:
Bitmap b = Bitmap.createBitmap(int width, int height, Bitmap.Config config);
myLayerDrawable.draw(new Canvas(b));
然后您可以将位图对象写入到输出流。
Then you can write the Bitmap object to an output stream.
这篇关于LayerDrawable位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文