Package com.avpkit.core.demos
Class CaptureScreenToFile
- java.lang.Object
-
- com.avpkit.core.demos.CaptureScreenToFile
-
public class CaptureScreenToFile extends java.lang.Object
This demonstration application shows how to use AVPKit and Java to take snapshots of your screen and encode them in a video.You can find the original code here .
- Author:
- Denis Zgonjanin, aclarke
-
-
Constructor Summary
Constructors Constructor Description CaptureScreenToFile(java.lang.String outFile)Create the demonstration object with lots of defaults.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcloseStreams()Close out the file we're currently working on.static java.awt.image.BufferedImageconvertToType(java.awt.image.BufferedImage sourceImage, int targetType)Convert aBufferedImageof any type, toBufferedImageof a specified type.voidencodeImage(java.awt.image.BufferedImage originalImage)Encode the given image to the file and increment our time stamp.static voidmain(java.lang.String[] args)Takes up to one argument, which just gives a file name to encode as.java.awt.image.BufferedImagetakeSingleSnapshot()Use the AWT robot to take a snapshot of the current screen.
-
-
-
Constructor Detail
-
CaptureScreenToFile
public CaptureScreenToFile(java.lang.String outFile)
Create the demonstration object with lots of defaults. Throws an exception if we can't get the screen or open the file.- Parameters:
outFile- File to write to.
-
-
Method Detail
-
main
public static void main(java.lang.String[] args)
Takes up to one argument, which just gives a file name to encode as. We guess which video codec to use based on the filename.- Parameters:
args- The filename to write to.
-
encodeImage
public void encodeImage(java.awt.image.BufferedImage originalImage)
Encode the given image to the file and increment our time stamp.- Parameters:
originalImage- an image of the screen.
-
closeStreams
public void closeStreams()
Close out the file we're currently working on.
-
takeSingleSnapshot
public java.awt.image.BufferedImage takeSingleSnapshot()
Use the AWT robot to take a snapshot of the current screen.- Returns:
- a picture of the desktop
-
convertToType
public static java.awt.image.BufferedImage convertToType(java.awt.image.BufferedImage sourceImage, int targetType)
Convert aBufferedImageof any type, toBufferedImageof a specified type. If the source image is the same type as the target type, then original image is returned, otherwise new image of the correct type is created and the content of the source image is copied into the new image.- Parameters:
sourceImage- the image to be convertedtargetType- the desired BufferedImage type- Returns:
- a BufferedImage of the specifed target type.
- See Also:
BufferedImage
-
-