public class ScreenCapture
extends java.lang.Object
Constructor and Description |
---|
ScreenCapture() |
Modifier and Type | Method and Description |
---|---|
static java.awt.image.BufferedImage |
captureImageContent(javax.swing.JComponent component,
java.awt.Rectangle region,
java.lang.String fileName)
Captures the graphical content of the given region of the provided swing
JComponent . |
static java.awt.image.BufferedImage |
captureImageContent(javax.swing.JComponent component,
java.lang.String fileName)
Captures the graphical content of the provided swing
JComponent . |
static java.awt.image.BufferedImage |
captureScreen(java.awt.Rectangle region,
java.lang.String fileName)
Creates a BufferedImage from a rectangular region on the screen.
|
static java.awt.image.BufferedImage |
createImage(java.awt.Component component,
java.lang.String fileName)
Captures the graphical content of the provided AWT
Component . |
static javax.swing.ImageIcon |
resizeImage(java.awt.Image src,
int width,
int height)
Resizes the given Image to the provided dimensions.
|
static void |
writeImage(java.awt.image.BufferedImage image,
java.lang.String fileName)
Writes a BufferedImage to a File.
|
public static java.awt.image.BufferedImage captureImageContent(javax.swing.JComponent component, java.lang.String fileName) throws java.io.IOException
JComponent
.
The result will be saved to the given file and returned as a
BufferedImage
. The entire component will be captured to an image.component
- Swing component to create the image fromfileName
- name of file to be created. Passing null skips
saving.java.io.IOException
- if an error occurs during writingpublic static java.awt.image.BufferedImage captureImageContent(javax.swing.JComponent component, java.awt.Rectangle region, java.lang.String fileName) throws java.io.IOException
JComponent
. The result will be saved to the given file and
returned as a BufferedImage
. The entire component will be
captured to an image.component
- Swing component to create image fromregion
- The region of the component to be captured to an imagefileName
- name of file to be created. Passing null skips
saving.java.io.IOException
- if an error occurs during writingpublic static java.awt.image.BufferedImage createImage(java.awt.Component component, java.lang.String fileName) throws java.awt.AWTException, java.io.IOException
Component
. The
result will be saved to the given file and returned as a
BufferedImage
. The entire component will be captured to an image.component
- AWT component to create the image offileName
- name of file to be created. Passing null skips
saving.java.awt.AWTException
- see Robot.Robot()
java.io.IOException
- if an error occurs during writingpublic static java.awt.image.BufferedImage captureScreen(java.awt.Rectangle region, java.lang.String fileName) throws java.awt.AWTException, java.io.IOException
region
- region on the screen to create image fromfileName
- name of file to be created or nulljava.awt.AWTException
- see Robot.Robot()
java.io.IOException
- if an error occurs during writingpublic static void writeImage(java.awt.image.BufferedImage image, java.lang.String fileName) throws java.io.IOException
image
- image to be writtenfileName
- name of file to be createdjava.io.IOException
- if an error occurs during writingpublic static javax.swing.ImageIcon resizeImage(java.awt.Image src, int width, int height)
src
- the source imagewidth
- the new widthheight
- the new height