[gimp/goat-invasion: 115/234] app: use Babl in gimp_brush_core_paint_line_pixmap_mask()
- From: Ãyvind KolÃs <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/goat-invasion: 115/234] app: use Babl in gimp_brush_core_paint_line_pixmap_mask()
- Date: Fri, 23 Mar 2012 12:03:04 +0000 (UTC)
commit b3b4e19c9e916fbf16ad42c1f30548fbcd8a7ca4
Author: Michael Natterer <mitch gimp org>
Date: Sun Mar 18 13:50:28 2012 +0100
app: use Babl in gimp_brush_core_paint_line_pixmap_mask()
to convert the brush pixmap's colors. This code still needs some
love...
app/paint/gimpbrushcore.c | 31 +++++++++++++++++--------------
1 files changed, 17 insertions(+), 14 deletions(-)
---
diff --git a/app/paint/gimpbrushcore.c b/app/paint/gimpbrushcore.c
index 21d5b97..aea5d7e 100644
--- a/app/paint/gimpbrushcore.c
+++ b/app/paint/gimpbrushcore.c
@@ -1604,13 +1604,13 @@ gimp_brush_core_paint_line_pixmap_mask (GimpImage *dest,
gint width,
GimpBrushApplicationMode mode)
{
- const guchar *mask;
- guchar *b;
- guchar *p;
- gdouble alpha;
- const gdouble factor = 0.00392156986; /* 1.0 / 255.0 */
- gint x_index;
- gint i;
+ const Babl *fish;
+ guchar *b;
+ guchar *p;
+ gint i;
+
+ fish = babl_fish (babl_format ("RGB u8"), /* brush's pixmap is flat */
+ gimp_drawable_get_babl_format (drawable));
/* Make sure x, y are positive */
while (x < 0)
@@ -1627,12 +1627,15 @@ gimp_brush_core_paint_line_pixmap_mask (GimpImage *dest,
/* ditto, except for the brush mask, so we can pre-multiply the
* alpha value
*/
- mask = (temp_buf_get_data (brush_mask) +
- (y % brush_mask->height) * brush_mask->width);
+ const guchar *mask = (temp_buf_get_data (brush_mask) +
+ (y % brush_mask->height) * brush_mask->width);
for (i = 0; i < width; i++)
{
- gint byte_loop;
+ const gdouble factor = 1.0 / 255.0;
+ gint x_index;
+ gint byte_loop;
+ gdouble alpha;
/* attempt to avoid doing this calc twice in the loop */
x_index = ((i + x) % pixmap_mask->width);
@@ -1648,8 +1651,7 @@ gimp_brush_core_paint_line_pixmap_mask (GimpImage *dest,
for (byte_loop = 0; byte_loop < bytes - 1; byte_loop++)
d[byte_loop] *= alpha;
- gimp_image_transform_color (dest, gimp_drawable_type (drawable), d,
- GIMP_RGB, p);
+ babl_process (fish, p, d, 1);
d += bytes;
}
}
@@ -1657,6 +1659,8 @@ gimp_brush_core_paint_line_pixmap_mask (GimpImage *dest,
{
for (i = 0; i < width; i++)
{
+ gint x_index;
+
/* attempt to avoid doing this calc twice in the loop */
x_index = ((i + x) % pixmap_mask->width);
p = b + x_index * pixmap_mask->bytes;
@@ -1666,8 +1670,7 @@ gimp_brush_core_paint_line_pixmap_mask (GimpImage *dest,
* maybe we could do this at tool creation or brush switch time?
* and compute it for the whole brush at once and cache it?
*/
- gimp_image_transform_color (dest, gimp_drawable_type (drawable), d,
- GIMP_RGB, p);
+ babl_process (fish, p, d, 1);
d += bytes;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]