libgimpwidgets: port GimpPickButton color picking to cairo
This commit is contained in:
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "gimpwidgetstypes.h"
|
#include "gimpwidgetstypes.h"
|
||||||
|
|
||||||
|
#include "gimpcairo-utils.h"
|
||||||
#include "gimphelpui.h"
|
#include "gimphelpui.h"
|
||||||
#include "gimppickbutton.h"
|
#include "gimppickbutton.h"
|
||||||
#include "gimpstock.h"
|
#include "gimpstock.h"
|
||||||
@ -387,25 +388,28 @@ gimp_pick_button_pick (GdkScreen *screen,
|
|||||||
gint y_root,
|
gint y_root,
|
||||||
GimpPickButton *button)
|
GimpPickButton *button)
|
||||||
{
|
{
|
||||||
GdkColormap *colormap = gdk_screen_get_system_colormap (screen);
|
GdkWindow *root_window = gdk_screen_get_root_window (screen);
|
||||||
GdkWindow *root_window = gdk_screen_get_root_window (screen);
|
cairo_surface_t *image;
|
||||||
GdkImage *image;
|
cairo_t *cr;
|
||||||
guint32 pixel;
|
guchar *data;
|
||||||
GdkColor color;
|
guchar color[3];
|
||||||
GimpRGB rgb;
|
GimpRGB rgb;
|
||||||
|
|
||||||
image = gdk_drawable_get_image (GDK_DRAWABLE (root_window),
|
image = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 1, 1);
|
||||||
x_root, y_root, 1, 1);
|
|
||||||
pixel = gdk_image_get_pixel (image, 0, 0);
|
|
||||||
g_object_unref (image);
|
|
||||||
|
|
||||||
gdk_colormap_query_color (colormap, pixel, &color);
|
cr = cairo_create (image);
|
||||||
|
|
||||||
gimp_rgba_set (&rgb,
|
gdk_cairo_set_source_pixmap (cr, root_window, -x_root, -y_root);
|
||||||
color.red / 65535.0,
|
cairo_paint (cr);
|
||||||
color.green / 65535.0,
|
|
||||||
color.blue / 65535.0,
|
cairo_destroy (cr);
|
||||||
1.0);
|
|
||||||
|
data = cairo_image_surface_get_data (image);
|
||||||
|
GIMP_CAIRO_RGB24_GET_PIXEL (data, color[0], color[1], color[2]);
|
||||||
|
|
||||||
|
cairo_surface_destroy (image);
|
||||||
|
|
||||||
|
gimp_rgba_set_uchar (&rgb, color[0], color[1], color[2], 1.0);
|
||||||
|
|
||||||
g_signal_emit (button, pick_button_signals[COLOR_PICKED], 0, &rgb);
|
g_signal_emit (button, pick_button_signals[COLOR_PICKED], 0, &rgb);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user