Class SwingFXUtils
public class SwingFXUtils extends Object
- Since:
- JavaFX 2.2
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
static BufferedImage |
fromFXImage |
Snapshots the specified JavaFX Image object and stores a copy of its pixels into a BufferedImage object, creating a new object if needed. |
static WritableImage |
toFXImage |
Snapshots the specified BufferedImage and stores a copy of its pixels into a JavaFX Image object, creating a new object if needed. |
Method Details
toFXImage
public static WritableImage toFXImage(BufferedImage bimg, WritableImage wimg)
BufferedImage and stores a copy of its pixels into a JavaFX Image object, creating a new object if needed. The returned Image will be a static snapshot of the state of the pixels in the BufferedImage at the time the method completes. Further changes to the BufferedImage will not be reflected in the Image. The optional JavaFX WritableImage parameter may be reused to store the copy of the pixels. A new Image will be created if the supplied object is null, is too small or of a type which the image pixels cannot be easily converted into.
- Parameters:
-
bimg- theBufferedImageobject to be converted -
wimg- an optionalWritableImageobject that can be used to store the returned pixel data - Returns:
- an
Imageobject representing a snapshot of the current pixels in theBufferedImage. - Since:
- JavaFX 2.2
fromFXImage
public static BufferedImage fromFXImage(Image img, BufferedImage bimg)
Image object and stores a copy of its pixels into a BufferedImage object, creating a new object if needed. The method will only convert a JavaFX Image that is readable as per the conditions on the Image.getPixelReader() method. If the Image is not readable, as determined by its getPixelReader() method, then this method will return null. If the Image is a writable, or other dynamic image, then the BufferedImage will only be set to the current state of the pixels in the image as determined by its PixelReader. Further changes to the pixels of the Image will not be reflected in the returned BufferedImage. The optional BufferedImage parameter may be reused to store the copy of the pixels. A new BufferedImage will be created if the supplied object is null, is too small or of a type which the image pixels cannot be easily converted into.
- Parameters:
-
img- the JavaFXImageto be converted -
bimg- an optionalBufferedImageobject that may be used to store the returned pixel data - Returns:
- a
BufferedImagecontaining a snapshot of the JavaFXImage, or null if theImageis not readable. - Since:
- JavaFX 2.2
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.