[]截屏无法实现
View gameView = mPlugin.game_plugin_get_view();
this.setContentView(gameView);
这个gameView应该就是游戏显示视图,但获取出来是空的,屏幕保存成文件全是黑的
现在不知道用什么方法进行截屏了
this.setContentView(gameView);
这个gameView应该就是游戏显示视图,但获取出来是空的,屏幕保存成文件全是黑的
现在不知道用什么方法进行截屏了
没有找到相关结果
已邀请:
要回复问题请先登录
2 个回复
cuixueying
赞同来自:
gmajrtfp
赞同来自:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
mProxy = new RuntimeProxy(this);
mPlugin = new GameEngine(this);
mPlugin.game_plugin_set_runtime_proxy(mProxy);
mPlugin.game_plugin_set_option("localize", "true");
mPlugin.game_plugin_set_option("gameUrl",
"http://stand.alone.version/index.html");
mPlugin.game_plugin_init();
View gameView = mPlugin.game_plugin_get_view();
this.setContentView(gameView);
isLoad = true;
gv = gameView;
}
public static void screenshot() {
// 获取屏幕
View dView = gv;
dView.setDrawingCacheEnabled(true);
dView.buildDrawingCache();
Bitmap bmp = dView.getDrawingCache();
if (bmp != null) {
try {
// 获取内置SD卡路径
String sdCardPath = Environment.getExternalStorageDirectory()
.getPath();
// 图片文件路径
String filePath = sdCardPath + File.separator
+ "__screenshot.png";
File file = new File(filePath);
FileOutputStream os = new FileOutputStream(file);
bmp.compress(Bitmap.CompressFormat.PNG, 100, os);
os.flush();
os.close();
} catch (Exception e) {
}
} else {
}
}
这是android端的截屏代码,生成的图片是黑的
增加一个static View gv的变量指向gameView