Quantcast
Channel: Adobe Community : Unanswered Discussions - AIR Development
Viewing all articles
Browse latest Browse all 2010

Taking a screenshot of StageWebView for websites running a plugin?

$
0
0

I've been trying to take a screenshot of an instance of StageWebView for websites with embedded SWF and PDF content on the Android. The method drawViewPortToBitmapData works fine for regular websites after enabling hardware acceleration in the manifest.

 

//create a bitmap from the webview and display it

var bitmap_data:BitmapData = new BitmapData(stage.stageWidth - 2*WEBVIEWOFFSET, stage.stageHeight - 40 - WEBVIEWOFFSET);

webView.drawViewPortToBitmapData(bitmap_data); 

//remove webview and display snapshot

webView.stage = null;

var webViewBitmap:Bitmap = new Bitmap(bitmap_data);

addChild(webViewBitmap);

 

The previous code works for embedded content only on the emulator in the Flash IDE. The image is generated  in the folder I specified in Windows but on the Android a blank image is created instead.

 

The API states "The behavior of this method is not guaranteed for pages that contain plugin content (such as embedded PDF and SWF files)."

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fla sh/media/StageWebView.html#drawViewPortToBitmapData%28%29

 

I tried using Context3D instead:

 

var stage3D:Stage3D = webView.stage.stage3Ds[0];

stage3D.addEventListener(Event.CONTEXT3D_CREATE, context3dCreated);

stage3D.requestContext3D(Context3DRenderMode.AUTO);

 

function context3dCreated(evt:Event ):void {

    //context 3d creation handler

   

    var bitmap_data:BitmapData = new BitmapData(stage.stageWidth - 2*WEBVIEWOFFSET, stage.stageHeight - 40 - WEBVIEWOFFSET);

    var renderContext:Context3D = Stage3D(evt.target).context3D;

    trace("3D driver: " + renderContext.driverInfo);

    renderContext.drawToBitmapData(bitmap_data);

    renderContext.present();

   

    //remove webview and display snapshot

    webView.stage = null;

    var webViewBitmap:Bitmap = new Bitmap(bitmap_data);

    addChild(webViewBitmap);      

}

but this approach only generates blank images on both the emulator and the device.

 

Does anybody know of a way to take a screenshot from a StageWebView displaying embedded SWF or PDF content? or is there a free native extension that can trigger the screenshot in Android (power + home)?


Viewing all articles
Browse latest Browse all 2010

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>