mirror of https://github.com/GNOME/gimp.git
Some code cleanup while trying to fix bug #105062:
2003-02-03 Sven Neumann <neo@wintermute> Some code cleanup while trying to fix bug #105062: * libgimp/gimpmisc.[ch]: moved the declaration of the GimpPixelFetcher struct to the .c file since noone should ever access it directly. * libgimp/gimpmiscui.c: cosmetics. * plug-ins/common/plasma.c: code cleanup, doesn't fix #105062.
This commit is contained in:
parent
0b90802f3b
commit
6d4e953412
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2003-02-03 Sven Neumann <neo@wintermute>
|
||||
|
||||
Some code cleanup while trying to fix bug #105062:
|
||||
|
||||
* libgimp/gimpmisc.[ch]: moved the declaration of the
|
||||
GimpPixelFetcher struct to the .c file since noone should ever
|
||||
access it directly.
|
||||
|
||||
* libgimp/gimpmiscui.c: cosmetics.
|
||||
|
||||
* plug-ins/common/plasma.c: code cleanup, doesn't fix #105062.
|
||||
|
||||
2003-02-02 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/ifscompose/ifscompose.c: fixed some issues (mainly
|
||||
|
|
|
@ -23,17 +23,33 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpmisc.h"
|
||||
|
||||
|
||||
struct _GimpPixelFetcher
|
||||
{
|
||||
gint col, row;
|
||||
gint img_width;
|
||||
gint img_height;
|
||||
gint sel_x1, sel_y1, sel_x2, sel_y2;
|
||||
gint img_bpp;
|
||||
gint img_has_alpha;
|
||||
gint tile_width, tile_height;
|
||||
guchar bg_color[4];
|
||||
GimpDrawable *drawable;
|
||||
GimpTile *tile;
|
||||
gboolean tile_dirty;
|
||||
gboolean shadow;
|
||||
};
|
||||
|
||||
|
||||
GimpPixelFetcher *
|
||||
gimp_pixel_fetcher_new (GimpDrawable *drawable)
|
||||
{
|
||||
|
@ -47,9 +63,9 @@ gimp_pixel_fetcher_new (GimpDrawable *drawable)
|
|||
|
||||
pf->col = -1;
|
||||
pf->row = -1;
|
||||
pf->img_width = gimp_drawable_width (drawable->drawable_id);
|
||||
pf->img_height = gimp_drawable_height (drawable->drawable_id);
|
||||
pf->img_bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||
pf->img_width = gimp_drawable_width (drawable->drawable_id);
|
||||
pf->img_height = gimp_drawable_height (drawable->drawable_id);
|
||||
pf->img_bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||
pf->img_has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
||||
pf->tile_width = gimp_tile_width ();
|
||||
pf->tile_height = gimp_tile_height ();
|
||||
|
@ -57,11 +73,13 @@ gimp_pixel_fetcher_new (GimpDrawable *drawable)
|
|||
pf->bg_color[1] = 0;
|
||||
pf->bg_color[2] = 0;
|
||||
pf->bg_color[3] = 255;
|
||||
pf->drawable = drawable;
|
||||
pf->tile = NULL;
|
||||
pf->tile_dirty = FALSE;
|
||||
pf->shadow = FALSE;
|
||||
|
||||
pf->drawable = drawable;
|
||||
pf->tile = NULL;
|
||||
pf->tile_dirty = FALSE;
|
||||
pf->shadow = FALSE;
|
||||
/* this allows us to use (slightly faster) do-while loops */
|
||||
g_assert (pf->img_bpp > 0);
|
||||
|
||||
return pf;
|
||||
}
|
||||
|
@ -90,18 +108,18 @@ gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf)
|
|||
|
||||
void
|
||||
gimp_pixel_fetcher_set_shadow (GimpPixelFetcher *pf,
|
||||
gboolean shadow)
|
||||
gboolean shadow)
|
||||
{
|
||||
pf->shadow = shadow;
|
||||
}
|
||||
|
||||
static guchar*
|
||||
static guchar *
|
||||
gimp_pixel_fetcher_provide_tile (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y)
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
gint col, row;
|
||||
gint coloff, rowoff;
|
||||
gint col, row;
|
||||
gint coloff, rowoff;
|
||||
|
||||
col = x / pf->tile_width;
|
||||
coloff = x % pf->tile_width;
|
||||
|
@ -111,7 +129,7 @@ gimp_pixel_fetcher_provide_tile (GimpPixelFetcher *pf,
|
|||
if ((col != pf->col) || (row != pf->row) || (pf->tile == NULL))
|
||||
{
|
||||
if (pf->tile != NULL)
|
||||
gimp_tile_unref(pf->tile, pf->tile_dirty);
|
||||
gimp_tile_unref (pf->tile, pf->tile_dirty);
|
||||
|
||||
pf->tile = gimp_drawable_get_tile (pf->drawable, pf->shadow, row, col);
|
||||
pf->tile_dirty = FALSE;
|
||||
|
@ -126,9 +144,9 @@ gimp_pixel_fetcher_provide_tile (GimpPixelFetcher *pf,
|
|||
|
||||
void
|
||||
gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
{
|
||||
guchar *p;
|
||||
gint i;
|
||||
|
@ -141,15 +159,17 @@ gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
|||
|
||||
p = gimp_pixel_fetcher_provide_tile (pf, x, y);
|
||||
|
||||
for (i = pf->img_bpp; i; i--)
|
||||
i = pf->img_bpp;
|
||||
do
|
||||
*pixel++ = *p++;
|
||||
while (--i);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
{
|
||||
guchar *p;
|
||||
gint i;
|
||||
|
@ -162,18 +182,20 @@ gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
|||
|
||||
p = gimp_pixel_fetcher_provide_tile (pf, x, y);
|
||||
|
||||
for (i = pf->img_bpp; i; i--)
|
||||
i = pf->img_bpp;
|
||||
do
|
||||
*p++ = *pixel++;
|
||||
while (--i);
|
||||
|
||||
pf->tile_dirty = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
gint wrapmode,
|
||||
guchar *pixel)
|
||||
gint x,
|
||||
gint y,
|
||||
gint wrapmode,
|
||||
guchar *pixel)
|
||||
{
|
||||
guchar *p;
|
||||
gint i;
|
||||
|
@ -196,33 +218,41 @@ gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
|
|||
y += pf->img_height;
|
||||
}
|
||||
break;
|
||||
|
||||
case PIXEL_SMEAR:
|
||||
x = CLAMP (x, 0, pf->img_width - 1);
|
||||
y = CLAMP (y, 0, pf->img_height - 1);
|
||||
break;
|
||||
|
||||
case PIXEL_BLACK:
|
||||
if (x < 0 || x >= pf->img_width ||
|
||||
y < 0 || y >= pf->img_height)
|
||||
{
|
||||
for (i = 0; i < pf->img_bpp; i++)
|
||||
i = pf->img_bpp;
|
||||
do
|
||||
pixel[i] = 0;
|
||||
while (--i);
|
||||
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
p = gimp_pixel_fetcher_provide_tile (pf, x, y);
|
||||
|
||||
for (i = pf->img_bpp; i; i--)
|
||||
i = pf->img_bpp;
|
||||
do
|
||||
*pixel++ = *p++;
|
||||
while (--i);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf)
|
||||
{
|
||||
if (pf->tile != NULL)
|
||||
if (pf->tile)
|
||||
gimp_tile_unref (pf->tile, pf->tile_dirty);
|
||||
|
||||
g_free (pf);
|
||||
|
@ -230,8 +260,8 @@ gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf)
|
|||
|
||||
void
|
||||
gimp_get_bg_guchar (GimpDrawable *drawable,
|
||||
gboolean transparent,
|
||||
guchar *bg)
|
||||
gboolean transparent,
|
||||
guchar *bg)
|
||||
{
|
||||
GimpRGB background;
|
||||
|
||||
|
@ -265,12 +295,12 @@ gimp_get_bg_guchar (GimpDrawable *drawable,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_rgn_render_row (guchar *src,
|
||||
guchar *dest,
|
||||
gint col, /* row width in pixels */
|
||||
gint bpp,
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data)
|
||||
gimp_rgn_render_row (guchar *src,
|
||||
guchar *dest,
|
||||
gint col, /* row width in pixels */
|
||||
gint bpp,
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data)
|
||||
{
|
||||
while (col--)
|
||||
{
|
||||
|
@ -283,9 +313,10 @@ gimp_rgn_render_row (guchar *src,
|
|||
static void
|
||||
gimp_rgn_render_region (const GimpPixelRgn *srcPR,
|
||||
const GimpPixelRgn *destPR,
|
||||
GimpRgnFunc2 func, gpointer data)
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data)
|
||||
{
|
||||
gint row;
|
||||
gint row;
|
||||
guchar* src = srcPR->data;
|
||||
guchar* dest = destPR->data;
|
||||
|
||||
|
@ -299,8 +330,10 @@ gimp_rgn_render_region (const GimpPixelRgn *srcPR,
|
|||
}
|
||||
|
||||
void
|
||||
gimp_rgn_iterate1 (GimpDrawable *drawable, GimpRunMode run_mode,
|
||||
GimpRgnFunc1 func, gpointer data)
|
||||
gimp_rgn_iterate1 (GimpDrawable *drawable,
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc1 func,
|
||||
gpointer data)
|
||||
{
|
||||
GimpPixelRgn srcPR;
|
||||
gint x1, y1, x2, y2;
|
||||
|
@ -323,7 +356,7 @@ gimp_rgn_iterate1 (GimpDrawable *drawable, GimpRunMode run_mode,
|
|||
pr = gimp_pixel_rgns_process (pr))
|
||||
{
|
||||
guchar *src = srcPR.data;
|
||||
gint y;
|
||||
gint y;
|
||||
|
||||
for (y = 0; y < srcPR.h; y++)
|
||||
{
|
||||
|
@ -343,14 +376,17 @@ gimp_rgn_iterate1 (GimpDrawable *drawable, GimpRunMode run_mode,
|
|||
{
|
||||
area_so_far += srcPR.w * srcPR.h;
|
||||
if (((progress_skip++) % 10) == 0)
|
||||
gimp_progress_update ((double) area_so_far / (double) total_area);
|
||||
gimp_progress_update ((gdouble) area_so_far /
|
||||
(gdouble) total_area);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgn_iterate2 (GimpDrawable *drawable, GimpRunMode run_mode,
|
||||
GimpRgnFunc2 func, gpointer data)
|
||||
gimp_rgn_iterate2 (GimpDrawable *drawable,
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data)
|
||||
{
|
||||
GimpPixelRgn srcPR, destPR;
|
||||
gint x1, y1, x2, y2;
|
||||
|
@ -381,7 +417,8 @@ gimp_rgn_iterate2 (GimpDrawable *drawable, GimpRunMode run_mode,
|
|||
{
|
||||
area_so_far += srcPR.w * srcPR.h;
|
||||
if (((progress_skip++) % 10) == 0)
|
||||
gimp_progress_update ((double) area_so_far / (double) total_area);
|
||||
gimp_progress_update ((gdouble) area_so_far /
|
||||
(gdouble) total_area);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ G_BEGIN_DECLS
|
|||
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PIXEL_WRAP,
|
||||
|
@ -37,59 +38,46 @@ enum
|
|||
PIXEL_BLACK,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint col, row;
|
||||
gint img_width;
|
||||
gint img_height;
|
||||
gint sel_x1, sel_y1, sel_x2, sel_y2;
|
||||
gint img_bpp;
|
||||
gint img_has_alpha;
|
||||
gint tile_width, tile_height;
|
||||
guchar bg_color[4];
|
||||
GimpDrawable *drawable;
|
||||
GimpTile *tile;
|
||||
gboolean tile_dirty;
|
||||
gboolean shadow;
|
||||
} GimpPixelFetcher;
|
||||
|
||||
GimpPixelFetcher *gimp_pixel_fetcher_new (GimpDrawable *drawable);
|
||||
void gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf);
|
||||
void gimp_pixel_fetcher_set_shadow (GimpPixelFetcher *pf,
|
||||
gboolean shadow);
|
||||
void gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
gint wrapmode,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf);
|
||||
typedef struct _GimpPixelFetcher GimpPixelFetcher;
|
||||
|
||||
|
||||
void gimp_get_bg_guchar (GimpDrawable *drawable,
|
||||
gboolean transparent,
|
||||
guchar *bg);
|
||||
GimpPixelFetcher * gimp_pixel_fetcher_new (GimpDrawable *drawable);
|
||||
void gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf);
|
||||
void gimp_pixel_fetcher_set_shadow (GimpPixelFetcher *pf,
|
||||
gboolean shadow);
|
||||
void gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
gint wrapmode,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf);
|
||||
|
||||
|
||||
typedef void (*GimpRgnFunc1)(guchar *src, gint bpp, gpointer);
|
||||
typedef void (*GimpRgnFunc2)(guchar *src, guchar *dest, gint bpp, gpointer);
|
||||
void gimp_get_bg_guchar (GimpDrawable *drawable,
|
||||
gboolean transparent,
|
||||
guchar *bg);
|
||||
|
||||
|
||||
typedef void (* GimpRgnFunc1) (guchar *src, gint bpp, gpointer);
|
||||
typedef void (* GimpRgnFunc2) (guchar *src, guchar *dest, gint bpp, gpointer);
|
||||
|
||||
void gimp_rgn_iterate1 (GimpDrawable *drawable,
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc1 func,
|
||||
gpointer data);
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc1 func,
|
||||
gpointer data);
|
||||
|
||||
void gimp_rgn_iterate2 (GimpDrawable *drawable,
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data);
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -23,25 +23,28 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpintl.h"
|
||||
#include "gimpmiscui.h"
|
||||
|
||||
#include "gimpintl.h"
|
||||
|
||||
|
||||
#define PREVIEW_SIZE 128
|
||||
|
||||
|
||||
GimpFixMePreview*
|
||||
gimp_fixme_preview_new (GimpDrawable *drawable, gboolean has_frame)
|
||||
gimp_fixme_preview_new (GimpDrawable *drawable,
|
||||
gboolean has_frame)
|
||||
{
|
||||
GimpFixMePreview *preview = g_new0 (GimpFixMePreview, 1);
|
||||
|
||||
|
@ -85,9 +88,9 @@ gimp_fixme_preview_free (GimpFixMePreview *preview)
|
|||
|
||||
void
|
||||
gimp_fixme_preview_do_row (GimpFixMePreview *preview,
|
||||
gint row,
|
||||
gint width,
|
||||
guchar *src)
|
||||
gint row,
|
||||
gint width,
|
||||
guchar *src)
|
||||
{
|
||||
gint x;
|
||||
guchar *p0 = preview->even;
|
||||
|
@ -167,20 +170,20 @@ gimp_fixme_preview_do_row (GimpFixMePreview *preview,
|
|||
}
|
||||
|
||||
void
|
||||
gimp_fixme_preview_update (GimpFixMePreview *preview,
|
||||
GimpFixeMePreviewFunc func,
|
||||
gpointer data)
|
||||
gimp_fixme_preview_update (GimpFixMePreview *preview,
|
||||
GimpFixeMePreviewFunc func,
|
||||
gpointer data)
|
||||
{
|
||||
gint x, y;
|
||||
guchar *buffer;
|
||||
gint bpp;
|
||||
gint bpp;
|
||||
|
||||
bpp = preview->bpp;
|
||||
buffer = (guchar*) g_malloc (preview->rowstride);
|
||||
bpp = preview->bpp;
|
||||
buffer = g_new (guchar, preview->rowstride);
|
||||
|
||||
for (y = 0; y < preview->height; y++)
|
||||
{
|
||||
guchar *src = preview->cache + y * preview->rowstride;
|
||||
guchar *src = preview->cache + y * preview->rowstride;
|
||||
guchar *dest = buffer;
|
||||
|
||||
for (x = 0; x < preview->width; x++)
|
||||
|
@ -190,16 +193,18 @@ gimp_fixme_preview_update (GimpFixMePreview *preview,
|
|||
src += bpp;
|
||||
dest += bpp;
|
||||
}
|
||||
gimp_fixme_preview_do_row(preview, y, preview->width, buffer);
|
||||
|
||||
gimp_fixme_preview_do_row (preview, y, preview->width, buffer);
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw(preview->widget);
|
||||
gtk_widget_queue_draw (preview->widget);
|
||||
|
||||
g_free (buffer);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_fixme_preview_fill_with_thumb (GimpFixMePreview *preview,
|
||||
gint32 drawable_ID)
|
||||
gint32 drawable_ID)
|
||||
{
|
||||
gint bpp;
|
||||
gint y;
|
||||
|
@ -244,21 +249,21 @@ gimp_fixme_preview_fill_with_thumb (GimpFixMePreview *preview,
|
|||
}
|
||||
|
||||
preview->buffer = GTK_PREVIEW (preview->widget)->buffer;
|
||||
preview->width = GTK_PREVIEW (preview->widget)->buffer_width;
|
||||
preview->width = GTK_PREVIEW (preview->widget)->buffer_width;
|
||||
preview->height = GTK_PREVIEW (preview->widget)->buffer_height;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_fixme_preview_fill (GimpFixMePreview *preview,
|
||||
GimpDrawable *drawable)
|
||||
GimpDrawable *drawable)
|
||||
{
|
||||
GimpPixelRgn srcPR;
|
||||
gint width;
|
||||
gint height;
|
||||
gint x1, x2, y1, y2;
|
||||
gint bpp;
|
||||
gint y;
|
||||
guchar *src;
|
||||
gint width;
|
||||
gint height;
|
||||
gint x1, x2, y1, y2;
|
||||
gint bpp;
|
||||
gint y;
|
||||
guchar *src;
|
||||
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||
|
||||
|
@ -306,7 +311,7 @@ gimp_fixme_preview_fill (GimpFixMePreview *preview,
|
|||
}
|
||||
|
||||
preview->buffer = GTK_PREVIEW (preview->widget)->buffer;
|
||||
preview->width = GTK_PREVIEW (preview->widget)->buffer_width;
|
||||
preview->width = GTK_PREVIEW (preview->widget)->buffer_width;
|
||||
preview->height = GTK_PREVIEW (preview->widget)->buffer_height;
|
||||
|
||||
g_free (src);
|
||||
|
@ -314,19 +319,19 @@ gimp_fixme_preview_fill (GimpFixMePreview *preview,
|
|||
|
||||
void
|
||||
gimp_fixme_preview_fill_scaled (GimpFixMePreview *preview,
|
||||
GimpDrawable *drawable)
|
||||
GimpDrawable *drawable)
|
||||
{
|
||||
gint bpp;
|
||||
gint x1, y1, x2, y2;
|
||||
gint sel_width, sel_height;
|
||||
gint width, height;
|
||||
gdouble px, py;
|
||||
gdouble dx, dy;
|
||||
gint x, y;
|
||||
guchar *dest;
|
||||
gint bpp;
|
||||
gint x1, y1, x2, y2;
|
||||
gint sel_width, sel_height;
|
||||
gint width, height;
|
||||
gdouble px, py;
|
||||
gdouble dx, dy;
|
||||
gint x, y;
|
||||
guchar *dest;
|
||||
GimpPixelFetcher *pft;
|
||||
|
||||
gimp_drawable_mask_bounds(drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||
|
||||
sel_width = x2 - x1;
|
||||
sel_height = y2 - y1;
|
||||
|
@ -334,7 +339,7 @@ gimp_fixme_preview_fill_scaled (GimpFixMePreview *preview,
|
|||
/* Calculate preview size */
|
||||
if (sel_width > sel_height)
|
||||
{
|
||||
width = MIN(sel_width, PREVIEW_SIZE);
|
||||
width = MIN (sel_width, PREVIEW_SIZE);
|
||||
height = sel_height * width / sel_width;
|
||||
}
|
||||
else
|
||||
|
@ -360,11 +365,11 @@ gimp_fixme_preview_fill_scaled (GimpFixMePreview *preview,
|
|||
|
||||
gtk_preview_size (GTK_PREVIEW (preview->widget), width, height);
|
||||
|
||||
preview->even = g_malloc (width * 3);
|
||||
preview->odd = g_malloc (width * 3);
|
||||
preview->cache = g_malloc(width * bpp * height);
|
||||
preview->even = g_malloc (width * 3);
|
||||
preview->odd = g_malloc (width * 3);
|
||||
preview->cache = g_malloc (width * bpp * height);
|
||||
preview->rowstride = width * bpp;
|
||||
preview->bpp = bpp;
|
||||
preview->bpp = bpp;
|
||||
|
||||
dx = (gdouble) (x2 - x1 - 1) / (width - 1);
|
||||
dy = (gdouble) (y2 - y1 - 1) / (height - 1);
|
||||
|
@ -389,15 +394,15 @@ gimp_fixme_preview_fill_scaled (GimpFixMePreview *preview,
|
|||
gimp_pixel_fetcher_destroy (pft);
|
||||
|
||||
preview->buffer = GTK_PREVIEW (preview->widget)->buffer;
|
||||
preview->width = GTK_PREVIEW (preview->widget)->buffer_width;
|
||||
preview->width = GTK_PREVIEW (preview->widget)->buffer_width;
|
||||
preview->height = GTK_PREVIEW (preview->widget)->buffer_height;
|
||||
}
|
||||
|
||||
GList*
|
||||
gimp_plug_in_parse_path (gchar *path_name, const gchar *dir_name)
|
||||
gimp_plug_in_parse_path (gchar *path_name,
|
||||
const gchar *dir_name)
|
||||
{
|
||||
GList *path_list = NULL;
|
||||
GList *fail_list = NULL;
|
||||
gchar *path;
|
||||
|
||||
path = gimp_gimprc_query (path_name);
|
||||
|
@ -424,19 +429,14 @@ gimp_plug_in_parse_path (gchar *path_name, const gchar *dir_name)
|
|||
g_free (gimprc);
|
||||
g_free (full_path);
|
||||
g_free (esc_path);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
path_list = gimp_path_parse (path, 16, TRUE, &fail_list);
|
||||
path_list = gimp_path_parse (path, 16, TRUE, NULL);
|
||||
|
||||
g_free (path);
|
||||
|
||||
if (fail_list)
|
||||
{
|
||||
/* We just ignore the fail_list */
|
||||
gimp_path_free (fail_list);
|
||||
}
|
||||
|
||||
return path_list;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,17 +23,33 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpmisc.h"
|
||||
|
||||
|
||||
struct _GimpPixelFetcher
|
||||
{
|
||||
gint col, row;
|
||||
gint img_width;
|
||||
gint img_height;
|
||||
gint sel_x1, sel_y1, sel_x2, sel_y2;
|
||||
gint img_bpp;
|
||||
gint img_has_alpha;
|
||||
gint tile_width, tile_height;
|
||||
guchar bg_color[4];
|
||||
GimpDrawable *drawable;
|
||||
GimpTile *tile;
|
||||
gboolean tile_dirty;
|
||||
gboolean shadow;
|
||||
};
|
||||
|
||||
|
||||
GimpPixelFetcher *
|
||||
gimp_pixel_fetcher_new (GimpDrawable *drawable)
|
||||
{
|
||||
|
@ -47,9 +63,9 @@ gimp_pixel_fetcher_new (GimpDrawable *drawable)
|
|||
|
||||
pf->col = -1;
|
||||
pf->row = -1;
|
||||
pf->img_width = gimp_drawable_width (drawable->drawable_id);
|
||||
pf->img_height = gimp_drawable_height (drawable->drawable_id);
|
||||
pf->img_bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||
pf->img_width = gimp_drawable_width (drawable->drawable_id);
|
||||
pf->img_height = gimp_drawable_height (drawable->drawable_id);
|
||||
pf->img_bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||
pf->img_has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
||||
pf->tile_width = gimp_tile_width ();
|
||||
pf->tile_height = gimp_tile_height ();
|
||||
|
@ -57,11 +73,13 @@ gimp_pixel_fetcher_new (GimpDrawable *drawable)
|
|||
pf->bg_color[1] = 0;
|
||||
pf->bg_color[2] = 0;
|
||||
pf->bg_color[3] = 255;
|
||||
pf->drawable = drawable;
|
||||
pf->tile = NULL;
|
||||
pf->tile_dirty = FALSE;
|
||||
pf->shadow = FALSE;
|
||||
|
||||
pf->drawable = drawable;
|
||||
pf->tile = NULL;
|
||||
pf->tile_dirty = FALSE;
|
||||
pf->shadow = FALSE;
|
||||
/* this allows us to use (slightly faster) do-while loops */
|
||||
g_assert (pf->img_bpp > 0);
|
||||
|
||||
return pf;
|
||||
}
|
||||
|
@ -90,18 +108,18 @@ gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf)
|
|||
|
||||
void
|
||||
gimp_pixel_fetcher_set_shadow (GimpPixelFetcher *pf,
|
||||
gboolean shadow)
|
||||
gboolean shadow)
|
||||
{
|
||||
pf->shadow = shadow;
|
||||
}
|
||||
|
||||
static guchar*
|
||||
static guchar *
|
||||
gimp_pixel_fetcher_provide_tile (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y)
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
gint col, row;
|
||||
gint coloff, rowoff;
|
||||
gint col, row;
|
||||
gint coloff, rowoff;
|
||||
|
||||
col = x / pf->tile_width;
|
||||
coloff = x % pf->tile_width;
|
||||
|
@ -111,7 +129,7 @@ gimp_pixel_fetcher_provide_tile (GimpPixelFetcher *pf,
|
|||
if ((col != pf->col) || (row != pf->row) || (pf->tile == NULL))
|
||||
{
|
||||
if (pf->tile != NULL)
|
||||
gimp_tile_unref(pf->tile, pf->tile_dirty);
|
||||
gimp_tile_unref (pf->tile, pf->tile_dirty);
|
||||
|
||||
pf->tile = gimp_drawable_get_tile (pf->drawable, pf->shadow, row, col);
|
||||
pf->tile_dirty = FALSE;
|
||||
|
@ -126,9 +144,9 @@ gimp_pixel_fetcher_provide_tile (GimpPixelFetcher *pf,
|
|||
|
||||
void
|
||||
gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
{
|
||||
guchar *p;
|
||||
gint i;
|
||||
|
@ -141,15 +159,17 @@ gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
|||
|
||||
p = gimp_pixel_fetcher_provide_tile (pf, x, y);
|
||||
|
||||
for (i = pf->img_bpp; i; i--)
|
||||
i = pf->img_bpp;
|
||||
do
|
||||
*pixel++ = *p++;
|
||||
while (--i);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
{
|
||||
guchar *p;
|
||||
gint i;
|
||||
|
@ -162,18 +182,20 @@ gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
|||
|
||||
p = gimp_pixel_fetcher_provide_tile (pf, x, y);
|
||||
|
||||
for (i = pf->img_bpp; i; i--)
|
||||
i = pf->img_bpp;
|
||||
do
|
||||
*p++ = *pixel++;
|
||||
while (--i);
|
||||
|
||||
pf->tile_dirty = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
gint wrapmode,
|
||||
guchar *pixel)
|
||||
gint x,
|
||||
gint y,
|
||||
gint wrapmode,
|
||||
guchar *pixel)
|
||||
{
|
||||
guchar *p;
|
||||
gint i;
|
||||
|
@ -196,33 +218,41 @@ gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
|
|||
y += pf->img_height;
|
||||
}
|
||||
break;
|
||||
|
||||
case PIXEL_SMEAR:
|
||||
x = CLAMP (x, 0, pf->img_width - 1);
|
||||
y = CLAMP (y, 0, pf->img_height - 1);
|
||||
break;
|
||||
|
||||
case PIXEL_BLACK:
|
||||
if (x < 0 || x >= pf->img_width ||
|
||||
y < 0 || y >= pf->img_height)
|
||||
{
|
||||
for (i = 0; i < pf->img_bpp; i++)
|
||||
i = pf->img_bpp;
|
||||
do
|
||||
pixel[i] = 0;
|
||||
while (--i);
|
||||
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
p = gimp_pixel_fetcher_provide_tile (pf, x, y);
|
||||
|
||||
for (i = pf->img_bpp; i; i--)
|
||||
i = pf->img_bpp;
|
||||
do
|
||||
*pixel++ = *p++;
|
||||
while (--i);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf)
|
||||
{
|
||||
if (pf->tile != NULL)
|
||||
if (pf->tile)
|
||||
gimp_tile_unref (pf->tile, pf->tile_dirty);
|
||||
|
||||
g_free (pf);
|
||||
|
@ -230,8 +260,8 @@ gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf)
|
|||
|
||||
void
|
||||
gimp_get_bg_guchar (GimpDrawable *drawable,
|
||||
gboolean transparent,
|
||||
guchar *bg)
|
||||
gboolean transparent,
|
||||
guchar *bg)
|
||||
{
|
||||
GimpRGB background;
|
||||
|
||||
|
@ -265,12 +295,12 @@ gimp_get_bg_guchar (GimpDrawable *drawable,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_rgn_render_row (guchar *src,
|
||||
guchar *dest,
|
||||
gint col, /* row width in pixels */
|
||||
gint bpp,
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data)
|
||||
gimp_rgn_render_row (guchar *src,
|
||||
guchar *dest,
|
||||
gint col, /* row width in pixels */
|
||||
gint bpp,
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data)
|
||||
{
|
||||
while (col--)
|
||||
{
|
||||
|
@ -283,9 +313,10 @@ gimp_rgn_render_row (guchar *src,
|
|||
static void
|
||||
gimp_rgn_render_region (const GimpPixelRgn *srcPR,
|
||||
const GimpPixelRgn *destPR,
|
||||
GimpRgnFunc2 func, gpointer data)
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data)
|
||||
{
|
||||
gint row;
|
||||
gint row;
|
||||
guchar* src = srcPR->data;
|
||||
guchar* dest = destPR->data;
|
||||
|
||||
|
@ -299,8 +330,10 @@ gimp_rgn_render_region (const GimpPixelRgn *srcPR,
|
|||
}
|
||||
|
||||
void
|
||||
gimp_rgn_iterate1 (GimpDrawable *drawable, GimpRunMode run_mode,
|
||||
GimpRgnFunc1 func, gpointer data)
|
||||
gimp_rgn_iterate1 (GimpDrawable *drawable,
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc1 func,
|
||||
gpointer data)
|
||||
{
|
||||
GimpPixelRgn srcPR;
|
||||
gint x1, y1, x2, y2;
|
||||
|
@ -323,7 +356,7 @@ gimp_rgn_iterate1 (GimpDrawable *drawable, GimpRunMode run_mode,
|
|||
pr = gimp_pixel_rgns_process (pr))
|
||||
{
|
||||
guchar *src = srcPR.data;
|
||||
gint y;
|
||||
gint y;
|
||||
|
||||
for (y = 0; y < srcPR.h; y++)
|
||||
{
|
||||
|
@ -343,14 +376,17 @@ gimp_rgn_iterate1 (GimpDrawable *drawable, GimpRunMode run_mode,
|
|||
{
|
||||
area_so_far += srcPR.w * srcPR.h;
|
||||
if (((progress_skip++) % 10) == 0)
|
||||
gimp_progress_update ((double) area_so_far / (double) total_area);
|
||||
gimp_progress_update ((gdouble) area_so_far /
|
||||
(gdouble) total_area);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgn_iterate2 (GimpDrawable *drawable, GimpRunMode run_mode,
|
||||
GimpRgnFunc2 func, gpointer data)
|
||||
gimp_rgn_iterate2 (GimpDrawable *drawable,
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data)
|
||||
{
|
||||
GimpPixelRgn srcPR, destPR;
|
||||
gint x1, y1, x2, y2;
|
||||
|
@ -381,7 +417,8 @@ gimp_rgn_iterate2 (GimpDrawable *drawable, GimpRunMode run_mode,
|
|||
{
|
||||
area_so_far += srcPR.w * srcPR.h;
|
||||
if (((progress_skip++) % 10) == 0)
|
||||
gimp_progress_update ((double) area_so_far / (double) total_area);
|
||||
gimp_progress_update ((gdouble) area_so_far /
|
||||
(gdouble) total_area);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ G_BEGIN_DECLS
|
|||
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PIXEL_WRAP,
|
||||
|
@ -37,59 +38,46 @@ enum
|
|||
PIXEL_BLACK,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint col, row;
|
||||
gint img_width;
|
||||
gint img_height;
|
||||
gint sel_x1, sel_y1, sel_x2, sel_y2;
|
||||
gint img_bpp;
|
||||
gint img_has_alpha;
|
||||
gint tile_width, tile_height;
|
||||
guchar bg_color[4];
|
||||
GimpDrawable *drawable;
|
||||
GimpTile *tile;
|
||||
gboolean tile_dirty;
|
||||
gboolean shadow;
|
||||
} GimpPixelFetcher;
|
||||
|
||||
GimpPixelFetcher *gimp_pixel_fetcher_new (GimpDrawable *drawable);
|
||||
void gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf);
|
||||
void gimp_pixel_fetcher_set_shadow (GimpPixelFetcher *pf,
|
||||
gboolean shadow);
|
||||
void gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
gint wrapmode,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf);
|
||||
typedef struct _GimpPixelFetcher GimpPixelFetcher;
|
||||
|
||||
|
||||
void gimp_get_bg_guchar (GimpDrawable *drawable,
|
||||
gboolean transparent,
|
||||
guchar *bg);
|
||||
GimpPixelFetcher * gimp_pixel_fetcher_new (GimpDrawable *drawable);
|
||||
void gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf);
|
||||
void gimp_pixel_fetcher_set_shadow (GimpPixelFetcher *pf,
|
||||
gboolean shadow);
|
||||
void gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
gint wrapmode,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf);
|
||||
|
||||
|
||||
typedef void (*GimpRgnFunc1)(guchar *src, gint bpp, gpointer);
|
||||
typedef void (*GimpRgnFunc2)(guchar *src, guchar *dest, gint bpp, gpointer);
|
||||
void gimp_get_bg_guchar (GimpDrawable *drawable,
|
||||
gboolean transparent,
|
||||
guchar *bg);
|
||||
|
||||
|
||||
typedef void (* GimpRgnFunc1) (guchar *src, gint bpp, gpointer);
|
||||
typedef void (* GimpRgnFunc2) (guchar *src, guchar *dest, gint bpp, gpointer);
|
||||
|
||||
void gimp_rgn_iterate1 (GimpDrawable *drawable,
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc1 func,
|
||||
gpointer data);
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc1 func,
|
||||
gpointer data);
|
||||
|
||||
void gimp_rgn_iterate2 (GimpDrawable *drawable,
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data);
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -23,17 +23,33 @@
|
|||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpmisc.h"
|
||||
|
||||
|
||||
struct _GimpPixelFetcher
|
||||
{
|
||||
gint col, row;
|
||||
gint img_width;
|
||||
gint img_height;
|
||||
gint sel_x1, sel_y1, sel_x2, sel_y2;
|
||||
gint img_bpp;
|
||||
gint img_has_alpha;
|
||||
gint tile_width, tile_height;
|
||||
guchar bg_color[4];
|
||||
GimpDrawable *drawable;
|
||||
GimpTile *tile;
|
||||
gboolean tile_dirty;
|
||||
gboolean shadow;
|
||||
};
|
||||
|
||||
|
||||
GimpPixelFetcher *
|
||||
gimp_pixel_fetcher_new (GimpDrawable *drawable)
|
||||
{
|
||||
|
@ -47,9 +63,9 @@ gimp_pixel_fetcher_new (GimpDrawable *drawable)
|
|||
|
||||
pf->col = -1;
|
||||
pf->row = -1;
|
||||
pf->img_width = gimp_drawable_width (drawable->drawable_id);
|
||||
pf->img_height = gimp_drawable_height (drawable->drawable_id);
|
||||
pf->img_bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||
pf->img_width = gimp_drawable_width (drawable->drawable_id);
|
||||
pf->img_height = gimp_drawable_height (drawable->drawable_id);
|
||||
pf->img_bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||
pf->img_has_alpha = gimp_drawable_has_alpha (drawable->drawable_id);
|
||||
pf->tile_width = gimp_tile_width ();
|
||||
pf->tile_height = gimp_tile_height ();
|
||||
|
@ -57,11 +73,13 @@ gimp_pixel_fetcher_new (GimpDrawable *drawable)
|
|||
pf->bg_color[1] = 0;
|
||||
pf->bg_color[2] = 0;
|
||||
pf->bg_color[3] = 255;
|
||||
pf->drawable = drawable;
|
||||
pf->tile = NULL;
|
||||
pf->tile_dirty = FALSE;
|
||||
pf->shadow = FALSE;
|
||||
|
||||
pf->drawable = drawable;
|
||||
pf->tile = NULL;
|
||||
pf->tile_dirty = FALSE;
|
||||
pf->shadow = FALSE;
|
||||
/* this allows us to use (slightly faster) do-while loops */
|
||||
g_assert (pf->img_bpp > 0);
|
||||
|
||||
return pf;
|
||||
}
|
||||
|
@ -90,18 +108,18 @@ gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf)
|
|||
|
||||
void
|
||||
gimp_pixel_fetcher_set_shadow (GimpPixelFetcher *pf,
|
||||
gboolean shadow)
|
||||
gboolean shadow)
|
||||
{
|
||||
pf->shadow = shadow;
|
||||
}
|
||||
|
||||
static guchar*
|
||||
static guchar *
|
||||
gimp_pixel_fetcher_provide_tile (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y)
|
||||
gint x,
|
||||
gint y)
|
||||
{
|
||||
gint col, row;
|
||||
gint coloff, rowoff;
|
||||
gint col, row;
|
||||
gint coloff, rowoff;
|
||||
|
||||
col = x / pf->tile_width;
|
||||
coloff = x % pf->tile_width;
|
||||
|
@ -111,7 +129,7 @@ gimp_pixel_fetcher_provide_tile (GimpPixelFetcher *pf,
|
|||
if ((col != pf->col) || (row != pf->row) || (pf->tile == NULL))
|
||||
{
|
||||
if (pf->tile != NULL)
|
||||
gimp_tile_unref(pf->tile, pf->tile_dirty);
|
||||
gimp_tile_unref (pf->tile, pf->tile_dirty);
|
||||
|
||||
pf->tile = gimp_drawable_get_tile (pf->drawable, pf->shadow, row, col);
|
||||
pf->tile_dirty = FALSE;
|
||||
|
@ -126,9 +144,9 @@ gimp_pixel_fetcher_provide_tile (GimpPixelFetcher *pf,
|
|||
|
||||
void
|
||||
gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
{
|
||||
guchar *p;
|
||||
gint i;
|
||||
|
@ -141,15 +159,17 @@ gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
|||
|
||||
p = gimp_pixel_fetcher_provide_tile (pf, x, y);
|
||||
|
||||
for (i = pf->img_bpp; i; i--)
|
||||
i = pf->img_bpp;
|
||||
do
|
||||
*pixel++ = *p++;
|
||||
while (--i);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
{
|
||||
guchar *p;
|
||||
gint i;
|
||||
|
@ -162,18 +182,20 @@ gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
|||
|
||||
p = gimp_pixel_fetcher_provide_tile (pf, x, y);
|
||||
|
||||
for (i = pf->img_bpp; i; i--)
|
||||
i = pf->img_bpp;
|
||||
do
|
||||
*p++ = *pixel++;
|
||||
while (--i);
|
||||
|
||||
pf->tile_dirty = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
gint wrapmode,
|
||||
guchar *pixel)
|
||||
gint x,
|
||||
gint y,
|
||||
gint wrapmode,
|
||||
guchar *pixel)
|
||||
{
|
||||
guchar *p;
|
||||
gint i;
|
||||
|
@ -196,33 +218,41 @@ gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
|
|||
y += pf->img_height;
|
||||
}
|
||||
break;
|
||||
|
||||
case PIXEL_SMEAR:
|
||||
x = CLAMP (x, 0, pf->img_width - 1);
|
||||
y = CLAMP (y, 0, pf->img_height - 1);
|
||||
break;
|
||||
|
||||
case PIXEL_BLACK:
|
||||
if (x < 0 || x >= pf->img_width ||
|
||||
y < 0 || y >= pf->img_height)
|
||||
{
|
||||
for (i = 0; i < pf->img_bpp; i++)
|
||||
i = pf->img_bpp;
|
||||
do
|
||||
pixel[i] = 0;
|
||||
while (--i);
|
||||
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
p = gimp_pixel_fetcher_provide_tile (pf, x, y);
|
||||
|
||||
for (i = pf->img_bpp; i; i--)
|
||||
i = pf->img_bpp;
|
||||
do
|
||||
*pixel++ = *p++;
|
||||
while (--i);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf)
|
||||
{
|
||||
if (pf->tile != NULL)
|
||||
if (pf->tile)
|
||||
gimp_tile_unref (pf->tile, pf->tile_dirty);
|
||||
|
||||
g_free (pf);
|
||||
|
@ -230,8 +260,8 @@ gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf)
|
|||
|
||||
void
|
||||
gimp_get_bg_guchar (GimpDrawable *drawable,
|
||||
gboolean transparent,
|
||||
guchar *bg)
|
||||
gboolean transparent,
|
||||
guchar *bg)
|
||||
{
|
||||
GimpRGB background;
|
||||
|
||||
|
@ -265,12 +295,12 @@ gimp_get_bg_guchar (GimpDrawable *drawable,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_rgn_render_row (guchar *src,
|
||||
guchar *dest,
|
||||
gint col, /* row width in pixels */
|
||||
gint bpp,
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data)
|
||||
gimp_rgn_render_row (guchar *src,
|
||||
guchar *dest,
|
||||
gint col, /* row width in pixels */
|
||||
gint bpp,
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data)
|
||||
{
|
||||
while (col--)
|
||||
{
|
||||
|
@ -283,9 +313,10 @@ gimp_rgn_render_row (guchar *src,
|
|||
static void
|
||||
gimp_rgn_render_region (const GimpPixelRgn *srcPR,
|
||||
const GimpPixelRgn *destPR,
|
||||
GimpRgnFunc2 func, gpointer data)
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data)
|
||||
{
|
||||
gint row;
|
||||
gint row;
|
||||
guchar* src = srcPR->data;
|
||||
guchar* dest = destPR->data;
|
||||
|
||||
|
@ -299,8 +330,10 @@ gimp_rgn_render_region (const GimpPixelRgn *srcPR,
|
|||
}
|
||||
|
||||
void
|
||||
gimp_rgn_iterate1 (GimpDrawable *drawable, GimpRunMode run_mode,
|
||||
GimpRgnFunc1 func, gpointer data)
|
||||
gimp_rgn_iterate1 (GimpDrawable *drawable,
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc1 func,
|
||||
gpointer data)
|
||||
{
|
||||
GimpPixelRgn srcPR;
|
||||
gint x1, y1, x2, y2;
|
||||
|
@ -323,7 +356,7 @@ gimp_rgn_iterate1 (GimpDrawable *drawable, GimpRunMode run_mode,
|
|||
pr = gimp_pixel_rgns_process (pr))
|
||||
{
|
||||
guchar *src = srcPR.data;
|
||||
gint y;
|
||||
gint y;
|
||||
|
||||
for (y = 0; y < srcPR.h; y++)
|
||||
{
|
||||
|
@ -343,14 +376,17 @@ gimp_rgn_iterate1 (GimpDrawable *drawable, GimpRunMode run_mode,
|
|||
{
|
||||
area_so_far += srcPR.w * srcPR.h;
|
||||
if (((progress_skip++) % 10) == 0)
|
||||
gimp_progress_update ((double) area_so_far / (double) total_area);
|
||||
gimp_progress_update ((gdouble) area_so_far /
|
||||
(gdouble) total_area);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_rgn_iterate2 (GimpDrawable *drawable, GimpRunMode run_mode,
|
||||
GimpRgnFunc2 func, gpointer data)
|
||||
gimp_rgn_iterate2 (GimpDrawable *drawable,
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data)
|
||||
{
|
||||
GimpPixelRgn srcPR, destPR;
|
||||
gint x1, y1, x2, y2;
|
||||
|
@ -381,7 +417,8 @@ gimp_rgn_iterate2 (GimpDrawable *drawable, GimpRunMode run_mode,
|
|||
{
|
||||
area_so_far += srcPR.w * srcPR.h;
|
||||
if (((progress_skip++) % 10) == 0)
|
||||
gimp_progress_update ((double) area_so_far / (double) total_area);
|
||||
gimp_progress_update ((gdouble) area_so_far /
|
||||
(gdouble) total_area);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ G_BEGIN_DECLS
|
|||
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PIXEL_WRAP,
|
||||
|
@ -37,59 +38,46 @@ enum
|
|||
PIXEL_BLACK,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint col, row;
|
||||
gint img_width;
|
||||
gint img_height;
|
||||
gint sel_x1, sel_y1, sel_x2, sel_y2;
|
||||
gint img_bpp;
|
||||
gint img_has_alpha;
|
||||
gint tile_width, tile_height;
|
||||
guchar bg_color[4];
|
||||
GimpDrawable *drawable;
|
||||
GimpTile *tile;
|
||||
gboolean tile_dirty;
|
||||
gboolean shadow;
|
||||
} GimpPixelFetcher;
|
||||
|
||||
GimpPixelFetcher *gimp_pixel_fetcher_new (GimpDrawable *drawable);
|
||||
void gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf);
|
||||
void gimp_pixel_fetcher_set_shadow (GimpPixelFetcher *pf,
|
||||
gboolean shadow);
|
||||
void gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
gint wrapmode,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf);
|
||||
typedef struct _GimpPixelFetcher GimpPixelFetcher;
|
||||
|
||||
|
||||
void gimp_get_bg_guchar (GimpDrawable *drawable,
|
||||
gboolean transparent,
|
||||
guchar *bg);
|
||||
GimpPixelFetcher * gimp_pixel_fetcher_new (GimpDrawable *drawable);
|
||||
void gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf);
|
||||
void gimp_pixel_fetcher_set_shadow (GimpPixelFetcher *pf,
|
||||
gboolean shadow);
|
||||
void gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
gint wrapmode,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_put_pixel (GimpPixelFetcher *pf,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
void gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf);
|
||||
|
||||
|
||||
typedef void (*GimpRgnFunc1)(guchar *src, gint bpp, gpointer);
|
||||
typedef void (*GimpRgnFunc2)(guchar *src, guchar *dest, gint bpp, gpointer);
|
||||
void gimp_get_bg_guchar (GimpDrawable *drawable,
|
||||
gboolean transparent,
|
||||
guchar *bg);
|
||||
|
||||
|
||||
typedef void (* GimpRgnFunc1) (guchar *src, gint bpp, gpointer);
|
||||
typedef void (* GimpRgnFunc2) (guchar *src, guchar *dest, gint bpp, gpointer);
|
||||
|
||||
void gimp_rgn_iterate1 (GimpDrawable *drawable,
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc1 func,
|
||||
gpointer data);
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc1 func,
|
||||
gpointer data);
|
||||
|
||||
void gimp_rgn_iterate2 (GimpDrawable *drawable,
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data);
|
||||
GimpRunMode run_mode,
|
||||
GimpRgnFunc2 func,
|
||||
gpointer data);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -83,63 +83,64 @@
|
|||
|
||||
typedef struct
|
||||
{
|
||||
guint32 seed;
|
||||
gdouble turbulence;
|
||||
guint32 seed;
|
||||
gdouble turbulence;
|
||||
} PlasmaValues;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint run;
|
||||
gboolean run;
|
||||
} PlasmaInterface;
|
||||
|
||||
/*
|
||||
* Function prototypes.
|
||||
*/
|
||||
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
gint nparams,
|
||||
GimpParam *param,
|
||||
gint *nreturn_vals,
|
||||
GimpParam **return_vals);
|
||||
|
||||
static GtkWidget *preview_widget (GimpImageType drawable_type);
|
||||
static gint plasma_dialog (GimpDrawable *drawable,
|
||||
GimpImageType drawable_type);
|
||||
static void plasma_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void plasma_seed_changed_callback (GimpDrawable *drawable,
|
||||
gpointer data);
|
||||
static GtkWidget *preview_widget (GimpImageType drawable_type);
|
||||
static gboolean plasma_dialog (GimpDrawable *drawable,
|
||||
GimpImageType drawable_type);
|
||||
static void plasma_ok_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void plasma_seed_changed_callback (GimpDrawable *drawable,
|
||||
gpointer data);
|
||||
|
||||
static void plasma (GimpDrawable *drawable,
|
||||
gboolean preview_mode);
|
||||
static void random_rgb (GRand *gr,
|
||||
guchar *d);
|
||||
static void add_random (GRand *gr,
|
||||
guchar *d,
|
||||
gint amnt);
|
||||
gboolean preview_mode);
|
||||
static void random_rgb (GRand *gr,
|
||||
guchar *pixel);
|
||||
static void add_random (GRand *gr,
|
||||
guchar *pixel,
|
||||
gint amount);
|
||||
static GimpPixelFetcher *init_plasma (GimpDrawable *drawable,
|
||||
gboolean preview_mode,
|
||||
GRand *gr);
|
||||
static void end_plasma (GimpDrawable *drawable,
|
||||
gboolean preview_mode,
|
||||
GRand *gr);
|
||||
static void end_plasma (GimpDrawable *drawable,
|
||||
GimpPixelFetcher *pft,
|
||||
GRand *gr);
|
||||
GRand *gr);
|
||||
static void get_pixel (GimpPixelFetcher *pft,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
static void put_pixel (GimpPixelFetcher *pft,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
static gint do_plasma (GimpPixelFetcher *pft,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gint depth,
|
||||
gint scale_depth,
|
||||
GRand *gr);
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel);
|
||||
static gboolean do_plasma (GimpPixelFetcher *pft,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gint depth,
|
||||
gint scale_depth,
|
||||
GRand *gr);
|
||||
|
||||
|
||||
/***** Local vars *****/
|
||||
|
||||
|
@ -162,7 +163,7 @@ static PlasmaInterface pint =
|
|||
FALSE /* run */
|
||||
};
|
||||
|
||||
static guchar *work_buffer;
|
||||
static guchar *work_buffer;
|
||||
static GtkWidget *preview;
|
||||
|
||||
/***** Functions *****/
|
||||
|
@ -174,21 +175,19 @@ query (void)
|
|||
{
|
||||
static GimpParamDef args[]=
|
||||
{
|
||||
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
|
||||
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
|
||||
{ GIMP_PDB_INT32, "seed", "Random seed" },
|
||||
{ GIMP_PDB_FLOAT, "turbulence", "Turbulence of plasma" }
|
||||
{ GIMP_PDB_INT32, "run_mode", "Interactive, non-interactive" },
|
||||
{ GIMP_PDB_IMAGE, "image", "Input image (unused)" },
|
||||
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable" },
|
||||
{ GIMP_PDB_INT32, "seed", "Random seed" },
|
||||
{ GIMP_PDB_FLOAT, "turbulence", "Turbulence of plasma" }
|
||||
};
|
||||
|
||||
gimp_install_procedure ("plug_in_plasma",
|
||||
"Create a plasma cloud like image to the specified drawable",
|
||||
"Create a plasma cloud like image on the specified drawable",
|
||||
"More help",
|
||||
"Stephen Norris & (ported to 1.0 by) Eiichi Takamori",
|
||||
"Stephen Norris",
|
||||
"May 2000",
|
||||
/* don't translate '<Image>', it's a special
|
||||
* keyword of the gtk toolkit */
|
||||
N_("<Image>/Filters/Render/Clouds/Plasma..."),
|
||||
"RGB*, GRAY*",
|
||||
GIMP_PLUGIN,
|
||||
|
@ -293,8 +292,9 @@ run (gchar *name,
|
|||
gimp_drawable_detach (drawable);
|
||||
}
|
||||
|
||||
static gint
|
||||
plasma_dialog (GimpDrawable *drawable, GimpImageType drawable_type)
|
||||
static gboolean
|
||||
plasma_dialog (GimpDrawable *drawable,
|
||||
GimpImageType drawable_type)
|
||||
{
|
||||
GtkWidget *dlg;
|
||||
GtkWidget *main_vbox;
|
||||
|
@ -325,7 +325,8 @@ plasma_dialog (GimpDrawable *drawable, GimpImageType drawable_type)
|
|||
|
||||
main_vbox = gtk_vbox_new (FALSE, 4);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 6);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox), main_vbox, TRUE, TRUE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
|
||||
main_vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
/* make a nice preview frame */
|
||||
|
@ -408,19 +409,21 @@ static void
|
|||
plasma_seed_changed_callback (GimpDrawable *drawable,
|
||||
gpointer data)
|
||||
{
|
||||
plasma(drawable, TRUE);
|
||||
plasma (drawable, TRUE);
|
||||
}
|
||||
|
||||
#define AVE(n, v1, v2) n[0] = ((gint)v1[0] + (gint)v2[0]) / 2;\
|
||||
n[1] = ((gint)v1[1] + (gint)v2[1]) / 2;\
|
||||
n[2] = ((gint)v1[2] + (gint)v2[2]) / 2;
|
||||
#define AVE(n, v1, v2) n[0] = ((gint)v1[0] + (gint)v2[0]) / 2; \
|
||||
n[1] = ((gint)v1[1] + (gint)v2[1]) / 2; \
|
||||
n[2] = ((gint)v1[2] + (gint)v2[2]) / 2;
|
||||
|
||||
|
||||
/*
|
||||
* Some glabals to save passing too many paramaters that don't change.
|
||||
* Some globals to save passing too many paramaters that don't change.
|
||||
*/
|
||||
|
||||
static gint ix1, iy1, ix2, iy2; /* Selected image size. */
|
||||
static gint bpp, has_alpha, alpha;
|
||||
static gint bpp, alpha;
|
||||
static gboolean has_alpha;
|
||||
static gdouble turbulence;
|
||||
static glong max_progress, progress;
|
||||
|
||||
|
@ -430,12 +433,12 @@ static glong max_progress, progress;
|
|||
|
||||
static void
|
||||
plasma (GimpDrawable *drawable,
|
||||
gboolean preview_mode)
|
||||
gboolean preview_mode)
|
||||
{
|
||||
GimpPixelFetcher *pft;
|
||||
gint depth;
|
||||
GRand *gr;
|
||||
|
||||
gint depth;
|
||||
GRand *gr;
|
||||
|
||||
gr = g_rand_new ();
|
||||
|
||||
pft = init_plasma (drawable, preview_mode, gr);
|
||||
|
@ -454,15 +457,16 @@ plasma (GimpDrawable *drawable,
|
|||
depth = 1;
|
||||
while (!do_plasma (pft, ix1, iy1, ix2 - 1, iy2 - 1, depth, 0, gr))
|
||||
{
|
||||
depth ++;
|
||||
depth++;
|
||||
}
|
||||
|
||||
end_plasma (drawable, pft, gr);
|
||||
}
|
||||
|
||||
static GimpPixelFetcher*
|
||||
init_plasma (GimpDrawable *drawable,
|
||||
gboolean preview_mode,
|
||||
GRand *gr)
|
||||
gboolean preview_mode,
|
||||
GRand *gr)
|
||||
{
|
||||
GimpPixelFetcher *pft;
|
||||
|
||||
|
@ -475,33 +479,41 @@ init_plasma (GimpDrawable *drawable,
|
|||
ix1 = iy1 = 0;
|
||||
ix2 = GTK_PREVIEW (preview)->buffer_width;
|
||||
iy2 = GTK_PREVIEW (preview)->buffer_height;
|
||||
bpp = GTK_PREVIEW (preview)->bpp;
|
||||
alpha = bpp;
|
||||
has_alpha = 0;
|
||||
|
||||
bpp = GTK_PREVIEW (preview)->bpp;
|
||||
alpha = bpp;
|
||||
has_alpha = FALSE;
|
||||
|
||||
work_buffer = g_malloc (GTK_PREVIEW (preview)->rowstride * iy2);
|
||||
memcpy (work_buffer, GTK_PREVIEW (preview)->buffer, GTK_PREVIEW (preview)->rowstride * iy2);
|
||||
memcpy (work_buffer,
|
||||
GTK_PREVIEW (preview)->buffer,
|
||||
GTK_PREVIEW (preview)->rowstride * iy2);
|
||||
|
||||
pft = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id, &ix1, &iy1, &ix2, &iy2);
|
||||
bpp = drawable->bpp;
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id,
|
||||
&ix1, &iy1, &ix2, &iy2);
|
||||
|
||||
bpp = drawable->bpp;
|
||||
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);
|
||||
gimp_pixel_fetcher_set_shadow (pft, TRUE);
|
||||
}
|
||||
|
||||
progress = 0;
|
||||
max_progress = (ix2 - ix1) * (iy2 - iy1);
|
||||
progress = 0;
|
||||
|
||||
return pft;
|
||||
}
|
||||
|
||||
static void
|
||||
end_plasma (GimpDrawable *drawable,
|
||||
end_plasma (GimpDrawable *drawable,
|
||||
GimpPixelFetcher *pft,
|
||||
GRand *gr)
|
||||
GRand *gr)
|
||||
{
|
||||
if (pft)
|
||||
{
|
||||
|
@ -517,16 +529,18 @@ end_plasma (GimpDrawable *drawable,
|
|||
memcpy (GTK_PREVIEW (preview)->buffer, work_buffer,
|
||||
GTK_PREVIEW (preview)->rowstride * iy2);
|
||||
g_free (work_buffer);
|
||||
|
||||
gtk_widget_queue_draw (preview);
|
||||
}
|
||||
|
||||
g_rand_free (gr);
|
||||
}
|
||||
|
||||
static void
|
||||
get_pixel (GimpPixelFetcher *pft,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
{
|
||||
if (pft)
|
||||
{
|
||||
|
@ -544,9 +558,9 @@ get_pixel (GimpPixelFetcher *pft,
|
|||
|
||||
static void
|
||||
put_pixel (GimpPixelFetcher *pft,
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
gint x,
|
||||
gint y,
|
||||
guchar *pixel)
|
||||
{
|
||||
if (pft)
|
||||
{
|
||||
|
@ -563,47 +577,43 @@ put_pixel (GimpPixelFetcher *pft,
|
|||
}
|
||||
|
||||
static void
|
||||
random_rgb (GRand *gr,
|
||||
guchar *d)
|
||||
random_rgb (GRand *gr,
|
||||
guchar *pixel)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for(i = 0; i < alpha; i++)
|
||||
{
|
||||
d[i] = g_rand_int_range (gr, 0, 256);
|
||||
}
|
||||
for (i = 0; i < alpha; i++)
|
||||
pixel[i] = g_rand_int_range (gr, 0, 256);
|
||||
|
||||
if (has_alpha)
|
||||
d[alpha] = 255;
|
||||
pixel[alpha] = 255;
|
||||
}
|
||||
|
||||
static void
|
||||
add_random (GRand *gr,
|
||||
guchar *d,
|
||||
gint amnt)
|
||||
add_random (GRand *gr,
|
||||
guchar *pixel,
|
||||
gint amount)
|
||||
{
|
||||
gint i, tmp;
|
||||
|
||||
if (amnt == 0)
|
||||
{
|
||||
amnt = 1;
|
||||
}
|
||||
amount /= 2;
|
||||
|
||||
for (i = 0; i < alpha; i++)
|
||||
{
|
||||
tmp = d[i] + g_rand_int_range(gr, -amnt/2, amnt/2);
|
||||
d[i] = CLAMP0255 (tmp);
|
||||
tmp = pixel[i] + g_rand_int_range (gr, - amount, amount);
|
||||
pixel[i] = CLAMP0255 (tmp);
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
do_plasma (GimpPixelFetcher *pft,
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gint depth,
|
||||
gint scale_depth,
|
||||
GRand *gr)
|
||||
gint x1,
|
||||
gint y1,
|
||||
gint x2,
|
||||
gint y2,
|
||||
gint depth,
|
||||
gint scale_depth,
|
||||
GRand *gr)
|
||||
{
|
||||
guchar tl[4], ml[4], bl[4], mt[4], mm[4], mb[4], tr[4], mr[4], br[4];
|
||||
guchar tmp[4];
|
||||
|
@ -635,7 +645,7 @@ do_plasma (GimpPixelFetcher *pft,
|
|||
random_rgb (gr, ml);
|
||||
put_pixel (pft, (x1 + x2) / 2, y2, ml);
|
||||
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -644,8 +654,8 @@ do_plasma (GimpPixelFetcher *pft,
|
|||
*/
|
||||
if (depth == 0)
|
||||
{
|
||||
gdouble rnd;
|
||||
gint xave, yave;
|
||||
gdouble rnd;
|
||||
gint xave, yave;
|
||||
|
||||
get_pixel (pft, x1, y1, tl);
|
||||
get_pixel (pft, x1, y2, bl);
|
||||
|
@ -660,7 +670,7 @@ do_plasma (GimpPixelFetcher *pft,
|
|||
|
||||
if (xave == x1 && xave == x2 && yave == y1 && yave == y2)
|
||||
{
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (xave != x1 || xave != x2)
|
||||
|
@ -709,18 +719,19 @@ do_plasma (GimpPixelFetcher *pft,
|
|||
put_pixel (pft, xave, yave, mm);
|
||||
}
|
||||
|
||||
count ++;
|
||||
count++;
|
||||
|
||||
if (!(count % 2000) && pft)
|
||||
{
|
||||
gimp_progress_update ((double) progress / (double) max_progress);
|
||||
gimp_progress_update ((gdouble) progress / (gdouble) max_progress);
|
||||
}
|
||||
|
||||
if ((x2 - x1) < 3 && (y2 - y1) < 3)
|
||||
{
|
||||
return 1;
|
||||
return TRUE;
|
||||
}
|
||||
return 0;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
xm = (x1 + x2) >> 1;
|
||||
|
@ -743,29 +754,36 @@ do_plasma (GimpPixelFetcher *pft,
|
|||
static GtkWidget *
|
||||
preview_widget (GimpImageType drawable_type)
|
||||
{
|
||||
GtkWidget *preview;
|
||||
guchar *buf;
|
||||
GtkWidget *preview = NULL;
|
||||
guchar *buf = NULL;
|
||||
gint y;
|
||||
|
||||
if (drawable_type == GIMP_GRAY_IMAGE ||
|
||||
drawable_type == GIMP_GRAYA_IMAGE)
|
||||
{
|
||||
preview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
buf = g_malloc0 (PREVIEW_SIZE);
|
||||
}
|
||||
else /* Gray & colour are the only possibilities here */
|
||||
{
|
||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
buf = g_malloc0 (PREVIEW_SIZE * 3);
|
||||
}
|
||||
switch (drawable_type)
|
||||
{
|
||||
case GIMP_GRAY_IMAGE:
|
||||
case GIMP_GRAYA_IMAGE:
|
||||
preview = gtk_preview_new (GTK_PREVIEW_GRAYSCALE);
|
||||
buf = g_malloc0 (PREVIEW_SIZE);
|
||||
break;
|
||||
|
||||
case GIMP_RGB_IMAGE:
|
||||
case GIMP_RGBA_IMAGE:
|
||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
buf = g_malloc0 (PREVIEW_SIZE * 3);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
break;
|
||||
}
|
||||
|
||||
gtk_preview_size (GTK_PREVIEW (preview), PREVIEW_SIZE, PREVIEW_SIZE);
|
||||
|
||||
for (y = 0; y < PREVIEW_SIZE; y++)
|
||||
gtk_preview_draw_row (GTK_PREVIEW (preview), buf, 0, y, PREVIEW_SIZE);
|
||||
|
||||
|
||||
g_free (buf);
|
||||
|
||||
|
||||
return preview;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue