[gimp/metadata-browser] app: remove "bytes" from GimpBuffer and add a format API



commit e99f5899a965e1384a4f95f463fbb882869efb06
Author: Michael Natterer <mitch gimp org>
Date:   Sat Mar 31 19:31:43 2012 +0200

    app: remove "bytes" from GimpBuffer and add a format API
    
    and change all users accordingly.

 app/core/gimpbuffer.c           |   22 +++++++++++-----------
 app/core/gimpbuffer.h           |    2 +-
 app/core/gimppatternclipboard.c |   18 +++++++++---------
 app/pdb/buffer-cmds.c           |    6 +++++-
 tools/pdbgen/pdb/buffer.pdb     |    6 +++++-
 5 files changed, 31 insertions(+), 23 deletions(-)
---
diff --git a/app/core/gimpbuffer.c b/app/core/gimpbuffer.c
index a64fef3..8f31d69 100644
--- a/app/core/gimpbuffer.c
+++ b/app/core/gimpbuffer.c
@@ -196,19 +196,19 @@ gimp_buffer_get_new_preview (GimpViewable *viewable,
                              gint          height)
 {
   GimpBuffer *buffer = GIMP_BUFFER (viewable);
+  const Babl *format = gimp_buffer_get_format (buffer);
   TempBuf    *preview;
 
-  preview = temp_buf_new (width, height, gimp_buffer_get_bytes (buffer),
+  preview = temp_buf_new (width, height,
+                          babl_format_get_bytes_per_pixel (format),
                           0, 0, NULL);
 
-  gegl_buffer_get (buffer->buffer,
-                   NULL,
-                   MIN ((gdouble) width / (gdouble) gimp_buffer_get_width (buffer),
+  gegl_buffer_get (buffer->buffer, NULL,
+                   MIN ((gdouble) width  / (gdouble) gimp_buffer_get_width (buffer),
                         (gdouble) height / (gdouble) gimp_buffer_get_height (buffer)),
-                   gimp_bpp_to_babl_format (gimp_buffer_get_bytes (buffer)),
+                   NULL,
                    temp_buf_get_data (preview),
-                   width * gimp_buffer_get_bytes (buffer),
-                   GEGL_ABYSS_NONE);
+                   GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
 
   return preview;
 }
@@ -296,12 +296,12 @@ gimp_buffer_get_height (const GimpBuffer *buffer)
   return gegl_buffer_get_height (buffer->buffer);
 }
 
-gint
-gimp_buffer_get_bytes (const GimpBuffer *buffer)
+const Babl *
+gimp_buffer_get_format (const GimpBuffer *buffer)
 {
-  g_return_val_if_fail (GIMP_IS_BUFFER (buffer), 0);
+  g_return_val_if_fail (GIMP_IS_BUFFER (buffer), NULL);
 
-  return GIMP_IMAGE_TYPE_BYTES (buffer->image_type);
+  return gegl_buffer_get_format (buffer->buffer);
 }
 
 GimpImageType
diff --git a/app/core/gimpbuffer.h b/app/core/gimpbuffer.h
index ee10a5e..3909c91 100644
--- a/app/core/gimpbuffer.h
+++ b/app/core/gimpbuffer.h
@@ -63,8 +63,8 @@ GimpBuffer    * gimp_buffer_new_from_pixbuf (GdkPixbuf        *pixbuf,
 
 gint            gimp_buffer_get_width       (const GimpBuffer *buffer);
 gint            gimp_buffer_get_height      (const GimpBuffer *buffer);
+const Babl    * gimp_buffer_get_format      (const GimpBuffer *buffer);
 
-gint            gimp_buffer_get_bytes       (const GimpBuffer *buffer);
 GimpImageType   gimp_buffer_get_image_type  (const GimpBuffer *buffer);
 GeglBuffer    * gimp_buffer_get_buffer      (const GimpBuffer *buffer);
 
diff --git a/app/core/gimppatternclipboard.c b/app/core/gimppatternclipboard.c
index f685980..5d155d8 100644
--- a/app/core/gimppatternclipboard.c
+++ b/app/core/gimppatternclipboard.c
@@ -188,23 +188,23 @@ gimp_pattern_clipboard_buffer_changed (Gimp        *gimp,
 
   if (gimp->global_buffer)
     {
-      GimpBuffer    *buffer = gimp->global_buffer;
-      gint           width;
-      gint           height;
-      gint           bytes;
+      GimpBuffer *buffer = gimp->global_buffer;
+      const Babl *format = gimp_buffer_get_format (buffer);
+      gint        width;
+      gint        height;
+      gint        bytes;
 
       width  = MIN (gimp_buffer_get_width  (buffer), 512);
       height = MIN (gimp_buffer_get_height (buffer), 512);
-      bytes  = gimp_buffer_get_bytes (buffer);
+      bytes  = babl_format_get_bytes_per_pixel (format);
 
       pattern->mask = temp_buf_new (width, height, bytes, 0, 0, NULL);
 
       gegl_buffer_get (gimp_buffer_get_buffer (buffer),
-                       GIMP_GEGL_RECT (0,0,width,height), 1.0,
-                       gimp_bpp_to_babl_format (bytes),
+                       GIMP_GEGL_RECT (0, 0, width, height), 1.0,
+                       NULL,
                        temp_buf_get_data (pattern->mask),
-                       width * gimp_buffer_get_bytes (buffer),
-                       GEGL_ABYSS_NONE);
+                       GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
     }
   else
     {
diff --git a/app/pdb/buffer-cmds.c b/app/pdb/buffer-cmds.c
index 5b48573..48e0c18 100644
--- a/app/pdb/buffer-cmds.c
+++ b/app/pdb/buffer-cmds.c
@@ -225,7 +225,11 @@ buffer_get_bytes_invoker (GimpProcedure      *procedure,
       GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error);
 
       if (buffer)
-        bytes = gimp_buffer_get_bytes (buffer);
+        {
+          const Babl *format = gimp_buffer_get_format (buffer);
+
+          bytes = babl_format_get_bytes_per_pixel (format);
+        }
       else
         success = FALSE;
     }
diff --git a/tools/pdbgen/pdb/buffer.pdb b/tools/pdbgen/pdb/buffer.pdb
index ffb3aa4..943e3b3 100644
--- a/tools/pdbgen/pdb/buffer.pdb
+++ b/tools/pdbgen/pdb/buffer.pdb
@@ -191,7 +191,11 @@ sub buffer_get_bytes {
   GimpBuffer *buffer = gimp_pdb_get_buffer (gimp, buffer_name, error);
 
   if (buffer)
-    bytes = gimp_buffer_get_bytes (buffer);
+    {
+      const Babl *format = gimp_buffer_get_format (buffer);
+
+      bytes = babl_format_get_bytes_per_pixel (format);
+    }
   else
     success = FALSE;
 }



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