mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-23 04:51:44 +00:00
use enum GimpOrientationType instead of local #defines for HORIZONTAL and
2009-03-01 Michael Natterer <mitch@gimp.org> * plug-ins/common/ripple.c: use enum GimpOrientationType instead of local #defines for HORIZONTAL and VERTICAL with identical values. Some indentation and formatting fixups. svn path=/trunk/; revision=28086
This commit is contained in:
parent
12492a4a15
commit
2ca579d666
|
@ -1,3 +1,9 @@
|
|||
2009-03-01 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* plug-ins/common/ripple.c: use enum GimpOrientationType instead
|
||||
of local #defines for HORIZONTAL and VERTICAL with identical
|
||||
values. Some indentation and formatting fixups.
|
||||
|
||||
2009-02-28 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimp/gimpregioniterator.c: update the progress less often.
|
||||
|
|
|
@ -22,10 +22,10 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
#include <libgimp/gimpui.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
#include <libgimp/gimpui.h>
|
||||
|
||||
#include "libgimp/stdplugins-intl.h"
|
||||
|
||||
|
@ -37,9 +37,6 @@
|
|||
#define SCALE_WIDTH 200
|
||||
#define TILE_CACHE_SIZE 16
|
||||
|
||||
#define HORIZONTAL 0
|
||||
#define VERTICAL 1
|
||||
|
||||
#define SMEAR 0
|
||||
#define WRAP 1
|
||||
#define BLANK 2
|
||||
|
@ -51,7 +48,7 @@ typedef struct
|
|||
{
|
||||
gint period;
|
||||
gint amplitude;
|
||||
gint orientation;
|
||||
GimpOrientationType orientation;
|
||||
gint edges;
|
||||
gint waveform;
|
||||
gboolean antialias;
|
||||
|
@ -95,7 +92,7 @@ static RippleValues rvals =
|
|||
{
|
||||
20, /* period */
|
||||
5, /* amplitude */
|
||||
HORIZONTAL, /* orientation */
|
||||
GIMP_ORIENTATION_HORIZONTAL, /* orientation */
|
||||
WRAP, /* edges */
|
||||
SINE, /* waveform */
|
||||
TRUE, /* antialias */
|
||||
|
@ -115,10 +112,10 @@ query (void)
|
|||
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }" },
|
||||
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
|
||||
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
|
||||
{ GIMP_PDB_INT32, "period", "period; number of pixels for one wave to complete" },
|
||||
{ GIMP_PDB_INT32, "amplitude", "amplitude; maximum displacement of wave" },
|
||||
{ GIMP_PDB_INT32, "orientation", "orientation; 0 = Horizontal, 1 = Vertical" },
|
||||
{ GIMP_PDB_INT32, "edges", "edges; 0 = smear, 1 = wrap, 2 = blank" },
|
||||
{ GIMP_PDB_INT32, "period", "Period; number of pixels for one wave to complete" },
|
||||
{ GIMP_PDB_INT32, "amplitude", "Amplitude; maximum displacement of wave" },
|
||||
{ GIMP_PDB_INT32, "orientation", "Orientation { ORIENTATION-HORIZONTAL (0), ORIENTATION-VERTICAL (1) }" },
|
||||
{ GIMP_PDB_INT32, "edges", "Edges; 0 = smear, 1 = wrap, 2 = blank" },
|
||||
{ GIMP_PDB_INT32, "waveform", "0 = sawtooth, 1 = sine wave" },
|
||||
{ GIMP_PDB_INT32, "antialias", "antialias; True or False" },
|
||||
{ GIMP_PDB_INT32, "tile", "tile; if this is true, the image will retain it's tilability" }
|
||||
|
@ -190,8 +187,8 @@ run (const gchar *name,
|
|||
{
|
||||
rvals.period = param[3].data.d_int32;
|
||||
rvals.amplitude = param[4].data.d_int32;
|
||||
rvals.orientation = (param[5].data.d_int32) ? VERTICAL : HORIZONTAL;
|
||||
rvals.edges = (param[6].data.d_int32);
|
||||
rvals.orientation = (param[5].data.d_int32) ? GIMP_ORIENTATION_VERTICAL : GIMP_ORIENTATION_HORIZONTAL;
|
||||
rvals.edges = param[6].data.d_int32;
|
||||
rvals.waveform = param[7].data.d_int32;
|
||||
rvals.antialias = (param[8].data.d_int32) ? TRUE : FALSE;
|
||||
rvals.tile = (param[9].data.d_int32) ? TRUE : FALSE;
|
||||
|
@ -272,9 +269,10 @@ ripple_vertical (gint x,
|
|||
yi = floor (needy);
|
||||
yi_a = yi + 1;
|
||||
|
||||
/* Tile the image. */
|
||||
if (rvals.edges == WRAP)
|
||||
{
|
||||
/* Tile the image. */
|
||||
|
||||
needy = fmod (needy, height);
|
||||
|
||||
if (needy < 0.0)
|
||||
|
@ -287,9 +285,10 @@ ripple_vertical (gint x,
|
|||
|
||||
yi_a = yi_a % height;
|
||||
}
|
||||
/* Smear out the edges of the image by repeating pixels. */
|
||||
else if (rvals.edges == SMEAR)
|
||||
{
|
||||
/* Smear out the edges of the image by repeating pixels. */
|
||||
|
||||
needy = CLAMP (needy, 0, height - 1);
|
||||
yi = CLAMP (yi, 0, height - 1);
|
||||
yi_a = CLAMP (yi_a, 0, height - 1);
|
||||
|
@ -308,7 +307,7 @@ ripple_vertical (gint x,
|
|||
memset (pixel[1], 0, 4);
|
||||
|
||||
average_two_pixels (dest, pixel, needy - yi, bpp, param->has_alpha);
|
||||
} /* antialias */
|
||||
}
|
||||
else
|
||||
{
|
||||
if (yi >= 0 && yi < height)
|
||||
|
@ -336,9 +335,10 @@ ripple_horizontal (gint x,
|
|||
xi = floor (needx);
|
||||
xi_a = xi + 1;
|
||||
|
||||
/* Tile the image. */
|
||||
if (rvals.edges == WRAP)
|
||||
{
|
||||
/* Tile the image. */
|
||||
|
||||
needx = fmod (needx, width);
|
||||
|
||||
while (needx < 0.0)
|
||||
|
@ -351,9 +351,10 @@ ripple_horizontal (gint x,
|
|||
|
||||
xi_a = (xi+1) % width;
|
||||
}
|
||||
/* Smear out the edges of the image by repeating pixels. */
|
||||
else if (rvals.edges == SMEAR)
|
||||
{
|
||||
/* Smear out the edges of the image by repeating pixels. */
|
||||
|
||||
needx = CLAMP (needx, 0, width - 1);
|
||||
xi = CLAMP (xi, 0, width - 1);
|
||||
xi_a = CLAMP (xi_a, 0, width - 1);
|
||||
|
@ -365,13 +366,14 @@ ripple_horizontal (gint x,
|
|||
gimp_pixel_fetcher_get_pixel (pft, xi, y, pixel[0]);
|
||||
else
|
||||
memset (pixel[0], 0, 4);
|
||||
|
||||
if (xi_a >= 0 && xi_a < width)
|
||||
gimp_pixel_fetcher_get_pixel (pft, xi_a, y, pixel[1]);
|
||||
else
|
||||
memset (pixel[1], 0, 4);
|
||||
|
||||
average_two_pixels (dest, pixel, needx - xi, bpp, param->has_alpha);
|
||||
} /* antialias */
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
@ -402,9 +404,9 @@ ripple (GimpDrawable *drawable,
|
|||
{
|
||||
rvals.edges = WRAP;
|
||||
rvals.period = (param.width / (param.width / rvals.period) *
|
||||
(rvals.orientation == HORIZONTAL) +
|
||||
(rvals.orientation == GIMP_ORIENTATION_HORIZONTAL) +
|
||||
param.height / (param.height / rvals.period) *
|
||||
(rvals.orientation == VERTICAL));
|
||||
(rvals.orientation == GIMP_ORIENTATION_VERTICAL));
|
||||
}
|
||||
|
||||
if (preview)
|
||||
|
@ -423,10 +425,11 @@ ripple (GimpDrawable *drawable,
|
|||
for (y = 0; y < height ; y++)
|
||||
for (x = 0; x < width ; x++)
|
||||
{
|
||||
if (rvals.orientation == VERTICAL)
|
||||
if (rvals.orientation == GIMP_ORIENTATION_VERTICAL)
|
||||
ripple_vertical (x1 + x, y1 + y, d, bpp, ¶m);
|
||||
else
|
||||
ripple_horizontal (x1 + x, y1 + y, d, bpp, ¶m);
|
||||
|
||||
d += bpp;
|
||||
}
|
||||
|
||||
|
@ -438,11 +441,13 @@ ripple (GimpDrawable *drawable,
|
|||
GimpRgnIterator *iter;
|
||||
|
||||
iter = gimp_rgn_iterator_new (drawable, 0);
|
||||
|
||||
gimp_rgn_iterator_dest (iter,
|
||||
rvals.orientation == VERTICAL ?
|
||||
rvals.orientation == GIMP_ORIENTATION_VERTICAL ?
|
||||
ripple_vertical :
|
||||
ripple_horizontal,
|
||||
¶m);
|
||||
|
||||
gimp_rgn_iterator_free (iter);
|
||||
}
|
||||
|
||||
|
@ -549,8 +554,11 @@ ripple_dialog (GimpDrawable *drawable)
|
|||
G_CALLBACK (gimp_radio_button_update),
|
||||
&rvals.orientation, rvals.orientation,
|
||||
|
||||
_("_Horizontal"), HORIZONTAL, &horizontal,
|
||||
_("_Vertical"), VERTICAL, &vertical,
|
||||
_("_Horizontal"), GIMP_ORIENTATION_HORIZONTAL,
|
||||
&horizontal,
|
||||
|
||||
_("_Vertical"), GIMP_ORIENTATION_VERTICAL,
|
||||
&vertical,
|
||||
|
||||
NULL);
|
||||
|
||||
|
|
Loading…
Reference in a new issue