JDK-8099385 : Draw to buffered image for later processing
  • Type: Enhancement
  • Component: javafx
  • Sub-Component: graphics
  • Priority: P3
  • Status: Resolved
  • Resolution: Duplicate
  • Submitted: 2009-08-31
  • Updated: 2015-06-16
  • Resolved: 2012-07-31
Related Reports
Duplicate :  
Description
There are times you want to draw nodes into an image so that you can later muck with the pixels or save it to disk.

requirements:
* must allow drawing into an image that you can retrieve pixel values from
* must be able to save to disk (enabled by the above)
* does not need to be hardware accelerated
* does not need to support drawing nodes already in a scene (if that would make it harder)
* this is likely a desktop only feature so it can be in the desktop profile and use java2d apis.

API Proposal

javafx.ext.swing.SwingUtils {
	//add script level function
	public function drawToImage(node:Node,image:BufferedImage);
}

then the developer can use the standard Java2D apis to grab and manipulate pixels, save to disk, and convert back into a JavaFX image.

Comments
This is implemented by the snapshot feature.
31-07-2012

We are providing a "non-public" way of doing this in JavaFX 2.0 and could consider making that public at some point.
15-04-2011

Consider for a future release.
09-09-2009