Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert any text or letter to image in javafx

I have a Text object, where is something written - a letter or sentence. How can I convert this text into an image in javafx and then show it as image. I can't use Labels, because I need to have possibility of editing any pixel of this converted image.

Any advice is appreciated.

like image 324
drewpol Avatar asked Sep 03 '25 15:09

drewpol


1 Answers

private WritableImage textToImage(String text) {

    Text t = new Text(text);
    Scene scene = new Scene(new StackPane(t));
    return t.snapshot(null, null);
}
like image 143
James_D Avatar answered Sep 05 '25 05:09

James_D