[mousetrap/gnome3-wip: 58/240] Improve readability of call to Pixbuf.new_from_data.



commit ef7ab7ff0766f59779c9e690db44eb57ecb8d9cc
Author: Stoney Jackson <dr stoney gmail com>
Date:   Wed Jun 4 21:57:41 2014 -0400

    Improve readability of call to Pixbuf.new_from_data.

 src/mousetrap/gui.py |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/src/mousetrap/gui.py b/src/mousetrap/gui.py
index 7c6cde8..b59fab6 100644
--- a/src/mousetrap/gui.py
+++ b/src/mousetrap/gui.py
@@ -38,6 +38,17 @@ def _cvimage_to_pixbuf(cvimage):
     has_alpha_channel = False
     width = cvimage.shape[1]
     height = cvimage.shape[0]
+
+    # dist in bytes between row starts
+    row_stride = cvimage.strides[0]
+
+    # Function used to free the data when the pixbuf's reference count drops to
+    # zero, or None if the data should not be freed.
+    destroy_fn = None
+
+    # Closure data to pass to the destroy notification function.
+    destroy_fn_data = None
+
     return GdkPixbuf.Pixbuf.new_from_data(
             data,
             colorspace, # FIXME: Need to handle grayscale.
@@ -45,9 +56,9 @@ def _cvimage_to_pixbuf(cvimage):
             _GDK_PIXBUF_BIT_PER_SAMPLE,
             width,
             height,
-            cvimage.strides[0], # FIXME: what is this parameter?
-            None, # FIXME: what is this parameter?
-            None  # FIXME: what is this parameter?
+            row_stride,
+            destroy_fn,
+            destroy_fn_data
             )
 
 


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