I'm migrating a project from Swing to JavaFX, and I have a problem. Since java.awt.BufferedImage provides getGraphics and it has lots of convenient methods (like drawLine, drawImage, etc.), I have some codes that uses these features.

But in JavaFX' WritableImage, I can't find any similar methods.
Did I miss something? Or should I use something else instead of WritableImage?

  • 1
    \$\begingroup\$ If you're going to use a framework you might as well use LibGDX, which is specifically made for creating games and has a lot of active members (like me!) around the 'net. Much more so than JavaFX from what I've seen anyways. \$\endgroup\$ – Charanor Nov 26 '17 at 21:38

You can use getGraphics in BufferedImage and do all the drawing job in the BufferedImage, and use SwingFXUtils.toFXImage to convert it into a WritableImage.

It's slow, and I have an alternative.

Draw everything on a Canvas, and use this:

override val screenCut get() =
      SnapshotParameters(), null), null))

This will probably help.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.