1
\$\begingroup\$

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?

\$\endgroup\$
1
  • 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, 2017 at 21:38

1 Answer 1

1
\$\begingroup\$

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() =
  JvmImage(SwingFXUtils.fromFXImage(canvas.snapshot(
      SnapshotParameters(), null), null))

This will probably help.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .