static gboolean process (GeglOperation *operation, GeglBuffer *input, const GeglRectangle *result, gint level) { GeglProperties *o = GEGL_PROPERTIES (operation); GOutputStream *stream; GFile *file = NULL; GError *error = NULL; gboolean status = TRUE; stream = gegl_gio_open_output_stream (NULL, o->path, &file, &error); if (stream == NULL) { status = FALSE; g_warning ("%s", error->message); goto cleanup; } if (!export_numpy (operation, input, result, stream)) { status = FALSE; g_warning ("could not export NumPy file"); goto cleanup; } cleanup: g_clear_object (&stream); g_clear_object (&file); return status; }
static gboolean process(GeglOperation *operation, GeglBuffer *input, const GeglRectangle *result, int level) { GeglProperties *o = GEGL_PROPERTIES(operation); Priv *p = g_new0(Priv, 1); gboolean status = TRUE; GError *error = NULL; g_assert(p != NULL); o->user_data = (void*) p; p->stream = gegl_gio_open_output_stream(NULL, o->path, &p->file, &error); if (p->stream != NULL && p->file != NULL) p->can_seek = g_seekable_can_seek(G_SEEKABLE(p->stream)); if (p->stream == NULL) { status = FALSE; g_warning("%s", error->message); goto cleanup; } TIFFSetErrorHandler(error_handler); TIFFSetWarningHandler(warning_handler); p->tiff = TIFFClientOpen("GEGL-tiff-save", "w", (thandle_t) p, read_from_stream, write_to_stream, seek_in_stream, close_stream, get_file_size, NULL, NULL); if (p->tiff == NULL) { status = FALSE; g_warning("failed to open TIFF from %s", o->path); goto cleanup; } if (export_tiff(operation, input, result)) { status = FALSE; g_warning("could not export TIFF file"); goto cleanup; } cleanup: cleanup(operation); if (o->user_data != NULL) g_free(o->user_data); o->user_data = NULL; if (error != NULL) g_error_free(error); return status; }
static gboolean process (GeglOperation *operation, GeglBuffer *input, const GeglRectangle *result, gint level) { GeglProperties *o = GEGL_PROPERTIES (operation); png_structp png = NULL; png_infop info = NULL; GOutputStream *stream = NULL; GFile *file = NULL; gboolean status = TRUE; GError *error = NULL; png = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, error_fn, NULL); if (png != NULL) info = png_create_info_struct (png); if (png == NULL || info == NULL) { status = FALSE; g_warning ("failed to initialize PNG writer"); goto cleanup; } stream = gegl_gio_open_output_stream (NULL, o->path, &file, &error); if (stream == NULL) { status = FALSE; g_warning ("%s", error->message); goto cleanup; } png_set_write_fn (png, stream, write_fn, flush_fn); if (export_png (operation, input, result, png, info, o->compression, o->bitdepth)) { status = FALSE; g_warning("could not export PNG file"); goto cleanup; } cleanup: if (info != NULL) png_destroy_write_struct (&png, &info); else if (png != NULL) png_destroy_write_struct (&png, NULL); if (stream != NULL) g_clear_object(&stream); if (file != NULL) g_clear_object(&file); return status; }