diff --git a/libgimpwidgets/gimppickbutton-default.c b/libgimpwidgets/gimppickbutton-default.c index 38c160ca49..c6f33007f3 100644 --- a/libgimpwidgets/gimppickbutton-default.c +++ b/libgimpwidgets/gimppickbutton-default.c @@ -185,7 +185,7 @@ gimp_pick_button_pick (GimpPickButton *button, GdkScreen *screen = gdk_event_get_screen (event); GimpColorProfile *monitor_profile; GdkMonitor *monitor; - GeglColor *rgb = gegl_color_new ("none"); + GeglColor *rgb = gegl_color_new ("black"); const Babl *space = NULL; gint x_root; gint y_root; @@ -212,6 +212,7 @@ gimp_pick_button_pick (GimpPickButton *button, HDC hdc; RECT rect; COLORREF win32_color; + guchar temp_rgb[3]; /* For MS Windows, use native GDI functions to get the pixel, as * cairo does not handle the case where you have multiple monitors @@ -225,12 +226,12 @@ gimp_pick_button_pick (GimpPickButton *button, win32_color = GetPixel (hdc, x_root + rect.left, y_root + rect.top); ReleaseDC (HWND_DESKTOP, hdc); - gegl_color_set_rgba_with_space (rgb, - GetRValue (win32_color) / 255.0, - GetGValue (win32_color) / 255.0, - GetBValue (win32_color) / 255.0, - 1.0, - space); + temp_rgb[0] = GetRValue (win32_color); + temp_rgb[1] = GetGValue (win32_color); + temp_rgb[2] = GetBValue (win32_color); + + gegl_color_set_pixel (rgb, babl_format_with_space ("R'G'B' u8", space), + temp_rgb); } #else @@ -273,12 +274,8 @@ gimp_pick_button_pick (GimpPickButton *button, cairo_surface_destroy (image); - gegl_color_set_rgba_with_space (rgb, - color[0] / 255.0, - color[1] / 255.0, - color[2] / 255.0, - 1.0, - space); + gegl_color_set_pixel (rgb, babl_format_with_space ("R'G'B' u8", space), + color); } #endif diff --git a/libgimpwidgets/gimppickbutton-kwin.c b/libgimpwidgets/gimppickbutton-kwin.c index e37462bcda..25280241e6 100644 --- a/libgimpwidgets/gimppickbutton-kwin.c +++ b/libgimpwidgets/gimppickbutton-kwin.c @@ -82,17 +82,19 @@ _gimp_pick_button_kwin_pick (GimpPickButton *button) -1, NULL, &error); if (retval) { - GeglColor *rgb = gegl_color_new ("none"); + GeglColor *rgb = gegl_color_new ("black"); guint32 color; + guchar temp_rgba[4]; g_variant_get (retval, "((u))", &color); g_variant_unref (retval); /* Returned value is ARGB stored in uint32. */ - gegl_color_set_rgba (rgb, - ((color >> 16) & 0xff) / 255.0, /* Red */ - ((color >> 8) & 0xff) / 255.0, /* Green */ - (color & 0xff) / 255.0, /* Blue: least significant byte. */ - ((color >> 24) & 0xff) / 255.0); /* Alpha: most significant byte. */ + temp_rgba[0] = (color >> 16) & 0xff; /* Red */ + temp_rgba[1] = (color >> 8) & 0xff; /* Green */ + temp_rgba[2] = color & 0xff; /* Blue: least significant byte. */ + temp_rgba[3] = (color >> 24) & 0xff; /* Alpha: most significant byte. */ + + gegl_color_set_pixel (rgb, babl_format ("R'G'B'A u8"), temp_rgba); g_signal_emit_by_name (button, "color-picked", rgb); g_object_unref (rgb); diff --git a/libgimpwidgets/gimppickbutton-quartz.c b/libgimpwidgets/gimppickbutton-quartz.c index e948aa53e2..9981e575f6 100644 --- a/libgimpwidgets/gimppickbutton-quartz.c +++ b/libgimpwidgets/gimppickbutton-quartz.c @@ -156,7 +156,8 @@ CGImageRef root_image_ref; CFDataRef pixel_data; const guchar *data; - GeglColor *rgb = gegl_color_new ("none"); + GeglColor *rgb = gegl_color_new ("black"); + guchar temp_rgb[3]; const Babl *space = NULL; NSPoint point; GimpColorProfile *profile = NULL; @@ -212,12 +213,11 @@ g_object_unref (profile); } - gegl_color_set_rgba_with_space (rgb, - data[2] / 255.0, - data[1] / 255.0, - data[0] / 255.0, - 1.0, - space); + for (gint i = 0; i < 3; i++) + temp_rgb[i] = data[2 - i]; + + gegl_color_set_pixel (rgb, babl_format_with_space ("R'G'B' u8", space), + temp_rgb); CGImageRelease (root_image_ref); CFRelease (pixel_data); diff --git a/libgimpwidgets/gimppickbutton-win32.c b/libgimpwidgets/gimppickbutton-win32.c index 367919a138..693d79a4a3 100644 --- a/libgimpwidgets/gimppickbutton-win32.c +++ b/libgimpwidgets/gimppickbutton-win32.c @@ -1072,9 +1072,10 @@ remove_screen_tracking (void) static GeglColor * pick_color_with_gdi (POINT physical_point) { - GeglColor *rgb = gegl_color_new ("none"); + GeglColor *rgb = gegl_color_new ("black"); COLORREF color; HDC hdc; + guchar temp_rgb[3]; hdc = GetDC (HWND_DESKTOP); @@ -1083,11 +1084,11 @@ pick_color_with_gdi (POINT physical_point) color = GetPixel (hdc, physical_point.x, physical_point.y); - gegl_color_set_rgba (rgb, - GetRValue (color) / 255.0, - GetGValue (color) / 255.0, - GetBValue (color) / 255.0, - 1.0); + temp_rgb[0] = GetRValue (color); + temp_rgb[1] = GetGValue (color); + temp_rgb[2] = GetBValue (color); + + gegl_color_set_pixel (rgb, babl_format ("R'G'B' u8"), temp_rgb); ReleaseDC (HWND_DESKTOP, hdc); @@ -1099,7 +1100,7 @@ user_picked (MonitorData *monitor, POINT physical_point) { GeglColor *rgb; - GList *l; + GList *l; /* Currently unused */ (void) monitor;