UNPKG

nativescript-ar

Version:

NativeScript Augmented Reality plugin. ARKit on iOS and (with the help of Sceneform) ARCore on Android.

29 lines (28 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var image_source_1 = require("tns-core-modules/image-source"); var FragmentScreenGrab = (function () { function FragmentScreenGrab() { } FragmentScreenGrab.prototype.grabScreenshot = function (fragment) { return new Promise(function (resolve, reject) { var view = fragment.getArSceneView(); var bitmap = android.graphics.Bitmap.createBitmap(view.getWidth(), view.getHeight(), android.graphics.Bitmap.Config.ARGB_8888); var handlerThread = new android.os.HandlerThread("PixelCopier"); handlerThread.start(); android.view.PixelCopy.request(view, bitmap, new android.view.PixelCopy.OnPixelCopyFinishedListener({ onPixelCopyFinished: function (copyResult) { if (copyResult === android.view.PixelCopy.SUCCESS) { resolve(image_source_1.fromNativeSource(bitmap)); } else { reject("Field to copy screen image"); } handlerThread.quitSafely(); } }), new android.os.Handler(handlerThread.getLooper())); }); }; return FragmentScreenGrab; }()); exports.FragmentScreenGrab = FragmentScreenGrab;