Commit 2a71ce5e authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

if sample_merged is FALSE and drawable is NULL, just get the image's

2005-07-09  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpimage-pick-color.c (gimp_image_pick_color): if
	sample_merged is FALSE and drawable is NULL, just get the image's
	active drawable instead of bailing out.

	* app/widgets/gimpcursorview.c (gimp_cursor_view_update_cursor):
	use gimp_image_pick_color() insted of duplicating its code.
parent 5b6b74f3
2005-07-09 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-pick-color.c (gimp_image_pick_color): if
sample_merged is FALSE and drawable is NULL, just get the image's
active drawable instead of bailing out.
* app/widgets/gimpcursorview.c (gimp_cursor_view_update_cursor):
use gimp_image_pick_color() insted of duplicating its code.
2005-07-09 Sven Neumann <sven@gimp.org>
* app/widgets/gimpviewabledialog.c: ellipsize the name label.
......
......@@ -43,11 +43,20 @@ gimp_image_pick_color (GimpImage *gimage,
GimpPickable *pickable;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (sample_merged || GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (drawable == NULL || GIMP_IS_DRAWABLE (drawable), FALSE);
g_return_val_if_fail (drawable == NULL ||
gimp_item_get_image (GIMP_ITEM (drawable)) == gimage,
FALSE);
if (! sample_merged)
{
if (! drawable)
drawable = gimp_image_active_drawable (gimage);
if (! drawable)
return FALSE;
}
if (sample_merged)
{
pickable = GIMP_PICKABLE (gimage->projection);
......
......@@ -32,8 +32,8 @@
#include "widgets-types.h"
#include "core/gimpimage.h"
#include "core/gimpimage-pick-color.h"
#include "core/gimpitem.h"
#include "core/gimppickable.h"
#include "core/gimpunit.h"
#include "gimpcolorframe.h"
......@@ -408,8 +408,9 @@ gimp_cursor_view_update_cursor (GimpCursorView *view,
gdouble x,
gdouble y)
{
GimpPickable *pickable = NULL;
guchar *color = NULL;
GimpImageType sample_type;
GimpRGB color;
gint color_index;
g_return_if_fail (GIMP_IS_CURSOR_VIEW (view));
g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image));
......@@ -460,56 +461,17 @@ gimp_cursor_view_update_cursor (GimpCursorView *view,
gtk_label_set_text (GTK_LABEL (view->unit_y_label), _("n/a"));
}
if (image)
{
if (view->sample_merged)
{
pickable = GIMP_PICKABLE (image->projection);
color = gimp_pickable_get_color_at (pickable,
(gint) floor (x),
(gint) floor (y));
}
else
{
GimpDrawable *drawable;
drawable = gimp_image_active_drawable (image);
if (drawable)
{
gint off_x, off_y;
pickable = GIMP_PICKABLE (drawable);
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
color = gimp_pickable_get_color_at (pickable,
((gint) floor (x)) - off_x,
((gint) floor (y)) - off_y);
}
}
}
if (color)
if (image && gimp_image_pick_color (image, NULL,
(gint) floor (x),
(gint) floor (y),
view->sample_merged,
FALSE, 0.0,
&sample_type, &color, &color_index))
{
GimpImageType sample_type;
GimpRGB rgb;
sample_type = gimp_pickable_get_image_type (pickable);
gimp_rgba_set_uchar (&rgb,
color[RED_PIX],
color[GREEN_PIX],
color[BLUE_PIX],
color[ALPHA_PIX]);
gimp_color_frame_set_color (GIMP_COLOR_FRAME (view->color_frame_1),
sample_type, &rgb, color[4]);
sample_type, &color, color_index);
gimp_color_frame_set_color (GIMP_COLOR_FRAME (view->color_frame_2),
sample_type, &rgb, color[4]);
g_free (color);
sample_type, &color, color_index);
}
else
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment