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

Use of WritableImage in GraphicsContext.drawImage() produces unwanted results

XMLWordPrintable

      WritableImage is not immutable object so when it is passed to Canvas GraphicsContext.drawImage() method its value could be different from what it contains when actual drawing is executed.

      See the attached sample. It draws a serie of WritableImage in a loop. When the same WritableImage instance is reused on each iteration, the resulting canvas contains just last image drawn multiple times which results in a completely red canvas. When new WritableImage is created on each loop iteration, result is a nice gradient from black to red.

      I believe at least javadoc of drawImage should be improved to cover these cases.

        1. HelloCanvas.java
          1 kB
          Alexander Kuznetcov

            Unassigned Unassigned
            mrkam Alexander Kuznetcov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Imported: