diff options
| author | Paul Buetow <paul@buetow.org> | 2026-07-21 18:39:47 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-07-21 18:39:47 +0300 |
| commit | cfda8297cc4432a77e3f7e8679753a908e9f5759 (patch) | |
| tree | bc8c1469989bb55656c93a65c277ab86e17adf9a /src/enhancer.h | |
| parent | dc127b5089656944dab7ab72799d0755ca122803 (diff) | |
enhance: wire up GEGL image filters (a cycle / s save) + fix export bugs
The enhancer module existed (GEGL presets: Auto-fix, Brightness, Contrast,
Saturation, Warm, Cool, Sharpen, Denoise) but was never connected to the
app and GEGL was never initialized. Wire it up:
- app.c: gegl_init() once in GApplication::startup (GEGL-gated).
- enhancer.c: add enhancer_load(GFile) -> GeglBuffer (gegl:load) and
enhancer_buffer_to_texture(GeglBuffer) -> GdkTexture (RGBA8 ->
GdkMemoryTexture) for the live preview bridge.
- enhancer_export: pick the saver from the output extension (jpg/png/webp)
instead of always gegl:jpg-save (ju0 - was writing JPEG bytes into .png);
verify the save actually produced a non-empty newer file instead of
trusting g_file_test(EXISTS) on a pre-existing path (ku0 - false success).
- window.c: win.enhance (a) cycles the active preset and previews it on the
current image (switches to large view, loads via GEGL, applies, shows the
texture); win.enhance-save (s) exports <stem>-enhanced.<ext> with the
active preset, never overwriting the original. Preview resets on
navigation; the title shows the active preset.
- shortcuts.c: a -> win.enhance, s -> win.enhance-save; ? overlay Enhance
group.
- tests: test_enhancer gains load_and_to_texture, export_format (PNG/JPEG
signature checks), export_real_success (ku0 - parent-missing and
pre-existing-directory both return FALSE). LSAN suppressions cover
GEGL's jpg-load plugin leak. test_shortcut full-table updated (25 rows).
Synchronous apply (may briefly block on large images) and a navigate-away
dirty prompt are deliberately out of scope for v1.
Diffstat (limited to 'src/enhancer.h')
| -rw-r--r-- | src/enhancer.h | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/enhancer.h b/src/enhancer.h index fce3fe7..f466d21 100644 --- a/src/enhancer.h +++ b/src/enhancer.h @@ -1,6 +1,9 @@ #ifndef GGAZE_ENHANCER_H #define GGAZE_ENHANCER_H +#include "ggaze-config.h" + +#include <gdk/gdk.h> #include <gio/gio.h> #include <glib.h> #include <gegl.h> @@ -25,12 +28,25 @@ const GPtrArray *enhancer_get_presets(Enhancer *p_e); GeglBuffer *enhancer_apply(Enhancer *p_e, GeglBuffer *p_in, const EnhancerPreset *p_preset, GError **p_err); -/* Export the enhanced buffer to a file (JPEG quality 95, EXIF Orientation=1). - * Returns TRUE on success. */ +/* Export the enhanced buffer to a file. The saver is chosen from p_out's + * extension: .jpg/.jpeg -> gegl:jpg-save (quality 95), .png -> gegl:png-save, + * .webp -> gegl:webp-save (if available). Other extensions fail with + * G_IO_ERROR_NOT_SUPPORTED. Success is verified by a real stat of the output + * (not pre-existence). Returns TRUE on success. */ gboolean enhancer_export(Enhancer *p_e, GeglBuffer *p_in, const EnhancerPreset *p_preset, GFile *p_out, GError **p_err); +#if GGAZE_HAVE_GEGL +/* Load a file into a GeglBuffer via the gegl:load op. Returns a new buffer + * (caller unrefs) or NULL with p_err set. */ +GeglBuffer *enhancer_load(GFile *p_file, GError **p_err); + +/* Convert a GeglBuffer to a GdkTexture for preview (RGBA8 bytes). Returns a + * new GdkTexture (caller unrefs) or NULL with p_err set. Needs no display. */ +GdkTexture *enhancer_buffer_to_texture(GeglBuffer *p_buf, GError **p_err); +#endif /* GGAZE_HAVE_GEGL */ + G_END_DECLS #endif
\ No newline at end of file |
