安卓:创建具有SurfaceView内容的位图 [英] Android: creating a Bitmap with SurfaceView content
问题描述
我怕已经有不幸的回答这个问题,但为了以防万一......我使用SurfaceView做一些与位图(灯光和颜色修改),图像处理和我需要导入修改位图(即SurfaceView的内容)的新位图,这样我可以将其保存为图像文件。
I'm afraid to already have the unfortunate answer to this question but just in case... I'm using a SurfaceView to do some image processing with bitmaps (lights and colors modifications) and I would need to import the modified bitmap (i.e. the content of the SurfaceView) in a new bitmap so that I can save it as an image file.
我一直在环顾四周,似乎有可能得到View.getDrawingCache()位图,但它不与SurfaceView工作。我得到的是一个空的位图。
I've been looking around and it seems that it's possible to get a bitmap from View.getDrawingCache() but it doesn't work with SurfaceView. All I get is an empty bitmap.
有没有什么解决办法?
感谢
推荐答案
你能绘制SurfaceView到多数民众赞成背靠一个位图一个帆布?
Can you draw your SurfaceView onto a Canvas that's backed by a Bitmap?
// be sure to call the createBitmap that returns a mutable Bitmap
Bitmap b = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(b);
yourSurfaceView.draw(c);
这篇关于安卓:创建具有SurfaceView内容的位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!