Native. js Screenshot Instance Code

  • 2021-10-15 11:37:37
  • OfStack

Universal screenshots of Android and iOS can be realized without using Native. js

Directly on the code:


<!DOCTYPE html>
<html>
	<head>
	<meta charset="utf-8">
	<title>Webview Example</title>
	<script type="text/javascript">
var ws=null;
// H5 plus Event handling 
function plusReady(){
	ws=plus.webview.currentWebview();
}
if(window.plus){
	plusReady();
}else{
	document.addEventListener('plusready', plusReady, false);
}
//  Screen capture drawing 
var bitmap=null;
function captureWebview() {
	bitmap = new plus.nativeObj.Bitmap('test');
	//  Will webview Content is drawn to Bitmap Object 
	ws.draw(bitmap,function(){
		console.log(' Screen capture and drawing of picture successfully ');
	},function(e){
		console.log(' Screen capture failed to draw picture: '+JSON.stringify(e));
	});
}
	</script>
	</head>
	<body>
		 Screen capture drawing Webview Window <br/>
		<button onclick="captureWebview()">Draw</button>
	</body>
</html>
	

Description:

draw

How to use screen capture drawing


 void wobj.draw( bitmap, successCallback, errorCallback, options );

Screen capture of the visual area of the Webview window and draw it into the Bitmap picture object.

Parameters:

bitmap: ( plus.nativeObj.Bitmap ) You can choose a picture object to draw

Overwrite if there is already content in the picture, and keep the previous picture content if the screenshot fails to draw.

successCallback: ( SuccessCallback ) Optional screenshot drawing operation successful callback

Called when the screenshot drawing operation is successful.

errorCallback: ( ErrorCallback ) Optional screenshot drawing operation failure callback

Called when the screenshot drawing operation fails, and returns the failure information.

options: ( WebviewDrawOptions ) Optional screen capture drawing operation parameters

Set and control screen capture drawing area, whether to detect white screen, etc.

Return value:

void: None

Attached is a detailed introduction and explanation of API supported by Native. js of Dcloud

www.dcloud.io/docs/api/index.html

To see more about native. js instance code, you can see the related links on page 1


Related articles: