android更快的方式捕获屏幕?

时间:2018-05-02 01:35:58

标签: android screen-capture

我需要在屏幕上捕获主要布局,如果速度更快,则需要整个屏幕。我尝试过两种方法,都会造成明显的延迟。

方法1:绘制缓存 - 大约需要80毫秒

setDrawingCacheEnabled (true);
Bitmap oldLayout = Bitmap.createBitmap (getDrawingCache ());
setDrawingCacheEnabled (false);

方法2:绘制到画布 - 大约需要50毫秒

Bitmap oldLayout = Bitmap.createBitmap (getWidth (), getHeight (), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas (oldLayout);
int wSpec = MeasureSpec.makeMeasureSpec (getWidth (), MeasureSpec.EXACTLY);
int hSpec = MeasureSpec.makeMeasureSpec (getHeight (), MeasureSpec.EXACTLY);
measure (wSpec, hSpec);
layout (0, 0, getWidth (), getHeight ());
draw (canvas);

似乎如果我可以直接从屏幕捕获那会更快。但是,我还没有看到这样做的方法。还有其他值得尝试的技术吗?

0 个答案:

没有答案