|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/* This file is an image processing operation for GEGL
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* GEGL is free software; you can redistribute it and/or
|
|
Packit Service |
2781ba |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
2781ba |
* version 3 of the License, or (at your option) any later version.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* GEGL is distributed in the hope that it will be useful,
|
|
Packit Service |
2781ba |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
2781ba |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
2781ba |
* Lesser General Public License for more details.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Copyright 2010 Danny Robson <danny@blubinc.net>
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "config.h"
|
|
Packit Service |
2781ba |
#include <glib/gi18n-lib.h>
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#ifdef GEGL_CHANT_PROPERTIES
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_chant_string (path, _("File"), "",
|
|
Packit Service |
2781ba |
_("Target path and filename, use '-' for stdout."))
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#else
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#define GEGL_CHANT_TYPE_SINK
|
|
Packit Service |
2781ba |
#define GEGL_CHANT_C_FILE "rgbe-save.c"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "gegl-chant.h"
|
|
Packit Service |
2781ba |
#include "rgbe/rgbe.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static const gchar *FORMAT = "RGB float";
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static gboolean
|
|
Packit Service |
2781ba |
gegl_rgbe_save_process (GeglOperation *operation,
|
|
Packit Service |
2781ba |
GeglBuffer *input,
|
|
Packit Service |
2781ba |
const GeglRectangle *rect,
|
|
Packit Service |
2781ba |
gint level)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
|
|
Packit Service |
2781ba |
gfloat *pixels = NULL;
|
|
Packit Service |
2781ba |
gboolean success = FALSE;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
/* Write the scanlines */
|
|
Packit Service |
2781ba |
pixels = g_malloc (rect->width *
|
|
Packit Service |
2781ba |
rect->height *
|
|
Packit Service |
2781ba |
sizeof (pixels[0]) *
|
|
Packit Service |
2781ba |
babl_format_get_n_components (babl_format (FORMAT)));
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_buffer_get (input, rect, 1.0, babl_format (FORMAT), pixels,
|
|
Packit Service |
2781ba |
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (!rgbe_save_path (o->path, rect->width, rect->height, pixels))
|
|
Packit Service |
2781ba |
goto cleanup;
|
|
Packit Service |
2781ba |
success = TRUE;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
cleanup:
|
|
Packit Service |
2781ba |
g_free (pixels);
|
|
Packit Service |
2781ba |
return success;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_chant_class_init (GeglChantClass *klass)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglOperationClass *operation_class;
|
|
Packit Service |
2781ba |
GeglOperationSinkClass *sink_class;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
operation_class = GEGL_OPERATION_CLASS (klass);
|
|
Packit Service |
2781ba |
sink_class = GEGL_OPERATION_SINK_CLASS (klass);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
sink_class->process = gegl_rgbe_save_process;
|
|
Packit Service |
2781ba |
sink_class->needs_full = TRUE;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_operation_class_set_keys (operation_class,
|
|
Packit Service |
2781ba |
"name" , "gegl:rgbe-save",
|
|
Packit Service |
2781ba |
"categories" , "output",
|
|
Packit Service |
2781ba |
"description" ,
|
|
Packit Service |
2781ba |
_("RGBE image saver (Radiance HDR format)"),
|
|
Packit Service |
2781ba |
NULL);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_extension_handler_register_saver (".hdr", "gegl:rgbe-save");
|
|
Packit Service |
2781ba |
gegl_extension_handler_register_saver (".pic", "gegl:rgbe-save");
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#endif
|
|
Packit Service |
2781ba |
|