包含 Flash 元素的网页的屏幕截图
我想截取 WebView 中显示的页面的屏幕截图。该页面包含 flash 元素 - 这就是问题所在。当我截取屏幕截图时,页面的所有 Flash 部分都是空白的。
我正在使用这段代码来截取屏幕截图:
WebView webView = (WebView) findViewById(R.id.webview);
Picture picture = webView.capturePicture();
Bitmap screenshot = Bitmap.createBitmap(picture.getWidth(),
picture.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(screenshot);
picture.draw(c);
File file = new File("/sdcard/screenshot.jpg");
FileOutputStream ostream = null;
try {
file.createNewFile();
ostream = new FileOutputStream(file);
screenshot.compress(CompressFormat.JPEG, 90, ostream);
Log.d("Test", "Screenshot taken");
} catch (Exception e) {
Log.e("Test", "Error", e);
} finally {
try {
ostream.close();
} catch (IOException ignore) {
}
}
我还尝试使用 这个问题:
View webView = findViewById(R.id.webview);
Bitmap bitmap = webView.getDrawingCache();
这也不起作用 - 结果是相同的(即空白的 Flash 元素)。
所以问题是:如何使用 flash 元素对 WebView 内容进行屏幕截图?
I would like to take a screenshot of a page displayed in a WebView. The page contains flash elements - and here is the problem. When I take a screenshot all the flash parts of the page are blank.
I am using this piece of code to take a screenshot:
WebView webView = (WebView) findViewById(R.id.webview);
Picture picture = webView.capturePicture();
Bitmap screenshot = Bitmap.createBitmap(picture.getWidth(),
picture.getHeight(), Bitmap.Config.ARGB_8888);
Canvas c = new Canvas(screenshot);
picture.draw(c);
File file = new File("/sdcard/screenshot.jpg");
FileOutputStream ostream = null;
try {
file.createNewFile();
ostream = new FileOutputStream(file);
screenshot.compress(CompressFormat.JPEG, 90, ostream);
Log.d("Test", "Screenshot taken");
} catch (Exception e) {
Log.e("Test", "Error", e);
} finally {
try {
ostream.close();
} catch (IOException ignore) {
}
}
I was also trying to acquire Bitmap
of the screen contents using the solution given in this SO question:
View webView = findViewById(R.id.webview);
Bitmap bitmap = webView.getDrawingCache();
This also doesn't work - the result is the same (i.e. blank flash elements).
So the question is: How to take a screenshot of WebView contents also with flash elements?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论