I have written a program that generates images for me. That works so far, save on the save.
In the method I want to save I have a WritabelImage
I make a BuffertImage
with the SwingFXUtils.fromFXImage ()
. In the debugger of Intellij I can also look at it and it is actually there.
Then I have the output path created as URI and pass this to a Fil
object.
With ImageIO.write ()
I would like to combine and save both.
And that does not work.
The path exits.
I tried it with the direct URI and also with the uri.getPath ()
I just do not know how to continue. Can you please help me with that?
try {
String path;
URI uri;
uri = this.getClass().getResource("").toURI();
path = uri.toString().replace("foo/bar/foobar/generate/", "generate/out/" + name + ".png");
uri = URI.create(path);
File outputFile = new File(uri.getPath());
BufferedImage bImage = SwingFXUtils.fromFXImage(writableImage, null);
System.out.println("Saved");
ImageIO.write(bImage, ".png", outputFile);
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (URISyntaxException e) {
e.printStackTrace();
}