{"version":"0.1.0","code":"0000","result":true,"message":"处理成功","errdetail":"","timestamp":1671508806234,"data":{"id":71712801,"title":"2.4.7 后台截图","slug":"gxezyl","format":"lake","bookId":26046811,"body":null,"body_draft":null,"body_html":"

场景图

\"image.png\"

说明:

截屏功能常用于地图App退到后台,也能对渲染进行截图,截图信息用于在窗口小部件上展示地图画面。

时序图

地图服务初始化

地图设备创建

地图视图创建


关键参数

MapDevice.setScreenshotMode

com.autonavi.gbl.map.model.ScreenShotMode

取值

含义

ScreenShotModeNull

不截图

ScreenShotModeBackGround

后台截图

ScreenShotModeFront

前台截图

com.autonavi.gbl.map.model.ScreenShotCallbackMethod

取值

含义

ScreenShotCallbackMethodBuffer

buffer回调

ScreenShotCallbackMethodBitmap

暂不支持

ScreenShotCallbackMethodFile

暂不支持


MapDevice.setScreenshotRect

取值

含义

0 ~ 设备宽度

截图起点,gl坐标x,左下是(0,0)

取值

含义

0 ~ 设备高度

截图起点,gl坐标y,左下是(0,0)

取值

含义

设备宽度减去px1,需要小于宽度

截屏宽

取值

含义

设备高度减去py1,需要小于高度

截屏高


MapDevice.attachSurfaceToDevice

com.autonavi.gbl.map.model.EGLSurfaceAttr.nativeWindow

取值

含义

-1

后台截图模式下,nativeWindow必须传-1

com.autonavi.gbl.map.model.EGLSurfaceAttr.width

com.autonavi.gbl.map.model.EGLSurfaceAttr.heigh

核心接口

// 设置截屏模式\nvoid com.autonavi.gbl.map.MapDevice.setScreenshotMode(\t\n    @ScreenShotMode.ScreenShotMode1 int screenshotMode,\n\tIEGLScreenshotObserver Observer \n)\t\n    \n// 设置截屏区域\nvoid com.autonavi.gbl.map.MapDevice.setScreenshotRect(\t\n    int px1,\n\tint py1,\n\tint w,\n\tint h \n)\t\t\n\n// 设置截屏回调方式\nvoid com.autonavi.gbl.map.MapDevice.setScreenshotCallBackMethod\t(\n    @ScreenShotCallbackMethod.ScreenShotCallbackMethod1 int method\n)\t\n\n// 绑定nativewindow为-1的surface\nvoid com.autonavi.gbl.map.MapDevice.attachSurfaceToDevice(\t\n    EGLSurfaceAttr surfaceAttr\n)

   说明:函数详情,请复制函数名称到在线API搜索

调用示例

EGLSurfaceAttr eglSurfaceAttr = new EGLSurfaceAttr();\neglSurfaceAttr.nativeWindow = -1;\neglSurfaceAttr.isOnlyCreatePBSurface = true;\n// 创建一个1024 * 1024的地图设备\neglSurfaceAttr.height = 1024;\neglSurfaceAttr.width = 1024;\nmapDevice.attachSurfaceToDevice(eglSurfaceAttr);\n\n// attachSurfaceToDevice之后调用需要在\n// 截图左下角,500,500范围内的图片\nmapDevice.setScreenshotRect(0, 0, 500, 500);\nmapDevice.setScreenshotMode(ScreenShotModeBackGround, this);\nmapDevice.setScreenshotCallBackMethod(ScreenShotCallbackMethodBuffer);

HMI通过回调获取到的截图数据,在创建的Widget窗口小部件上展示。

由于mapview地图实例仍在运行,每次刷新地图,就会一次截图回调,这样就具体带动画效果。

Widget窗口小部件的实现与销毁,请参考安卓开发的相关资料。

@Override\npublic void onEGLScreenshot(int deviceId, byte[] pBitmapBuffer, ScreenShotDataInfo bufferDataParams, @ScreenShotCallbackMethod.ScreenShotCallbackMethod1 int nMethod, long pParamEx){\n    // 回调处理,需要转其他线程,刷新到widget上\n}


","body_lake":null,"pub_level":null,"status":"0","updated_at":"2022-04-06 07:01:26","deleted_at":null,"nameSpace":"mnlcaa/v610","browseCount":98,"collectCount":0,"estimateDate":5,"docStatus":0,"permissions":true,"overView":false}}