Take a snapshot with JavaFX!
Posted
by user12610255
on Oracle Blogs
See other posts from Oracle Blogs
or by user12610255
Published on Fri, 24 Aug 2012 19:25:34 +0000
Indexed on
2012/08/27
21:50 UTC
Read the original article
Hit count: 224
/General
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 javafx.scene.Scene
class.
The most basic version has the following signature:
public WritableImage snapshot(WritableImage image)
The 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 javafx.scene.image
:
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 anImage
or other surface containing pixels.PixelWriter
: Defines methods for writing the pixel data of aWritableImage
or 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© Oracle Blogs or respective owner