[gimp] app: port GimpInk mask painting from guchar to float
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: port GimpInk mask painting from guchar to float
- Date: Tue, 18 Sep 2012 22:08:32 +0000 (UTC)
commit e8937b2f51ca83c1f16f2877af44cd9c140b8711
Author: Michael Natterer <mitch gimp org>
Date: Wed Sep 19 00:07:32 2012 +0200
app: port GimpInk mask painting from guchar to float
app/paint/gimpink.c | 24 ++++++++++++++----------
1 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/app/paint/gimpink.c b/app/paint/gimpink.c
index d61d9b8..9eddd17 100644
--- a/app/paint/gimpink.c
+++ b/app/paint/gimpink.c
@@ -516,13 +516,17 @@ insert_sort (gint *data,
}
static void
-fill_run (guchar *dest,
- guchar alpha,
+fill_run (gfloat *dest,
+ gfloat alpha,
gint w)
{
- if (alpha == 255)
+ if (alpha == 1.0)
{
- memset (dest, 255, w);
+ while (w--)
+ {
+ *dest = 1.0;
+ dest++;
+ }
}
else
{
@@ -536,7 +540,7 @@ fill_run (guchar *dest,
static void
render_blob_line (GimpBlob *blob,
- guchar *dest,
+ gfloat *dest,
gint x,
gint y,
gint width)
@@ -606,7 +610,7 @@ render_blob_line (GimpBlob *blob,
/* Fill in portion leading up to this pixel */
if (current && cur_x != last_x)
- fill_run (dest + last_x, (255 * current) / SUBSAMPLE, cur_x - last_x);
+ fill_run (dest + last_x, (gfloat) current / SUBSAMPLE, cur_x - last_x);
/* Compute the value for this pixel */
pixel = current * SUBSAMPLE;
@@ -632,13 +636,13 @@ render_blob_line (GimpBlob *blob,
i++;
}
- dest[cur_x] = MAX (dest[cur_x], (pixel * 255) / (SUBSAMPLE * SUBSAMPLE));
+ dest[cur_x] = MAX (dest[cur_x], (gfloat) pixel / (SUBSAMPLE * SUBSAMPLE));
last_x = cur_x + 1;
}
if (current != 0)
- fill_run (dest + last_x, (255 * current)/ SUBSAMPLE, width - last_x);
+ fill_run (dest + last_x, (gfloat) current / SUBSAMPLE, width - last_x);
}
static void
@@ -649,13 +653,13 @@ render_blob (GeglBuffer *buffer,
GeglBufferIterator *iter;
GeglRectangle *roi;
- iter = gegl_buffer_iterator_new (buffer, rect, 0, babl_format ("Y u8"),
+ iter = gegl_buffer_iterator_new (buffer, rect, 0, babl_format ("Y float"),
GEGL_BUFFER_READWRITE, GEGL_ABYSS_NONE);
roi = &iter->roi[0];
while (gegl_buffer_iterator_next (iter))
{
- guchar *d = iter->data[0];
+ gfloat *d = iter->data[0];
gint h = roi->height;
gint y;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]