static gboolean gegl_jpg_load_process (GeglOperation *operation, GeglBuffer *output, const GeglRectangle *result) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); GeglRectangle rect={0,0}; gint problem; problem = gegl_jpg_load_query_jpg (o->path, &rect.width, &rect.height); if (problem) { g_warning ("%s failed to open file %s for reading.", G_OBJECT_TYPE_NAME (operation), o->path); return FALSE; } problem = gegl_jpg_load_buffer_import_jpg (output, o->path, 0, 0); if (problem) { g_warning ("%s failed to open file %s for reading.", G_OBJECT_TYPE_NAME (operation), o->path); return FALSE; } return TRUE; }
static GeglRectangle gegl_jpg_load_get_bounding_box (GeglOperation *operation) { gint width, height; GeglProperties *o = GEGL_PROPERTIES (operation); const Babl *format = NULL; GFile *file = NULL; GError *err = NULL; gint status = -1; GInputStream *stream = gegl_gio_open_input_stream(o->uri, o->path, &file, &err); if (!stream) return (GeglRectangle) {0, 0, 0, 0}; status = gegl_jpg_load_query_jpg (stream, &width, &height, &format); g_input_stream_close(stream, NULL, NULL); if (format) gegl_operation_set_format (operation, "output", format); g_object_unref(stream); if (file) g_object_unref(file); if (err || status) return (GeglRectangle) {0, 0, 0, 0}; else return (GeglRectangle) {0, 0, width, height}; }
static GeglRectangle gegl_jpg_load_get_bounding_box (GeglOperation *operation) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); gint width, height, components; gint status; status = gegl_jpg_load_query_jpg (o->path, &width, &height, &components); if (components == 1) gegl_operation_set_format (operation, "output", babl_format ("Y' u8")); else if (components == 3) gegl_operation_set_format (operation, "output", babl_format ("R'G'B' u8")); else { g_warning ("attempted to load unsupported JPEG (components=%d)", components); status = -1; } if (status) return (GeglRectangle) {0, 0, 0, 0}; else return (GeglRectangle) {0, 0, width, height}; }
static GeglRectangle gegl_jpg_load_get_bounding_box (GeglOperation *operation) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); GeglRectangle result = {0,0,0,0}; gint width, height; gint status; gegl_operation_set_format (operation, "output", babl_format ("R'G'B' u8")); status = gegl_jpg_load_query_jpg (o->path, &width, &height); if (status) { /*g_warning ("calc have rect of %s failed", o->path);*/ result.width = 10; result.height = 10; } else { result.width = width; result.height = height; } return result; }