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



commit e6ed0a4c500b8bf5435f4eb7ab13a31379acb4e1
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 f1e2f31..ddc073d 100644
--- a/libgimpwidgets/gimppickbutton.c
+++ b/libgimpwidgets/gimppickbutton.c
@@ -35,6 +35,9 @@
 
 #include "libgimp/libgimp-intl.h"
 
+#ifdef GDK_WINDOWING_QUARTZ
+#include <ApplicationServices/ApplicationServices.h>
+#endif
 
 /**
  * SECTION: gimppickbutton
@@ -354,6 +357,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;
@@ -377,5 +381,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]