Automobile.Mobile.Android.Automation.AndroidDevice.TakeScreenshot C# (CSharp) Method

TakeScreenshot() public method

Take a screenshot of the device
public TakeScreenshot ( ) : byte[]
return byte[]
        public override byte[] TakeScreenshot()
        {
            // Force a regen of the drawing cache
            WebView.DestroyDrawingCache();
            WebView.BuildDrawingCache();
            // Copy the cache to a new bitmap
            var bmp = WebView.DrawingCache.Copy(WebView.DrawingCache.GetConfig(), true);

            // Compress the bitmap into a png stream
            var stream = new MemoryStream();
            bmp.Compress(Bitmap.CompressFormat.Png, 100, stream); // Quality is ignored on a png

            // Return bytes out of the stream
            return stream.GetBuffer();
        }