Changed plug-ins so they now use gimpmisc functions.

This commit is contained in:
Maurits Rijk 2002-11-21 22:04:39 +00:00
parent 2a37c9e62e
commit a64029bad6
11 changed files with 461 additions and 359 deletions

View File

@ -1,3 +1,17 @@
2002-11-21 Maurits Rijk <lpeek.mrijk@consunet.nl>
* plug-ins/common/blinds.c: use gimp_get_bg_guchar
* libgimp/gimpmisc.[ch]: added gimp_pixel_fetcher routine with
wrapmode and generic get background color routine (gimp_get_bg_guchar)
* plug-ins/common/edge.c: : use gimp_pixel_fetcher routines
2002-11-21 Maurits Rijk <lpeek.mrijk@consunet.nl>
* plug-ins/common/AlienMap.c
* plug-ins/common/AlienMap2.c: use gimp_pixel_fetcher routines
2002-11-21 Sven Neumann <sven@gimp.org>
* app/config/gimpdisplayconfig.[ch]

View File

@ -81,9 +81,9 @@ gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf)
void
gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
gint x,
gint y,
guchar *pixel)
gint x,
gint y,
guchar *pixel)
{
gint col, row;
gint coloff, rowoff;
@ -104,9 +104,83 @@ gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
row = y / pf->tile_height;
rowoff = y % pf->tile_height;
if ((col != pf->col) ||
(row != pf->row) ||
(pf->tile == NULL))
if ((col != pf->col) || (row != pf->row) || (pf->tile == NULL))
{
if (pf->tile != NULL)
gimp_tile_unref(pf->tile, FALSE);
pf->tile = gimp_drawable_get_tile (pf->drawable, FALSE, row, col);
gimp_tile_ref (pf->tile);
pf->col = col;
pf->row = row;
}
p = pf->tile->data + pf->img_bpp * (pf->tile->ewidth * rowoff + coloff);
for (i = pf->img_bpp; i; i--)
*pixel++ = *p++;
}
void
gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
gint x,
gint y,
gint wrapmode,
guchar *pixel)
{
gint col, row;
gint coloff, rowoff;
guchar *p;
gint i;
if (x < 0 || x >= pf->img_width ||
y < 0 || y >= pf->img_height)
switch (wrapmode)
{
case PIXEL_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 PIXEL_SMEAR:
if (x < 0)
x = 0;
if (x >= pf->img_width)
x = pf->img_width - 1;
if (y < 0)
y = 0;
if (y >= pf->img_height)
y = 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++)
pixel[i] = 0;
return;
}
break;
default:
return;
}
col = x / pf->tile_width;
coloff = x % pf->tile_width;
row = y / pf->tile_height;
rowoff = y % pf->tile_height;
if ((col != pf->col) || (row != pf->row) || (pf->tile == NULL))
{
if (pf->tile != NULL)
gimp_tile_unref(pf->tile, FALSE);
@ -132,3 +206,39 @@ gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf)
g_free (pf);
}
void
gimp_get_bg_guchar (GimpDrawable *drawable,
gboolean transparent,
guchar *bg)
{
GimpRGB background;
gimp_palette_get_background (&background);
switch (gimp_drawable_type (drawable->drawable_id))
{
case GIMP_RGB_IMAGE :
gimp_rgb_get_uchar (&background, &bg[0], &bg[1], &bg[2]);
bg[3] = 255;
break;
case GIMP_RGBA_IMAGE:
gimp_rgb_get_uchar (&background, &bg[0], &bg[1], &bg[2]);
bg[3] = transparent ? 0 : 255;
break;
case GIMP_GRAY_IMAGE:
bg[0] = gimp_rgb_intensity_uchar (&background);
bg[1] = 255;
break;
case GIMP_GRAYA_IMAGE:
bg[0] = gimp_rgb_intensity_uchar (&background);
bg[1] = transparent ? 0 : 255;
break;
default:
break;
}
}

View File

@ -30,6 +30,13 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
enum
{
PIXEL_WRAP,
PIXEL_SMEAR,
PIXEL_BLACK
};
typedef struct
{
gint col, row;
@ -47,11 +54,21 @@ typedef struct
GimpPixelFetcher *gimp_pixel_fetcher_new (GimpDrawable *drawable);
void gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf);
void gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
int x,
int y,
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_destroy (GimpPixelFetcher *pf);
void gimp_get_bg_guchar (GimpDrawable *drawable,
gboolean transparent,
guchar *bg);
G_END_DECLS
#endif /* __GIMP_MISC_H__ */

View File

@ -81,9 +81,9 @@ gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf)
void
gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
gint x,
gint y,
guchar *pixel)
gint x,
gint y,
guchar *pixel)
{
gint col, row;
gint coloff, rowoff;
@ -104,9 +104,83 @@ gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
row = y / pf->tile_height;
rowoff = y % pf->tile_height;
if ((col != pf->col) ||
(row != pf->row) ||
(pf->tile == NULL))
if ((col != pf->col) || (row != pf->row) || (pf->tile == NULL))
{
if (pf->tile != NULL)
gimp_tile_unref(pf->tile, FALSE);
pf->tile = gimp_drawable_get_tile (pf->drawable, FALSE, row, col);
gimp_tile_ref (pf->tile);
pf->col = col;
pf->row = row;
}
p = pf->tile->data + pf->img_bpp * (pf->tile->ewidth * rowoff + coloff);
for (i = pf->img_bpp; i; i--)
*pixel++ = *p++;
}
void
gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
gint x,
gint y,
gint wrapmode,
guchar *pixel)
{
gint col, row;
gint coloff, rowoff;
guchar *p;
gint i;
if (x < 0 || x >= pf->img_width ||
y < 0 || y >= pf->img_height)
switch (wrapmode)
{
case PIXEL_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 PIXEL_SMEAR:
if (x < 0)
x = 0;
if (x >= pf->img_width)
x = pf->img_width - 1;
if (y < 0)
y = 0;
if (y >= pf->img_height)
y = 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++)
pixel[i] = 0;
return;
}
break;
default:
return;
}
col = x / pf->tile_width;
coloff = x % pf->tile_width;
row = y / pf->tile_height;
rowoff = y % pf->tile_height;
if ((col != pf->col) || (row != pf->row) || (pf->tile == NULL))
{
if (pf->tile != NULL)
gimp_tile_unref(pf->tile, FALSE);
@ -132,3 +206,39 @@ gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf)
g_free (pf);
}
void
gimp_get_bg_guchar (GimpDrawable *drawable,
gboolean transparent,
guchar *bg)
{
GimpRGB background;
gimp_palette_get_background (&background);
switch (gimp_drawable_type (drawable->drawable_id))
{
case GIMP_RGB_IMAGE :
gimp_rgb_get_uchar (&background, &bg[0], &bg[1], &bg[2]);
bg[3] = 255;
break;
case GIMP_RGBA_IMAGE:
gimp_rgb_get_uchar (&background, &bg[0], &bg[1], &bg[2]);
bg[3] = transparent ? 0 : 255;
break;
case GIMP_GRAY_IMAGE:
bg[0] = gimp_rgb_intensity_uchar (&background);
bg[1] = 255;
break;
case GIMP_GRAYA_IMAGE:
bg[0] = gimp_rgb_intensity_uchar (&background);
bg[1] = transparent ? 0 : 255;
break;
default:
break;
}
}

View File

@ -30,6 +30,13 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
enum
{
PIXEL_WRAP,
PIXEL_SMEAR,
PIXEL_BLACK
};
typedef struct
{
gint col, row;
@ -47,11 +54,21 @@ typedef struct
GimpPixelFetcher *gimp_pixel_fetcher_new (GimpDrawable *drawable);
void gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf);
void gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
int x,
int y,
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_destroy (GimpPixelFetcher *pf);
void gimp_get_bg_guchar (GimpDrawable *drawable,
gboolean transparent,
guchar *bg);
G_END_DECLS
#endif /* __GIMP_MISC_H__ */

View File

@ -81,9 +81,9 @@ gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf)
void
gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
gint x,
gint y,
guchar *pixel)
gint x,
gint y,
guchar *pixel)
{
gint col, row;
gint coloff, rowoff;
@ -104,9 +104,83 @@ gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
row = y / pf->tile_height;
rowoff = y % pf->tile_height;
if ((col != pf->col) ||
(row != pf->row) ||
(pf->tile == NULL))
if ((col != pf->col) || (row != pf->row) || (pf->tile == NULL))
{
if (pf->tile != NULL)
gimp_tile_unref(pf->tile, FALSE);
pf->tile = gimp_drawable_get_tile (pf->drawable, FALSE, row, col);
gimp_tile_ref (pf->tile);
pf->col = col;
pf->row = row;
}
p = pf->tile->data + pf->img_bpp * (pf->tile->ewidth * rowoff + coloff);
for (i = pf->img_bpp; i; i--)
*pixel++ = *p++;
}
void
gimp_pixel_fetcher_get_pixel2 (GimpPixelFetcher *pf,
gint x,
gint y,
gint wrapmode,
guchar *pixel)
{
gint col, row;
gint coloff, rowoff;
guchar *p;
gint i;
if (x < 0 || x >= pf->img_width ||
y < 0 || y >= pf->img_height)
switch (wrapmode)
{
case PIXEL_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 PIXEL_SMEAR:
if (x < 0)
x = 0;
if (x >= pf->img_width)
x = pf->img_width - 1;
if (y < 0)
y = 0;
if (y >= pf->img_height)
y = 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++)
pixel[i] = 0;
return;
}
break;
default:
return;
}
col = x / pf->tile_width;
coloff = x % pf->tile_width;
row = y / pf->tile_height;
rowoff = y % pf->tile_height;
if ((col != pf->col) || (row != pf->row) || (pf->tile == NULL))
{
if (pf->tile != NULL)
gimp_tile_unref(pf->tile, FALSE);
@ -132,3 +206,39 @@ gimp_pixel_fetcher_destroy (GimpPixelFetcher *pf)
g_free (pf);
}
void
gimp_get_bg_guchar (GimpDrawable *drawable,
gboolean transparent,
guchar *bg)
{
GimpRGB background;
gimp_palette_get_background (&background);
switch (gimp_drawable_type (drawable->drawable_id))
{
case GIMP_RGB_IMAGE :
gimp_rgb_get_uchar (&background, &bg[0], &bg[1], &bg[2]);
bg[3] = 255;
break;
case GIMP_RGBA_IMAGE:
gimp_rgb_get_uchar (&background, &bg[0], &bg[1], &bg[2]);
bg[3] = transparent ? 0 : 255;
break;
case GIMP_GRAY_IMAGE:
bg[0] = gimp_rgb_intensity_uchar (&background);
bg[1] = 255;
break;
case GIMP_GRAYA_IMAGE:
bg[0] = gimp_rgb_intensity_uchar (&background);
bg[1] = transparent ? 0 : 255;
break;
default:
break;
}
}

View File

@ -30,6 +30,13 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
enum
{
PIXEL_WRAP,
PIXEL_SMEAR,
PIXEL_BLACK
};
typedef struct
{
gint col, row;
@ -47,11 +54,21 @@ typedef struct
GimpPixelFetcher *gimp_pixel_fetcher_new (GimpDrawable *drawable);
void gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf);
void gimp_pixel_fetcher_get_pixel (GimpPixelFetcher *pf,
int x,
int y,
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_destroy (GimpPixelFetcher *pf);
void gimp_get_bg_guchar (GimpDrawable *drawable,
gboolean transparent,
guchar *bg);
G_END_DECLS
#endif /* __GIMP_MISC_H__ */

View File

@ -862,7 +862,6 @@ typedef struct
} alienmap_interface_t;
/* Declare local functions. */
static void query (void);
@ -878,7 +877,6 @@ static void alienmap_render_row (const guchar *src_row,
gint row,
gint row_width,
gint bytes, double, double, double);
static void alienmap_get_pixel (int x, int y, guchar *pixel);
static void transform (guchar *, guchar *, guchar *,
double, double, double);
@ -895,9 +893,6 @@ static void alienmap_logo_dialog (void);
/***** Variables *****/
GtkWidget *maindlg;
GtkWidget *logodlg;
GimpPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
@ -925,13 +920,8 @@ static alienmap_vals_t wvals =
};
static GimpDrawable *drawable;
static gint tile_width, tile_height;
static gint img_width, img_height, img_bpp;
static gint sel_x1, sel_y1, sel_x2, sel_y2;
static gint sel_width, sel_height;
static gint preview_width, preview_height;
static GimpTile *the_tile = NULL;
static gdouble cen_x, cen_y;
static gdouble scale_x, scale_y;
/***** Functions *****/
@ -1048,11 +1038,10 @@ run (char *name,
GimpParam **return_vals)
{
static GimpParam values[1];
/* GDrawable *drawable; */
/* gint32 image_ID; */
GimpRunMode run_mode;
double xhsiz, yhsiz;
int pwidth, pheight;
double xhsiz, yhsiz;
gint sel_width, sel_height;
int pwidth, pheight;
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
INIT_I18N_UI ();
@ -1067,13 +1056,6 @@ run (char *name,
/* Get the specified drawable */
drawable = gimp_drawable_get (param[2].data.d_drawable);
/* image_ID = param[1].data.d_image; */
tile_width = gimp_tile_width();
tile_height = gimp_tile_height();
img_width = gimp_drawable_width(drawable->drawable_id);
img_height = gimp_drawable_height(drawable->drawable_id);
img_bpp = gimp_drawable_bpp(drawable->drawable_id);
gimp_drawable_mask_bounds(drawable->drawable_id,
&sel_x1, &sel_y1, &sel_x2, &sel_y2);
@ -1081,9 +1063,6 @@ run (char *name,
sel_width = sel_x2 - sel_x1;
sel_height = sel_y2 - sel_y1;
cen_x = (double) (sel_x2 - 1 + sel_x1) / 2.0;
cen_y = (double) (sel_y2 - 1 + sel_y1) / 2.0;
xhsiz = (double) (sel_width - 1) / 2.0;
yhsiz = (double) (sel_height - 1) / 2.0;
@ -1188,49 +1167,6 @@ run (char *name,
gimp_drawable_detach (drawable);
}
static void
alienmap_get_pixel (int x,
int y,
guchar *pixel)
{
static gint row = -1;
static gint col = -1;
gint newcol, newrow;
gint newcoloff, newrowoff;
guchar *p;
int i;
if ((x < 0) || (x >= img_width) || (y < 0) || (y >= img_height))
{
pixel[0] = 0;
pixel[1] = 0;
pixel[2] = 0;
pixel[3] = 0;
return;
}
newcol = x / tile_width; /* The compiler should optimize this */
newcoloff = x % tile_width;
newrow = y / tile_height;
newrowoff = y % tile_height;
if ((col != newcol) || (row != newrow) || (the_tile == NULL))
{
if (the_tile != NULL)
gimp_tile_unref(the_tile, FALSE);
the_tile = gimp_drawable_get_tile(drawable, FALSE, newrow, newcol);
gimp_tile_ref(the_tile);
col = newcol;
row = newrow;
}
p = the_tile->data + the_tile->bpp * (the_tile->ewidth * newrowoff + newcoloff);
for (i = img_bpp; i; i--)
*pixel++ = *p++;
}
static void
alienmap_render_row (const guchar *src_row,
guchar *dest_row,
@ -1328,6 +1264,7 @@ build_preview_source_image (void)
int x, y;
guchar *p;
guchar pixel[4];
GimpPixelFetcher *pft;
wint.image = g_new (guchar, preview_width * preview_height * 3);
wint.wimage = g_new (guchar, preview_width * preview_height * 3);
@ -1344,12 +1281,14 @@ build_preview_source_image (void)
p = wint.image;
pft = gimp_pixel_fetcher_new (drawable);
for (y = 0; y < preview_height; y++)
{
px = left;
for (x = 0; x < preview_width; x++)
{
alienmap_get_pixel((int) px, (int) py, pixel);
gimp_pixel_fetcher_get_pixel (pft, (gint) px, (gint) py, pixel);
*p++ = pixel[0];
*p++ = pixel[1];
@ -1360,6 +1299,7 @@ build_preview_source_image (void)
py += dy;
}
gimp_pixel_fetcher_destroy (pft);
}
static gint
@ -1378,13 +1318,13 @@ alienmap_dialog (void)
build_preview_source_image ();
dialog = maindlg =
dialog =
gimp_dialog_new (_("AlienMap"), "alienmap",
gimp_standard_help_func, "filters/alienmap.html",
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
_("About"), alienmap_logo_dialog,
_("About..."), alienmap_logo_dialog,
NULL, NULL, NULL, FALSE, FALSE,
GTK_STOCK_CANCEL, gtk_widget_destroy,
@ -1531,12 +1471,6 @@ alienmap_dialog (void)
gimp_help_free ();
gdk_flush ();
if (the_tile != NULL)
{
gimp_tile_unref (the_tile, FALSE);
the_tile = NULL;
}
g_free (wint.image);
g_free (wint.wimage);
@ -1634,6 +1568,7 @@ alienmap_toggle_update (GtkWidget *widget,
static void
alienmap_logo_dialog (void)
{
static GtkWidget *logodlg = NULL;
GtkWidget *xlabel;
GtkWidget *xlogo_box;
GtkWidget *xpreview;

View File

@ -880,7 +880,6 @@ static void alienmap2_render_row (const guchar *src_row,
gint row,
gint row_width,
gint bytes);
static void alienmap2_get_pixel (int x, int y, guchar *pixel);
static void transform (guchar*, guchar*, guchar*);
@ -930,13 +929,9 @@ static alienmap2_vals_t wvals =
};
static GimpDrawable *drawable;
static gint tile_width, tile_height;
static gint img_width, img_height, img_bpp;
static gint sel_x1, sel_y1, sel_x2, sel_y2;
static gint sel_width, sel_height;
static gint preview_width, preview_height;
static GimpTile *the_tile = NULL;
static gdouble cen_x, cen_y;
static gdouble scale_x, scale_y;
/***** Functions *****/
@ -1047,13 +1042,6 @@ run (char *name,
/* Get the specified drawable */
drawable = gimp_drawable_get (param[2].data.d_drawable);
/* image_ID = param[1].data.d_image; */
tile_width = gimp_tile_width();
tile_height = gimp_tile_height();
img_width = gimp_drawable_width(drawable->drawable_id);
img_height = gimp_drawable_height(drawable->drawable_id);
img_bpp = gimp_drawable_bpp(drawable->drawable_id);
gimp_drawable_mask_bounds(drawable->drawable_id,
&sel_x1, &sel_y1, &sel_x2, &sel_y2);
@ -1061,9 +1049,6 @@ run (char *name,
sel_width = sel_x2 - sel_x1;
sel_height = sel_y2 - sel_y1;
cen_x = (double) (sel_x2 - 1 + sel_x1) / 2.0;
cen_y = (double) (sel_y2 - 1 + sel_y1) / 2.0;
xhsiz = (double) (sel_width - 1) / 2.0;
yhsiz = (double) (sel_height - 1) / 2.0;
@ -1153,7 +1138,6 @@ run (char *name,
/* Run! */
/* gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width()+1));*/
alienmap2 (drawable);
if (run_mode != GIMP_RUN_NONINTERACTIVE)
gimp_displays_flush();
@ -1174,49 +1158,6 @@ run (char *name,
gimp_drawable_detach (drawable);
}
static void
alienmap2_get_pixel (int x,
int y,
guchar *pixel)
{
static gint row = -1;
static gint col = -1;
gint newcol, newrow;
gint newcoloff, newrowoff;
guchar *p;
int i;
if ((x < 0) || (x >= img_width) || (y < 0) || (y >= img_height))
{
pixel[0] = 0;
pixel[1] = 0;
pixel[2] = 0;
pixel[3] = 0;
return;
}
newcol = x / tile_width; /* The compiler should optimize this */
newcoloff = x % tile_width;
newrow = y / tile_height;
newrowoff = y % tile_height;
if ((col != newcol) || (row != newrow) || (the_tile == NULL))
{
if (the_tile != NULL)
gimp_tile_unref(the_tile, FALSE);
the_tile = gimp_drawable_get_tile(drawable, FALSE, newrow, newcol);
gimp_tile_ref(the_tile);
col = newcol;
row = newrow;
}
p = the_tile->data + the_tile->bpp * (the_tile->ewidth * newrowoff + newcoloff);
for (i = img_bpp; i; i--)
*pixel++ = *p++;
}
static void
alienmap2_render_row (const guchar *src_row,
guchar *dest_row,
@ -1308,6 +1249,7 @@ build_preview_source_image (void)
int x, y;
guchar *p;
guchar pixel[4];
GimpPixelFetcher *pft;
wint.image = g_new (guchar, preview_width * preview_height * 3);
wint.wimage = g_new (guchar, preview_width * preview_height * 3);
@ -1324,12 +1266,14 @@ build_preview_source_image (void)
p = wint.image;
pft = gimp_pixel_fetcher_new (drawable);
for (y = 0; y < preview_height; y++)
{
px = left;
for (x = 0; x < preview_width; x++)
{
alienmap2_get_pixel((int) px, (int) py, pixel);
gimp_pixel_fetcher_get_pixel (pft, (gint) px, (gint) py, pixel);
*p++ = pixel[0];
*p++ = pixel[1];
@ -1337,9 +1281,9 @@ build_preview_source_image (void)
px += dx;
}
py += dy;
}
gimp_pixel_fetcher_destroy (pft);
}
static gint
@ -1364,7 +1308,7 @@ alienmap2_dialog (void)
GTK_WIN_POS_MOUSE,
FALSE, TRUE, FALSE,
_("About"), alienmap2_logo_dialog,
_("About..."), alienmap2_logo_dialog,
NULL, NULL, NULL, FALSE, FALSE,
GTK_STOCK_CANCEL, gtk_widget_destroy,
@ -1535,12 +1479,6 @@ alienmap2_dialog (void)
gimp_help_free ();
gdk_flush ();
if (the_tile != NULL)
{
gimp_tile_unref (the_tile, FALSE);
the_tile = NULL;
}
g_free (wint.image);
g_free (wint.wimage);

View File

@ -133,7 +133,6 @@ static void blinds_button_update (GtkWidget *widget,
static void dialog_update_preview (void);
static void cache_preview (void);
static void apply_blinds (void);
static void blinds_get_bg (guchar *bg);
GimpPlugInInfo PLUG_IN_INFO =
{
@ -643,40 +642,6 @@ blindsapply (guchar *srow,
}
}
static void
blinds_get_bg (guchar *bg)
{
GimpRGB background;
gimp_palette_get_background (&background);
switch (gimp_drawable_type (blindsdrawable->drawable_id))
{
case GIMP_RGB_IMAGE :
gimp_rgb_get_uchar (&background, &bg[0], &bg[1], &bg[2]);
bg[3] = 255;
break;
case GIMP_RGBA_IMAGE:
gimp_rgb_get_uchar (&background, &bg[0], &bg[1], &bg[2]);
bg[3] = bvals.bg_trans ? 0 : 255;
break;
case GIMP_GRAY_IMAGE:
bg[0] = gimp_rgb_intensity_uchar (&background);
bg[1] = 255;
break;
case GIMP_GRAYA_IMAGE:
bg[0] = gimp_rgb_intensity_uchar (&background);
bg[1] = bvals.bg_trans ? 0 : 255;
break;
default:
break;
}
}
static void
dialog_update_preview (void)
{
@ -687,7 +652,8 @@ dialog_update_preview (void)
p = bint.pv_cache;
blinds_get_bg (bg);
/* blinds_get_bg (bg); */
gimp_get_bg_guchar (blindsdrawable, bvals.bg_trans, bg);
if (bvals.orientation)
{
@ -856,7 +822,7 @@ apply_blinds (void)
int x,y;
guchar bg[4];
blinds_get_bg (bg);
gimp_get_bg_guchar (blindsdrawable, bvals.bg_trans, bg);
gimp_pixel_rgn_init (&src_rgn, blindsdrawable,
sel_x1, sel_y1, sel_width, sel_height, FALSE, FALSE);

View File

@ -63,13 +63,6 @@ static gchar rcsid[] = "$Id$";
#define TILE_CACHE_SIZE 48
enum
{
WRAP,
SMEAR,
BLACK
};
typedef struct
{
gdouble amount;
@ -81,16 +74,6 @@ typedef struct
gint run;
} EdgeInterface;
typedef struct
{
GimpTile *tile;
gint row, col; /* tile's row, col */
gint bpp;
gint tile_width, tile_height;
GimpDrawable *drawable;
gint drawable_width, drawable_height;
} TileBuf;
/*
* Function prototypes.
*/
@ -107,15 +90,6 @@ static gint edge_dialog (GimpDrawable *drawable);
static long long_sqrt (long n);
static void init_tile_buf (TileBuf *buf,
GimpDrawable *drawable);
static void get_tile_pixel (TileBuf *buf,
gint x,
gint y,
guchar *pixel,
gint wrapmode);
static void end_tile_buf (TileBuf *buf);
/***** Local vars *****/
GimpPlugInInfo PLUG_IN_INFO =
@ -129,7 +103,7 @@ GimpPlugInInfo PLUG_IN_INFO =
static EdgeVals evals =
{
2.0, /* amount */
SMEAR /* wrapmode */
PIXEL_SMEAR /* wrapmode */
};
static EdgeInterface eint =
@ -258,113 +232,6 @@ run (gchar *name,
gimp_drawable_detach (drawable);
}
/*********************************************************************
TileBuf Util Routines: Util routines for getting arbitrary pixel
CAUTION -- the tile is read only !!
**********************************************************************/
static void
init_tile_buf (TileBuf *buf,
GimpDrawable *drawable)
{
buf->tile = NULL;
buf->col = 0;
buf->row = 0;
if (gimp_drawable_is_rgb (drawable->drawable_id))
buf->bpp = 3;
else
buf->bpp = 1;
buf->tile_width = gimp_tile_width();
buf->tile_height = gimp_tile_height();
buf->drawable = drawable;
buf->drawable_width = gimp_drawable_width(drawable->drawable_id);
buf->drawable_height = gimp_drawable_height(drawable->drawable_id);
}
static void
get_tile_pixel (TileBuf *buf,
gint x,
gint y,
guchar *pixel,
gint wrapmode)
{
gint b;
gint offx, offy;
gint row, col;
guchar *ptr;
if (x < 0 || x >= buf->drawable_width ||
y < 0 || y >= buf->drawable_height)
switch (wrapmode)
{
case WRAP:
if (x < 0 || x >= buf->drawable_width)
{
x %= buf->drawable_width;
if (x < 0)
x += buf->drawable_width;
}
if (y < 0 || y >= buf->drawable_height)
{
y %= buf->drawable_height;
if (y < 0)
y += buf->drawable_height;
}
break;
case SMEAR:
if (x < 0)
x = 0;
if (x >= buf->drawable_width)
x = buf->drawable_width - 1;
if (y < 0)
y = 0;
if (y >= buf->drawable_height)
y = buf->drawable_height - 1;
break;
case BLACK:
if (x < 0 || x >= buf->drawable_width ||
y < 0 || y >= buf->drawable_height)
{
for (b = 0; b < buf->bpp; b++)
pixel[b] = 0;
return;
}
break;
default:
return;
}
col = x / buf->tile_width;
offx = x % buf->tile_width;
row = y / buf->tile_height;
offy = y % buf->tile_height;
/* retrieve tile */
if (!buf->tile || col != buf->col || row != buf->row)
{
if(buf->tile)
gimp_tile_unref (buf->tile, FALSE);
buf->col = col;
buf->row = row;
buf->tile = gimp_drawable_get_tile (buf->drawable, FALSE, row, col);
gimp_tile_ref (buf->tile);
}
/* retrieve target pixel */
ptr = buf->tile->data + (offy * buf->tile->ewidth + offx) * buf->tile->bpp;
for(b = 0; b < buf->bpp; b++)
pixel[b] = ptr[b];
}
static void
end_tile_buf (TileBuf *buf)
{
if (buf->tile)
gimp_tile_unref (buf->tile, FALSE);
}
/**********************************************************************
TileBuf Util Routines End
**********************************************************************/
@ -466,12 +333,12 @@ edge (GimpDrawable *drawable)
*/
GimpPixelRgn src_rgn, dest_rgn;
gpointer pr;
TileBuf buf;
GimpPixelFetcher *pft;
guchar *srcrow, *src;
guchar *destrow, *dest;
guchar pix00[3], pix01[3], pix02[3];
guchar pix10[3],/*pix11[3],*/ pix12[3];
guchar pix20[3], pix21[3], pix22[3];
guchar pix00[4], pix01[4], pix02[4];
guchar pix10[4],/*pix11[4],*/ pix12[4];
guchar pix20[4], pix21[4], pix22[4];
glong width, height;
gint alpha, has_alpha, chan;
gint x, y;
@ -486,7 +353,7 @@ edge (GimpDrawable *drawable)
if (evals.amount < 1.0)
evals.amount = 1.0;
init_tile_buf (&buf, drawable);
pft = gimp_pixel_fetcher_new (drawable);
gimp_drawable_mask_bounds (drawable->drawable_id, &x1, &y1, &x2, &y2);
@ -572,14 +439,14 @@ edge (GimpDrawable *drawable)
* image, get_tile_pixel() will (should) do the
* right work with `wrapmode'.
*/
get_tile_pixel (&buf, x-1, y-1, pix00, wrapmode);
get_tile_pixel (&buf, x , y-1, pix10, wrapmode);
get_tile_pixel (&buf, x+1, y-1, pix20, wrapmode);
get_tile_pixel (&buf, x-1, y , pix01, wrapmode);
get_tile_pixel (&buf, x+1, y , pix21, wrapmode);
get_tile_pixel (&buf, x-1, y+1, pix02, wrapmode);
get_tile_pixel (&buf, x , y+1, pix12, wrapmode);
get_tile_pixel (&buf, x+1, y+1, pix22, wrapmode);
gimp_pixel_fetcher_get_pixel2(pft, x-1, y-1, wrapmode, pix00);
gimp_pixel_fetcher_get_pixel2(pft, x , y-1, wrapmode, pix10);
gimp_pixel_fetcher_get_pixel2(pft, x+1, y-1, wrapmode, pix20);
gimp_pixel_fetcher_get_pixel2(pft, x-1, y , wrapmode, pix01);
gimp_pixel_fetcher_get_pixel2(pft, x+1, y , wrapmode, pix21);
gimp_pixel_fetcher_get_pixel2(pft, x-1, y+1, wrapmode, pix02);
gimp_pixel_fetcher_get_pixel2(pft, x , y+1, wrapmode, pix12);
gimp_pixel_fetcher_get_pixel2(pft, x+1, y+1, wrapmode, pix22);
for (chan = 0; chan < alpha; chan++)
{
@ -605,7 +472,8 @@ edge (GimpDrawable *drawable)
gimp_progress_update ((double) cur_progress / (double) max_progress);
}
end_tile_buf (&buf);
gimp_pixel_fetcher_destroy (pft);
gimp_drawable_flush (drawable);
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
gimp_drawable_update (drawable->drawable_id, x1, y1, (x2 - x1), (y2 - y1));
@ -635,9 +503,9 @@ edge_dialog (GimpDrawable *drawable)
GtkObject *scale_data;
GSList *group = NULL;
gint use_wrap = (evals.wrapmode == WRAP);
gint use_smear = (evals.wrapmode == SMEAR);
gint use_black = (evals.wrapmode == BLACK);
gboolean use_wrap = (evals.wrapmode == PIXEL_WRAP);
gboolean use_smear = (evals.wrapmode == PIXEL_SMEAR);
gboolean use_black = (evals.wrapmode == PIXEL_BLACK);
gimp_ui_init ("edge", FALSE);
@ -725,11 +593,11 @@ edge_dialog (GimpDrawable *drawable)
gdk_flush ();
if (use_wrap)
evals.wrapmode = WRAP;
evals.wrapmode = PIXEL_WRAP;
else if (use_smear)
evals.wrapmode = SMEAR;
evals.wrapmode = PIXEL_SMEAR;
else if (use_black)
evals.wrapmode = BLACK;
evals.wrapmode = PIXEL_BLACK;
return eint.run;
}