我如何将 javafx.image.Image 保存到 javafxports android 应用程序中的 jpg 文件?我找不到我唯一创建的 api 是 Android 不支持的 ImageIO。我需要一些帮助示例代码:
@Override public void start(Stage primaryStage) {
StackPane root = new StackPane();
Scene scene = new Scene(root, 400, 450);
WritableImage wim = new WritableImage(300, 250);
Canvas canvas = new Canvas(300, 250);
GraphicsContext gc = canvas.getGraphicsContext2D();
drawShapes(gc);
canvas.snapshot(null, wim);
root.getChildren().add(canvas);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
File file = new File("CanvasImage.png");
try {
//on desktop ImageIO.write(SwingFXUtils.fromFXImage(wim, null), "png", file);
// on android ??????????
} catch (Exception s) {
}
}