Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8113656

Scene.renderToImage() returns a null if no size is specified

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: fx2.0
    • Fix Version/s: fx2.0
    • Component/s: javafx
    • Labels:

      Description

      I created a Scene to wrap a node that I wanted to turn into an image, but the renderToImage() method returned a null.

      The examples all use a Scene constructor that specifies a manual width and height and if you do that then it returns an image. But if you want the scene to naturally size itself to the contents then it won't do this for you.

      It would seem appropriate for renderToImage() to update any layout and scene sizing issues (and CSS propagation) before it invokes the rendering pass, as if it were preparing for "the next pulse".

      A workaround is to execute scene.impl_preferredSize() which internally sizes the scene to match the content, but I don't believe that handles any other layout or CSS issues.

      Also, if the size of the Scene is 0x0 then a dummy image should be returned rather than null. If a 0x0 image is invalid then it should return a 1x1 transparent image.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              kprazdnikwse Kirill.Prazdnikov (Inactive)
              Reporter:
              flar Jim Graham
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported: