[英]javacv - fast screenshot - how to get image
I just found a good example of JavaCV which using FFmpegFrameGrabber to make screenshot code for linux which supposed to be "fast": 我刚刚找到了一个JavaCV的好例子,它使用FFmpegFrameGrabber为linux创建屏幕截图代码,该代码应该是“快速的”:
try {
int x = 0, y = 0, w = 1366, h = 768;
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(":0.0+" + x + "," + y);
grabber.setFormat("x11grab");
grabber.setImageWidth(w);
grabber.setImageHeight(h);
grabber.start();
CanvasFrame frame = new CanvasFrame("Screen Capture");
frame.showImage(grabber.grabImage());
frame.dispose();
grabber.stop();
} catch (FrameGrabber.Exception ex) {
ex.printStackTrace();
}
...anyways I'm still not sure how to get image of the screenshot to save in a file. ...无论如何,我仍然不确定如何获取屏幕快照的图像以保存在文件中。 I couldn't find any related example so I do need your advice... 我找不到任何相关示例,因此我确实需要您的建议...
So my question how to get image of screenshot to make possible IO? 所以我的问题是如何获取屏幕快照的图像以实现IO?
Looking at the API of JavaCV , there is an abstract FrameConverter<F>
class. 查看JavaCV的API ,有一个抽象的FrameConverter<F>
类。 The concrete implementation Java2DFrameConverter
looks like what you are looking for. 具体的实现Java2DFrameConverter
看起来像您想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.