CN110888575A - 一种基于web实现截图并保存的方法 - Google Patents

一种基于web实现截图并保存的方法 Download PDF

Info

Publication number
CN110888575A
CN110888575A CN201811033754.1A CN201811033754A CN110888575A CN 110888575 A CN110888575 A CN 110888575A CN 201811033754 A CN201811033754 A CN 201811033754A CN 110888575 A CN110888575 A CN 110888575A
Authority
CN
China
Prior art keywords
screenshot
mouse
realizing
web
picture
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201811033754.1A
Other languages
English (en)
Inventor
丁继锋
张来卿
庞严冬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhuhai Hengqin Shengda Zhaoye Technology Investment Co Ltd
Original Assignee
Zhuhai Hengqin Shengda Zhaoye Technology Investment Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhuhai Hengqin Shengda Zhaoye Technology Investment Co Ltd filed Critical Zhuhai Hengqin Shengda Zhaoye Technology Investment Co Ltd
Priority to CN201811033754.1A priority Critical patent/CN110888575A/zh
Publication of CN110888575A publication Critical patent/CN110888575A/zh
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0484Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range
    • G06F3/04845Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range for image manipulation, e.g. dragging, rotation, expansion or change of colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0484Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range
    • G06F3/0486Drag-and-drop
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0487Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Processing Or Creating Images (AREA)

Abstract

本发明涉及Web应用与开发技术领域,具体涉及一种基于WEB实现截图并保存的方法。本发明所述的方法包含以下几个步骤:1、声明必需变量创建构造函数;2、对屏幕进行拍照监听鼠标拖拽事件;3、监听鼠标释放及Esc键退出事件;4、拷贝屏幕截图到BufferedImage对象;5、保存并输出图片。本发明解决了WEB应用中无需借助第三方截图工具直接实现拖拽鼠标截图并保存的问题,可广泛应用于WEB应用与开发中。

Description

一种基于WEB实现截图并保存的方法
技术领域
本发明涉及Web应用与开发技术领域,具体涉及一种基于WEB实现截图并保存的方法。
背景技术
截图是由计算机截取的能显示在屏幕或其他显示设备上的可视图像。通常截图可以由操作系统或专用截图软件截取,也有有外部设备如数字相机拍摄。就是把在电脑屏幕上看到的,拍下来,保存为图片可以选择性的拍一部分,效果与你看到的几乎一样可以自己保存,或者与他人分享。
通常情况下在操作WEB应用时,需要重点标记某些WEB内容,甚至需要对某些内容进行保存,可以保存整个网页,但直接截图保存最快,最有效,但在截图时通常需要借助第三方工具。本发明通过在WEB应用自动嵌入截图工具,直接快捷调用截图并保存,解决了WEB应用中无需借助第三方截图工具直接实现拖拽鼠标截图并保存的问题,可广泛应用于WEB应用与开发过程中。
发明内容
本发明解决的技术问题在于提供一种基于WEB实现截图并保存的方法;解决了WEB应用中无需借助第三方截图工具直接实现拖拽鼠标截图并保存的问题。
本发明解决上述技术问题的技术方案是:
所述的方法包含以下几个步骤:
步骤一、声明必需变量创建构造函数;
步骤二、对屏幕进行拍照监听鼠标拖拽事件;
步骤三、监听鼠标释放及Esc键退出事件;
步骤四、拷贝屏幕截图到BufferedImage对象;
步骤五、保存并输出图片。
所述的基于WEB实现截图并保存的方法,步骤一中,声明文件名称、默认截图名称、截图对象、默认图片格式、鼠标开始与结束坐标等必需变量,并创建构截图造函数。
所述的步骤二中,编写鼠标运动监听器监听鼠标拖拽事件,根据鼠标起始位置坐标绘制矩形图形。
所述的步骤三中,监听鼠标释放及Esc键退出事件,鼠标释放时图片绘制完毕,Esc键触发时退出截图,释放资源。
所述的步骤四和步骤五中,步骤三中鼠标释放时,创建屏幕截图对象,并拷贝截图到BufferedImage对象中,转换成图片并保存。
本发明解决了WEB应用中无需借助第三方截图工具直接实现拖拽鼠标截图并保存的问题,可广泛应用于WEB应用和开发过程中。
附图说明
下面结合附图对本发明进一步说明:
图1是本发明方法流程图。
具体实施方式
如图1所示,本发明具体包含以下几个步骤 :
步骤一、声明必需变量创建构造函数;
步骤二、对屏幕进行拍照监听鼠标拖拽事件;
步骤三、监听鼠标释放及Esc键退出事件;
步骤四、拷贝屏幕截图到BufferedImage对象;
步骤五、保存并输出图片。
所述的步骤一中,声明文件名称、默认截图名称、截图对象、默认图片格式、鼠标开始与结束坐标等必需变量,并创建构截图造函数。
private String fileName;
private String defaultName = "GuiCamera";
static int serialNum = 0;
private String imageFormat;//图像文件的格式
private String defaultImageFormat = "jpg";
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
public GuiCamera()
{
fileName = defaultName;
imageFormat = defaultImageFormat;
}
public GuiCamera(String s, String format)
{
fileName = s;
imageFormat = format;
}
所述的步骤二中,编写鼠标运动监听器监听鼠标拖拽事件,根据鼠标起始位置坐标绘制矩形图形。
public void paint(Graphics g)
{
//缩放因子和偏移量
RescaleOp ro = new RescaleOp(0.8f, 0, null);
tempImage = ro.filter(image, null);
g.drawImage(tempImage, 0, 0, this);
}
public RectD()
{
snapshot();
setVisible(true);
//setSize(d);//最大化窗口
setDefaultCloseOperation(EXIT_ON_CLOSE);
this.addMouseListener(new MouseAdapter()
{
public void mousePressed(MouseEvent e)
{
orgx = e.getX();
orgy = e.getY();
}
});
//鼠标运动监听器
this.addMouseMotionListener(new MouseMotionAdapter()
{
//鼠标拖拽事件
public void mouseDragged(MouseEvent e)
{
endx = e.getX();
endy = e.getY();
g = getGraphics();
g.drawImage(tempImage, 0, 0, RectD.this);
int x = Math.min(orgx, endx);
int y = Math.min(orgy, endy);
//加上1,防止width,height为0
int width = Math.abs(endx - orgx) + 1;
int height = Math.abs(endy - orgy) + 1;
g.setColor(Color.BLUE);
g.drawRect(x - 1, y - 1, width + 1, height + 1);
//减1,加1都是为了防止图片将矩形框覆盖掉
saveImage = image.getSubimage(x, y, width, height);
g.drawImage(saveImage, x, y, RectD.this);
}
});
所述的步骤三中,监听鼠标释放及Esc键退出事件,鼠标释放时图片绘制完毕,Esc键触发时退出截图,释放资源。
this.addKeyListener(new KeyAdapter()
{
//按键释放
public void keyReleased(KeyEvent e)
{
//按Esc键退出
if (e.getKeyCode() == 27)
{
saveToFile();
System.exit(0);
}}}
所述的步骤四和步骤五中,步骤三中鼠标释放时,创建屏幕截图对象,并拷贝截图到BufferedImage对象中,转换成图片并保存。
public void saveToFile()
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyymmddHHmmss");
String name = sdf.format(new Date());
File path = FileSystemView.getFileSystemView().getHomeDirectory();
String format = "jpg";
File f = new File(path + File.separator + name + "." + format);
try
{
ImageIO.write(saveImage, format, f);
}
catch (IOException e)
{
e.printStackTrace();
}
}。

Claims (5)

1.一种基于WEB实现截图并保存的方法,其特征在于:所述的方法包含以下几个步骤:
步骤一、声明必需变量创建构造函数;
步骤二、对屏幕进行拍照监听鼠标拖拽事件;
步骤三、监听鼠标释放及Esc键退出事件;
步骤四、拷贝屏幕截图到BufferedImage对象;
步骤五、保存并输出图片。
2.根据权利要求1所述的一种基于WEB实现截图并保存的方法,其特征在于:所述的步骤一中,声明文件名称、默认截图名称、截图对象、默认图片格式、鼠标开始与结束坐标等必需变量,并创建构截图造函数。
3.根据权利要求1所述的一种基于WEB实现截图并保存的方法,其特征在于:所述的步骤二中,编写鼠标运动监听器监听鼠标拖拽事件,根据鼠标起始位置坐标绘制矩形图形。
4.根据权利要求1所述的一种基于WEB实现截图并保存的方法,其特征在于:所述的步骤三中,监听鼠标释放及Esc键退出事件,鼠标释放时图片绘制完毕,Esc键触发时退出截图,释放资源。
5.根据权利要求1所述的一种基于WEB实现截图并保存的方法,其特征在于:所述的步骤四和步骤五中,步骤三中鼠标释放时,创建屏幕截图对象,并拷贝截图到BufferedImage对象中,转换成图片并保存。
CN201811033754.1A 2018-09-07 2018-09-07 一种基于web实现截图并保存的方法 Pending CN110888575A (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811033754.1A CN110888575A (zh) 2018-09-07 2018-09-07 一种基于web实现截图并保存的方法

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811033754.1A CN110888575A (zh) 2018-09-07 2018-09-07 一种基于web实现截图并保存的方法

Publications (1)

Publication Number Publication Date
CN110888575A true CN110888575A (zh) 2020-03-17

Family

ID=69744277

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811033754.1A Pending CN110888575A (zh) 2018-09-07 2018-09-07 一种基于web实现截图并保存的方法

Country Status (1)

Country Link
CN (1) CN110888575A (zh)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115220629A (zh) * 2022-06-23 2022-10-21 惠州华阳通用电子有限公司 一种界面元素位置调整方法
CN117519888A (zh) * 2024-01-05 2024-02-06 成都泰盟软件有限公司 一种基于Web截图生成聊天记录文档的方法及系统

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20100031784A (ko) * 2008-09-11 2010-03-25 주식회사 디자인메이드 웹페이지 캡쳐 화면 인쇄 방법
CN104834753A (zh) * 2015-05-28 2015-08-12 百度在线网络技术(北京)有限公司 生成网页截图的方法及其装置
CN106406851A (zh) * 2016-08-24 2017-02-15 北京松鼠山科技有限公司 一种网页截图方法、系统

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20100031784A (ko) * 2008-09-11 2010-03-25 주식회사 디자인메이드 웹페이지 캡쳐 화면 인쇄 방법
CN104834753A (zh) * 2015-05-28 2015-08-12 百度在线网络技术(北京)有限公司 生成网页截图的方法及其装置
CN106406851A (zh) * 2016-08-24 2017-02-15 北京松鼠山科技有限公司 一种网页截图方法、系统

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
SANLUO11: "java实现截图并保存到本地", 《HTTPS://BLOG.CSDN.NET/SANLUO11/ARTICLE/DETAILS/61923549/》 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115220629A (zh) * 2022-06-23 2022-10-21 惠州华阳通用电子有限公司 一种界面元素位置调整方法
CN115220629B (zh) * 2022-06-23 2024-04-05 惠州华阳通用电子有限公司 一种界面元素位置调整方法
CN117519888A (zh) * 2024-01-05 2024-02-06 成都泰盟软件有限公司 一种基于Web截图生成聊天记录文档的方法及系统

Similar Documents

Publication Publication Date Title
US10007963B2 (en) Context-based provision of screenshot modifications
JP1706195S (ja) 動画キャプチャー用画像
US10831262B2 (en) Dynamic augmented reality media creation
CN110888575A (zh) 一种基于web实现截图并保存的方法
CN112243505B (zh) 信息处理装置、信息处理方法和程序
US20190295300A1 (en) Method and Apparatus for Generating Image by Using Multi-Sticker
CN112348929A (zh) 帧动画的渲染方法、装置、计算机设备及存储介质
JP2008287691A (ja) 情報処理装置及びプログラム
JP2009210625A (ja) 表示装置及び表示方法
US20090006966A1 (en) Creating A Usability Observation Video For A Computing Device Being Studied For Usability
US11194598B2 (en) Information display method, terminal and storage medium
KR20200067999A (ko) 전자 서명된 문서를 생성하는 방법 및 장치
JP4761553B2 (ja) プレゼンテーション装置及び制御方法
CN111164569B (zh) 一种基于智能终端的滤镜切换方法及滤镜切换系统
JP7146428B2 (ja) 画像記録装置及びその制御方法
WO2023087642A1 (zh) 用户代码的运行方法及装置、电子设备和存储介质
CN103853534A (zh) 一种照片即时显示方法及装置
KR101396753B1 (ko) 터치를 이용하여 뷰 파인더를 적응적으로 사용하는 방법 및 그 단말
US20180225476A1 (en) Automated image editing system
CN110324515B (zh) 图像记录设备及其控制方法
TWI267793B (en) Editable image monitoring system, monitoring method and its graphics user interface for comparing image characteristics to activate an event process
JP5162855B2 (ja) 画像処理装置、遠隔画像処理システム及び画像処理方法
JP3998884B2 (ja) 画面コピーを抑止するコンテンツ表示装置
KR102168323B1 (ko) 문서에 삽입되어 있는 개체들 간의 서식 속성의 동기화를 처리하는 문서 편집용 전자 단말 장치 및 그 동작 방법
CN113347378A (zh) 一种录像方法及设备

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20200317