如何保存屏幕截图(matlab) [英] how to save a screenshot (matlab)
本文介绍了如何保存屏幕截图(matlab)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用Matlab将屏幕快照保存在特定目录中.我可以生成屏幕截图,但是找不到将其保存在特定目录中的解决方案.我已经尝试过保存和另存为,但收到错误消息...有什么想法吗?非常感谢您的帮助.
I am trying to save a screenshot in a specific directory using Matlab. I am able to generate the screenshot but I find no solution to save it in a specific directory. I have tried save and saveas but get error messages...Any ideas? Really appreciate any help.
robo = java.awt.Robot;
t = java.awt.Toolkit.getDefaultToolkit();
rectangle = java.awt.Rectangle(t.getScreenSize());
image = robo.createScreenCapture(rectangle);
filehandle = java.io.File(sprintf('%s_screencapture.jpg',current_stock));
javax.imageio.ImageIO.write(image,'jpg',filehandle);
dest_dir = 'D:\screenshot\';
推荐答案
这对您有用吗?
filepath = fullfile(dest_dir, sprintf('%s_screencapture.jpg',current_stock));
filehandle = java.io.File(filepath);
javax.imageio.ImageIO.write(image,'jpg',filehandle);
PS-最好不要使用image
或rectangle
作为变量名,因为它们是内置MATLAB命令的名称.
PS - best not to use image
or rectangle
as variable names, as they are the names of built-in MATLAB commands.
这篇关于如何保存屏幕截图(matlab)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文