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

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

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • fx2.0
    • fx2.0
    • javafx

      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.

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

              Created:
              Updated:
              Resolved:
              Imported: