How to capture videos.

Source: Internet
Author: User

Capture the current screen image.
Hope to have more communication. 8 -)
Package com. borland. samples. welcome;
/**
* Title:
* Description:
* Copyright: Copyright (c) 2001
* Company:
* @ Author
* @ Version 1.0
*/
Import java. awt .*;
Import java. awt. image .*;
Import com.sun.image.codec.jpeg .*;
Class ImageCanvas extends Canvas {
Private Image image;
Private Dimension prefSize;
Public ImageCanvas (Image image ){
This. image = image;
CalculatePreferredSize ();
}
Public void setImage (Image image ){
This. image = image;
CalculatePreferredSize ();
Repaint ();
}
Private void calculatePreferredSize (){
PrefSize = new Dimension (image. getWidth (this), image. getHeight (this ));
System. out. println (image. getWidth (this ));
SetSize (prefSize );
}
Public Dimension getPreferredSize (){
Return prefSize;
}
Public Dimension getMinimumSize (){
Return prefSize;
}
Public void update (Graphics g ){
Paint (g );
}
Public void paint (Graphics g ){
G. drawImage (image, 0, 0, null );
}
}
Class ImageUtils {
Public static Image getScreenImage (){
Robot robot;
Try {
Robot = new Robot ();
} Catch (Exception e ){
Throw new RuntimeException ("unable to construct Robot ");

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.