gimp/libgimp/gimppixelfetcher.c

335 lines
8.6 KiB
C
Raw Normal View History

2004-01-13 18:26:10 +08:00
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimppixelfetcher.c
*
* This library is free software: you can redistribute it and/or
2004-01-13 18:26:10 +08:00
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
2004-01-13 18:26:10 +08:00
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
2004-01-13 18:26:10 +08:00
*/
#include "config.h"
#define GIMP_DISABLE_DEPRECATION_WARNINGS
2004-01-13 18:26:10 +08:00
#include "gimp.h"
/**
* SECTION: gimppixelfetcher
* @title: gimppixelfetcher
* @short_description: Functions for operating on pixel regions.
*
* These functions provide neighbourhood-based algorithms which get
* dramatically slower on region boundaries, to the point where a
* special treatment for neighbourhoods which are completely inside a
* tile is called for. It hides the special treatment of tile borders,
* making plug-in code more readable and shorter.
**/
2004-01-13 18:26:10 +08:00
struct _GimpPixelFetcher
{
gint col, row;
gint img_width;
gint img_height;
gint sel_x1, sel_y1, sel_x2, sel_y2;
gint img_bpp;
gint tile_width, tile_height;
guchar bg_color[4];
GimpPixelFetcherEdgeMode mode;
GimpDrawable *drawable;
GimpTile *tile;
gboolean tile_dirty;
gboolean shadow;
};
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
/* local function prototypes */
static guchar * gimp_pixel_fetcher_provide_tile (GimpPixelFetcher *pf,
gint x,
gint y);
/* public functions */
/**
* gimp_pixel_fetcher_new:
* @drawable: the #GimpDrawable the new region will be attached to.
* @shadow: a #gboolean indicating whether the region is attached to
* the shadow tiles or the real @drawable tiles.
*
* Initialize a pixel region from the drawable.
*
* Return value: a pointer to a #GimpPixelRgn structure (or NULL).
**/
2004-01-13 18:26:10 +08:00
GimpPixelFetcher *
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
gimp_pixel_fetcher_new (GimpDrawable *drawable,
gboolean shadow)
2004-01-13 18:26:10 +08:00
{
GimpPixelFetcher *pf;
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
gint width;
gint height;
gint bpp;
g_return_val_if_fail (drawable != NULL, NULL);
width = gimp_drawable_width (drawable->drawable_id);
height = gimp_drawable_height (drawable->drawable_id);
bpp = gimp_drawable_bpp (drawable->drawable_id);
2004-01-13 18:26:10 +08:00
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
g_return_val_if_fail (width > 0 && height > 0 && bpp > 0, NULL);
pf = g_slice_new0 (GimpPixelFetcher);
2004-01-13 18:26:10 +08:00
gimp_drawable_mask_bounds (drawable->drawable_id,
&pf->sel_x1, &pf->sel_y1,
&pf->sel_x2, &pf->sel_y2);
pf->col = -1;
pf->row = -1;
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
pf->img_width = width;
pf->img_height = height;
pf->img_bpp = bpp;
2004-01-13 18:26:10 +08:00
pf->tile_width = gimp_tile_width ();
pf->tile_height = gimp_tile_height ();
pf->bg_color[0] = 0;
pf->bg_color[1] = 0;
pf->bg_color[2] = 0;
pf->bg_color[3] = 255;
pf->mode = GIMP_PIXEL_FETCHER_EDGE_NONE;
pf->drawable = drawable;
pf->tile = NULL;
pf->tile_dirty = FALSE;
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
pf->shadow = shadow;
2004-01-13 18:26:10 +08:00
return pf;
}
/**
* gimp_pixel_fetcher_destroy:
* @pf: a pointer to a previously initialized #GimpPixelFetcher.
*
* Close a previously initializd pixel region.
**/
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
void
gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf)
{
g_return_if_fail (pf != NULL);
if (pf->tile)
gimp_tile_unref (pf->tile, pf->tile_dirty);
g_slice_free (GimpPixelFetcher, pf);
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
}
/**
* gimp_pixel_fetcher_set_edge_mode:
* @pf: a pointer to a previously initialized #GimpPixelFetcher.
* @mode: the new edge mode from #GimpPixelFetcherEdgeMode.
*
* Change the edage mode of a previously initialized pixel region.
**/
2004-01-13 18:26:10 +08:00
void
gimp_pixel_fetcher_set_edge_mode (GimpPixelFetcher *pf,
GimpPixelFetcherEdgeMode mode)
{
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
g_return_if_fail (pf != NULL);
2004-01-13 18:26:10 +08:00
pf->mode = mode;
}
/**
* gimp_pixel_fetcher_set_bg_color:
* @pf: a pointer to a previously initialized #GimpPixelFetcher.
* @color: the color to be used as bg color.
*
* Change the background color of a previously initialized pixel region.
**/
2004-01-13 18:26:10 +08:00
void
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf,
const GimpRGB *color)
2004-01-13 18:26:10 +08:00
{
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
g_return_if_fail (pf != NULL);
g_return_if_fail (color != NULL);
2004-01-13 18:26:10 +08:00
switch (pf->img_bpp)
{
case 2: pf->bg_color[1] = 255;
case 1:
pf->bg_color[0] = gimp_rgb_luminance_uchar (color);
2004-01-13 18:26:10 +08:00
break;
case 4: pf->bg_color[3] = 255;
case 3:
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
gimp_rgb_get_uchar (color,
2004-01-13 18:26:10 +08:00
pf->bg_color, pf->bg_color + 1, pf->bg_color + 2);
break;
}
}
/**
* gimp_pixel_fetcher_get_pixel:
* @pf: a pointer to a previously initialized #GimpPixelFetcher.
* @x: the x coordinate of the pixel to get.
* @y: the y coordinate of the pixel to get.
* @pixel: the memory location where to return the pixel.
*
* Get a pixel from the pixel region.
**/
2004-01-13 18:26:10 +08:00
void
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
2004-01-13 18:26:10 +08:00
gint x,
gint y,
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
guchar *pixel)
2004-01-13 18:26:10 +08:00
{
guchar *p;
gint i;
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
g_return_if_fail (pf != NULL);
g_return_if_fail (pixel != NULL);
if (pf->mode == GIMP_PIXEL_FETCHER_EDGE_NONE &&
(x < pf->sel_x1 || x >= pf->sel_x2 ||
y < pf->sel_y1 || y >= pf->sel_y2))
2004-01-13 18:26:10 +08:00
{
return;
}
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
if (x < 0 || x >= pf->img_width ||
y < 0 || y >= pf->img_height)
{
switch (pf->mode)
{
case GIMP_PIXEL_FETCHER_EDGE_WRAP:
if (x < 0 || x >= pf->img_width)
{
x %= pf->img_width;
if (x < 0)
x += pf->img_width;
}
if (y < 0 || y >= pf->img_height)
{
y %= pf->img_height;
if (y < 0)
y += pf->img_height;
}
break;
case GIMP_PIXEL_FETCHER_EDGE_SMEAR:
x = CLAMP (x, 0, pf->img_width - 1);
y = CLAMP (y, 0, pf->img_height - 1);
break;
case GIMP_PIXEL_FETCHER_EDGE_BLACK:
for (i = 0; i < pf->img_bpp; i++)
pixel[i] = 0;
return;
case GIMP_PIXEL_FETCHER_EDGE_BACKGROUND:
for (i = 0; i < pf->img_bpp; i++)
pixel[i] = pf->bg_color[i];
return;
default:
return;
}
}
2004-01-13 18:26:10 +08:00
p = gimp_pixel_fetcher_provide_tile (pf, x, y);
i = pf->img_bpp;
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
2004-01-13 18:26:10 +08:00
do
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
{
*pixel++ = *p++;
}
2004-01-13 18:26:10 +08:00
while (--i);
}
/**
* gimp_pixel_fetcher_put_pixel:
* @pf: a pointer to a previously initialized #GimpPixelFetcher.
* @x: the x coordinate of the pixel to set.
* @y: the y coordinate of the pixel to set.
* @pixel: the pixel to set.
*
* Set a pixel in the pixel region.
**/
2004-01-13 18:26:10 +08:00
void
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
2004-01-13 18:26:10 +08:00
gint x,
gint y,
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
const guchar *pixel)
2004-01-13 18:26:10 +08:00
{
guchar *p;
gint i;
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
g_return_if_fail (pf != NULL);
g_return_if_fail (pixel != NULL);
if (x < pf->sel_x1 || x >= pf->sel_x2 ||
y < pf->sel_y1 || y >= pf->sel_y2)
2004-01-13 18:26:10 +08:00
{
return;
}
p = gimp_pixel_fetcher_provide_tile (pf, x, y);
i = pf->img_bpp;
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
2004-01-13 18:26:10 +08:00
do
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
{
*p++ = *pixel++;
}
2004-01-13 18:26:10 +08:00
while (--i);
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
pf->tile_dirty = TRUE;
2004-01-13 18:26:10 +08:00
}
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
/* private functions */
2004-01-13 18:26:10 +08:00
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
static guchar *
gimp_pixel_fetcher_provide_tile (GimpPixelFetcher *pf,
gint x,
gint y)
2004-01-13 18:26:10 +08:00
{
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
gint col, row;
gint coloff, rowoff;
2004-01-13 18:26:10 +08:00
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
col = x / pf->tile_width;
coloff = x % pf->tile_width;
row = y / pf->tile_height;
rowoff = y % pf->tile_height;
2004-01-13 18:26:10 +08:00
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
if ((col != pf->col) || (row != pf->row) || (pf->tile == NULL))
{
if (pf->tile != NULL)
gimp_tile_unref (pf->tile, pf->tile_dirty);
2004-01-13 18:26:10 +08:00
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
pf->tile = gimp_drawable_get_tile (pf->drawable, pf->shadow, row, col);
pf->tile_dirty = FALSE;
gimp_tile_ref (pf->tile);
2004-01-13 18:26:10 +08:00
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
pf->col = col;
pf->row = row;
2004-01-13 18:26:10 +08:00
}
Cleaned up the remaining libgimp API issues: 2004-03-12 Michael Natterer <mitch@gimp.org> Cleaned up the remaining libgimp API issues: * libgimp/gimppixelfetcher.[ch] (enum GimpPixelFetcherEdgeMode): added new enum value GIMP_PIXEL_FETCHER_EDGE_BACKGROUND so we can actually use the bg_color feature of the GimpPixelFetcher. (gimp_pixel_fetcher_new): added "gboolean shadow" parameter because it must not change while the GimpPixelFetcher exists. (gimp_pixel_fetcher_set_shadow): removed. (gimp_pixel_fetcher_set_bg_color): added "GimpRGB *color" parameter and don't call gimp_palette_get_foreground(). (gimp_pixel_fetcher_get_pixel): handle BACKGROUND mode. Cleaned up the function. (gimp_get_bg_guchar) (gimp_get_fg_guchar): removed these functions... * libgimp/gimpdrawable.[ch]: ...and added gimp_drawable_get_color_uchar() instead. * libgimp/gimp.def * plug-ins/common/blinds.c * plug-ins/common/checkerboard.c * plug-ins/common/cubism.c * plug-ins/common/curve_bend.c * plug-ins/common/displace.c * plug-ins/common/edge.c * plug-ins/common/illusion.c * plug-ins/common/mblur.c * plug-ins/common/mosaic.c * plug-ins/common/plasma.c * plug-ins/common/polar.c * plug-ins/common/ripple.c * plug-ins/common/shift.c * plug-ins/common/spread.c * plug-ins/common/tileit.c * plug-ins/common/whirlpinch.c * plug-ins/gflare/gflare.c * plug-ins/libgimpoldpreview/gimpoldpreview.c: changed accordingly. (Didn't test the changed plug-ins because I wanted to get this API change into CVS as soon as possible)
2004-03-13 06:46:25 +08:00
return pf->tile->data + pf->img_bpp * (pf->tile->ewidth * rowoff + coloff);
2004-01-13 18:26:10 +08:00
}