用MATLAB实现屏幕截屏的代码
2014-12-04 16:11
302 查看
function screen_capture(movie_name,recording_time)
%Can be used to record any screen activity and output
%the recorded actions as video file (MOVIE.avi). It also saves the frames used to
%create the movie in a jpg format frames. The images are named as
%scrcapture -frame number- .jpg
%For example the first frame is named scrcapture1.jpg
%The recording time is almost identical to the actual cpu time.
%The quality of the video is excellent, but the size is big. One is advised
%to record short videos(order of minutes).For even better quality, one could replace the
% png format to jpg(simply uncomment the respective commands).
% to call the function, one types:
%
% screen_capture(movie_name,recording_time)
% where
% movie_name: is a string representing the name of the movie
% recording_time: is the length of the capturing (in seconds)
%To try, one might use the following example:
% screen_capture('movie',30)
%When the code is done writing the movie, a gong sound will be played
%to inform the user that the movie is finished.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%This function is written by :
% Nassim Khaled
% Wayne State University
% Phd Candidate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
movie_name1=strcat(movie_name,'.avi')
mov = avifile(movie_name1);
count=0;
robo = java.awt.Robot;
t = java.awt.Toolkit.getDefaultToolkit();
rectangle = java.awt.Rectangle(t.getScreenSize());
number_of_frames=round(recording_time/0.65);
display_time_of_frame=10;
for i=1:number_of_frames
name1=strcat('scrcapture',num2str(i),'.png');
% name1=strcat('scrcapture',num2str(i),'.jpg');
image = robo.createScreenCapture(rectangle);
filehandle = java.io.File(name1);
javax.imageio.ImageIO.write(image,'png',filehandle);
% javax.imageio.ImageIO.write(image,'jpg',filehandle);
end
for i=1:number_of_frames
name1=strcat('scrcapture',num2str(i),'.png');
% name1=strcat('scrcapture',num2str(i),'.jpg');
a=imread(name1);
while count<display_time_of_frame
count=count+1;
F = im2frame(a);
mov=addframe(mov,F);
end
count=0;
end
close all
mov=close(mov);
load gong;
% wavplay(y,Fs)
%Can be used to record any screen activity and output
%the recorded actions as video file (MOVIE.avi). It also saves the frames used to
%create the movie in a jpg format frames. The images are named as
%scrcapture -frame number- .jpg
%For example the first frame is named scrcapture1.jpg
%The recording time is almost identical to the actual cpu time.
%The quality of the video is excellent, but the size is big. One is advised
%to record short videos(order of minutes).For even better quality, one could replace the
% png format to jpg(simply uncomment the respective commands).
% to call the function, one types:
%
% screen_capture(movie_name,recording_time)
% where
% movie_name: is a string representing the name of the movie
% recording_time: is the length of the capturing (in seconds)
%To try, one might use the following example:
% screen_capture('movie',30)
%When the code is done writing the movie, a gong sound will be played
%to inform the user that the movie is finished.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%This function is written by :
% Nassim Khaled
% Wayne State University
% Phd Candidate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
movie_name1=strcat(movie_name,'.avi')
mov = avifile(movie_name1);
count=0;
robo = java.awt.Robot;
t = java.awt.Toolkit.getDefaultToolkit();
rectangle = java.awt.Rectangle(t.getScreenSize());
number_of_frames=round(recording_time/0.65);
display_time_of_frame=10;
for i=1:number_of_frames
name1=strcat('scrcapture',num2str(i),'.png');
% name1=strcat('scrcapture',num2str(i),'.jpg');
image = robo.createScreenCapture(rectangle);
filehandle = java.io.File(name1);
javax.imageio.ImageIO.write(image,'png',filehandle);
% javax.imageio.ImageIO.write(image,'jpg',filehandle);
end
for i=1:number_of_frames
name1=strcat('scrcapture',num2str(i),'.png');
% name1=strcat('scrcapture',num2str(i),'.jpg');
a=imread(name1);
while count<display_time_of_frame
count=count+1;
F = im2frame(a);
mov=addframe(mov,F);
end
count=0;
end
close all
mov=close(mov);
load gong;
% wavplay(y,Fs)
相关文章推荐
- java编程实现屏幕截图(截屏)代码总结
- 基于C#实现的屏幕指定区域截屏代码
- iPhone 应用里实现截屏功能的代码
- HMM matlab代码实现+分析
- 基于模型设计的FPGA开发与实现:滤波器设计与实现(三)Matlab中滤波器的HDL代码生成
- TabHost 默认布局,以及将TAB移到屏幕底部, 代码实现
- android截屏代码实现方法
- 用matlab转换图片为C代码,实现液晶屏显示
- 实现HMTL网页的全屏幕显示或模态显示 (JS代码)
- JQuery获取当前屏幕的高度宽度的实现代码
- TabHost 默认布局,以及将TAB移到屏幕底部, 代码实现
- ABAP 用户选择屏幕 搜索帮助 实现代码
- 在屏幕上画图的C#实现代码
- iPhone 应用里实现截屏功能的代码
- Flex 屏幕截图实现代码
- iPhone 应用里实现截屏功能的代码
- 图像细化matlab代码实现
- 实现程序内截屏功能的代码
- 用C#实现屏幕吸色功能,附逻辑思维讲解图,功能代码不超过50行即可实现
- JAVA功能代码《6》----用Java实现屏幕截图