mirror of https://github.com/GNOME/gimp.git
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)
This commit is contained in:
parent
5f9f60f408
commit
a779e74817
48
ChangeLog
48
ChangeLog
|
@ -1,3 +1,51 @@
|
||||||
|
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-12 Raphaël Quinet <quinet@gamers.org>
|
2004-03-12 Raphaël Quinet <quinet@gamers.org>
|
||||||
|
|
||||||
* app/core/gimpdrawable-transform.c (RECURSION_LEVEL): Set to 0 in
|
* app/core/gimpdrawable-transform.c (RECURSION_LEVEL): Set to 0 in
|
||||||
|
|
|
@ -54,6 +54,7 @@ EXPORTS
|
||||||
gimp_drawable_fill
|
gimp_drawable_fill
|
||||||
gimp_drawable_flush
|
gimp_drawable_flush
|
||||||
gimp_drawable_get
|
gimp_drawable_get
|
||||||
|
gimp_drawable_get_color_uchar
|
||||||
gimp_drawable_get_image
|
gimp_drawable_get_image
|
||||||
gimp_drawable_get_linked
|
gimp_drawable_get_linked
|
||||||
gimp_drawable_get_name
|
gimp_drawable_get_name
|
||||||
|
@ -121,9 +122,7 @@ EXPORTS
|
||||||
gimp_free_select
|
gimp_free_select
|
||||||
gimp_fuzzy_select
|
gimp_fuzzy_select
|
||||||
gimp_gamma
|
gimp_gamma
|
||||||
gimp_get_bg_guchar
|
|
||||||
gimp_get_default_comment
|
gimp_get_default_comment
|
||||||
gimp_get_fg_guchar
|
|
||||||
gimp_get_module_load_inhibit
|
gimp_get_module_load_inhibit
|
||||||
gimp_get_monitor_resolution
|
gimp_get_monitor_resolution
|
||||||
gimp_get_path_by_tattoo
|
gimp_get_path_by_tattoo
|
||||||
|
@ -314,7 +313,6 @@ EXPORTS
|
||||||
gimp_pixel_fetcher_put_pixel
|
gimp_pixel_fetcher_put_pixel
|
||||||
gimp_pixel_fetcher_set_bg_color
|
gimp_pixel_fetcher_set_bg_color
|
||||||
gimp_pixel_fetcher_set_edge_mode
|
gimp_pixel_fetcher_set_edge_mode
|
||||||
gimp_pixel_fetcher_set_shadow
|
|
||||||
gimp_pixel_rgn_get_col
|
gimp_pixel_rgn_get_col
|
||||||
gimp_pixel_rgn_get_pixel
|
gimp_pixel_rgn_get_pixel
|
||||||
gimp_pixel_rgn_get_rect
|
gimp_pixel_rgn_get_rect
|
||||||
|
|
|
@ -182,6 +182,43 @@ gimp_drawable_get_tile2 (GimpDrawable *drawable,
|
||||||
return gimp_drawable_get_tile (drawable, shadow, row, col);
|
return gimp_drawable_get_tile (drawable, shadow, row, col);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_drawable_get_color_uchar (gint32 drawable_ID,
|
||||||
|
const GimpRGB *color,
|
||||||
|
guchar *color_uchar)
|
||||||
|
{
|
||||||
|
g_return_if_fail (color != NULL);
|
||||||
|
g_return_if_fail (color_uchar != NULL);
|
||||||
|
|
||||||
|
switch (gimp_drawable_type (drawable_ID))
|
||||||
|
{
|
||||||
|
case GIMP_RGB_IMAGE:
|
||||||
|
gimp_rgb_get_uchar (color,
|
||||||
|
&color_uchar[0], &color_uchar[1], &color_uchar[2]);
|
||||||
|
color_uchar[3] = 255;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GIMP_RGBA_IMAGE:
|
||||||
|
gimp_rgba_get_uchar (color,
|
||||||
|
&color_uchar[0], &color_uchar[1], &color_uchar[2],
|
||||||
|
&color_uchar[3]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GIMP_GRAY_IMAGE:
|
||||||
|
color_uchar[0] = gimp_rgb_intensity_uchar (color);
|
||||||
|
color_uchar[1] = 255;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GIMP_GRAYA_IMAGE:
|
||||||
|
color_uchar[0] = gimp_rgb_intensity_uchar (color);
|
||||||
|
gimp_rgba_get_uchar (color, NULL, NULL, NULL, &color_uchar[1]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
guchar *
|
guchar *
|
||||||
gimp_drawable_get_thumbnail_data (gint32 drawable_ID,
|
gimp_drawable_get_thumbnail_data (gint32 drawable_ID,
|
||||||
gint *width,
|
gint *width,
|
||||||
|
|
|
@ -52,6 +52,10 @@ GimpTile * gimp_drawable_get_tile2 (GimpDrawable *drawable,
|
||||||
gint x,
|
gint x,
|
||||||
gint y);
|
gint y);
|
||||||
|
|
||||||
|
void gimp_drawable_get_color_uchar (gint32 drawable_ID,
|
||||||
|
const GimpRGB *color,
|
||||||
|
guchar *color_uchar);
|
||||||
|
|
||||||
guchar * gimp_drawable_get_thumbnail_data (gint32 drawable_ID,
|
guchar * gimp_drawable_get_thumbnail_data (gint32 drawable_ID,
|
||||||
gint *width,
|
gint *width,
|
||||||
gint *height,
|
gint *height,
|
||||||
|
|
|
@ -27,12 +27,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <glib.h>
|
|
||||||
|
|
||||||
#include "gimp.h"
|
#include "gimp.h"
|
||||||
#include "gimppixelfetcher.h"
|
|
||||||
|
|
||||||
|
|
||||||
struct _GimpPixelFetcher
|
struct _GimpPixelFetcher
|
||||||
|
@ -51,12 +46,34 @@ struct _GimpPixelFetcher
|
||||||
gboolean shadow;
|
gboolean shadow;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* local function prototypes */
|
||||||
|
|
||||||
|
static guchar * gimp_pixel_fetcher_provide_tile (GimpPixelFetcher *pf,
|
||||||
|
gint x,
|
||||||
|
gint y);
|
||||||
|
|
||||||
|
|
||||||
|
/* public functions */
|
||||||
|
|
||||||
GimpPixelFetcher *
|
GimpPixelFetcher *
|
||||||
gimp_pixel_fetcher_new (GimpDrawable *drawable)
|
gimp_pixel_fetcher_new (GimpDrawable *drawable,
|
||||||
|
gboolean shadow)
|
||||||
{
|
{
|
||||||
GimpPixelFetcher *pf;
|
GimpPixelFetcher *pf;
|
||||||
|
gint width;
|
||||||
|
gint height;
|
||||||
|
gint bpp;
|
||||||
|
|
||||||
pf = g_new (GimpPixelFetcher, 1);
|
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);
|
||||||
|
|
||||||
|
g_return_val_if_fail (width > 0 && height > 0 && bpp > 0, NULL);
|
||||||
|
|
||||||
|
pf = g_new0 (GimpPixelFetcher, 1);
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id,
|
gimp_drawable_mask_bounds (drawable->drawable_id,
|
||||||
&pf->sel_x1, &pf->sel_y1,
|
&pf->sel_x1, &pf->sel_y1,
|
||||||
|
@ -64,9 +81,9 @@ gimp_pixel_fetcher_new (GimpDrawable *drawable)
|
||||||
|
|
||||||
pf->col = -1;
|
pf->col = -1;
|
||||||
pf->row = -1;
|
pf->row = -1;
|
||||||
pf->img_width = gimp_drawable_width (drawable->drawable_id);
|
pf->img_width = width;
|
||||||
pf->img_height = gimp_drawable_height (drawable->drawable_id);
|
pf->img_height = height;
|
||||||
pf->img_bpp = gimp_drawable_bpp (drawable->drawable_id);
|
pf->img_bpp = bpp;
|
||||||
pf->tile_width = gimp_tile_width ();
|
pf->tile_width = gimp_tile_width ();
|
||||||
pf->tile_height = gimp_tile_height ();
|
pf->tile_height = gimp_tile_height ();
|
||||||
pf->bg_color[0] = 0;
|
pf->bg_color[0] = 0;
|
||||||
|
@ -77,50 +94,160 @@ gimp_pixel_fetcher_new (GimpDrawable *drawable)
|
||||||
pf->drawable = drawable;
|
pf->drawable = drawable;
|
||||||
pf->tile = NULL;
|
pf->tile = NULL;
|
||||||
pf->tile_dirty = FALSE;
|
pf->tile_dirty = FALSE;
|
||||||
pf->shadow = FALSE;
|
pf->shadow = shadow;
|
||||||
|
|
||||||
/* this allows us to use (slightly faster) do-while loops */
|
|
||||||
g_assert (pf->img_bpp > 0);
|
|
||||||
|
|
||||||
return pf;
|
return pf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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_free (pf);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_pixel_fetcher_set_edge_mode (GimpPixelFetcher *pf,
|
gimp_pixel_fetcher_set_edge_mode (GimpPixelFetcher *pf,
|
||||||
GimpPixelFetcherEdgeMode mode)
|
GimpPixelFetcherEdgeMode mode)
|
||||||
{
|
{
|
||||||
|
g_return_if_fail (pf != NULL);
|
||||||
|
|
||||||
pf->mode = mode;
|
pf->mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf)
|
gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf,
|
||||||
|
const GimpRGB *color)
|
||||||
{
|
{
|
||||||
GimpRGB background;
|
g_return_if_fail (pf != NULL);
|
||||||
|
g_return_if_fail (color != NULL);
|
||||||
gimp_palette_get_background (&background);
|
|
||||||
|
|
||||||
switch (pf->img_bpp)
|
switch (pf->img_bpp)
|
||||||
{
|
{
|
||||||
case 2: pf->bg_color[1] = 255;
|
case 2: pf->bg_color[1] = 255;
|
||||||
case 1:
|
case 1:
|
||||||
pf->bg_color[0] = gimp_rgb_intensity_uchar (&background);
|
pf->bg_color[0] = gimp_rgb_intensity_uchar (color);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4: pf->bg_color[3] = 255;
|
case 4: pf->bg_color[3] = 255;
|
||||||
case 3:
|
case 3:
|
||||||
gimp_rgb_get_uchar (&background,
|
gimp_rgb_get_uchar (color,
|
||||||
pf->bg_color, pf->bg_color + 1, pf->bg_color + 2);
|
pf->bg_color, pf->bg_color + 1, pf->bg_color + 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_pixel_fetcher_set_shadow (GimpPixelFetcher *pf,
|
gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
||||||
gboolean shadow)
|
gint x,
|
||||||
|
gint y,
|
||||||
|
guchar *pixel)
|
||||||
{
|
{
|
||||||
pf->shadow = shadow;
|
guchar *p;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
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))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p = gimp_pixel_fetcher_provide_tile (pf, x, y);
|
||||||
|
|
||||||
|
i = pf->img_bpp;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
*pixel++ = *p++;
|
||||||
|
}
|
||||||
|
while (--i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
||||||
|
gint x,
|
||||||
|
gint y,
|
||||||
|
const guchar *pixel)
|
||||||
|
{
|
||||||
|
guchar *p;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = gimp_pixel_fetcher_provide_tile (pf, x, y);
|
||||||
|
|
||||||
|
i = pf->img_bpp;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
*p++ = *pixel++;
|
||||||
|
}
|
||||||
|
while (--i);
|
||||||
|
|
||||||
|
pf->tile_dirty = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* private functions */
|
||||||
|
|
||||||
static guchar *
|
static guchar *
|
||||||
gimp_pixel_fetcher_provide_tile (GimpPixelFetcher *pf,
|
gimp_pixel_fetcher_provide_tile (GimpPixelFetcher *pf,
|
||||||
gint x,
|
gint x,
|
||||||
|
@ -149,155 +276,3 @@ gimp_pixel_fetcher_provide_tile (GimpPixelFetcher *pf,
|
||||||
|
|
||||||
return pf->tile->data + pf->img_bpp * (pf->tile->ewidth * rowoff + coloff);
|
return pf->tile->data + pf->img_bpp * (pf->tile->ewidth * rowoff + coloff);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
|
||||||
gint x,
|
|
||||||
gint y,
|
|
||||||
const guchar *pixel)
|
|
||||||
{
|
|
||||||
guchar *p;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
if (x < pf->sel_x1 || x >= pf->sel_x2 ||
|
|
||||||
y < pf->sel_y1 || y >= pf->sel_y2)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = gimp_pixel_fetcher_provide_tile (pf, x, y);
|
|
||||||
|
|
||||||
i = pf->img_bpp;
|
|
||||||
do
|
|
||||||
*p++ = *pixel++;
|
|
||||||
while (--i);
|
|
||||||
|
|
||||||
pf->tile_dirty = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
|
||||||
gint x,
|
|
||||||
gint y,
|
|
||||||
guchar *pixel)
|
|
||||||
{
|
|
||||||
guchar *p;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
if (pf->mode == GIMP_PIXEL_FETCHER_EDGE_NONE &&
|
|
||||||
(x < pf->sel_x1 || x >= pf->sel_x2 ||
|
|
||||||
y < pf->sel_y1 || y >= pf->sel_y2))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else 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:
|
|
||||||
if (x < 0 || x >= pf->img_width ||
|
|
||||||
y < 0 || y >= pf->img_height)
|
|
||||||
{
|
|
||||||
for (i = 0; i < pf->img_bpp; i++)
|
|
||||||
pixel[i] = 0;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = gimp_pixel_fetcher_provide_tile (pf, x, y);
|
|
||||||
|
|
||||||
i = pf->img_bpp;
|
|
||||||
do
|
|
||||||
*pixel++ = *p++;
|
|
||||||
while (--i);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf)
|
|
||||||
{
|
|
||||||
if (pf->tile)
|
|
||||||
gimp_tile_unref (pf->tile, pf->tile_dirty);
|
|
||||||
|
|
||||||
g_free (pf);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_get_color_guchar (GimpDrawable *drawable,
|
|
||||||
GimpRGB *color,
|
|
||||||
gboolean transparent,
|
|
||||||
guchar *bg)
|
|
||||||
{
|
|
||||||
switch (gimp_drawable_type (drawable->drawable_id))
|
|
||||||
{
|
|
||||||
case GIMP_RGB_IMAGE :
|
|
||||||
gimp_rgb_get_uchar (color, &bg[0], &bg[1], &bg[2]);
|
|
||||||
bg[3] = 255;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GIMP_RGBA_IMAGE:
|
|
||||||
gimp_rgb_get_uchar (color, &bg[0], &bg[1], &bg[2]);
|
|
||||||
bg[3] = transparent ? 0 : 255;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GIMP_GRAY_IMAGE:
|
|
||||||
bg[0] = gimp_rgb_intensity_uchar (color);
|
|
||||||
bg[1] = 255;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GIMP_GRAYA_IMAGE:
|
|
||||||
bg[0] = gimp_rgb_intensity_uchar (color);
|
|
||||||
bg[1] = transparent ? 0 : 255;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gimp_get_bg_guchar (GimpDrawable *drawable,
|
|
||||||
gboolean transparent,
|
|
||||||
guchar *bg)
|
|
||||||
{
|
|
||||||
GimpRGB background;
|
|
||||||
|
|
||||||
gimp_palette_get_background (&background);
|
|
||||||
gimp_get_color_guchar (drawable, &background, transparent, bg);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gimp_get_fg_guchar (GimpDrawable *drawable,
|
|
||||||
gboolean transparent,
|
|
||||||
guchar *fg)
|
|
||||||
{
|
|
||||||
GimpRGB foreground;
|
|
||||||
|
|
||||||
gimp_palette_get_foreground (&foreground);
|
|
||||||
gimp_get_color_guchar (drawable, &foreground, transparent, fg);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -35,36 +35,31 @@ typedef enum
|
||||||
GIMP_PIXEL_FETCHER_EDGE_NONE,
|
GIMP_PIXEL_FETCHER_EDGE_NONE,
|
||||||
GIMP_PIXEL_FETCHER_EDGE_WRAP,
|
GIMP_PIXEL_FETCHER_EDGE_WRAP,
|
||||||
GIMP_PIXEL_FETCHER_EDGE_SMEAR,
|
GIMP_PIXEL_FETCHER_EDGE_SMEAR,
|
||||||
GIMP_PIXEL_FETCHER_EDGE_BLACK
|
GIMP_PIXEL_FETCHER_EDGE_BLACK,
|
||||||
|
GIMP_PIXEL_FETCHER_EDGE_BACKGROUND
|
||||||
} GimpPixelFetcherEdgeMode;
|
} GimpPixelFetcherEdgeMode;
|
||||||
|
|
||||||
|
|
||||||
typedef struct _GimpPixelFetcher GimpPixelFetcher;
|
typedef struct _GimpPixelFetcher GimpPixelFetcher;
|
||||||
|
|
||||||
GimpPixelFetcher * gimp_pixel_fetcher_new (GimpDrawable *drawable);
|
|
||||||
void gimp_pixel_fetcher_set_edge_mode (GimpPixelFetcher *pf,
|
|
||||||
GimpPixelFetcherEdgeMode mode);
|
|
||||||
|
|
||||||
void gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf);
|
GimpPixelFetcher * gimp_pixel_fetcher_new (GimpDrawable *drawable,
|
||||||
void gimp_pixel_fetcher_set_shadow (GimpPixelFetcher *pf,
|
gboolean shadow);
|
||||||
gboolean shadow);
|
void gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf);
|
||||||
void gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
|
||||||
gint x,
|
|
||||||
gint y,
|
|
||||||
guchar *pixel);
|
|
||||||
void gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
|
||||||
gint x,
|
|
||||||
gint y,
|
|
||||||
const guchar *pixel);
|
|
||||||
void gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf);
|
|
||||||
|
|
||||||
|
void gimp_pixel_fetcher_set_edge_mode (GimpPixelFetcher *pf,
|
||||||
|
GimpPixelFetcherEdgeMode mode);
|
||||||
|
void gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf,
|
||||||
|
const GimpRGB *color);
|
||||||
|
|
||||||
void gimp_get_bg_guchar (GimpDrawable *drawable,
|
void gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
||||||
gboolean transparent,
|
gint x,
|
||||||
guchar *bg);
|
gint y,
|
||||||
void gimp_get_fg_guchar (GimpDrawable *drawable,
|
guchar *pixel);
|
||||||
gboolean transparent,
|
void gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
||||||
guchar *fg);
|
gint x,
|
||||||
|
gint y,
|
||||||
|
const guchar *pixel);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -528,13 +528,19 @@ blindsapply (guchar *srow,
|
||||||
static void
|
static void
|
||||||
dialog_update_preview (void)
|
dialog_update_preview (void)
|
||||||
{
|
{
|
||||||
gint y;
|
gint y;
|
||||||
guchar *p, *buffer;
|
guchar *p, *buffer;
|
||||||
guchar bg[4];
|
GimpRGB background;
|
||||||
|
guchar bg[4];
|
||||||
|
|
||||||
p = preview->cache;
|
p = preview->cache;
|
||||||
|
|
||||||
gimp_get_bg_guchar (blindsdrawable, bvals.bg_trans, bg);
|
gimp_palette_get_background (&background);
|
||||||
|
|
||||||
|
if (bvals.bg_trans)
|
||||||
|
gimp_rgb_set_alpha (&background, 0.0);
|
||||||
|
|
||||||
|
gimp_drawable_get_color_uchar (blindsdrawable->drawable_id, &background, bg);
|
||||||
|
|
||||||
buffer = (guchar*) g_malloc (preview->rowstride);
|
buffer = (guchar*) g_malloc (preview->rowstride);
|
||||||
|
|
||||||
|
@ -620,18 +626,24 @@ dialog_update_preview (void)
|
||||||
static void
|
static void
|
||||||
apply_blinds (void)
|
apply_blinds (void)
|
||||||
{
|
{
|
||||||
GimpPixelRgn des_rgn;
|
GimpPixelRgn des_rgn;
|
||||||
GimpPixelRgn src_rgn;
|
GimpPixelRgn src_rgn;
|
||||||
guchar *src_rows, *des_rows;
|
guchar *src_rows, *des_rows;
|
||||||
gint x,y;
|
gint x, y;
|
||||||
guchar bg[4];
|
GimpRGB background;
|
||||||
gint sel_x1, sel_y1, sel_x2, sel_y2;
|
guchar bg[4];
|
||||||
gint sel_width, sel_height;
|
gint sel_x1, sel_y1, sel_x2, sel_y2;
|
||||||
|
gint sel_width, sel_height;
|
||||||
|
|
||||||
gimp_get_bg_guchar (blindsdrawable, bvals.bg_trans, bg);
|
gimp_palette_get_background (&background);
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (blindsdrawable->drawable_id, &sel_x1, &sel_y1,
|
if (bvals.bg_trans)
|
||||||
&sel_x2, &sel_y2);
|
gimp_rgb_set_alpha (&background, 0.0);
|
||||||
|
|
||||||
|
gimp_drawable_get_color_uchar (blindsdrawable->drawable_id, &background, bg);
|
||||||
|
|
||||||
|
gimp_drawable_mask_bounds (blindsdrawable->drawable_id,
|
||||||
|
&sel_x1, &sel_y1, &sel_x2, &sel_y2);
|
||||||
|
|
||||||
sel_width = sel_x2 - sel_x1;
|
sel_width = sel_x2 - sel_x1;
|
||||||
sel_height = sel_y2 - sel_y1;
|
sel_height = sel_y2 - sel_y1;
|
||||||
|
@ -648,8 +660,8 @@ apply_blinds (void)
|
||||||
{
|
{
|
||||||
for (y = 0; y < sel_height; y += STEP)
|
for (y = 0; y < sel_height; y += STEP)
|
||||||
{
|
{
|
||||||
int rr;
|
gint rr;
|
||||||
int step;
|
gint step;
|
||||||
|
|
||||||
if((y + STEP) > sel_height)
|
if((y + STEP) > sel_height)
|
||||||
step = sel_height - y;
|
step = sel_height - y;
|
||||||
|
@ -686,7 +698,7 @@ apply_blinds (void)
|
||||||
* this act as a transfomation matrix for the
|
* this act as a transfomation matrix for the
|
||||||
* rows. Make row 0 invalid so we can find it again!
|
* rows. Make row 0 invalid so we can find it again!
|
||||||
*/
|
*/
|
||||||
int i;
|
gint i;
|
||||||
gint *sr = g_new (gint, sel_height * 4);
|
gint *sr = g_new (gint, sel_height * 4);
|
||||||
gint *dr = g_new (gint, sel_height * 4);
|
gint *dr = g_new (gint, sel_height * 4);
|
||||||
guchar *dst = g_new (guchar, STEP * 4);
|
guchar *dst = g_new (guchar, STEP * 4);
|
||||||
|
|
|
@ -216,11 +216,15 @@ checkerboard_func (gint x,
|
||||||
static void
|
static void
|
||||||
do_checkerboard_pattern (GimpDrawable *drawable)
|
do_checkerboard_pattern (GimpDrawable *drawable)
|
||||||
{
|
{
|
||||||
CheckerboardParam_t param;
|
CheckerboardParam_t param;
|
||||||
GimpRgnIterator *iter;
|
GimpRgnIterator *iter;
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
gimp_get_bg_guchar (drawable, FALSE, param.bg);
|
gimp_palette_get_background (&color);
|
||||||
gimp_get_fg_guchar (drawable, FALSE, param.fg);
|
gimp_drawable_get_color_uchar (drawable->drawable_id, &color, param.bg);
|
||||||
|
|
||||||
|
gimp_palette_get_foreground (&color);
|
||||||
|
gimp_drawable_get_color_uchar (drawable->drawable_id, &color, param.fg);
|
||||||
|
|
||||||
if (cvals.size < 1)
|
if (cvals.size < 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -317,25 +317,25 @@ static void
|
||||||
cubism (GimpDrawable *drawable)
|
cubism (GimpDrawable *drawable)
|
||||||
{
|
{
|
||||||
GimpPixelRgn src_rgn;
|
GimpPixelRgn src_rgn;
|
||||||
guchar bg_col[4];
|
guchar bg_col[4];
|
||||||
gdouble x, y;
|
gdouble x, y;
|
||||||
gdouble width, height;
|
gdouble width, height;
|
||||||
gdouble theta;
|
gdouble theta;
|
||||||
gint ix, iy;
|
gint ix, iy;
|
||||||
gint rows, cols;
|
gint rows, cols;
|
||||||
gint i, j, count;
|
gint i, j, count;
|
||||||
gint num_tiles;
|
gint num_tiles;
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1, x2, y2;
|
||||||
Polygon poly;
|
Polygon poly;
|
||||||
guchar col[4];
|
guchar col[4];
|
||||||
guchar *dest;
|
guchar *dest;
|
||||||
gint bytes;
|
gint bytes;
|
||||||
gint has_alpha;
|
gboolean has_alpha;
|
||||||
gint *random_indices;
|
gint *random_indices;
|
||||||
gpointer pr;
|
gpointer pr;
|
||||||
GRand *gr;
|
GRand *gr;
|
||||||
|
|
||||||
gr = g_rand_new();
|
gr = g_rand_new ();
|
||||||
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
||||||
bytes = drawable->bpp;
|
bytes = drawable->bpp;
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||||
|
@ -347,7 +347,11 @@ cubism (GimpDrawable *drawable)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gimp_get_bg_guchar (drawable, TRUE, bg_col);
|
GimpRGB color;
|
||||||
|
|
||||||
|
gimp_palette_get_background (&color);
|
||||||
|
gimp_rgb_set_alpha (&color, 0.0);
|
||||||
|
gimp_drawable_get_color_uchar (drawable->drawable_id, &color, bg_col);
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_progress_init (_("Cubistic Transformation"));
|
gimp_progress_init (_("Cubistic Transformation"));
|
||||||
|
@ -358,6 +362,7 @@ cubism (GimpDrawable *drawable)
|
||||||
/* Fill the image with the background color */
|
/* Fill the image with the background color */
|
||||||
gimp_pixel_rgn_init (&src_rgn, drawable,
|
gimp_pixel_rgn_init (&src_rgn, drawable,
|
||||||
x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE);
|
x1, y1, (x2 - x1), (y2 - y1), TRUE, TRUE);
|
||||||
|
|
||||||
for (pr = gimp_pixel_rgns_register (1, &src_rgn);
|
for (pr = gimp_pixel_rgns_register (1, &src_rgn);
|
||||||
pr != NULL;
|
pr != NULL;
|
||||||
pr = gimp_pixel_rgns_process (pr))
|
pr = gimp_pixel_rgns_process (pr))
|
||||||
|
@ -385,15 +390,15 @@ cubism (GimpDrawable *drawable)
|
||||||
{
|
{
|
||||||
i = random_indices[count] / (cols + 1);
|
i = random_indices[count] / (cols + 1);
|
||||||
j = random_indices[count] % (cols + 1);
|
j = random_indices[count] % (cols + 1);
|
||||||
x = j * cvals.tile_size + (cvals.tile_size / 4.0)
|
x = j * cvals.tile_size + (cvals.tile_size / 4.0)
|
||||||
- g_rand_double_range (gr, 0, cvals.tile_size/2.0) + x1;
|
- g_rand_double_range (gr, 0, cvals.tile_size/2.0) + x1;
|
||||||
y = i * cvals.tile_size + (cvals.tile_size / 4.0)
|
y = i * cvals.tile_size + (cvals.tile_size / 4.0)
|
||||||
- g_rand_double_range (gr, 0, cvals.tile_size/2.0) + y1;
|
- g_rand_double_range (gr, 0, cvals.tile_size/2.0) + y1;
|
||||||
width = (cvals.tile_size +
|
width = (cvals.tile_size +
|
||||||
g_rand_double_range (gr, 0, cvals.tile_size / 4.0) -
|
g_rand_double_range (gr, 0, cvals.tile_size / 4.0) -
|
||||||
cvals.tile_size / 8.0) * cvals.tile_saturation;
|
cvals.tile_size / 8.0) * cvals.tile_saturation;
|
||||||
height = (cvals.tile_size +
|
height = (cvals.tile_size +
|
||||||
g_rand_double_range (gr, 0, cvals.tile_size / 4.0) -
|
g_rand_double_range (gr, 0, cvals.tile_size / 4.0) -
|
||||||
cvals.tile_size / 8.0) * cvals.tile_saturation;
|
cvals.tile_size / 8.0) * cvals.tile_saturation;
|
||||||
theta = g_rand_double_range (gr, 0, 2 * G_PI);
|
theta = g_rand_double_range (gr, 0, 2 * G_PI);
|
||||||
polygon_reset (&poly);
|
polygon_reset (&poly);
|
||||||
|
|
|
@ -2552,13 +2552,13 @@ p_end_gdrw (t_GDRW *gdrw)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
p_init_gdrw (t_GDRW *gdrw,
|
p_init_gdrw (t_GDRW *gdrw,
|
||||||
GimpDrawable *drawable,
|
GimpDrawable *drawable,
|
||||||
int dirty,
|
int dirty,
|
||||||
int shadow)
|
int shadow)
|
||||||
{
|
{
|
||||||
gdrw->drawable = drawable;
|
gdrw->drawable = drawable;
|
||||||
gdrw->pft = gimp_pixel_fetcher_new (drawable);
|
gdrw->pft = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
gimp_pixel_fetcher_set_edge_mode (gdrw->pft, GIMP_PIXEL_FETCHER_EDGE_BLACK);
|
gimp_pixel_fetcher_set_edge_mode (gdrw->pft, GIMP_PIXEL_FETCHER_EDGE_BLACK);
|
||||||
gdrw->tile_width = gimp_tile_width ();
|
gdrw->tile_width = gimp_tile_width ();
|
||||||
gdrw->tile_height = gimp_tile_height ();
|
gdrw->tile_height = gimp_tile_height ();
|
||||||
|
@ -2586,7 +2586,7 @@ static void
|
||||||
p_get_pixel (t_GDRW *gdrw,
|
p_get_pixel (t_GDRW *gdrw,
|
||||||
gint32 x,
|
gint32 x,
|
||||||
gint32 y,
|
gint32 y,
|
||||||
guchar *pixel )
|
guchar *pixel)
|
||||||
{
|
{
|
||||||
pixel[1] = 255;
|
pixel[1] = 255;
|
||||||
pixel[3] = 255; /* simulate full visible alpha channel */
|
pixel[3] = 255; /* simulate full visible alpha channel */
|
||||||
|
|
|
@ -469,7 +469,7 @@ displace (GimpDrawable *drawable)
|
||||||
mxrow = NULL;
|
mxrow = NULL;
|
||||||
myrow = NULL;
|
myrow = NULL;
|
||||||
|
|
||||||
pft = gimp_pixel_fetcher_new (drawable);
|
pft = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
gimp_pixel_fetcher_set_edge_mode (pft, dvals.displace_type);
|
gimp_pixel_fetcher_set_edge_mode (pft, dvals.displace_type);
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||||
|
|
|
@ -275,7 +275,7 @@ edge (GimpDrawable *drawable)
|
||||||
if (evals.amount < 1.0)
|
if (evals.amount < 1.0)
|
||||||
evals.amount = 1.0;
|
evals.amount = 1.0;
|
||||||
|
|
||||||
pft = gimp_pixel_fetcher_new (drawable);
|
pft = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
gimp_pixel_fetcher_set_edge_mode (pft, evals.wrapmode);
|
gimp_pixel_fetcher_set_edge_mode (pft, evals.wrapmode);
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||||
|
@ -299,20 +299,22 @@ edge (GimpDrawable *drawable)
|
||||||
pr != NULL;
|
pr != NULL;
|
||||||
pr = gimp_pixel_rgns_process (pr))
|
pr = gimp_pixel_rgns_process (pr))
|
||||||
{
|
{
|
||||||
srcrow = src_rgn.data;
|
srcrow = src_rgn.data;
|
||||||
destrow = dest_rgn.data;
|
destrow = dest_rgn.data;
|
||||||
|
|
||||||
for (y = dest_rgn.y;
|
for (y = dest_rgn.y;
|
||||||
y < (dest_rgn.y + dest_rgn.h);
|
y < (dest_rgn.y + dest_rgn.h);
|
||||||
y++, srcrow += src_rgn.rowstride, destrow += dest_rgn.rowstride)
|
y++, srcrow += src_rgn.rowstride, destrow += dest_rgn.rowstride)
|
||||||
{
|
{
|
||||||
src = srcrow;
|
src = srcrow;
|
||||||
dest = destrow;
|
dest = destrow;
|
||||||
|
|
||||||
for (x = dest_rgn.x;
|
for (x = dest_rgn.x;
|
||||||
x < (dest_rgn.x + dest_rgn.w);
|
x < (dest_rgn.x + dest_rgn.w);
|
||||||
x++, src += src_rgn.bpp, dest += dest_rgn.bpp)
|
x++, src += src_rgn.bpp, dest += dest_rgn.bpp)
|
||||||
{
|
{
|
||||||
if(dest_rgn.x < x && x < dest_rgn.x + dest_rgn.w - 2 &&
|
if (dest_rgn.x < x && x < dest_rgn.x + dest_rgn.w - 2 &&
|
||||||
dest_rgn.y < y && y < dest_rgn.y + dest_rgn.h - 2)
|
dest_rgn.y < y && y < dest_rgn.y + dest_rgn.h - 2)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
** 3x3 kernel is inside of the tile -- do fast
|
** 3x3 kernel is inside of the tile -- do fast
|
||||||
|
@ -323,13 +325,16 @@ edge (GimpDrawable *drawable)
|
||||||
/* get the 3x3 kernel into a guchar array,
|
/* get the 3x3 kernel into a guchar array,
|
||||||
* and send it to edge_detect */
|
* and send it to edge_detect */
|
||||||
guchar kernel[9];
|
guchar kernel[9];
|
||||||
int i,j;
|
gint i,j;
|
||||||
|
|
||||||
#define PIX(X,Y) src[ (Y-1)*(int)src_rgn.rowstride + (X-1)*(int)src_rgn.bpp + chan ]
|
#define PIX(X,Y) src[ (Y-1)*(int)src_rgn.rowstride + (X-1)*(int)src_rgn.bpp + chan ]
|
||||||
/* make convolution */
|
/* make convolution */
|
||||||
for(i = 0; i < 3; i++)
|
for(i = 0; i < 3; i++)
|
||||||
for(j = 0; j < 3; j++)
|
for(j = 0; j < 3; j++)
|
||||||
kernel[3*i + j] = PIX(i,j);
|
kernel[3*i + j] = PIX(i,j);
|
||||||
|
|
||||||
#undef PIX
|
#undef PIX
|
||||||
|
|
||||||
dest[chan] = edge_detect(kernel);
|
dest[chan] = edge_detect(kernel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,17 +255,18 @@ illusion_func (gint x,
|
||||||
static void
|
static void
|
||||||
filter (GimpDrawable *drawable)
|
filter (GimpDrawable *drawable)
|
||||||
{
|
{
|
||||||
IllusionParam_t param;
|
IllusionParam_t param;
|
||||||
GimpRgnIterator *iter;
|
GimpRgnIterator *iter;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1, x2, y2;
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||||
width = x2 - x1;
|
width = x2 - x1;
|
||||||
height = y2 - y1;
|
height = y2 - y1;
|
||||||
|
|
||||||
param.pft = gimp_pixel_fetcher_new (drawable);
|
param.pft = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
gimp_pixel_fetcher_set_edge_mode (param.pft, GIMP_PIXEL_FETCHER_EDGE_SMEAR);
|
gimp_pixel_fetcher_set_edge_mode (param.pft, GIMP_PIXEL_FETCHER_EDGE_SMEAR);
|
||||||
|
|
||||||
param.has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
param.has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
||||||
param.center_x = (x1 + x2) / 2.0;
|
param.center_x = (x1 + x2) / 2.0;
|
||||||
param.center_y = (y1 + y2) / 2.0;
|
param.center_y = (y1 + y2) / 2.0;
|
||||||
|
|
|
@ -264,9 +264,10 @@ run (const gchar *name,
|
||||||
static void
|
static void
|
||||||
mblur_linear (void)
|
mblur_linear (void)
|
||||||
{
|
{
|
||||||
GimpPixelRgn dest_rgn;
|
GimpPixelRgn dest_rgn;
|
||||||
GimpPixelFetcher *pft;
|
GimpPixelFetcher *pft;
|
||||||
gpointer pr;
|
gpointer pr;
|
||||||
|
GimpRGB background;
|
||||||
|
|
||||||
guchar *dest;
|
guchar *dest;
|
||||||
guchar *d;
|
guchar *d;
|
||||||
|
@ -280,9 +281,10 @@ mblur_linear (void)
|
||||||
gimp_pixel_rgn_init (&dest_rgn, drawable,
|
gimp_pixel_rgn_init (&dest_rgn, drawable,
|
||||||
sel_x1, sel_y1, sel_width, sel_height, TRUE, TRUE);
|
sel_x1, sel_y1, sel_width, sel_height, TRUE, TRUE);
|
||||||
|
|
||||||
pft = gimp_pixel_fetcher_new (drawable);
|
pft = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
|
|
||||||
gimp_pixel_fetcher_set_bg_color (pft);
|
gimp_palette_get_background (&background);
|
||||||
|
gimp_pixel_fetcher_set_bg_color (pft, &background);
|
||||||
|
|
||||||
progress = 0;
|
progress = 0;
|
||||||
max_progress = sel_width * sel_height;
|
max_progress = sel_width * sel_height;
|
||||||
|
@ -423,9 +425,10 @@ mblur_linear (void)
|
||||||
static void
|
static void
|
||||||
mblur_radial (void)
|
mblur_radial (void)
|
||||||
{
|
{
|
||||||
GimpPixelRgn dest_rgn;
|
GimpPixelRgn dest_rgn;
|
||||||
GimpPixelFetcher *pft;
|
GimpPixelFetcher *pft;
|
||||||
gpointer pr;
|
gpointer pr;
|
||||||
|
GimpRGB background;
|
||||||
|
|
||||||
guchar *dest;
|
guchar *dest;
|
||||||
guchar *d;
|
guchar *d;
|
||||||
|
@ -446,9 +449,10 @@ mblur_radial (void)
|
||||||
gimp_pixel_rgn_init (&dest_rgn, drawable,
|
gimp_pixel_rgn_init (&dest_rgn, drawable,
|
||||||
sel_x1, sel_y1, sel_width, sel_height, TRUE, TRUE);
|
sel_x1, sel_y1, sel_width, sel_height, TRUE, TRUE);
|
||||||
|
|
||||||
pft = gimp_pixel_fetcher_new (drawable);
|
pft = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
|
|
||||||
gimp_pixel_fetcher_set_bg_color (pft);
|
gimp_palette_get_background (&background);
|
||||||
|
gimp_pixel_fetcher_set_bg_color (pft, &background);
|
||||||
|
|
||||||
progress = 0;
|
progress = 0;
|
||||||
max_progress = sel_width * sel_height;
|
max_progress = sel_width * sel_height;
|
||||||
|
@ -559,9 +563,10 @@ mblur_radial (void)
|
||||||
static void
|
static void
|
||||||
mblur_zoom (void)
|
mblur_zoom (void)
|
||||||
{
|
{
|
||||||
GimpPixelRgn dest_rgn;
|
GimpPixelRgn dest_rgn;
|
||||||
GimpPixelFetcher *pft;
|
GimpPixelFetcher *pft;
|
||||||
gpointer pr;
|
gpointer pr;
|
||||||
|
GimpRGB background;
|
||||||
|
|
||||||
guchar *dest, *d;
|
guchar *dest, *d;
|
||||||
guchar pixel[4];
|
guchar pixel[4];
|
||||||
|
@ -579,9 +584,10 @@ mblur_zoom (void)
|
||||||
gimp_pixel_rgn_init (&dest_rgn, drawable,
|
gimp_pixel_rgn_init (&dest_rgn, drawable,
|
||||||
sel_x1, sel_y1, sel_width, sel_height, TRUE, TRUE);
|
sel_x1, sel_y1, sel_width, sel_height, TRUE, TRUE);
|
||||||
|
|
||||||
pft = gimp_pixel_fetcher_new (drawable);
|
pft = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
|
|
||||||
gimp_pixel_fetcher_set_bg_color (pft);
|
gimp_palette_get_background (&background);
|
||||||
|
gimp_pixel_fetcher_set_bg_color (pft, &background);
|
||||||
|
|
||||||
progress = 0;
|
progress = 0;
|
||||||
max_progress = sel_width * sel_height;
|
max_progress = sel_width * sel_height;
|
||||||
|
|
|
@ -39,7 +39,6 @@
|
||||||
|
|
||||||
#define HORIZONTAL 0
|
#define HORIZONTAL 0
|
||||||
#define VERTICAL 1
|
#define VERTICAL 1
|
||||||
#define OPAQUE 255
|
|
||||||
#define SUPERSAMPLE 3
|
#define SUPERSAMPLE 3
|
||||||
#define MAG_THRESHOLD 7.5
|
#define MAG_THRESHOLD 7.5
|
||||||
#define COUNT_THRESHOLD 0.1
|
#define COUNT_THRESHOLD 0.1
|
||||||
|
@ -425,6 +424,7 @@ mosaic (GimpDrawable *drawable)
|
||||||
{
|
{
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1, x2, y2;
|
||||||
gint alpha;
|
gint alpha;
|
||||||
|
GimpRGB color;
|
||||||
|
|
||||||
/* Find the mask bounds */
|
/* Find the mask bounds */
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||||
|
@ -460,18 +460,17 @@ mosaic (GimpDrawable *drawable)
|
||||||
fore[0] = fore[1] = fore[2] = 255;
|
fore[0] = fore[1] = fore[2] = 255;
|
||||||
back[0] = back[1] = back[2] = 0;
|
back[0] = back[1] = back[2] = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FG_BG:
|
case FG_BG:
|
||||||
gimp_get_fg_guchar (drawable, FALSE, fore);
|
gimp_palette_get_foreground (&color);
|
||||||
gimp_get_bg_guchar (drawable, FALSE, back);
|
gimp_drawable_get_color_uchar (drawable->drawable_id, &color, fore);
|
||||||
|
|
||||||
|
gimp_palette_get_background (&color);
|
||||||
|
gimp_drawable_get_color_uchar (drawable->drawable_id, &color, back);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
alpha = drawable->bpp - 1;
|
alpha = drawable->bpp - 1;
|
||||||
if (gimp_drawable_has_alpha (drawable->drawable_id))
|
|
||||||
{
|
|
||||||
fore[alpha] = OPAQUE;
|
|
||||||
back[alpha] = OPAQUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
light_x = -cos (mvals.light_dir * G_PI / 180.0);
|
light_x = -cos (mvals.light_dir * G_PI / 180.0);
|
||||||
light_y = sin (mvals.light_dir * G_PI / 180.0);
|
light_y = sin (mvals.light_dir * G_PI / 180.0);
|
||||||
|
@ -760,7 +759,7 @@ find_gradients (GimpDrawable *drawable,
|
||||||
else {
|
else {
|
||||||
hmax = *dh - 128;
|
hmax = *dh - 128;
|
||||||
vmax = *dv - 128;
|
vmax = *dv - 128;
|
||||||
|
|
||||||
*gr = (guchar)sqrt (SQR (hmax) + SQR (hmax));
|
*gr = (guchar)sqrt (SQR (hmax) + SQR (hmax));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1994,9 +1993,9 @@ fill_poly_color (Polygon *poly,
|
||||||
ys = (gint) pts_tmp[poly_npts-1].y;
|
ys = (gint) pts_tmp[poly_npts-1].y;
|
||||||
xe = (gint) pts_tmp->x;
|
xe = (gint) pts_tmp->x;
|
||||||
ye = (gint) pts_tmp->y;
|
ye = (gint) pts_tmp->y;
|
||||||
|
|
||||||
calc_spec_vec (vecs, xs, ys, xe, ye);
|
calc_spec_vec (vecs, xs, ys, xe, ye);
|
||||||
|
|
||||||
for (i = 1; i < poly_npts; i++)
|
for (i = 1; i < poly_npts; i++)
|
||||||
{
|
{
|
||||||
xs = (gint) (pts_tmp->x);
|
xs = (gint) (pts_tmp->x);
|
||||||
|
@ -2004,7 +2003,7 @@ fill_poly_color (Polygon *poly,
|
||||||
pts_tmp++;
|
pts_tmp++;
|
||||||
xe = (gint) pts_tmp->x;
|
xe = (gint) pts_tmp->x;
|
||||||
ye = (gint) pts_tmp->y;
|
ye = (gint) pts_tmp->y;
|
||||||
|
|
||||||
calc_spec_vec (vecs+i, xs, ys, xe, ye);
|
calc_spec_vec (vecs+i, xs, ys, xe, ye);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2356,9 +2355,9 @@ convert_segment (gint x1,
|
||||||
gdouble xinc, xstart;
|
gdouble xinc, xstart;
|
||||||
|
|
||||||
if (y1 > y2)
|
if (y1 > y2)
|
||||||
{
|
{
|
||||||
tmp = y2; y2 = y1; y1 = tmp;
|
tmp = y2; y2 = y1; y1 = tmp;
|
||||||
tmp = x2; x2 = x1; x1 = tmp;
|
tmp = x2; x2 = x1; x1 = tmp;
|
||||||
}
|
}
|
||||||
ydiff = y2 - y1;
|
ydiff = y2 - y1;
|
||||||
|
|
||||||
|
|
|
@ -445,8 +445,7 @@ init_plasma (GimpDrawable *drawable,
|
||||||
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
||||||
alpha = (has_alpha) ? bpp - 1 : bpp;
|
alpha = (has_alpha) ? bpp - 1 : bpp;
|
||||||
|
|
||||||
pft = gimp_pixel_fetcher_new (drawable);
|
pft = gimp_pixel_fetcher_new (drawable, TRUE);
|
||||||
gimp_pixel_fetcher_set_shadow (pft, TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
progress = 0;
|
progress = 0;
|
||||||
|
|
|
@ -341,17 +341,21 @@ polarize_func (gint x,
|
||||||
static void
|
static void
|
||||||
polarize (void)
|
polarize (void)
|
||||||
{
|
{
|
||||||
GimpRgnIterator *iter;
|
GimpRgnIterator *iter;
|
||||||
GimpPixelFetcher *pft;
|
GimpPixelFetcher *pft;
|
||||||
|
GimpRGB background;
|
||||||
|
|
||||||
pft = gimp_pixel_fetcher_new (drawable);
|
pft = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
gimp_pixel_fetcher_set_bg_color (pft);
|
|
||||||
|
gimp_palette_get_background (&background);
|
||||||
|
gimp_pixel_fetcher_set_bg_color (pft, &background);
|
||||||
|
|
||||||
gimp_progress_init (_("Polarizing..."));
|
gimp_progress_init (_("Polarizing..."));
|
||||||
|
|
||||||
iter = gimp_rgn_iterator_new (drawable, run_mode);
|
iter = gimp_rgn_iterator_new (drawable, run_mode);
|
||||||
gimp_rgn_iterator_dest (iter, polarize_func, pft);
|
gimp_rgn_iterator_dest (iter, polarize_func, pft);
|
||||||
|
|
||||||
gimp_rgn_iterator_free (iter);
|
gimp_rgn_iterator_free (iter);
|
||||||
|
|
||||||
gimp_pixel_fetcher_destroy (pft);
|
gimp_pixel_fetcher_destroy (pft);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,33 +366,33 @@ calc_undistorted_coords (gdouble wx,
|
||||||
gdouble *y)
|
gdouble *y)
|
||||||
{
|
{
|
||||||
gboolean inside;
|
gboolean inside;
|
||||||
gdouble phi, phi2;
|
gdouble phi, phi2;
|
||||||
gdouble xx, xm, ym, yy;
|
gdouble xx, xm, ym, yy;
|
||||||
gint xdiff, ydiff;
|
gint xdiff, ydiff;
|
||||||
gdouble r;
|
gdouble r;
|
||||||
gdouble m;
|
gdouble m;
|
||||||
gdouble xmax, ymax, rmax;
|
gdouble xmax, ymax, rmax;
|
||||||
gdouble x_calc, y_calc;
|
gdouble x_calc, y_calc;
|
||||||
gdouble xi, yi;
|
gdouble xi, yi;
|
||||||
gdouble circle, angl, t, angle;
|
gdouble circle, angl, t, angle;
|
||||||
gint x1, x2, y1, y2;
|
gint x1, x2, y1, y2;
|
||||||
|
|
||||||
/* initialize */
|
/* initialize */
|
||||||
|
|
||||||
phi = 0.0;
|
phi = 0.0;
|
||||||
r = 0.0;
|
r = 0.0;
|
||||||
|
|
||||||
x1 = 0;
|
x1 = 0;
|
||||||
y1 = 0;
|
y1 = 0;
|
||||||
x2 = img_width;
|
x2 = img_width;
|
||||||
y2 = img_height;
|
y2 = img_height;
|
||||||
xdiff = x2 - x1;
|
xdiff = x2 - x1;
|
||||||
ydiff = y2 - y1;
|
ydiff = y2 - y1;
|
||||||
xm = xdiff / 2.0;
|
xm = xdiff / 2.0;
|
||||||
ym = ydiff / 2.0;
|
ym = ydiff / 2.0;
|
||||||
circle = pcvals.circle;
|
circle = pcvals.circle;
|
||||||
angle = pcvals.angle;
|
angle = pcvals.angle;
|
||||||
angl = (double)angle / 180.0 * G_PI;
|
angl = (gdouble) angle / 180.0 * G_PI;
|
||||||
|
|
||||||
if (pcvals.polrec)
|
if (pcvals.polrec)
|
||||||
{
|
{
|
||||||
|
@ -725,10 +729,13 @@ dialog_update_preview (void)
|
||||||
gint bpp;
|
gint bpp;
|
||||||
gdouble scale_x, scale_y;
|
gdouble scale_x, scale_y;
|
||||||
guchar *p_ul, *i;
|
guchar *p_ul, *i;
|
||||||
|
GimpRGB background;
|
||||||
guchar outside[4];
|
guchar outside[4];
|
||||||
guchar *buffer;
|
guchar *buffer;
|
||||||
|
|
||||||
gimp_get_bg_guchar (drawable, TRUE, outside);
|
gimp_palette_get_background (&background);
|
||||||
|
gimp_rgb_set_alpha (&background, 0.0);
|
||||||
|
gimp_drawable_get_color_uchar (drawable->drawable_id, &background, outside);
|
||||||
|
|
||||||
left = sel_x1;
|
left = sel_x1;
|
||||||
right = sel_x2 - 1;
|
right = sel_x2 - 1;
|
||||||
|
|
|
@ -264,7 +264,7 @@ ripple_vertical (gint x,
|
||||||
|
|
||||||
needy = y + displace_amount(x);
|
needy = y + displace_amount(x);
|
||||||
yi = floor(needy);
|
yi = floor(needy);
|
||||||
|
|
||||||
/* Tile the image. */
|
/* Tile the image. */
|
||||||
if (rvals.edges == WRAP)
|
if (rvals.edges == WRAP)
|
||||||
{
|
{
|
||||||
|
@ -276,7 +276,7 @@ ripple_vertical (gint x,
|
||||||
{
|
{
|
||||||
yi = CLAMP (yi, 0, height - 1);
|
yi = CLAMP (yi, 0, height - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rvals.antialias)
|
if (rvals.antialias)
|
||||||
{
|
{
|
||||||
if (yi == height - 1)
|
if (yi == height - 1)
|
||||||
|
@ -291,7 +291,7 @@ ripple_vertical (gint x,
|
||||||
{
|
{
|
||||||
gimp_pixel_fetcher_get_pixel (pft, x, yi, pixel[0]);
|
gimp_pixel_fetcher_get_pixel (pft, x, yi, pixel[0]);
|
||||||
gimp_pixel_fetcher_get_pixel (pft, x, yi + 1, pixel[1]);
|
gimp_pixel_fetcher_get_pixel (pft, x, yi + 1, pixel[1]);
|
||||||
|
|
||||||
average_two_pixels (dest, pixel, needy, bpp, param->has_alpha);
|
average_two_pixels (dest, pixel, needy, bpp, param->has_alpha);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -300,7 +300,7 @@ ripple_vertical (gint x,
|
||||||
gimp_pixel_fetcher_get_pixel (pft, x, yi + 1, pixel[1]);
|
gimp_pixel_fetcher_get_pixel (pft, x, yi + 1, pixel[1]);
|
||||||
gimp_pixel_fetcher_get_pixel (pft, x, yi - 1, pixel[2]);
|
gimp_pixel_fetcher_get_pixel (pft, x, yi - 1, pixel[2]);
|
||||||
gimp_pixel_fetcher_get_pixel (pft, x, yi + 2, pixel[3]);
|
gimp_pixel_fetcher_get_pixel (pft, x, yi + 2, pixel[3]);
|
||||||
|
|
||||||
average_four_pixels (dest, pixel, needy, bpp, param->has_alpha);
|
average_four_pixels (dest, pixel, needy, bpp, param->has_alpha);
|
||||||
}
|
}
|
||||||
} /* antialias */
|
} /* antialias */
|
||||||
|
@ -328,7 +328,7 @@ ripple_horizontal (gint x,
|
||||||
|
|
||||||
needx = x + displace_amount(y);
|
needx = x + displace_amount(y);
|
||||||
xi = floor (needx);
|
xi = floor (needx);
|
||||||
|
|
||||||
/* Tile the image. */
|
/* Tile the image. */
|
||||||
if (rvals.edges == WRAP)
|
if (rvals.edges == WRAP)
|
||||||
{
|
{
|
||||||
|
@ -340,7 +340,7 @@ ripple_horizontal (gint x,
|
||||||
{
|
{
|
||||||
xi = CLAMP(xi, 0, width - 1);
|
xi = CLAMP(xi, 0, width - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rvals.antialias)
|
if (rvals.antialias)
|
||||||
{
|
{
|
||||||
if (xi == width - 1)
|
if (xi == width - 1)
|
||||||
|
@ -351,12 +351,12 @@ ripple_horizontal (gint x,
|
||||||
{
|
{
|
||||||
gimp_pixel_fetcher_get_pixel (pft, 0, y, dest);
|
gimp_pixel_fetcher_get_pixel (pft, 0, y, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (xi == width - 2 || xi == 0)
|
else if (xi == width - 2 || xi == 0)
|
||||||
{
|
{
|
||||||
gimp_pixel_fetcher_get_pixel (pft, xi, y, pixel[0]);
|
gimp_pixel_fetcher_get_pixel (pft, xi, y, pixel[0]);
|
||||||
gimp_pixel_fetcher_get_pixel (pft, xi + 1, y, pixel[1]);
|
gimp_pixel_fetcher_get_pixel (pft, xi + 1, y, pixel[1]);
|
||||||
|
|
||||||
average_two_pixels (dest, pixel, needx, bpp, param->has_alpha);
|
average_two_pixels (dest, pixel, needx, bpp, param->has_alpha);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -365,11 +365,11 @@ ripple_horizontal (gint x,
|
||||||
gimp_pixel_fetcher_get_pixel (pft, xi + 1, y, pixel[1]);
|
gimp_pixel_fetcher_get_pixel (pft, xi + 1, y, pixel[1]);
|
||||||
gimp_pixel_fetcher_get_pixel (pft, xi - 1, y, pixel[2]);
|
gimp_pixel_fetcher_get_pixel (pft, xi - 1, y, pixel[2]);
|
||||||
gimp_pixel_fetcher_get_pixel (pft, xi + 2, y, pixel[3]);
|
gimp_pixel_fetcher_get_pixel (pft, xi + 2, y, pixel[3]);
|
||||||
|
|
||||||
average_four_pixels (dest, pixel, needx, bpp, param->has_alpha);
|
average_four_pixels (dest, pixel, needx, bpp, param->has_alpha);
|
||||||
}
|
}
|
||||||
} /* antialias */
|
} /* antialias */
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gimp_pixel_fetcher_get_pixel (pft, xi, y, dest);
|
gimp_pixel_fetcher_get_pixel (pft, xi, y, dest);
|
||||||
|
@ -380,12 +380,12 @@ static void
|
||||||
ripple (GimpDrawable *drawable)
|
ripple (GimpDrawable *drawable)
|
||||||
{
|
{
|
||||||
GimpRgnIterator *iter;
|
GimpRgnIterator *iter;
|
||||||
RippleParam_t param;
|
RippleParam_t param;
|
||||||
|
|
||||||
param.pft = gimp_pixel_fetcher_new (drawable);
|
param.pft = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
param.has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
param.has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
||||||
param.width = drawable->width;
|
param.width = drawable->width;
|
||||||
param.height = drawable->height;
|
param.height = drawable->height;
|
||||||
|
|
||||||
if ( rvals.tile )
|
if ( rvals.tile )
|
||||||
{
|
{
|
||||||
|
|
|
@ -210,24 +210,23 @@ run (const gchar *name,
|
||||||
static void
|
static void
|
||||||
shift (GimpDrawable *drawable)
|
shift (GimpDrawable *drawable)
|
||||||
{
|
{
|
||||||
GimpPixelRgn dest_rgn;
|
GimpPixelRgn dest_rgn;
|
||||||
gpointer pr;
|
gpointer pr;
|
||||||
GimpPixelFetcher *pft;
|
GimpPixelFetcher *pft;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint bytes;
|
gint bytes;
|
||||||
guchar *destline;
|
guchar *destline;
|
||||||
guchar *dest;
|
guchar *dest;
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1, x2, y2;
|
||||||
gint x, y;
|
gint x, y;
|
||||||
gint progress, max_progress;
|
gint progress, max_progress;
|
||||||
gint amount;
|
gint amount;
|
||||||
gint xdist, ydist;
|
gint xdist, ydist;
|
||||||
|
GRand *gr;
|
||||||
GRand *gr; /* The random number generator we're using */
|
|
||||||
|
|
||||||
gr = g_rand_new ();
|
gr = g_rand_new ();
|
||||||
|
|
||||||
pft = gimp_pixel_fetcher_new (drawable);
|
pft = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
gimp_pixel_fetcher_set_edge_mode (pft, GIMP_PIXEL_FETCHER_EDGE_WRAP);
|
gimp_pixel_fetcher_set_edge_mode (pft, GIMP_PIXEL_FETCHER_EDGE_WRAP);
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
* You can contact Federico Mena Quintero at quartic@polloux.fciencias.unam.mx
|
* You can contact Federico Mena Quintero at quartic@polloux.fciencias.unam.mx
|
||||||
* You can contact the original The Gimp authors at gimp@xcf.berkeley.edu
|
* You can contact the original The Gimp authors at gimp@xcf.berkeley.edu
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -212,27 +213,26 @@ run (const gchar *name,
|
||||||
static void
|
static void
|
||||||
spread (GimpDrawable *drawable)
|
spread (GimpDrawable *drawable)
|
||||||
{
|
{
|
||||||
GimpPixelRgn dest_rgn;
|
GimpPixelRgn dest_rgn;
|
||||||
gpointer pr;
|
gpointer pr;
|
||||||
GimpPixelFetcher *pft;
|
GimpPixelFetcher *pft;
|
||||||
|
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint bytes;
|
gint bytes;
|
||||||
guchar *destrow;
|
guchar *destrow;
|
||||||
guchar *dest;
|
guchar *dest;
|
||||||
gint x1, y1, x2, y2;
|
gint x1, y1, x2, y2;
|
||||||
gint x, y;
|
gint x, y;
|
||||||
gint progress, max_progress;
|
gint progress, max_progress;
|
||||||
gdouble x_amount, y_amount;
|
gdouble x_amount, y_amount;
|
||||||
gdouble angle;
|
gdouble angle;
|
||||||
gint xdist, ydist;
|
gint xdist, ydist;
|
||||||
gint xi, yi;
|
gint xi, yi;
|
||||||
|
GRand *gr;
|
||||||
GRand *gr;
|
|
||||||
|
|
||||||
gr = g_rand_new ();
|
gr = g_rand_new ();
|
||||||
|
|
||||||
pft = gimp_pixel_fetcher_new (drawable);
|
pft = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
|
|
||||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||||
|
|
||||||
|
|
|
@ -974,109 +974,113 @@ cache_preview (void)
|
||||||
static void
|
static void
|
||||||
do_tiles(void)
|
do_tiles(void)
|
||||||
{
|
{
|
||||||
GimpPixelRgn dest_rgn;
|
GimpPixelRgn dest_rgn;
|
||||||
gpointer pr;
|
gpointer pr;
|
||||||
gint progress, max_progress;
|
gint progress, max_progress;
|
||||||
guchar *dest_row;
|
guchar *dest_row;
|
||||||
guchar *dest;
|
guchar *dest;
|
||||||
gint row, col;
|
gint row, col;
|
||||||
gint bpp;
|
gint bpp;
|
||||||
guchar pixel[4];
|
guchar pixel[4];
|
||||||
int nc,nr;
|
gint nc, nr;
|
||||||
int i;
|
gint i;
|
||||||
GimpPixelFetcher *pft;
|
GimpPixelFetcher *pft;
|
||||||
|
|
||||||
/* Initialize pixel region */
|
/* Initialize pixel region */
|
||||||
|
|
||||||
pft = gimp_pixel_fetcher_new (tileitdrawable);
|
pft = gimp_pixel_fetcher_new (tileitdrawable, FALSE);
|
||||||
|
|
||||||
gimp_pixel_rgn_init(&dest_rgn, tileitdrawable, sel_x1, sel_y1, sel_width, sel_height, TRUE, TRUE);
|
gimp_pixel_rgn_init (&dest_rgn, tileitdrawable,
|
||||||
|
sel_x1, sel_y1, sel_width, sel_height, TRUE, TRUE);
|
||||||
|
|
||||||
progress = 0;
|
progress = 0;
|
||||||
max_progress = sel_width * sel_height;
|
max_progress = sel_width * sel_height;
|
||||||
|
|
||||||
img_bpp = gimp_drawable_bpp(tileitdrawable->drawable_id);
|
img_bpp = gimp_drawable_bpp (tileitdrawable->drawable_id);
|
||||||
|
|
||||||
bpp = (has_alpha) ? img_bpp - 1 : img_bpp;
|
bpp = (has_alpha) ? img_bpp - 1 : img_bpp;
|
||||||
|
|
||||||
for (pr = gimp_pixel_rgns_register(1, &dest_rgn);
|
for (pr = gimp_pixel_rgns_register(1, &dest_rgn);
|
||||||
pr != NULL; pr = gimp_pixel_rgns_process(pr)) {
|
pr != NULL;
|
||||||
dest_row = dest_rgn.data;
|
pr = gimp_pixel_rgns_process(pr))
|
||||||
|
{
|
||||||
|
dest_row = dest_rgn.data;
|
||||||
|
|
||||||
for (row = dest_rgn.y; row < (dest_rgn.y + dest_rgn.h); row++) {
|
for (row = dest_rgn.y; row < (dest_rgn.y + dest_rgn.h); row++)
|
||||||
dest = dest_row;
|
{
|
||||||
|
dest = dest_row;
|
||||||
|
|
||||||
for (col = dest_rgn.x; col < (dest_rgn.x + dest_rgn.w); col++)
|
for (col = dest_rgn.x; col < (dest_rgn.x + dest_rgn.w); col++)
|
||||||
{
|
{
|
||||||
int an_action;
|
gint an_action;
|
||||||
|
|
||||||
an_action =
|
an_action = tiles_xy (sel_width,
|
||||||
tiles_xy(sel_width,
|
sel_height,
|
||||||
sel_height,
|
col-sel_x1,row-sel_y1,
|
||||||
col-sel_x1,row-sel_y1,
|
&nc,&nr);
|
||||||
&nc,&nr);
|
|
||||||
|
|
||||||
gimp_pixel_fetcher_get_pixel (pft, nc + sel_x1, nr + sel_y1,
|
gimp_pixel_fetcher_get_pixel (pft, nc + sel_x1, nr + sel_y1,
|
||||||
pixel);
|
pixel);
|
||||||
|
|
||||||
for (i = 0; i < bpp; i++)
|
for (i = 0; i < bpp; i++)
|
||||||
*dest++ = pixel[i];
|
*dest++ = pixel[i];
|
||||||
|
|
||||||
if (has_alpha)
|
if (has_alpha)
|
||||||
{
|
*dest++ = (pixel[bpp] * opacity) / 100;
|
||||||
*dest++ = (pixel[bpp]*opacity)/100;
|
}
|
||||||
}
|
|
||||||
}
|
dest_row += dest_rgn.rowstride;
|
||||||
dest_row += dest_rgn.rowstride;
|
}
|
||||||
|
|
||||||
|
progress += dest_rgn.w * dest_rgn.h;
|
||||||
|
gimp_progress_update ((double) progress / max_progress);
|
||||||
}
|
}
|
||||||
|
|
||||||
progress += dest_rgn.w * dest_rgn.h;
|
|
||||||
gimp_progress_update((double) progress / max_progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
gimp_pixel_fetcher_destroy (pft);
|
gimp_pixel_fetcher_destroy (pft);
|
||||||
|
|
||||||
gimp_drawable_flush(tileitdrawable);
|
gimp_drawable_flush (tileitdrawable);
|
||||||
gimp_drawable_merge_shadow(tileitdrawable->drawable_id, TRUE);
|
gimp_drawable_merge_shadow (tileitdrawable->drawable_id, TRUE);
|
||||||
gimp_drawable_update(tileitdrawable->drawable_id,
|
gimp_drawable_update (tileitdrawable->drawable_id,
|
||||||
sel_x1, sel_y1, sel_width, sel_height);
|
sel_x1, sel_y1, sel_width, sel_height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Get the xy pos and any action */
|
/* Get the xy pos and any action */
|
||||||
static gint
|
static gint
|
||||||
tiles_xy(gint width,
|
tiles_xy (gint width,
|
||||||
gint height,
|
gint height,
|
||||||
gint x,
|
gint x,
|
||||||
gint y,
|
gint y,
|
||||||
gint *nx,
|
gint *nx,
|
||||||
gint *ny)
|
gint *ny)
|
||||||
{
|
{
|
||||||
gint px,py;
|
gint px,py;
|
||||||
gint rnum,cnum;
|
gint rnum,cnum;
|
||||||
gint actiontype;
|
gint actiontype;
|
||||||
gdouble rnd = 1 - (1.0/(gdouble)itvals.numtiles) +0.01;
|
gdouble rnd = 1 - (1.0 / (gdouble) itvals.numtiles) + 0.01;
|
||||||
|
|
||||||
rnum = y*itvals.numtiles/height;
|
rnum = y * itvals.numtiles / height;
|
||||||
|
|
||||||
py = (y*itvals.numtiles)%height;
|
py = (y * itvals.numtiles) % height;
|
||||||
px = (x*itvals.numtiles)%width;
|
px = (x * itvals.numtiles) % width;
|
||||||
cnum = x*itvals.numtiles/width;
|
cnum = x * itvals.numtiles / width;
|
||||||
|
|
||||||
if((actiontype = tileactions[cnum][rnum]))
|
if ((actiontype = tileactions[cnum][rnum]))
|
||||||
{
|
{
|
||||||
if(actiontype & HORIZONTAL)
|
if (actiontype & HORIZONTAL)
|
||||||
{
|
{
|
||||||
gdouble pyr;
|
gdouble pyr;
|
||||||
|
|
||||||
pyr = height - y - 1 + rnd;
|
pyr = height - y - 1 + rnd;
|
||||||
py = ((int)(pyr*(gdouble)itvals.numtiles))%height;
|
py = ((gint) (pyr * (gdouble) itvals.numtiles)) % height;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(actiontype & VERTICAL)
|
if (actiontype & VERTICAL)
|
||||||
{
|
{
|
||||||
gdouble pxr;
|
gdouble pxr;
|
||||||
|
|
||||||
pxr = width - x - 1 + rnd;
|
pxr = width - x - 1 + rnd;
|
||||||
px = ((int)(pxr*(gdouble)itvals.numtiles))%width;
|
px = ((gint) (pxr * (gdouble) itvals.numtiles)) % width;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1089,21 +1093,21 @@ tiles_xy(gint width,
|
||||||
|
|
||||||
/* Given a row then srink it down a bit */
|
/* Given a row then srink it down a bit */
|
||||||
static void
|
static void
|
||||||
do_tiles_preview(guchar *dest_row,
|
do_tiles_preview (guchar *dest_row,
|
||||||
guchar *src_rows,
|
guchar *src_rows,
|
||||||
gint width,
|
gint width,
|
||||||
gint dh,
|
gint dh,
|
||||||
gint height,
|
gint height,
|
||||||
gint bpp)
|
gint bpp)
|
||||||
{
|
{
|
||||||
gint x;
|
gint x;
|
||||||
gint i;
|
gint i;
|
||||||
gint px,py;
|
gint px, py;
|
||||||
gint rnum,cnum;
|
gint rnum,cnum;
|
||||||
gint actiontype;
|
gint actiontype;
|
||||||
gdouble rnd = 1 - (1.0/(gdouble)itvals.numtiles) +0.01;
|
gdouble rnd = 1 - (1.0 / (gdouble) itvals.numtiles) + 0.01;
|
||||||
|
|
||||||
rnum = dh*itvals.numtiles/height;
|
rnum = dh * itvals.numtiles / height;
|
||||||
|
|
||||||
for (x = 0; x < width; x ++)
|
for (x = 0; x < width; x ++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -340,17 +340,18 @@ run (const gchar *name,
|
||||||
static void
|
static void
|
||||||
whirl_pinch (void)
|
whirl_pinch (void)
|
||||||
{
|
{
|
||||||
GimpPixelRgn dest_rgn;
|
GimpPixelRgn dest_rgn;
|
||||||
gint progress, max_progress;
|
gint progress, max_progress;
|
||||||
guchar *top_row, *bot_row;
|
guchar *top_row, *bot_row;
|
||||||
guchar *top_p, *bot_p;
|
guchar *top_p, *bot_p;
|
||||||
gint row, col;
|
gint row, col;
|
||||||
guchar **pixel;
|
guchar **pixel;
|
||||||
double whirl;
|
gdouble whirl;
|
||||||
double cx, cy;
|
gdouble cx, cy;
|
||||||
int ix, iy;
|
gint ix, iy;
|
||||||
int i;
|
gint i;
|
||||||
GimpPixelFetcher *pft, *pfb;
|
GimpPixelFetcher *pft, *pfb;
|
||||||
|
GimpRGB background;
|
||||||
|
|
||||||
/* Initialize rows */
|
/* Initialize rows */
|
||||||
top_row = g_malloc (img_bpp * sel_width);
|
top_row = g_malloc (img_bpp * sel_width);
|
||||||
|
@ -363,11 +364,12 @@ whirl_pinch (void)
|
||||||
gimp_pixel_rgn_init (&dest_rgn, drawable,
|
gimp_pixel_rgn_init (&dest_rgn, drawable,
|
||||||
sel_x1, sel_y1, sel_width, sel_height, TRUE, TRUE);
|
sel_x1, sel_y1, sel_width, sel_height, TRUE, TRUE);
|
||||||
|
|
||||||
pft = gimp_pixel_fetcher_new (drawable);
|
pft = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
pfb = gimp_pixel_fetcher_new (drawable);
|
pfb = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
|
|
||||||
gimp_pixel_fetcher_set_bg_color (pft);
|
gimp_palette_get_background (&background);
|
||||||
gimp_pixel_fetcher_set_bg_color (pfb);
|
gimp_pixel_fetcher_set_bg_color (pft, &background);
|
||||||
|
gimp_pixel_fetcher_set_bg_color (pfb, &background);
|
||||||
|
|
||||||
progress = 0;
|
progress = 0;
|
||||||
max_progress = sel_width * sel_height;
|
max_progress = sel_width * sel_height;
|
||||||
|
@ -573,7 +575,7 @@ build_preview_source_image (void)
|
||||||
|
|
||||||
py = top;
|
py = top;
|
||||||
|
|
||||||
pf = gimp_pixel_fetcher_new (drawable);
|
pf = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
|
|
||||||
p = wpint.image;
|
p = wpint.image;
|
||||||
|
|
||||||
|
|
|
@ -1093,11 +1093,10 @@ plugin_do_non_asupsample (void)
|
||||||
static void
|
static void
|
||||||
plugin_do_asupsample (void)
|
plugin_do_asupsample (void)
|
||||||
{
|
{
|
||||||
tk_read = gimp_pixel_fetcher_new (drawable);
|
tk_read = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
gimp_pixel_fetcher_set_edge_mode (tk_read, GIMP_PIXEL_FETCHER_EDGE_BLACK);
|
gimp_pixel_fetcher_set_edge_mode (tk_read, GIMP_PIXEL_FETCHER_EDGE_BLACK);
|
||||||
|
|
||||||
tk_write = gimp_pixel_fetcher_new (drawable);
|
tk_write = gimp_pixel_fetcher_new (drawable, TRUE);
|
||||||
gimp_pixel_fetcher_set_shadow (tk_write, TRUE);
|
|
||||||
|
|
||||||
gimp_adaptive_supersample_area (dinfo.x1, dinfo.y1, dinfo.x2 - 1, dinfo.y2 - 1,
|
gimp_adaptive_supersample_area (dinfo.x1, dinfo.y1, dinfo.x2 - 1, dinfo.y2 - 1,
|
||||||
pvals.asupsample_max_depth,
|
pvals.asupsample_max_depth,
|
||||||
|
|
|
@ -487,7 +487,7 @@ gimp_old_preview_fill_scaled (GimpOldPreview *preview,
|
||||||
|
|
||||||
py = y1;
|
py = y1;
|
||||||
|
|
||||||
pft = gimp_pixel_fetcher_new (drawable);
|
pft = gimp_pixel_fetcher_new (drawable, FALSE);
|
||||||
|
|
||||||
for (y = 0; y < height; y++)
|
for (y = 0; y < height; y++)
|
||||||
{
|
{
|
||||||
|
@ -502,6 +502,7 @@ gimp_old_preview_fill_scaled (GimpOldPreview *preview,
|
||||||
gimp_old_preview_do_row (preview, y, width, dest);
|
gimp_old_preview_do_row (preview, y, width, dest);
|
||||||
py += dy;
|
py += dy;
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_pixel_fetcher_destroy (pft);
|
gimp_pixel_fetcher_destroy (pft);
|
||||||
|
|
||||||
preview->buffer = GTK_PREVIEW (preview->widget)->buffer;
|
preview->buffer = GTK_PREVIEW (preview->widget)->buffer;
|
||||||
|
|
Loading…
Reference in New Issue