From 36a04b2d27e1913ba70d6eb9e3393547736d8c5e Mon Sep 17 00:00:00 2001 From: e3ndr <33337309+e3ndr@users.noreply.github.com> Date: Mon, 2 Sep 2024 06:45:30 -0500 Subject: [PATCH] feat(icon): Add the new save() api. --- .../co/casterlabs/saucer/utils/SaucerIcon.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/api/src/main/java/co/casterlabs/saucer/utils/SaucerIcon.java b/api/src/main/java/co/casterlabs/saucer/utils/SaucerIcon.java index f6df53d..bbb9cef 100644 --- a/api/src/main/java/co/casterlabs/saucer/utils/SaucerIcon.java +++ b/api/src/main/java/co/casterlabs/saucer/utils/SaucerIcon.java @@ -1,5 +1,7 @@ package co.casterlabs.saucer.utils; +import java.nio.file.Path; + import org.jetbrains.annotations.Nullable; import com.sun.jna.Library; @@ -56,6 +58,16 @@ public boolean isEmpty() { return N.saucer_icon_empty(this); } + /** + * @implNote On GTK, macOS, and Windows, this saves as a PNG. + * @implNote On QT, BMP, JPG, GIF, PNG, and various X-specific formats are + * supported. + * @implNote It is recommended you stick to PNG for compatibility. + */ + public void saveToFile(@NonNull Path target) { + N.saucer_icon_save(this, target.toAbsolutePath().toString()); + } + /* ------------------------------------ */ /* ------------------------------------ */ /* ------------------------------------ */ @@ -69,6 +81,8 @@ static interface _Native extends Library { boolean saucer_icon_empty(SaucerIcon instance); + boolean saucer_icon_save(SaucerIcon instance, String path); + } }