Take a snapshot with JavaFX!
By Scott Hommel-Oracle on Aug 24, 2012
JavaFX 2.2 has a "snapshot" feature that enables you to take a picture of any node or scene.
Take a look at the API Documentation and you will find new
snapshot methods in the
The most basic version has the following signature:
public WritableImage snapshot(WritableImage image)
WritableImage class (also introduced in JavaFX 2.2) lives in the
javafx.scene.image package, and
represents a custom graphical image that is constructed from pixels supplied by the application.
In fact, there are 5 new classes in
PixelFormat: Defines the layout of data for a pixel of a given format.
WritablePixelFormat: Represents a pixel format that can store full colors and so can be used as a destination format to write pixel data from an arbitrary image.
PixelReader: Defines methods for retrieving the pixel data from an
Imageor other surface containing pixels.
PixelWriter: Defines methods for writing the pixel data of a
WritableImageor other surface containing writable pixels.
WritableImage: Represents a custom graphical image that is constructed from pixels supplied by the application, and possibly from PixelReader objects from any number of sources, including images read from a file or URL.
The API documentation contains lots of information, so go investigate and have fun with these useful new classes!-- Scott Hommel