The closest you get to a BufferedImage
in JavaFX is javafx.scene.image.WritableImage
. It is a subclass of javafx.scene.image.Image
, and was introduced in JavaFX 2.2.
Depending on your use case, javafx.scene.canvas.Canvas
and javafx.scene.canvas.GraphicsContext
(similar to a Graphics2D
Java2D) might be a better fit.
To paint on a Canvas
node and get the contents in a WritableImage
, use (adapted from the Canvas
JavaDoc):
// Create canvas
Canvas canvas = new Canvas(250, 250);
GraphicsContext gc = canvas.getGraphicsContext2D();
// Paint on it
gc.setFill(Color.BLUE);
gc.fillRect(75, 75, 100, 100);
// NOTE: The canvas must be part of a Scene for the following to work properly, omitted for brevity
// Obtain a snapshot of the canvas
WritableImage image = canvas.snapshot(null, null);
See Working with Canvas from he JavaFX tutorials for more information.