SurfaceControl替代截图

时间:2014-09-03 20:04:28

标签: android screenshot

我正在使用SurfaceControl的API来捕获屏幕截图:

public static Bitmap screenshot(int width, int height, int minLayer, int maxLayer) {
    // TODO: should take the display as a parameter
    IBinder displayToken = SurfaceControl.getBuiltInDisplay(
            SurfaceControl.BUILT_IN_DISPLAY_ID_MAIN);
    return nativeScreenshot(displayToken, width, height, minLayer, maxLayer, false);
}

然后按照说明(

中所述)进行此过程
 * CAVEAT: Versions of screenshot that return a {@link Bitmap} can
 * be extremely slow; avoid use unless absolutely necessary; prefer
 * the versions that use a {@link Surface} instead, such as
 * {@link SurfaceControl#screenshot(IBinder, Surface)}.

)让手机口吃了1/2秒。

目的是开发一个截取屏幕截图的服务,这样我就无法使用Surface建议的方法(我应该将哪些内容传递给服务)?

由于我在框架内工作,我也可以访问隐藏的API,任何建议?感谢

0 个答案:

没有答案