[gimp] app: add gimp_image_set_gamma_hack()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add gimp_image_set_gamma_hack()
- Date: Sun, 4 May 2014 18:47:24 +0000 (UTC)
commit 114a9d46be56932f92758c4bd95ed6539e871249
Author: Michael Natterer <mitch gimp org>
Date: Sun May 4 20:38:16 2014 +0200
app: add gimp_image_set_gamma_hack()
Which when enabled casts between linear and gamma-corrected data at
the operation's input and output. This is experimental stuff meant to
properly check ported gegl ops and prepare for plug-in removal.
app/core/gimpimagemap.c | 63 ++++++++++++++++++++++++++++++++++++++++++++---
app/core/gimpimagemap.h | 2 +
2 files changed, 61 insertions(+), 4 deletions(-)
---
diff --git a/app/core/gimpimagemap.c b/app/core/gimpimagemap.c
index ce35fc2..4628009 100644
--- a/app/core/gimpimagemap.c
+++ b/app/core/gimpimagemap.c
@@ -40,6 +40,7 @@
#include "core-types.h"
+#include "gegl/gimp-babl.h"
#include "gegl/gimpapplicator.h"
#include "gimpchannel.h"
@@ -66,6 +67,7 @@ struct _GimpImageMap
GeglNode *operation;
gchar *stock_id;
GimpImageMapRegion region;
+ gboolean gamma_hack;
gboolean filtering;
GeglRectangle filter_area;
@@ -73,6 +75,8 @@ struct _GimpImageMap
GimpFilter *filter;
GeglNode *translate;
GeglNode *crop;
+ GeglNode *cast_before;
+ GeglNode *cast_after;
GimpApplicator *applicator;
};
@@ -208,6 +212,15 @@ gimp_image_map_set_region (GimpImageMap *image_map,
}
void
+gimp_image_map_set_gamma_hack (GimpImageMap *image_map,
+ gboolean gamma_hack)
+{
+ g_return_if_fail (GIMP_IS_IMAGE_MAP (image_map));
+
+ image_map->gamma_hack = gamma_hack;
+}
+
+void
gimp_image_map_apply (GimpImageMap *image_map,
const GeglRectangle *area)
{
@@ -286,6 +299,40 @@ gimp_image_map_apply (GimpImageMap *image_map,
"operation", "gegl:crop",
NULL);
+ if (image_map->gamma_hack)
+ {
+ const Babl *drawable_format;
+ const Babl *cast_format;
+
+ drawable_format = gimp_drawable_get_format (image_map->drawable);
+
+ cast_format =
+ gimp_babl_format (gimp_babl_format_get_base_type (drawable_format),
+ gimp_babl_precision (gimp_babl_format_get_component_type (drawable_format),
+ ! gimp_babl_format_get_linear (drawable_format)),
+ babl_format_has_alpha (drawable_format));
+
+ image_map->cast_before = gegl_node_new_child (filter_node,
+ "operation", "gimp:cast-format",
+ "input-format", drawable_format,
+ "output-format", cast_format,
+ NULL);
+ image_map->cast_after = gegl_node_new_child (filter_node,
+ "operation", "gimp:cast-format",
+ "input-format", cast_format,
+ "output-format", drawable_format,
+ NULL);
+ }
+ else
+ {
+ image_map->cast_before = gegl_node_new_child (filter_node,
+ "operation", "gegl:nop",
+ NULL);
+ image_map->cast_after = gegl_node_new_child (filter_node,
+ "operation", "gegl:nop",
+ NULL);
+ }
+
input = gegl_node_get_input_proxy (filter_node, "input");
if (gegl_node_has_pad (image_map->operation, "input") &&
@@ -297,10 +344,12 @@ gimp_image_map_apply (GimpImageMap *image_map,
gegl_node_link_many (input,
image_map->translate,
image_map->crop,
+ image_map->cast_before,
image_map->operation,
+ image_map->cast_after,
NULL);
- filter_output = image_map->operation;
+ filter_output = image_map->cast_after;
}
else if (gegl_node_has_pad (image_map->operation, "output"))
{
@@ -318,8 +367,12 @@ gimp_image_map_apply (GimpImageMap *image_map,
over,
NULL);
- gegl_node_connect_to (image_map->operation, "output",
- over, "aux");
+ gegl_node_link_many (image_map->operation,
+ image_map->cast_after,
+ NULL);
+
+ gegl_node_connect_to (image_map->cast_after, "output",
+ over, "aux");
filter_output = over;
}
@@ -330,9 +383,11 @@ gimp_image_map_apply (GimpImageMap *image_map,
gegl_node_link_many (input,
image_map->translate,
image_map->crop,
+ image_map->cast_before,
+ image_map->cast_after,
NULL);
- filter_output = image_map->crop;
+ filter_output = image_map->cast_after;
}
gegl_node_connect_to (filter_output, "output",
diff --git a/app/core/gimpimagemap.h b/app/core/gimpimagemap.h
index 1027d19..e7aebf8 100644
--- a/app/core/gimpimagemap.h
+++ b/app/core/gimpimagemap.h
@@ -63,6 +63,8 @@ GimpImageMap * gimp_image_map_new (GimpDrawable *drawable,
void gimp_image_map_set_region (GimpImageMap *image_map,
GimpImageMapRegion region);
+void gimp_image_map_set_gamma_hack (GimpImageMap *image_map,
+ gboolean gamma_hack);
void gimp_image_map_apply (GimpImageMap *image_map,
const GeglRectangle *area);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]