我想将编码图像嵌入到 FXML 中(我需要这个,因为我正在编写 svg 和 fxml 之间的转换器)。我试过这个:
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml">
<children>
<ImageView fitHeight="150.0" fitWidth="200.0" layoutX="153.0" layoutY="94.0" pickOnBounds="true" preserveRatio="true">
<image>
<Image url="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYEAYAAACw5+G7AAAABmJLR0T///////8JWPfcAAAA CXBIWXMAAABIAAAASABGyWs+AAAACXZwQWcAAAAYAAAAGAB4TKWmAAAI1UlEQVRYw61YS4gc VRf+7r1Vt+pWdfdMd0/P9PTMOCGJBpNI4gPiRrPQnSKIigQEN4LgQoTgwpU7QYOggop7UVA3 ESMEDKiJmIlEhUwS85pM5tGP6Wemn/V2cVJ2xxjCr//d3K66davOd873nXNus+jGwH8cjuM4 jgN0Op1OpwOEYRiGIcAY54wBQgihaUAqlUwmkwDnnEcRwBhjmvbvv8v+VwCO43muC1y6dOHC 0hJQKhWL5TIghKYJARQK09PpNDA1lc9nMoBlWVYyCdRqtdrmJrC+vr5eqQAAYwAwOzs3VygA 09NTU1NTBIhW/k8AoigMgwBYWbl2rVgEfvnl998XF4F6vVq9dg2YmUkmGQNyOSn7fYBzxlx3 uF8IIYQANE3XlaI7ySRQrfq+YQBra9Vqrwdks7nczAzw6KOPPPLww0AymUwmEncGdFsAnud5 vg9cvbq8fPUq0GiUSpUK0GqVSouLgBC9XqkEWBbn3S6g62HougDnUaTrIx9gjHE+vA4C8r3r apquA5ubvp9IAL0eY9kskMnMzc3PA/feu3v3nj0UmXz+9gD+Yl8URVEQEHejCKhUyuVKBbBt KcMQaDY3N5eWgPHxKNrYIGo4Du2UEghDQCkgioRgDBg1enTE9w2DZtsG+n2g23Wc1VVASt9P JoFOp93u9YBqVdMaDWBiIpNJp2+NyC3yKZfJ8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ehx568MEhgDuNf32ov3jx0qWrV4FisVQa bSFmZ6em0mlgbq5QKBTI84kEUC4Xi6USsLFRrzebQ63Nzs7MFApAPj85mc1SZb7T2eI/Afj7 iHf7vu8HAdDtUr/vODeaLY1zzgHTVMo0qXeiyFCd+K9/q/wJwRXXOxs1rPEAAAAASUVORK5C YII= " preserveRatio="false" smooth="false" />
</image>
</ImageView>
</children>
</AnchorPane>
如您所见,我使用了对 HTML 或 CSS 执行的标准方式,通过图像的 Base64 编码传递数据 url。在这种情况下,它不会返回任何错误,但不会显示图像(将 url 传递给与文件相同的图像有效,但这不是我想要的)。
有人可以帮助我吗?
非常感谢!