资源简介

用MATLAB代码实现截屏功能,直接运行即可,如需存储可自行存储

资源截图

代码片段和文件信息

%%%%%-Matlab截取屏幕-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
robot = java.awt.Robot(); %创建java.awt.Robot对象robot,自动测试
rectangle = java.awt.Rectangle(); %创建java.awt.Rectangle对象rectangle,矩形
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
rectangle.x = 1; % 截图左上角横坐标(屏幕最左上角为原点)
rectangle.y = 1; % 截图左上角纵坐标(屏幕最左上角为原点)
rectangle.width = 1000; % 截图宽度(屏幕最左上角为原点)
rectangle.height = 600; % 截图高度(屏幕最左上角为原点)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
image = robot.createScreenCapture(rectangle); %创建包含从屏幕中读取的像素的图像
w = image.getWidth(); %获取图像宽度
h = image.getHeight(); %获取图像高度
raster = 

评论

共有 条评论