截屏
自2017-9-20日起,更新demo后将支持预览截屏功能 需要通过ScreenShotListener获得requestScreenShot返回的Bitmap图像,可以使用如下方法将bitmap保存到sdcard:
mStreamer.requestScreenShot(new IStreamer.ScreenShotListener() {
@Override
public void onBitmapAvailable(Bitmap bitmap) {
BufferedOutputStream bos = null;
try {
Date date = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd_HH_mm_ss");
final String fileName = "/sdcard/screenshot" + dateFormat.format(date) + ".jpg";
bos = new BufferedOutputStream(new FileOutputStream(fileName));
if (bitmap != null) {
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bos);
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(StreamActivity.this, "保存截图到" + fileName, Toast.LENGTH_SHORT).show();
}
});
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
if (bos != null)
try {
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
});