Fwd: API REVIEW request for RT-17398: snapshot (aka render to image)

Kevin Rushforth kevin.rushforth at oracle.com
Sat May 12 12:59:40 PDT 2012


If you snapshot a live scene it will reflect the state of those node in 
that scene at the time you take the snapshot (or on the next pulse for 
the async version), so yes, a button will be rendered in its hovered 
state if the mouse is over it.

Tooltips are not rendered as part of the scene, though, so I wouldn't 
expect them to be shown (they are rendered in a popup stage). It is a 
good question, though, about whether it might be something that a user 
would want to render (if so, we could consider making it available in a 
future release).

As for printing, it will be done differently since it has other needs to 
consider (although you may be able to use this as sort of a "poor man's" 
image-based printing of exactly what you see, it isn't suitable for 
generating a report or other printed rendering of a scene).

We had very briefly talked about providing an alternate stylesheet, but 
didn't take it anywhere for this release. I could imagine adding it to 
SnapshotParameters in a future version. Btw, printing will likely need 
to address this.

-- Kevin



Daniel Zwolenski wrote:
> Forgot to reply all...
>
> ---------- Forwarded message ----------
> From: Daniel Zwolenski <zonski at googlemail.com>
> Date: Sat, May 12, 2012 at 1:15 PM
> Subject: Re: API REVIEW request for RT-17398: snapshot (aka render to image)
> To: Jose Martinez <jmartine_1026 at yahoo.com>
>
>
> I like it.
>
> Does it snapshot the current state of the screen or the 'unused' view of it
> - e.g. if the mouse is over a button will the button be in that state or
> it's normal state? Similar question for tooltips, selected text in fields,
> etc?
>
> Is this the official solution for how we do printing too, or is that going
> to be something different again.
>
> Random thought, would it be possible to specify an alternate stylesheet
> (maybe in the params) to use for the snapshot? Feels like there could be
> some use cases for this, but not sure exactly - more a thought than a
> suggestion.
>
>
>
> On Sat, May 12, 2012 at 1:06 PM, Jose Martinez <jmartine_1026 at yahoo.com>wrote:
>
>   
>> Awesome feature.  I do not know enough about how rendering is done to
>> understand why the new SnapshotParams would need a Camera and depthBuffer
>> but I guess in the end that just gives it more flexibility or maybes it
>> required for Swing integration.  It would be good to know why the params in
>> that class were selected.  Also, I think the faster this feature is the
>> better... please keep speed in mind when selecting which params and
>> implementation should be used when making these snapshots.  Isolate
>> implementations that might be slower so its used only when needed.... slow
>> feature rich snapshot and quick get the job done snapshots.
>>
>>     
>>> E.g a node has a size of 2000x2000 but my screen is only 1024x768
>>>       
>> will the rendered image be 2000x2000?
>> Maybe the ViewPort in SnapshotParam will decide what part of the scene is
>> stored in the snapshot?
>>
>> jose
>>
>>
>> ________________________________
>>  From: Tom Schindl <tom.schindl at bestsolution.at>
>> To: openjfx-dev at openjdk.java.net
>> Sent: Friday, May 11, 2012 9:16 PM
>> Subject: Re: API REVIEW request for RT-17398: snapshot (aka render to
>> image)
>>
>> One question will the complete content get rendered into an image or the
>> only the visible one?
>>
>> E.g a node has a size of 2000x2000 but my screen is only 1024x768 will
>> the rendered image be 2000x2000?
>>
>> Tom
>>
>> Am 12.05.12 03:03, schrieb Kevin Rushforth:
>>     
>>> JIRA:  http://javafx-jira.kenai.com/browse/RT-17398
>>>
>>> This feature request will add public API to support taking a snapshot of
>>> a Scene or Node and rendering it into an Image.
>>>
>>> To address this feature, I propose to add the following methods on the
>>> existing Node and Scene class, along with two new classes to hold the
>>> parameters and the result, respectively.
>>>
>>> Scene:
>>>    public Image snapshot(Image image)
>>>    public void snapshot(Callback<SnapshotResult,Void> callback, Image
>>> image)
>>>
>>> Node:
>>>    public Image snapshot(SnapshotParameters params, Image image)
>>>    public void snapshot(Callback<SnapshotResult,Void> callback,
>>> SnapshotParameters params, Image image)
>>>
>>> // Data container class with the following attributes
>>> SnapshotParameters:
>>>    get/setDepthBuffer(boolean)
>>>    get/setCamera(Camera)
>>>    get/setTransform(Transform);
>>>    get/setFill(Paint);
>>>    get/setViewport(Rectangle2D)
>>>
>>> // Data container class to return the result of an async snapshot,
>>> currently immutable
>>> SnapshotResult:
>>>    Image image
>>>    Object source
>>>    SnapshotParameters params
>>>
>>>
>>> Here is the preliminary Javadoc for the four snapshot methods:
>>>
>>> -------------------------------------------------------------------
>>>
>>> Scene:
>>>    public Image snapshot(Image image)
>>>
>>> Takes a snapshot of this scene and returns the rendered image when it is
>>> ready. CSS and layout processing will be done for the scene prior to
>>> rendering it.
>>>
>>>    image - the image that will be used to hold the rendered scene. It
>>> may be null in which case a new Image will be constructed. If the image
>>> is non-null, the scene will be rendered into the existing image. If the
>>> image is larger than the scene, the area outside the bounds of the scene
>>> will be filled with the Scene fill color. If the image is smaller than
>>> the scene, the rendered image will be clipped.
>>>
>>> -------------------------------------------------------------------
>>>
>>> Scene:
>>>    public void snapshot(Callback<SnapshotResult,Void> callback, Image
>>> image)
>>>
>>> Takes a snapshot of this scene at the next frame and calls the specified
>>> callback method when the image is ready. CSS and layout processing will
>>> be done for the scene prior to rendering it. This is an asynchronous
>>> call, which means that other events or animation might be processed
>>> before the scene is rendered. If any such events modify a node in the
>>> scene that modification will be reflected in the rendered image (as it
>>> will also be reflected in the frame rendered to the Stage).
>>>
>>>    callback - a class whose call method will be called when the image is
>>> ready. The SnapshotResult that is passed into the call method of the
>>> callback will contain the rendered image and the source scene that was
>>> rendered.
>>>
>>>    image - the image that will be used to hold the rendered scene. It
>>> may be null in which case a new Image will be constructed. If the image
>>> is non-null, the scene will be rendered into the existing image. If the
>>> image is larger than the scene, the area outside the bounds of the scene
>>> will be filled with the Scene fill color. If the image is smaller than
>>> the scene, the rendered image will be clipped.
>>>
>>> -------------------------------------------------------------------
>>>
>>> Node:
>>>    public Image snapshot(SnapshotParameters params, Image image)
>>>
>>> Takes a snapshot of this node and returns the rendered image when it is
>>> ready. CSS and layout processing will be done for the node, and any of
>>> its children, prior to rendering it.
>>>
>>> Parameters:
>>>    params - the snapshot parameters containing attributes that will
>>> control the rendering.
>>>
>>>    image - the image that will be used to hold the rendered node. It may
>>> be null in which case a new Image will be constructed. If the image is
>>> non-null, the node will be rendered into the existing image. If the
>>> image is larger than the bounds of the node, the area outside the bounds
>>> will be filled with the fill color specified in the snapshot parameters.
>>> If the image is smaller than the bounds, the rendered image will be
>>> clipped.
>>>
>>> -------------------------------------------------------------------
>>>
>>> Node:
>>>    public void snapshot(Callback<SnapshotResult,Void> callback,
>>> SnapshotParameters params, Image image)
>>>
>>> Takes a snapshot of this node at the next frame and calls the specified
>>> callback method when the image is ready. CSS and layout processing will
>>> be done for the node, and any of its children, prior to rendering it.
>>> This is an asynchronous call, which means that other events or animation
>>> might be processed before the node is rendered. If any such events
>>> modify the node, or any of its children, that modification will be
>>> reflected in the rendered image (just like it will also be reflected in
>>> the frame rendered to the Stage, if this node is part of a live scene
>>> graph).
>>>
>>>    callback - a class whose call method will be called when the image is
>>> ready. The SnapshotResult that is passed into the call method of the
>>> callback will contain the rendered image, the source node that was
>>> rendered, and a copy of the SnapshotParameters.
>>>
>>>    params - the snapshot parameters containing attributes that will
>>> control the rendering.
>>>
>>>    image - the image that will be used to hold the rendered node. It may
>>> be null in which case a new Image will be constructed. If the image is
>>> non-null, the node will be rendered into the existing image. If the
>>> image is larger than the bounds of the node, the area outside the bounds
>>> will be filled with the fill color specified in the snapshot parameters.
>>> If the image is smaller than the bounds, the rendered image will be
>>> clipped.
>>>
>>>       
>> --
>> B e s t S o l u t i o n . a t                        EDV Systemhaus GmbH
>> ------------------------------------------------------------------------
>> tom schindl                 geschäftsführer/CEO
>> ------------------------------------------------------------------------
>> eduard-bodem-gasse 5-7/1   A-6020 innsbruck     fax      ++43 512 935833
>> http://www.BestSolution.at                      phone    ++43 512 935834
>>
>>     


More information about the openjfx-dev mailing list