[gimp/gimp-2-8] Use the Quartz core graphics API to implement gimp_pick_button_pick when building with GDK Quartz.



commit e2f93a777930916cb9487fd7048c62738f6ea2c8
Author: Daniel Sabo <DanielSabo gmail com>
Date:   Mon May 28 07:36:36 2012 -0700

    Use the Quartz core graphics API to implement gimp_pick_button_pick when building with GDK Quartz.
    
    Signed-off-by: Clayton Walker <clayton m walker gmail com>

 libgimpwidgets/gimppickbutton.c |   24 ++++++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/libgimpwidgets/gimppickbutton.c b/libgimpwidgets/gimppickbutton.c
index 05482a7..12bcdef 100644
--- a/libgimpwidgets/gimppickbutton.c
+++ b/libgimpwidgets/gimppickbutton.c
@@ -34,6 +34,9 @@
 
 #include "libgimp/libgimp-intl.h"
 
+#ifdef GDK_WINDOWING_QUARTZ
+#include <ApplicationServices/ApplicationServices.h>
+#endif
 
 /**
  * SECTION: gimppickbutton
@@ -364,6 +367,7 @@ gimp_pick_button_pick (GdkScreen      *screen,
                        gint            y_root,
                        GimpPickButton *button)
 {
+  #ifndef GDK_WINDOWING_QUARTZ
   GdkWindow       *root_window = gdk_screen_get_root_window (screen);
   cairo_surface_t *image;
   cairo_t         *cr;
@@ -387,5 +391,25 @@ gimp_pick_button_pick (GdkScreen      *screen,
 
   gimp_rgba_set_uchar (&rgb, color[0], color[1], color[2], 1.0);
 
+  #else /* GDK_WINDOWING_QUARTZ */
+  CGImageRef    root_image_ref;
+  CFDataRef     pixel_data;
+  const guchar *data;
+  GimpRGB       rgb;
+
+  CGRect rect = CGRectMake (x_root, y_root, 1, 1);
+  root_image_ref = CGWindowListCreateImage (rect,
+                                            kCGWindowListOptionOnScreenOnly,
+                                            kCGNullWindowID,
+                                            kCGWindowImageDefault);
+  pixel_data = CGDataProviderCopyData(CGImageGetDataProvider(root_image_ref));
+  data = CFDataGetBytePtr(pixel_data);
+
+  gimp_rgba_set_uchar (&rgb, data[2], data[1], data[0], 1.0);
+
+  CGImageRelease (root_image_ref);
+  CFRelease (pixel_data);
+  #endif /* GDK_WINDOWING_QUARTZ */
+
   g_signal_emit (button, pick_button_signals[COLOR_PICKED], 0, &rgb);
 }


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