mirror of https://github.com/GNOME/gimp.git
removed get_color_at() from the GimpPickable interface. Implement the same
2007-05-02 Sven Neumann <sven@gimp.org> * app/core/gimppickable.[ch]: removed get_color_at() from the GimpPickable interface. Implement the same functionality using get_pixel_at() but with a saner API. * app/core/gimpdrawable.c * app/core/gimpprojection.c * app/core/gimpimagemap.c: removed get_color_at() implementations. * app/tools/gimpbycolorselecttool.c: adapt to API change of gimp_pickable_get_color_at(). * app/tools/gimprectangleselecttool.c: added missing include. svn path=/trunk/; revision=22383
This commit is contained in:
parent
798f694fce
commit
c70b55a403
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2007-05-02 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/gimppickable.[ch]: removed get_color_at() from the
|
||||
GimpPickable interface. Implement the same functionality using
|
||||
get_pixel_at() but with a saner API.
|
||||
|
||||
* app/core/gimpdrawable.c
|
||||
* app/core/gimpprojection.c
|
||||
* app/core/gimpimagemap.c: removed get_color_at() implementations.
|
||||
|
||||
* app/tools/gimpbycolorselecttool.c: adapt to API change of
|
||||
gimp_pickable_get_color_at().
|
||||
|
||||
* app/tools/gimprectangleselecttool.c: added missing include.
|
||||
|
||||
2007-05-02 Mukund Sivaraman <muks@mukund.org>
|
||||
|
||||
* plug-ins/common/svg.c: Make size loading work properly with
|
||||
|
|
|
@ -119,10 +119,6 @@ static gboolean gimp_drawable_get_pixel_at (GimpPickable *pickable,
|
|||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
static guchar * gimp_drawable_get_color_at (GimpPickable *pickable,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
static void gimp_drawable_real_update (GimpDrawable *drawable,
|
||||
gint x,
|
||||
gint y,
|
||||
|
@ -241,7 +237,6 @@ gimp_drawable_pickable_iface_init (GimpPickableInterface *iface)
|
|||
iface->get_bytes = (gint (*) (GimpPickable *pickable)) gimp_drawable_bytes;
|
||||
iface->get_tiles = (TileManager * (*) (GimpPickable *pickable)) gimp_drawable_get_tiles;
|
||||
iface->get_pixel_at = gimp_drawable_get_pixel_at;
|
||||
iface->get_color_at = gimp_drawable_get_color_at;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -611,32 +606,6 @@ gimp_drawable_get_pixel_at (GimpPickable *pickable,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static guchar *
|
||||
gimp_drawable_get_color_at (GimpPickable *pickable,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
GimpDrawable *drawable = GIMP_DRAWABLE (pickable);
|
||||
guchar *dest;
|
||||
guchar pixel[4];
|
||||
|
||||
if (! gimp_drawable_get_pixel_at (pickable, x, y, pixel))
|
||||
return NULL;
|
||||
|
||||
dest = g_new (guchar, 5);
|
||||
|
||||
gimp_image_get_color (gimp_item_get_image (GIMP_ITEM (drawable)),
|
||||
gimp_drawable_type (drawable),
|
||||
pixel, dest);
|
||||
|
||||
if (gimp_drawable_is_indexed (drawable))
|
||||
dest[4] = pixel[0];
|
||||
else
|
||||
dest[4] = 0;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_drawable_real_update (GimpDrawable *drawable,
|
||||
gint x,
|
||||
|
|
|
@ -73,9 +73,6 @@ static gboolean gimp_image_map_get_pixel_at (GimpPickable *pickable,
|
|||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
static guchar * gimp_image_map_get_color_at (GimpPickable *pickable,
|
||||
gint x,
|
||||
gint y);
|
||||
|
||||
static gboolean gimp_image_map_do (GimpImageMap *image_map);
|
||||
|
||||
|
@ -114,7 +111,6 @@ gimp_image_map_pickable_iface_init (GimpPickableInterface *iface)
|
|||
iface->get_bytes = gimp_image_map_get_bytes;
|
||||
iface->get_tiles = gimp_image_map_get_tiles;
|
||||
iface->get_pixel_at = gimp_image_map_get_pixel_at;
|
||||
iface->get_color_at = gimp_image_map_get_color_at;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -236,32 +232,6 @@ gimp_image_map_get_pixel_at (GimpPickable *pickable,
|
|||
}
|
||||
}
|
||||
|
||||
static guchar *
|
||||
gimp_image_map_get_color_at (GimpPickable *pickable,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
GimpImageMap *image_map = GIMP_IMAGE_MAP (pickable);
|
||||
guchar *dest;
|
||||
guchar pixel[4];
|
||||
|
||||
if (! gimp_image_map_get_pixel_at (pickable, x, y, pixel))
|
||||
return NULL;
|
||||
|
||||
dest = g_new (guchar, 5);
|
||||
|
||||
gimp_image_get_color (gimp_item_get_image (GIMP_ITEM (image_map->drawable)),
|
||||
gimp_drawable_type (image_map->drawable),
|
||||
pixel, dest);
|
||||
|
||||
if (gimp_drawable_is_indexed (image_map->drawable))
|
||||
dest[4] = pixel[0];
|
||||
else
|
||||
dest[4] = 0;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
GimpImageMap *
|
||||
gimp_image_map_new (GimpDrawable *drawable,
|
||||
const gchar *undo_desc)
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "core-types.h"
|
||||
|
||||
#include "gimpobject.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimppickable.h"
|
||||
|
||||
|
||||
|
@ -148,21 +149,28 @@ gimp_pickable_get_pixel_at (GimpPickable *pickable,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
guchar *
|
||||
gboolean
|
||||
gimp_pickable_get_color_at (GimpPickable *pickable,
|
||||
gint x,
|
||||
gint y)
|
||||
gint y,
|
||||
GimpRGB *color)
|
||||
{
|
||||
GimpPickableInterface *pickable_iface;
|
||||
guchar pixel[4];
|
||||
guchar col[4];
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), FALSE);
|
||||
g_return_val_if_fail (color != NULL, FALSE);
|
||||
|
||||
pickable_iface = GIMP_PICKABLE_GET_INTERFACE (pickable);
|
||||
if (! gimp_pickable_get_pixel_at (pickable, x, y, pixel))
|
||||
return FALSE;
|
||||
|
||||
if (pickable_iface->get_color_at)
|
||||
return pickable_iface->get_color_at (pickable, x, y);
|
||||
gimp_image_get_color (gimp_pickable_get_image (pickable),
|
||||
gimp_pickable_get_image_type (pickable),
|
||||
pixel, col);
|
||||
|
||||
return NULL;
|
||||
gimp_rgba_set_uchar (color, col[0], col[1], col[2], col[3]);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gint
|
||||
|
@ -191,33 +199,38 @@ gimp_pickable_pick_color (GimpPickable *pickable,
|
|||
GimpRGB *color,
|
||||
gint *color_index)
|
||||
{
|
||||
guchar *col;
|
||||
GimpImage *image;
|
||||
GimpImageType type;
|
||||
guchar pixel[4];
|
||||
guchar col[4];
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_PICKABLE (pickable), FALSE);
|
||||
|
||||
if (! (col = gimp_pickable_get_color_at (pickable, x, y)))
|
||||
if (! gimp_pickable_get_pixel_at (pickable, x, y, pixel))
|
||||
return FALSE;
|
||||
|
||||
image = gimp_pickable_get_image (pickable);
|
||||
type = gimp_pickable_get_image_type (pickable);
|
||||
|
||||
if (sample_average)
|
||||
{
|
||||
gint i, j;
|
||||
gint count = 0;
|
||||
gint color_avg[4] = { 0, 0, 0, 0 };
|
||||
guchar *tmp_col;
|
||||
gint radius = (gint) average_radius;
|
||||
gint count = 0;
|
||||
gint color_avg[4] = { 0, 0, 0, 0 };
|
||||
gint radius = (gint) average_radius;
|
||||
gint i, j;
|
||||
|
||||
for (i = x - radius; i <= x + radius; i++)
|
||||
for (j = y - radius; j <= y + radius; j++)
|
||||
if ((tmp_col = gimp_pickable_get_color_at (pickable, i, j)))
|
||||
if (gimp_pickable_get_pixel_at (pickable, i, j, pixel))
|
||||
{
|
||||
count++;
|
||||
|
||||
color_avg[RED_PIX] += tmp_col[RED_PIX];
|
||||
color_avg[GREEN_PIX] += tmp_col[GREEN_PIX];
|
||||
color_avg[BLUE_PIX] += tmp_col[BLUE_PIX];
|
||||
color_avg[ALPHA_PIX] += tmp_col[ALPHA_PIX];
|
||||
gimp_image_get_color (image, type, pixel, col);
|
||||
|
||||
g_free (tmp_col);
|
||||
color_avg[RED_PIX] += col[RED_PIX];
|
||||
color_avg[GREEN_PIX] += col[GREEN_PIX];
|
||||
color_avg[BLUE_PIX] += col[BLUE_PIX];
|
||||
color_avg[ALPHA_PIX] += col[ALPHA_PIX];
|
||||
}
|
||||
|
||||
col[RED_PIX] = (guchar) (color_avg[RED_PIX] / count);
|
||||
|
@ -225,18 +238,25 @@ gimp_pickable_pick_color (GimpPickable *pickable,
|
|||
col[BLUE_PIX] = (guchar) (color_avg[BLUE_PIX] / count);
|
||||
col[ALPHA_PIX] = (guchar) (color_avg[ALPHA_PIX] / count);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_image_get_color (image, type, pixel, col);
|
||||
}
|
||||
|
||||
if (color)
|
||||
gimp_rgba_set_uchar (color,
|
||||
col[RED_PIX],
|
||||
col[GREEN_PIX],
|
||||
col[BLUE_PIX],
|
||||
col[ALPHA_PIX]);
|
||||
|
||||
gimp_rgba_set_uchar (color,
|
||||
col[RED_PIX],
|
||||
col[GREEN_PIX],
|
||||
col[BLUE_PIX],
|
||||
col[ALPHA_PIX]);
|
||||
|
||||
if (color_index)
|
||||
*color_index = sample_average ? -1 : col[4];
|
||||
|
||||
g_free (col);
|
||||
{
|
||||
if (GIMP_IMAGE_TYPE_IS_INDEXED (type) && ! sample_average)
|
||||
*color_index = pixel[0];
|
||||
else
|
||||
*color_index = -1;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -45,9 +45,6 @@ struct _GimpPickableInterface
|
|||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
guchar * (* get_color_at) (GimpPickable *pickable,
|
||||
gint x,
|
||||
gint y);
|
||||
gint (* get_opacity_at) (GimpPickable *pickable,
|
||||
gint x,
|
||||
gint y);
|
||||
|
@ -65,9 +62,10 @@ gboolean gimp_pickable_get_pixel_at (GimpPickable *pickable,
|
|||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
guchar * gimp_pickable_get_color_at (GimpPickable *pickable,
|
||||
gboolean gimp_pickable_get_color_at (GimpPickable *pickable,
|
||||
gint x,
|
||||
gint y);
|
||||
gint y,
|
||||
GimpRGB *color);
|
||||
gint gimp_pickable_get_opacity_at (GimpPickable *pickable,
|
||||
gint x,
|
||||
gint y);
|
||||
|
|
|
@ -55,9 +55,6 @@ static gboolean gimp_projection_get_pixel_at (GimpPickable *pickabl
|
|||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
static guchar * gimp_projection_get_color_at (GimpPickable *pickable,
|
||||
gint x,
|
||||
gint y);
|
||||
static gint gimp_projection_get_opacity_at (GimpPickable *pickable,
|
||||
gint x,
|
||||
gint y);
|
||||
|
@ -163,7 +160,6 @@ gimp_projection_pickable_iface_init (GimpPickableInterface *iface)
|
|||
iface->get_bytes = (gint (*) (GimpPickable *pickable)) gimp_projection_get_bytes;
|
||||
iface->get_tiles = (TileManager * (*) (GimpPickable *pickable)) gimp_projection_get_tiles;
|
||||
iface->get_pixel_at = gimp_projection_get_pixel_at;
|
||||
iface->get_color_at = gimp_projection_get_color_at;
|
||||
iface->get_opacity_at = gimp_projection_get_opacity_at;
|
||||
}
|
||||
|
||||
|
@ -232,27 +228,6 @@ gimp_projection_get_pixel_at (GimpPickable *pickable,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static guchar *
|
||||
gimp_projection_get_color_at (GimpPickable *pickable,
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
GimpProjection *proj = GIMP_PROJECTION (pickable);
|
||||
guchar *dest;
|
||||
guchar pixel[4];
|
||||
|
||||
if (! gimp_projection_get_pixel_at (pickable, x, y, pixel))
|
||||
return NULL;
|
||||
|
||||
dest = g_new (guchar, 5);
|
||||
|
||||
gimp_image_get_color (proj->image, gimp_projection_get_image_type (proj),
|
||||
pixel, dest);
|
||||
dest[4] = 0;
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
static gint
|
||||
gimp_projection_get_opacity_at (GimpPickable *pickable,
|
||||
gint x,
|
||||
|
|
|
@ -97,6 +97,7 @@ gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
|
|||
GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool);
|
||||
GimpDrawable *drawable;
|
||||
GimpPickable *pickable;
|
||||
GimpRGB color;
|
||||
guchar *col;
|
||||
gint x, y;
|
||||
|
||||
|
@ -123,23 +124,14 @@ gimp_by_color_select_tool_get_mask (GimpRegionSelectTool *region_select,
|
|||
|
||||
gimp_pickable_flush (pickable);
|
||||
|
||||
col = gimp_pickable_get_color_at (pickable, x, y);
|
||||
|
||||
if (col)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
gimp_rgba_set_uchar (&color, col[0], col[1], col[2], col[3]);
|
||||
g_free (col);
|
||||
|
||||
return gimp_image_contiguous_region_by_color (display->image, drawable,
|
||||
options->sample_merged,
|
||||
options->antialias,
|
||||
options->threshold,
|
||||
options->select_transparent,
|
||||
options->select_criterion,
|
||||
&color);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
if (gimp_pickable_get_color_at (pickable, x, y, &color))
|
||||
return gimp_image_contiguous_region_by_color (display->image, drawable,
|
||||
options->sample_merged,
|
||||
options->antialias,
|
||||
options->threshold,
|
||||
options->select_transparent,
|
||||
options->select_criterion,
|
||||
&color);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include "display/gimpdisplayshell-transform.h"
|
||||
#include "display/gimpdisplayshell-appearance.h"
|
||||
|
||||
#include "gimpeditselectiontool.h"
|
||||
#include "gimpselectiontool.h"
|
||||
#include "gimpselectionoptions.h"
|
||||
#include "gimprectangletool.h"
|
||||
|
|
Loading…
Reference in New Issue