[gimp/goat-invasion: 404/418] app: add gimp_gegl_dodgeburn() to replace the lut in GimpDodgeBurn
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 404/418] app: add gimp_gegl_dodgeburn() to replace the lut in GimpDodgeBurn
- Date: Wed, 4 Apr 2012 10:59:45 +0000 (UTC)
commit 9118ae163bd14523f6ddf7ea9852a1867deea64d
Author: Michael Natterer <mitch gimp org>
Date: Mon Apr 2 19:17:06 2012 +0200
app: add gimp_gegl_dodgeburn() to replace the lut in GimpDodgeBurn
app/gegl/gimp-gegl-loops.c | 118 ++++++++++++++++++++++++++++++++++++++++++++
app/gegl/gimp-gegl-loops.h | 26 ++++++---
2 files changed, 135 insertions(+), 9 deletions(-)
---
diff --git a/app/gegl/gimp-gegl-loops.c b/app/gegl/gimp-gegl-loops.c
index 9b26af2..38298da 100644
--- a/app/gegl/gimp-gegl-loops.c
+++ b/app/gegl/gimp-gegl-loops.c
@@ -189,3 +189,121 @@ gimp_gegl_convolve (GeglBuffer *src_buffer,
}
}
}
+
+void
+gimp_gegl_dodgeburn (GeglBuffer *src_buffer,
+ const GeglRectangle *src_rect,
+ GeglBuffer *dest_buffer,
+ const GeglRectangle *dest_rect,
+ gdouble exposure,
+ GimpDodgeBurnType type,
+ GimpTransferMode mode)
+{
+ GeglBufferIterator *iter;
+
+ if (type == GIMP_BURN)
+ exposure = -exposure;
+
+ iter = gegl_buffer_iterator_new (src_buffer, src_rect, 0,
+ babl_format ("R'G'B'A float"),
+ GEGL_BUFFER_READ, GEGL_ABYSS_NONE);
+
+ gegl_buffer_iterator_add (iter, dest_buffer, dest_rect, 0,
+ babl_format ("R'G'B'A float"),
+ GEGL_BUFFER_WRITE, GEGL_ABYSS_NONE);
+
+ switch (mode)
+ {
+ gfloat factor;
+
+ case GIMP_HIGHLIGHTS:
+ factor = 1.0 + exposure * (0.333333);
+
+ while (gegl_buffer_iterator_next (iter))
+ {
+ gfloat *src = iter->data[0];
+ gfloat *dest = iter->data[1];
+
+ while (iter->length--)
+ {
+ *dest++ = *src++ * factor;
+ *dest++ = *src++ * factor;
+ *dest++ = *src++ * factor;
+
+ *dest++ = *src++;
+ }
+ }
+ break;
+
+ case GIMP_MIDTONES:
+ if (exposure < 0)
+ factor = 1.0 - exposure * (0.333333);
+ else
+ factor = 1.0 / (1.0 + exposure);
+
+ while (gegl_buffer_iterator_next (iter))
+ {
+ gfloat *src = iter->data[0];
+ gfloat *dest = iter->data[1];
+
+ while (iter->length--)
+ {
+ *dest++ = pow (*src++, factor);
+ *dest++ = pow (*src++, factor);
+ *dest++ = pow (*src++, factor);
+
+ *dest++ = *src++;
+ }
+ }
+ break;
+
+ case GIMP_SHADOWS:
+ if (exposure >= 0)
+ factor = 0.333333 * exposure;
+ else
+ factor = -0.333333 * exposure;
+
+ while (gegl_buffer_iterator_next (iter))
+ {
+ gfloat *src = iter->data[0];
+ gfloat *dest = iter->data[1];
+
+ while (iter->length--)
+ {
+ if (exposure >= 0)
+ {
+ gfloat s;
+
+ s = *src++; *dest++ = factor + s - factor * s;
+ s = *src++; *dest++ = factor + s - factor * s;
+ s = *src++; *dest++ = factor + s - factor * s;
+ }
+ else
+ {
+ gfloat s;
+
+ s = *src++;
+ if (s < factor)
+ *dest++ = 0;
+ else /* factor <= value <=1 */
+ *dest++ = (s - factor) / (1.0 - factor);
+
+ s = *src++;
+ if (s < factor)
+ *dest++ = 0;
+ else /* factor <= value <=1 */
+ *dest++ = (s - factor) / (1.0 - factor);
+
+ s = *src++;
+ if (s < factor)
+ *dest++ = 0;
+ else /* factor <= value <=1 */
+ *dest++ = (s - factor) / (1.0 - factor);
+ }
+
+ *dest++ = *src++;
+ }
+ }
+ break;
+ }
+}
diff --git a/app/gegl/gimp-gegl-loops.h b/app/gegl/gimp-gegl-loops.h
index 6c49216..866d2a0 100644
--- a/app/gegl/gimp-gegl-loops.h
+++ b/app/gegl/gimp-gegl-loops.h
@@ -25,15 +25,23 @@
/* this is a pretty stupid port of concolve_region() that only works
* on a linear source buffer
*/
-void gimp_gegl_convolve (GeglBuffer *src_buffer,
- const GeglRectangle *src_rect,
- GeglBuffer *dest_buffer,
- const GeglRectangle *dest_rect,
- const gfloat *matrix,
- gint size,
- gdouble divisor,
- GimpConvolutionType mode,
- gboolean alpha_weighting);
+void gimp_gegl_convolve (GeglBuffer *src_buffer,
+ const GeglRectangle *src_rect,
+ GeglBuffer *dest_buffer,
+ const GeglRectangle *dest_rect,
+ const gfloat *matrix,
+ gint size,
+ gdouble divisor,
+ GimpConvolutionType mode,
+ gboolean alpha_weighting);
+
+void gimp_gegl_dodgeburn (GeglBuffer *src_buffer,
+ const GeglRectangle *src_rect,
+ GeglBuffer *dest_buffer,
+ const GeglRectangle *dest_rect,
+ gdouble exposure,
+ GimpDodgeBurnType type,
+ GimpTransferMode mode);
#endif /* __GIMP_GEGL_LOOPS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]