[gimp/goat-invasion: 472/608] app: swallow gimp_temp_buf_demultiply() into gimp_image_get_new_preview()



commit 901303117c360d0d24fa82e5a3dd91aafe31284d
Author: Michael Natterer <mitch gimp org>
Date:   Mon Apr 9 01:52:08 2012 +0200

    app: swallow gimp_temp_buf_demultiply() into gimp_image_get_new_preview()

 app/core/gimpimage-preview.c |   44 ++++++++++++++++++++++++++++++++++-
 app/core/gimptempbuf.c       |   52 ------------------------------------------
 app/core/gimptempbuf.h       |    2 -
 3 files changed, 43 insertions(+), 55 deletions(-)
---
diff --git a/app/core/gimpimage-preview.c b/app/core/gimpimage-preview.c
index ef17b47..12c02f6 100644
--- a/app/core/gimpimage-preview.c
+++ b/app/core/gimpimage-preview.c
@@ -147,7 +147,49 @@ gimp_image_get_new_preview (GimpViewable *viewable,
    *        preview code would know how to deal with pre-multiply alpha.
    */
   if (is_premult)
-    gimp_temp_buf_demultiply (buf);
+    {
+      guchar *data;
+      gint    pixels;
+
+      g_return_if_fail (buf != NULL);
+
+      switch (babl_format_get_bytes_per_pixel (buf->format))
+        {
+        case 1:
+          break;
+
+        case 2:
+          data = gimp_temp_buf_get_data (buf);
+          pixels = buf->width * buf->height;
+          while (pixels--)
+            {
+              data[0] = (data[0] << 8) / (data[1] + 1);
+
+              data += 2;
+            }
+          break;
+
+        case 3:
+          break;
+
+        case 4:
+          data = gimp_temp_buf_get_data (buf);
+          pixels = buf->width * buf->height;
+          while (pixels--)
+            {
+              data[0] = (data[0] << 8) / (data[3] + 1);
+              data[1] = (data[1] << 8) / (data[3] + 1);
+              data[2] = (data[2] << 8) / (data[3] + 1);
+
+              data += 4;
+            }
+          break;
+
+        default:
+          g_warn_if_reached ();
+          break;
+        }
+    }
 
   return buf;
 }
diff --git a/app/core/gimptempbuf.c b/app/core/gimptempbuf.c
index fe10cb0..fe5a0f6 100644
--- a/app/core/gimptempbuf.c
+++ b/app/core/gimptempbuf.c
@@ -149,58 +149,6 @@ gimp_temp_buf_scale (GimpTempBuf *src,
   return dest;
 }
 
-/**
- * gimp_temp_buf_demultiply:
- * @buf:
- *
- * Converts a GimpTempBuf with pre-multiplied alpha to a 'normal' GimpTempBuf.
- */
-void
-gimp_temp_buf_demultiply (GimpTempBuf *buf)
-{
-  guchar *data;
-  gint    pixels;
-
-  g_return_if_fail (buf != NULL);
-
-  switch (babl_format_get_bytes_per_pixel (buf->format))
-    {
-    case 1:
-      break;
-
-    case 2:
-      data = gimp_temp_buf_get_data (buf);
-      pixels = buf->width * buf->height;
-      while (pixels--)
-        {
-          data[0] = (data[0] << 8) / (data[1] + 1);
-
-          data += 2;
-        }
-      break;
-
-    case 3:
-      break;
-
-    case 4:
-      data = gimp_temp_buf_get_data (buf);
-      pixels = buf->width * buf->height;
-      while (pixels--)
-        {
-          data[0] = (data[0] << 8) / (data[3] + 1);
-          data[1] = (data[1] << 8) / (data[3] + 1);
-          data[2] = (data[2] << 8) / (data[3] + 1);
-
-          data += 4;
-        }
-      break;
-
-    default:
-      g_return_if_reached ();
-      break;
-    }
-}
-
 guchar *
 gimp_temp_buf_get_data (const GimpTempBuf *buf)
 {
diff --git a/app/core/gimptempbuf.h b/app/core/gimptempbuf.h
index fe3b072..88207a4 100644
--- a/app/core/gimptempbuf.h
+++ b/app/core/gimptempbuf.h
@@ -45,8 +45,6 @@ GimpTempBuf * gimp_temp_buf_scale         (GimpTempBuf       *buf,
                                            gint               width,
                                            gint               height) G_GNUC_WARN_UNUSED_RESULT;
 
-void          gimp_temp_buf_demultiply    (GimpTempBuf       *buf);
-
 guchar      * gimp_temp_buf_get_data      (const GimpTempBuf *buf);
 gsize         gimp_temp_buf_get_data_size (GimpTempBuf       *buf);
 guchar      * gimp_temp_buf_data_clear    (GimpTempBuf       *buf);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]