【问题标题】:How to convert any text or letter to image in javafx如何在 javafx 中将任何文本或字母转换为图像
【发布时间】:2017-04-01 11:00:07
【问题描述】:

我有一个 Text 对象,其中写了一些东西 - 一个字母或句子。如何将此文本转换为 javafx 中的图像,然后将其显示为图像。我不能使用标签,因为我需要编辑这个转换后图像的任何像素。

感谢任何建议。

【问题讨论】:

  • 创建一个Text对象并调用它的snapshot方法。 Label 将有更多样式选项,包括背景。

标签: java image text javafx


【解决方案1】:
private WritableImage textToImage(String text) {

    Text t = new Text(text);
    Scene scene = new Scene(new StackPane(t));
    return t.snapshot(null, null);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-02
    • 2018-10-17
    • 1970-01-01
    • 2015-02-09
    • 2020-09-24
    • 1970-01-01
    • 2020-03-27
    相关资源
    最近更新 更多