mirror of https://github.com/GNOME/gimp.git
More code clean-up in several plug-ins, mainly simplifying preview stuff.
This commit is contained in:
parent
47f2a7f8d9
commit
49e8789d59
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2003-02-01 Maurits Rijk <lpeek.mrijk@consunet.nl>
|
||||
|
||||
* libgimp/gimpmiscui.[ch]: factored out more preview stuff from several
|
||||
plug-ins.
|
||||
|
||||
* plug-ins/common/waves.c
|
||||
* plug-ins/common/sharpen.c
|
||||
* plug-ins/common/AlienMap.c
|
||||
* plug-ins/common/AlienMap2.c
|
||||
* plug-ins/common/noisify.c: more code clean-up
|
||||
|
||||
2003-02-01 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/config/gimpconfig.[ch]
|
||||
|
@ -180,6 +191,11 @@
|
|||
|
||||
* configure.in: Added Vietnamese (vi) to ALL_LINGUAS
|
||||
|
||||
2003-01-30 Maurits Rijk <lpeek.mrijk@consunet.nl>
|
||||
|
||||
* plug-ins/common/ps.c (save_dialog): corrected small error with
|
||||
mnemonic.
|
||||
|
||||
2003-01-30 Maurits Rijk <lpeek.mrijk@consunet.nl>
|
||||
|
||||
* plug-ins/common/c_astretch.c
|
||||
|
|
|
@ -166,6 +166,37 @@ gimp_fixme_preview_do_row (GimpFixMePreview *preview,
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
gimp_fixme_preview_update (GimpFixMePreview *preview,
|
||||
GimpFixeMePreviewFunc func,
|
||||
gpointer data)
|
||||
{
|
||||
gint x, y;
|
||||
guchar *buffer;
|
||||
gint bpp;
|
||||
|
||||
bpp = preview->bpp;
|
||||
buffer = (guchar*) g_malloc (preview->rowstride);
|
||||
|
||||
for (y = 0; y < preview->height; y++)
|
||||
{
|
||||
guchar *src = preview->cache + y * preview->rowstride;
|
||||
guchar *dest = buffer;
|
||||
|
||||
for (x = 0; x < preview->width; x++)
|
||||
{
|
||||
func (src, dest, bpp, data);
|
||||
|
||||
src += bpp;
|
||||
dest += bpp;
|
||||
}
|
||||
gimp_fixme_preview_do_row(preview, y, preview->width, buffer);
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw(preview->widget);
|
||||
g_free (buffer);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_fixme_preview_fill_with_thumb (GimpFixMePreview *preview,
|
||||
gint32 drawable_ID)
|
||||
|
@ -281,12 +312,92 @@ gimp_fixme_preview_fill (GimpFixMePreview *preview,
|
|||
g_free (src);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_fixme_preview_fill_scaled (GimpFixMePreview *preview,
|
||||
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;
|
||||
GimpPixelFetcher *pft;
|
||||
|
||||
gimp_drawable_mask_bounds(drawable->drawable_id, &x1, &y1, &x2, &y2);
|
||||
|
||||
sel_width = x2 - x1;
|
||||
sel_height = y2 - y1;
|
||||
|
||||
/* Calculate preview size */
|
||||
if (sel_width > sel_height)
|
||||
{
|
||||
width = MIN(sel_width, PREVIEW_SIZE);
|
||||
height = sel_height * width / sel_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
height = MIN(sel_height, PREVIEW_SIZE);
|
||||
width = sel_width * height / sel_height;
|
||||
}
|
||||
|
||||
if (width < 2) width = 2;
|
||||
if (height < 2) height = 2;
|
||||
|
||||
bpp = gimp_drawable_bpp (drawable->drawable_id);
|
||||
|
||||
if (gimp_drawable_is_indexed (drawable->drawable_id))
|
||||
{
|
||||
gint32 image_ID = gimp_drawable_image (drawable->drawable_id);
|
||||
preview->cmap = gimp_image_get_cmap (image_ID, &preview->ncolors);
|
||||
}
|
||||
else
|
||||
{
|
||||
preview->cmap = NULL;
|
||||
}
|
||||
|
||||
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->rowstride = width * bpp;
|
||||
preview->bpp = bpp;
|
||||
|
||||
dx = (gdouble) (x2 - x1 - 1) / (width - 1);
|
||||
dy = (gdouble) (y2 - y1 - 1) / (height - 1);
|
||||
|
||||
py = y1;
|
||||
|
||||
pft = gimp_pixel_fetcher_new (drawable);
|
||||
|
||||
for (y = 0; y < height; y++)
|
||||
{
|
||||
dest = preview->cache + y * preview->rowstride;
|
||||
px = x1;
|
||||
for (x = 0; x < width; x++)
|
||||
{
|
||||
gimp_pixel_fetcher_get_pixel (pft, (gint) px, (gint) py, dest);
|
||||
dest += bpp;
|
||||
px += dx;
|
||||
}
|
||||
gimp_fixme_preview_do_row (preview, y, width, dest);
|
||||
py += dy;
|
||||
}
|
||||
gimp_pixel_fetcher_destroy (pft);
|
||||
|
||||
preview->buffer = GTK_PREVIEW (preview->widget)->buffer;
|
||||
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)
|
||||
{
|
||||
GList *path_list = NULL;
|
||||
GList *fail_list = NULL;
|
||||
GList *list;
|
||||
gchar *path;
|
||||
|
||||
path = gimp_gimprc_query (path_name);
|
||||
|
@ -322,19 +433,7 @@ gimp_plug_in_parse_path (gchar *path_name, const gchar *dir_name)
|
|||
|
||||
if (fail_list)
|
||||
{
|
||||
GString *err = g_string_new (path_name);
|
||||
g_string_append (err, _(" misconfigured - "
|
||||
"the following folders were not found:"));
|
||||
|
||||
for (list = fail_list; list; list = g_list_next (list))
|
||||
{
|
||||
g_string_append_c (err, '\n');
|
||||
g_string_append (err, (gchar *) list->data);
|
||||
}
|
||||
|
||||
g_message (err->str);
|
||||
|
||||
g_string_free (err, TRUE);
|
||||
/* We just ignore the fail_list */
|
||||
gimp_path_free (fail_list);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,13 +56,23 @@ typedef struct {
|
|||
gdouble scale_y;
|
||||
} GimpFixMePreview;
|
||||
|
||||
typedef void (*GimpFixeMePreviewFunc)(guchar *src, guchar *dest,
|
||||
gint bpp, gpointer data);
|
||||
|
||||
GimpFixMePreview *gimp_fixme_preview_new (GimpDrawable *drawable,
|
||||
gboolean has_frame);
|
||||
void gimp_fixme_preview_free (GimpFixMePreview *preview);
|
||||
|
||||
void gimp_fixme_preview_update (GimpFixMePreview *preview,
|
||||
GimpFixeMePreviewFunc func,
|
||||
gpointer data);
|
||||
|
||||
void gimp_fixme_preview_fill_with_thumb (GimpFixMePreview *preview,
|
||||
gint32 drawable_ID);
|
||||
void gimp_fixme_preview_fill (GimpFixMePreview *preview,
|
||||
GimpDrawable *drawable);
|
||||
void gimp_fixme_preview_fill_scaled (GimpFixMePreview *preview,
|
||||
GimpDrawable *drawable);
|
||||
void gimp_fixme_preview_do_row (GimpFixMePreview *preview,
|
||||
gint row,
|
||||
gint width,
|
||||
|
|
|
@ -835,7 +835,6 @@ static unsigned char header_data[] = { 71,99,218,218,99,11,71,218,71,71,
|
|||
|
||||
/***** Magic numbers *****/
|
||||
|
||||
#define PREVIEW_SIZE 128
|
||||
#define SCALE_WIDTH 200
|
||||
|
||||
#define SINUS 0
|
||||
|
@ -855,9 +854,6 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *preview;
|
||||
guchar *image;
|
||||
guchar *wimage;
|
||||
gint run;
|
||||
} alienmap_interface_t;
|
||||
|
||||
|
@ -875,8 +871,6 @@ static void alienmap (GimpDrawable *drawable);
|
|||
static void transform (guchar *, guchar *, guchar *,
|
||||
double, double, double);
|
||||
|
||||
static void build_preview_source_image( void);
|
||||
|
||||
static gint alienmap_dialog (void);
|
||||
static void dialog_update_preview (void);
|
||||
static void dialog_scale_update (GtkAdjustment *adjustment,
|
||||
|
@ -889,6 +883,7 @@ static void alienmap_logo_dialog (void);
|
|||
/***** Variables *****/
|
||||
|
||||
static GimpRunMode run_mode;
|
||||
static GimpFixMePreview *preview;
|
||||
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
{
|
||||
|
@ -900,9 +895,6 @@ GimpPlugInInfo PLUG_IN_INFO =
|
|||
|
||||
static alienmap_interface_t wint =
|
||||
{
|
||||
NULL, /* preview */
|
||||
NULL, /* image */
|
||||
NULL, /* wimage */
|
||||
FALSE /* run */
|
||||
};
|
||||
|
||||
|
@ -917,9 +909,6 @@ static alienmap_vals_t wvals =
|
|||
};
|
||||
|
||||
static GimpDrawable *drawable;
|
||||
static gint sel_x1, sel_y1, sel_x2, sel_y2;
|
||||
static gint preview_width, preview_height;
|
||||
static gdouble scale_x, scale_y;
|
||||
|
||||
/***** Functions *****/
|
||||
|
||||
|
@ -1035,9 +1024,6 @@ run (char *name,
|
|||
GimpParam **return_vals)
|
||||
{
|
||||
static GimpParam values[1];
|
||||
double xhsiz, yhsiz;
|
||||
gint sel_width, sel_height;
|
||||
int pwidth, pheight;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
|
||||
INIT_I18N_UI ();
|
||||
|
@ -1053,46 +1039,6 @@ run (char *name,
|
|||
/* Get the specified drawable */
|
||||
drawable = gimp_drawable_get (param[2].data.d_drawable);
|
||||
|
||||
gimp_drawable_mask_bounds(drawable->drawable_id,
|
||||
&sel_x1, &sel_y1, &sel_x2, &sel_y2);
|
||||
|
||||
sel_width = sel_x2 - sel_x1;
|
||||
sel_height = sel_y2 - sel_y1;
|
||||
|
||||
xhsiz = (double) (sel_width - 1) / 2.0;
|
||||
yhsiz = (double) (sel_height - 1) / 2.0;
|
||||
|
||||
if (xhsiz < yhsiz)
|
||||
{
|
||||
scale_x = yhsiz / xhsiz;
|
||||
scale_y = 1.0;
|
||||
}
|
||||
else if (xhsiz > yhsiz)
|
||||
{
|
||||
scale_x = 1.0;
|
||||
scale_y = xhsiz / yhsiz;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale_x = 1.0;
|
||||
scale_y = 1.0;
|
||||
}
|
||||
|
||||
/* Calculate preview size */
|
||||
if (sel_width > sel_height)
|
||||
{
|
||||
pwidth = MIN (sel_width, PREVIEW_SIZE);
|
||||
pheight = sel_height * pwidth / sel_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
pheight = MIN (sel_height, PREVIEW_SIZE);
|
||||
pwidth = sel_width * pheight / sel_height;
|
||||
}
|
||||
|
||||
preview_width = MAX (pwidth, 2); /* Min size is 2 */
|
||||
preview_height = MAX (pheight, 2);
|
||||
|
||||
/* See how we will run */
|
||||
switch (run_mode)
|
||||
{
|
||||
|
@ -1189,53 +1135,6 @@ alienmap (GimpDrawable *drawable)
|
|||
gimp_rgn_iterate2 (drawable, run_mode, alienmap_func, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
build_preview_source_image (void)
|
||||
{
|
||||
double left, right, bottom, top;
|
||||
double px, py;
|
||||
double dx, dy;
|
||||
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);
|
||||
|
||||
left = sel_x1;
|
||||
right = sel_x2 - 1;
|
||||
bottom = sel_y2 - 1;
|
||||
top = sel_y1;
|
||||
|
||||
dx = (right - left) / (preview_width - 1);
|
||||
dy = (bottom - top) / (preview_height - 1);
|
||||
|
||||
py = top;
|
||||
|
||||
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++)
|
||||
{
|
||||
gimp_pixel_fetcher_get_pixel (pft, (gint) px, (gint) py, pixel);
|
||||
|
||||
*p++ = pixel[0];
|
||||
*p++ = pixel[1];
|
||||
*p++ = pixel[2];
|
||||
|
||||
px += dx;
|
||||
}
|
||||
|
||||
py += dy;
|
||||
}
|
||||
gimp_pixel_fetcher_destroy (pft);
|
||||
}
|
||||
|
||||
static gint
|
||||
alienmap_dialog (void)
|
||||
{
|
||||
|
@ -1250,8 +1149,6 @@ alienmap_dialog (void)
|
|||
|
||||
gimp_ui_init ("alienmap", TRUE);
|
||||
|
||||
build_preview_source_image ();
|
||||
|
||||
dialog =
|
||||
gimp_dialog_new (_("AlienMap"), "alienmap",
|
||||
gimp_standard_help_func, "filters/alienmap.html",
|
||||
|
@ -1287,10 +1184,10 @@ alienmap_dialog (void)
|
|||
gtk_table_attach (GTK_TABLE (top_table), frame, 0, 1, 0, 1, 0, 0, 0, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
wint.preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (wint.preview), preview_width, preview_height);
|
||||
gtk_container_add (GTK_CONTAINER (frame), wint.preview);
|
||||
gtk_widget_show (wint.preview);
|
||||
preview = gimp_fixme_preview_new (NULL, FALSE);
|
||||
gimp_fixme_preview_fill_scaled (preview, drawable);
|
||||
gtk_container_add (GTK_CONTAINER (frame), preview->widget);
|
||||
gtk_widget_show (preview->widget);
|
||||
|
||||
/* Controls */
|
||||
table = gtk_table_new (3, 3, FALSE);
|
||||
|
@ -1402,71 +1299,13 @@ alienmap_dialog (void)
|
|||
gtk_main ();
|
||||
gdk_flush ();
|
||||
|
||||
g_free (wint.image);
|
||||
g_free (wint.wimage);
|
||||
|
||||
return wint.run;
|
||||
}
|
||||
|
||||
static void
|
||||
dialog_update_preview (void)
|
||||
{
|
||||
double left, right, bottom, top;
|
||||
double dx, dy;
|
||||
int px, py;
|
||||
int x, y;
|
||||
double redstretch, greenstretch, bluestretch;
|
||||
guchar r,g,b;
|
||||
double scale_x, scale_y;
|
||||
guchar *p_ul, *i, *p;
|
||||
|
||||
left = sel_x1;
|
||||
right = sel_x2 - 1;
|
||||
bottom = sel_y2 - 1;
|
||||
top = sel_y1;
|
||||
dx = (right - left) / (preview_width - 1);
|
||||
dy = (bottom - top) / (preview_height - 1);
|
||||
|
||||
redstretch = wvals.redstretch;
|
||||
greenstretch = wvals.greenstretch;
|
||||
bluestretch = wvals.bluestretch;
|
||||
|
||||
scale_x = (double) (preview_width - 1) / (right - left);
|
||||
scale_y = (double) (preview_height - 1) / (bottom - top);
|
||||
|
||||
py = 0;
|
||||
|
||||
p_ul = wint.wimage;
|
||||
|
||||
for (y = 0; y < preview_height; y++)
|
||||
{
|
||||
px = 0;
|
||||
|
||||
for (x = 0; x < preview_width; x++)
|
||||
{
|
||||
i = wint.image + 3 * (preview_width * py + px);
|
||||
r = *i++;
|
||||
g = *i++;
|
||||
b = *i;
|
||||
transform(&r,&g,&b,redstretch, greenstretch, bluestretch);
|
||||
p_ul[0] = r;
|
||||
p_ul[1] = g;
|
||||
p_ul[2] = b;
|
||||
p_ul += 3;
|
||||
px += 1; /* dx; */
|
||||
}
|
||||
py +=1; /* dy; */
|
||||
}
|
||||
|
||||
p = wint.wimage;
|
||||
|
||||
for (y = 0; y < preview_height; y++)
|
||||
{
|
||||
gtk_preview_draw_row(GTK_PREVIEW(wint.preview), p, 0, y, preview_width);
|
||||
p += preview_width * 3;
|
||||
}
|
||||
gtk_widget_queue_draw(wint.preview);
|
||||
gdk_flush();
|
||||
gimp_fixme_preview_update (preview, alienmap_func, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -829,7 +829,6 @@ static unsigned char header_data[] = { 71,99,218,218,99,11,71,218,71,71,
|
|||
19,19,19,19,19,19,19,19,19,8};
|
||||
/***** Magic numbers *****/
|
||||
|
||||
#define PREVIEW_SIZE 128
|
||||
#define SCALE_WIDTH 200
|
||||
#define ENTRY_WIDTH 6
|
||||
|
||||
|
@ -855,14 +854,9 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
GtkWidget *preview;
|
||||
guchar *image;
|
||||
guchar *wimage;
|
||||
gint run;
|
||||
} alienmap2_interface_t;
|
||||
|
||||
|
||||
|
||||
/* Declare local functions. */
|
||||
|
||||
static void query (void);
|
||||
|
@ -875,9 +869,6 @@ static void run (char *name,
|
|||
static void alienmap2 (GimpDrawable *drawable);
|
||||
static void transform (guchar*, guchar*, guchar*);
|
||||
|
||||
|
||||
static void build_preview_source_image (void);
|
||||
|
||||
static gint alienmap2_dialog (void);
|
||||
static void dialog_update_preview (void);
|
||||
static void dialog_scale_update (GtkAdjustment *adjustment,
|
||||
|
@ -892,6 +883,7 @@ static void alienmap2_logo_dialog (void);
|
|||
/***** Variables *****/
|
||||
|
||||
static GimpRunMode run_mode;
|
||||
static GimpFixMePreview *preview;
|
||||
|
||||
GimpPlugInInfo PLUG_IN_INFO =
|
||||
{
|
||||
|
@ -903,9 +895,6 @@ GimpPlugInInfo PLUG_IN_INFO =
|
|||
|
||||
static alienmap2_interface_t wint =
|
||||
{
|
||||
NULL, /* preview */
|
||||
NULL, /* image */
|
||||
NULL, /* wimage */
|
||||
FALSE /* run */
|
||||
};
|
||||
|
||||
|
@ -924,10 +913,6 @@ static alienmap2_vals_t wvals =
|
|||
};
|
||||
|
||||
static GimpDrawable *drawable;
|
||||
static gint sel_x1, sel_y1, sel_x2, sel_y2;
|
||||
static gint sel_width, sel_height;
|
||||
static gint preview_width, preview_height;
|
||||
static gdouble scale_x, scale_y;
|
||||
|
||||
/***** Functions *****/
|
||||
|
||||
|
@ -1020,8 +1005,6 @@ run (char *name,
|
|||
GimpParam **return_vals)
|
||||
{
|
||||
static GimpParam values[1];
|
||||
double xhsiz, yhsiz;
|
||||
int pwidth, pheight;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
|
||||
INIT_I18N_UI ();
|
||||
|
@ -1037,46 +1020,6 @@ run (char *name,
|
|||
/* Get the specified drawable */
|
||||
drawable = gimp_drawable_get (param[2].data.d_drawable);
|
||||
|
||||
gimp_drawable_mask_bounds(drawable->drawable_id,
|
||||
&sel_x1, &sel_y1, &sel_x2, &sel_y2);
|
||||
|
||||
sel_width = sel_x2 - sel_x1;
|
||||
sel_height = sel_y2 - sel_y1;
|
||||
|
||||
xhsiz = (double) (sel_width - 1) / 2.0;
|
||||
yhsiz = (double) (sel_height - 1) / 2.0;
|
||||
|
||||
if (xhsiz < yhsiz)
|
||||
{
|
||||
scale_x = yhsiz / xhsiz;
|
||||
scale_y = 1.0;
|
||||
}
|
||||
else if (xhsiz > yhsiz)
|
||||
{
|
||||
scale_x = 1.0;
|
||||
scale_y = xhsiz / yhsiz;
|
||||
}
|
||||
else
|
||||
{
|
||||
scale_x = 1.0;
|
||||
scale_y = 1.0;
|
||||
}
|
||||
|
||||
/* Calculate preview size */
|
||||
if (sel_width > sel_height)
|
||||
{
|
||||
pwidth = MIN(sel_width, PREVIEW_SIZE);
|
||||
pheight = sel_height * pwidth / sel_width;
|
||||
}
|
||||
else
|
||||
{
|
||||
pheight = MIN(sel_height, PREVIEW_SIZE);
|
||||
pwidth = sel_width * pheight / sel_height;
|
||||
}
|
||||
|
||||
preview_width = MAX(pwidth, 2); /* Min size is 2 */
|
||||
preview_height = MAX(pheight, 2);
|
||||
|
||||
/* See how we will run */
|
||||
switch (run_mode)
|
||||
{
|
||||
|
@ -1177,52 +1120,6 @@ alienmap2 (GimpDrawable *drawable)
|
|||
gimp_rgn_iterate2 (drawable, run_mode, alienmap2_func, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
build_preview_source_image (void)
|
||||
{
|
||||
double left, right, bottom, top;
|
||||
double px, py;
|
||||
double dx, dy;
|
||||
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);
|
||||
|
||||
left = sel_x1;
|
||||
right = sel_x2 - 1;
|
||||
bottom = sel_y2 - 1;
|
||||
top = sel_y1;
|
||||
|
||||
dx = (right - left) / (preview_width - 1);
|
||||
dy = (bottom - top) / (preview_height - 1);
|
||||
|
||||
py = top;
|
||||
|
||||
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++)
|
||||
{
|
||||
gimp_pixel_fetcher_get_pixel (pft, (gint) px, (gint) py, pixel);
|
||||
|
||||
*p++ = pixel[0];
|
||||
*p++ = pixel[1];
|
||||
*p++ = pixel[2];
|
||||
|
||||
px += dx;
|
||||
}
|
||||
py += dy;
|
||||
}
|
||||
gimp_pixel_fetcher_destroy (pft);
|
||||
}
|
||||
|
||||
static gint
|
||||
alienmap2_dialog (void)
|
||||
{
|
||||
|
@ -1237,8 +1134,6 @@ alienmap2_dialog (void)
|
|||
|
||||
gimp_ui_init ("alienmap2", TRUE);
|
||||
|
||||
build_preview_source_image ();
|
||||
|
||||
dialog =
|
||||
gimp_dialog_new (_("AlienMap2"), "alienmap2",
|
||||
gimp_standard_help_func, "filters/alienmap2.html",
|
||||
|
@ -1275,10 +1170,10 @@ alienmap2_dialog (void)
|
|||
gtk_table_attach (GTK_TABLE (top_table), frame, 0, 1, 0, 1, 0, 0, 0, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
wint.preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (wint.preview), preview_width, preview_height);
|
||||
gtk_container_add (GTK_CONTAINER (frame), wint.preview);
|
||||
gtk_widget_show (wint.preview);
|
||||
preview = gimp_fixme_preview_new (NULL, FALSE);
|
||||
gimp_fixme_preview_fill_scaled (preview, drawable);
|
||||
gtk_container_add (GTK_CONTAINER (frame), preview->widget);
|
||||
gtk_widget_show (preview->widget);
|
||||
|
||||
/* Controls */
|
||||
table = gtk_table_new (6, 3, FALSE);
|
||||
|
@ -1413,66 +1308,13 @@ alienmap2_dialog (void)
|
|||
gtk_main ();
|
||||
gdk_flush ();
|
||||
|
||||
g_free (wint.image);
|
||||
g_free (wint.wimage);
|
||||
|
||||
return wint.run;
|
||||
}
|
||||
|
||||
static void
|
||||
dialog_update_preview (void)
|
||||
{
|
||||
double left, right, bottom, top;
|
||||
double dx, dy;
|
||||
int px, py;
|
||||
int x, y;
|
||||
guchar r,g,b;
|
||||
double scale_x, scale_y;
|
||||
guchar *p_ul, *i, *p;
|
||||
|
||||
left = sel_x1;
|
||||
right = sel_x2 - 1;
|
||||
bottom = sel_y2 - 1;
|
||||
top = sel_y1;
|
||||
dx = (right - left) / (preview_width - 1);
|
||||
dy = (bottom - top) / (preview_height - 1);
|
||||
|
||||
scale_x = (double) (preview_width - 1) / (right - left);
|
||||
scale_y = (double) (preview_height - 1) / (bottom - top);
|
||||
|
||||
py = 0;
|
||||
|
||||
p_ul = wint.wimage;
|
||||
|
||||
for (y = 0; y < preview_height; y++)
|
||||
{
|
||||
px = 0;
|
||||
|
||||
for (x = 0; x < preview_width; x++)
|
||||
{
|
||||
i = wint.image + 3 * (preview_width * py + px);
|
||||
r = *i++;
|
||||
g = *i++;
|
||||
b = *i;
|
||||
transform (&r, &g, &b);
|
||||
p_ul[0] = r;
|
||||
p_ul[1] = g;
|
||||
p_ul[2] = b;
|
||||
p_ul += 3;
|
||||
px += 1; /* dx; */
|
||||
}
|
||||
py +=1; /* dy; */
|
||||
}
|
||||
|
||||
p = wint.wimage;
|
||||
|
||||
for (y = 0; y < preview_height; y++)
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (wint.preview), p, 0, y, preview_width);
|
||||
p += preview_width * 3;
|
||||
}
|
||||
gtk_widget_queue_draw (wint.preview);
|
||||
gdk_flush ();
|
||||
gimp_fixme_preview_update (preview, alienmap2_func, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -230,8 +230,9 @@ run (gchar *name,
|
|||
}
|
||||
|
||||
static void
|
||||
noisify_func (guchar *src, guchar *dest, gint bpp, GRand *gr)
|
||||
noisify_func (guchar *src, guchar *dest, gint bpp, gpointer data)
|
||||
{
|
||||
GRand *gr = (GRand*) data;
|
||||
gint noise = 0, b;
|
||||
|
||||
if (!nvals.independent)
|
||||
|
@ -265,44 +266,11 @@ noisify (GimpDrawable *drawable,
|
|||
gr = g_rand_new ();
|
||||
|
||||
if (preview_mode)
|
||||
{
|
||||
guchar *src, *dest, *dest_data;
|
||||
gint width, height, row_stride;
|
||||
gint row, col;
|
||||
gint bpp;
|
||||
|
||||
width = preview->width;
|
||||
height = preview->height;
|
||||
bpp = preview->bpp;
|
||||
row_stride = preview->rowstride;
|
||||
|
||||
dest_data = g_malloc (row_stride);
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
src = preview->cache + row * row_stride;
|
||||
dest = dest_data;
|
||||
|
||||
for (col = 0; col < width; col++)
|
||||
{
|
||||
noisify_func (src, dest, bpp, gr);
|
||||
src += bpp;
|
||||
dest += bpp;
|
||||
}
|
||||
|
||||
gimp_fixme_preview_do_row(preview, row, width, dest_data);
|
||||
}
|
||||
|
||||
g_free (dest_data);
|
||||
gtk_widget_queue_draw (preview->widget);
|
||||
}
|
||||
gimp_fixme_preview_update (preview, noisify_func, gr);
|
||||
else
|
||||
{
|
||||
gimp_rgn_iterate2 (drawable, run_mode, (GimpRgnFunc2) noisify_func, gr);
|
||||
}
|
||||
gimp_rgn_iterate2 (drawable, run_mode, noisify_func, gr);
|
||||
|
||||
g_rand_free (gr);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -2889,7 +2889,7 @@ save_dialog (void)
|
|||
G_CALLBACK (gimp_double_adjustment_update),
|
||||
&psvals.y_offset);
|
||||
|
||||
toggle = gtk_check_button_new_with_label (_("_Keep Aspect Ratio"));
|
||||
toggle = gtk_check_button_new_with_mnemonic (_("_Keep Aspect Ratio"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), toggle, TRUE, TRUE, 0);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), psvals.keep_ratio);
|
||||
gtk_widget_show (toggle);
|
||||
|
|
|
@ -2889,7 +2889,7 @@ save_dialog (void)
|
|||
G_CALLBACK (gimp_double_adjustment_update),
|
||||
&psvals.y_offset);
|
||||
|
||||
toggle = gtk_check_button_new_with_label (_("_Keep Aspect Ratio"));
|
||||
toggle = gtk_check_button_new_with_mnemonic (_("_Keep Aspect Ratio"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), toggle, TRUE, TRUE, 0);
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), psvals.keep_ratio);
|
||||
gtk_widget_show (toggle);
|
||||
|
|
|
@ -904,12 +904,7 @@ gray_filter (gint width, /* I - Width of line in pixels */
|
|||
neg1[-1] - neg1[1] -
|
||||
neg2[-1] - neg2[0] - neg2[1]);
|
||||
pixel = (pixel + 4) >> 3;
|
||||
if (pixel < 0)
|
||||
*dst++ = 0;
|
||||
else if (pixel < 255)
|
||||
*dst++ = pixel;
|
||||
else
|
||||
*dst++ = 255;
|
||||
*dst++ = CLAMP0255 (pixel);
|
||||
|
||||
neg0 ++;
|
||||
neg1 ++;
|
||||
|
@ -944,12 +939,7 @@ graya_filter (gint width, /* I - Width of line in pixels */
|
|||
neg1[-2] - neg1[2] -
|
||||
neg2[-2] - neg2[0] - neg2[2]);
|
||||
pixel = (pixel + 4) >> 3;
|
||||
if (pixel < 0)
|
||||
*dst++ = 0;
|
||||
else if (pixel < 255)
|
||||
*dst++ = pixel;
|
||||
else
|
||||
*dst++ = 255;
|
||||
*dst++ = CLAMP0255 (pixel);
|
||||
|
||||
*dst++ = *src++;
|
||||
neg0 += 2;
|
||||
|
@ -987,34 +977,19 @@ rgb_filter (gint width, /* I - Width of line in pixels */
|
|||
neg1[-3] - neg1[3] -
|
||||
neg2[-3] - neg2[0] - neg2[3]);
|
||||
pixel = (pixel + 4) >> 3;
|
||||
if (pixel < 0)
|
||||
*dst++ = 0;
|
||||
else if (pixel < 255)
|
||||
*dst++ = pixel;
|
||||
else
|
||||
*dst++ = 255;
|
||||
*dst++ = CLAMP0255 (pixel);
|
||||
|
||||
pixel = (pos_lut[*src++] - neg0[-2] - neg0[1] - neg0[4] -
|
||||
neg1[-2] - neg1[4] -
|
||||
neg2[-2] - neg2[1] - neg2[4]);
|
||||
pixel = (pixel + 4) >> 3;
|
||||
if (pixel < 0)
|
||||
*dst++ = 0;
|
||||
else if (pixel < 255)
|
||||
*dst++ = pixel;
|
||||
else
|
||||
*dst++ = 255;
|
||||
*dst++ = CLAMP0255 (pixel);
|
||||
|
||||
pixel = (pos_lut[*src++] - neg0[-1] - neg0[2] - neg0[5] -
|
||||
neg1[-1] - neg1[5] -
|
||||
neg2[-1] - neg2[2] - neg2[5]);
|
||||
pixel = (pixel + 4) >> 3;
|
||||
if (pixel < 0)
|
||||
*dst++ = 0;
|
||||
else if (pixel < 255)
|
||||
*dst++ = pixel;
|
||||
else
|
||||
*dst++ = 255;
|
||||
*dst++ = CLAMP0255 (pixel);
|
||||
|
||||
neg0 += 3;
|
||||
neg1 += 3;
|
||||
|
@ -1053,34 +1028,19 @@ rgba_filter (gint width, /* I - Width of line in pixels */
|
|||
neg1[-4] - neg1[4] -
|
||||
neg2[-4] - neg2[0] - neg2[4]);
|
||||
pixel = (pixel + 4) >> 3;
|
||||
if (pixel < 0)
|
||||
*dst++ = 0;
|
||||
else if (pixel < 255)
|
||||
*dst++ = pixel;
|
||||
else
|
||||
*dst++ = 255;
|
||||
*dst++ = CLAMP0255 (pixel);
|
||||
|
||||
pixel = (pos_lut[*src++] - neg0[-3] - neg0[1] - neg0[5] -
|
||||
neg1[-3] - neg1[5] -
|
||||
neg2[-3] - neg2[1] - neg2[5]);
|
||||
pixel = (pixel + 4) >> 3;
|
||||
if (pixel < 0)
|
||||
*dst++ = 0;
|
||||
else if (pixel < 255)
|
||||
*dst++ = pixel;
|
||||
else
|
||||
*dst++ = 255;
|
||||
*dst++ = CLAMP0255 (pixel);
|
||||
|
||||
pixel = (pos_lut[*src++] - neg0[-2] - neg0[2] - neg0[6] -
|
||||
neg1[-2] - neg1[6] -
|
||||
neg2[-2] - neg2[2] - neg2[6]);
|
||||
pixel = (pixel + 4) >> 3;
|
||||
if (pixel < 0)
|
||||
*dst++ = 0;
|
||||
else if (pixel < 255)
|
||||
*dst++ = pixel;
|
||||
else
|
||||
*dst++ = 255;
|
||||
*dst++ = CLAMP0255 (pixel);
|
||||
|
||||
*dst++ = *src++;
|
||||
|
||||
|
|
|
@ -31,11 +31,6 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning GTK_DISABLE_DEPRECATED
|
||||
#endif
|
||||
#undef GTK_DISABLE_DEPRECATED
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include <libgimp/gimp.h>
|
||||
|
@ -60,26 +55,11 @@ typedef struct
|
|||
} piArgs;
|
||||
|
||||
/* preview stuff -- to be removed as soon as we have a real libgimp preview */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gint width;
|
||||
gint height;
|
||||
gint bpp;
|
||||
gdouble scale;
|
||||
guchar *bits;
|
||||
} mwPreview;
|
||||
|
||||
#define PREVIEW_SIZE 100
|
||||
|
||||
static gint do_preview = TRUE;
|
||||
static GimpFixMePreview *preview;
|
||||
|
||||
static GtkWidget *mw_preview_new (GtkWidget *parent,
|
||||
mwPreview *mwp);
|
||||
static mwPreview *mw_preview_build (GimpDrawable *drawable);
|
||||
|
||||
static mwPreview *mwp;
|
||||
|
||||
static GtkWidget *mw_preview_new (GtkWidget *parent,
|
||||
GimpDrawable *drawable);
|
||||
|
||||
static void query (void);
|
||||
static void run (gchar *name,
|
||||
|
@ -89,11 +69,11 @@ static void run (gchar *name,
|
|||
GimpParam **retvals);
|
||||
|
||||
static gint pluginCore (piArgs *argp,
|
||||
gint32 drawable);
|
||||
GimpDrawable *drawable);
|
||||
static gint pluginCoreIA (piArgs *argp,
|
||||
gint32 drawable);
|
||||
GimpDrawable *drawable);
|
||||
|
||||
static void waves_do_preview (GtkWidget *preview);
|
||||
static void waves_do_preview (void);
|
||||
|
||||
static void wave (guchar *src,
|
||||
guchar *dest,
|
||||
|
@ -155,6 +135,7 @@ run (gchar *name,
|
|||
GimpParam **retvals)
|
||||
{
|
||||
static GimpParam rvals[1];
|
||||
GimpDrawable *drawable;
|
||||
|
||||
piArgs args;
|
||||
|
||||
|
@ -168,9 +149,10 @@ run (gchar *name,
|
|||
args.type = -1;
|
||||
gimp_get_data ("plug_in_waves", &args);
|
||||
|
||||
drawable = gimp_drawable_get (param[2].data.d_drawable);
|
||||
|
||||
switch (param[0].data.d_int32)
|
||||
{
|
||||
GimpDrawable *drawable;
|
||||
|
||||
case GIMP_RUN_INTERACTIVE:
|
||||
INIT_I18N_UI();
|
||||
|
@ -184,10 +166,7 @@ run (gchar *name,
|
|||
args.reflective = 0;
|
||||
}
|
||||
|
||||
drawable = gimp_drawable_get (param[2].data.d_drawable);
|
||||
mwp = mw_preview_build (drawable);
|
||||
|
||||
if (pluginCoreIA(&args, param[2].data.d_drawable) == -1)
|
||||
if (pluginCoreIA(&args, drawable) == -1)
|
||||
{
|
||||
rvals[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
|
@ -212,7 +191,7 @@ run (gchar *name,
|
|||
args.type = param[6].data.d_int32;
|
||||
args.reflective = param[7].data.d_int32;
|
||||
|
||||
if (pluginCore (&args, param[2].data.d_drawable) == -1)
|
||||
if (pluginCore (&args, drawable) == -1)
|
||||
{
|
||||
rvals[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
|
||||
break;
|
||||
|
@ -222,7 +201,7 @@ run (gchar *name,
|
|||
case GIMP_RUN_WITH_LAST_VALS:
|
||||
INIT_I18N();
|
||||
/* XXX: add code here for last-values running */
|
||||
if (pluginCore (&args, param[2].data.d_drawable) == -1)
|
||||
if (pluginCore (&args, drawable) == -1)
|
||||
{
|
||||
rvals[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
|
||||
}
|
||||
|
@ -232,36 +211,33 @@ run (gchar *name,
|
|||
|
||||
static gint
|
||||
pluginCore (piArgs *argp,
|
||||
gint32 drawable)
|
||||
GimpDrawable *drawable)
|
||||
{
|
||||
gint retval=0;
|
||||
GimpDrawable *drw;
|
||||
GimpPixelRgn srcPr, dstPr;
|
||||
guchar *src, *dst;
|
||||
guint width, height, Bpp;
|
||||
guint width, height, bpp;
|
||||
|
||||
drw = gimp_drawable_get (drawable);
|
||||
width = drawable->width;
|
||||
height = drawable->height;
|
||||
bpp = drawable->bpp;
|
||||
|
||||
width = drw->width;
|
||||
height = drw->height;
|
||||
Bpp = drw->bpp;
|
||||
|
||||
src = g_new (guchar, width * height * Bpp);
|
||||
dst = g_new (guchar, width * height * Bpp);
|
||||
gimp_pixel_rgn_init (&srcPr, drw, 0, 0, width, height, FALSE, FALSE);
|
||||
gimp_pixel_rgn_init (&dstPr, drw, 0, 0, width, height, TRUE, TRUE);
|
||||
src = g_new (guchar, width * height * bpp);
|
||||
dst = g_new (guchar, width * height * bpp);
|
||||
gimp_pixel_rgn_init (&srcPr, drawable, 0, 0, width, height, FALSE, FALSE);
|
||||
gimp_pixel_rgn_init (&dstPr, drawable, 0, 0, width, height, TRUE, TRUE);
|
||||
gimp_pixel_rgn_get_rect (&srcPr, src, 0, 0, width, height);
|
||||
|
||||
wave (src, dst, width, height, Bpp, argp->amplitude, argp->wavelength,
|
||||
wave (src, dst, width, height, bpp, argp->amplitude, argp->wavelength,
|
||||
argp->phase, argp->type==0, argp->reflective, 1);
|
||||
gimp_pixel_rgn_set_rect (&dstPr, dst, 0, 0, width, height);
|
||||
|
||||
g_free (src);
|
||||
g_free (dst);
|
||||
|
||||
gimp_drawable_flush (drw);
|
||||
gimp_drawable_merge_shadow (drw->drawable_id, TRUE);
|
||||
gimp_drawable_update (drw->drawable_id, 0, 0, width, height);
|
||||
gimp_drawable_flush (drawable);
|
||||
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
||||
gimp_drawable_update (drawable->drawable_id, 0, 0, width, height);
|
||||
|
||||
gimp_displays_flush ();
|
||||
|
||||
|
@ -284,9 +260,7 @@ waves_toggle_button_update (GtkWidget *widget,
|
|||
gpointer data)
|
||||
{
|
||||
gimp_toggle_button_update (widget, data);
|
||||
|
||||
if (do_preview)
|
||||
waves_do_preview (NULL);
|
||||
waves_do_preview ();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -295,8 +269,8 @@ waves_radio_button_update (GtkWidget *widget,
|
|||
{
|
||||
gimp_radio_button_update (widget, data);
|
||||
|
||||
if (do_preview && GTK_TOGGLE_BUTTON (widget)->active)
|
||||
waves_do_preview (NULL);
|
||||
if (GTK_TOGGLE_BUTTON (widget)->active)
|
||||
waves_do_preview ();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -304,14 +278,12 @@ waves_double_adjustment_update (GtkAdjustment *adjustment,
|
|||
gpointer data)
|
||||
{
|
||||
gimp_double_adjustment_update (adjustment, data);
|
||||
|
||||
if (do_preview)
|
||||
waves_do_preview (NULL);
|
||||
waves_do_preview ();
|
||||
}
|
||||
|
||||
static gint
|
||||
pluginCoreIA (piArgs *argp,
|
||||
gint32 drawable)
|
||||
GimpDrawable *drawable)
|
||||
{
|
||||
GtkWidget *dlg;
|
||||
GtkWidget *main_vbox;
|
||||
|
@ -352,9 +324,9 @@ pluginCoreIA (piArgs *argp,
|
|||
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
preview = mw_preview_new (hbox, mwp);
|
||||
preview = mw_preview_new (hbox, drawable);
|
||||
g_object_set_data (G_OBJECT (preview), "piArgs", argp);
|
||||
waves_do_preview (preview);
|
||||
waves_do_preview ();
|
||||
|
||||
frame = gimp_radio_group_new2 (TRUE, _("Mode"),
|
||||
G_CALLBACK (waves_radio_button_update),
|
||||
|
@ -431,33 +403,30 @@ pluginCoreIA (piArgs *argp,
|
|||
}
|
||||
|
||||
static void
|
||||
waves_do_preview (GtkWidget *widget)
|
||||
waves_do_preview (void)
|
||||
{
|
||||
static GtkWidget *theWidget = NULL;
|
||||
piArgs *argp;
|
||||
guchar *dst;
|
||||
gint y;
|
||||
|
||||
if (theWidget == NULL)
|
||||
{
|
||||
theWidget = widget;
|
||||
}
|
||||
if (!do_preview)
|
||||
return;
|
||||
|
||||
argp = g_object_get_data (G_OBJECT (theWidget), "piArgs");
|
||||
dst = g_new (guchar, mwp->width * mwp->height * mwp->bpp);
|
||||
argp = g_object_get_data (G_OBJECT (preview->widget), "piArgs");
|
||||
dst = g_new (guchar, preview->width * preview->height * preview->bpp);
|
||||
|
||||
wave (mwp->bits, dst, mwp->width, mwp->height, mwp->bpp,
|
||||
(argp->amplitude / mwp->scale), (argp->wavelength / mwp->scale),
|
||||
wave (preview->cache, dst, preview->width, preview->height, preview->bpp,
|
||||
argp->amplitude * preview->scale_x,
|
||||
argp->wavelength * preview->scale_x,
|
||||
argp->phase, argp->type == 0, argp->reflective, 0);
|
||||
|
||||
for (y = 0; y < mwp->height; y++)
|
||||
for (y = 0; y < preview->height; y++)
|
||||
{
|
||||
gtk_preview_draw_row (GTK_PREVIEW (theWidget),
|
||||
dst + (y * mwp->width * mwp->bpp), 0, y,
|
||||
mwp->width);
|
||||
gimp_fixme_preview_do_row (preview, y, preview->width,
|
||||
dst + y * preview->rowstride);
|
||||
}
|
||||
|
||||
gtk_widget_queue_draw (theWidget);
|
||||
gtk_widget_queue_draw (preview->widget);
|
||||
|
||||
g_free (dst);
|
||||
}
|
||||
|
@ -468,75 +437,12 @@ mw_preview_toggle_callback (GtkWidget *widget,
|
|||
{
|
||||
gimp_toggle_button_update (widget, data);
|
||||
|
||||
if (do_preview)
|
||||
waves_do_preview (NULL);
|
||||
}
|
||||
|
||||
static mwPreview *
|
||||
mw_preview_build_virgin (GimpDrawable *drawable)
|
||||
{
|
||||
mwPreview *mwp;
|
||||
|
||||
mwp = g_new (mwPreview, 1);
|
||||
|
||||
if (drawable->width > drawable->height)
|
||||
{
|
||||
mwp->scale = (gdouble) drawable->width / (gdouble) PREVIEW_SIZE;
|
||||
mwp->width = PREVIEW_SIZE;
|
||||
mwp->height = drawable->height / mwp->scale;
|
||||
}
|
||||
else
|
||||
{
|
||||
mwp->scale = (gdouble) drawable->height / (gdouble) PREVIEW_SIZE;
|
||||
mwp->height = PREVIEW_SIZE;
|
||||
mwp->width = drawable->width / mwp->scale;
|
||||
}
|
||||
|
||||
mwp->bpp = 3;
|
||||
mwp->bits = NULL;
|
||||
|
||||
return mwp;
|
||||
}
|
||||
|
||||
static mwPreview *
|
||||
mw_preview_build (GimpDrawable *drawable)
|
||||
{
|
||||
mwPreview *mwp;
|
||||
gint x, y, b;
|
||||
guchar *bc;
|
||||
guchar *drawableBits;
|
||||
GimpPixelRgn pr;
|
||||
|
||||
mwp = mw_preview_build_virgin (drawable);
|
||||
|
||||
gimp_pixel_rgn_init (&pr, drawable,
|
||||
0, 0, drawable->width, drawable->height, FALSE, FALSE);
|
||||
drawableBits = g_new (guchar, drawable->width * drawable->bpp);
|
||||
|
||||
bc = mwp->bits = g_new (guchar, mwp->width * mwp->height * mwp->bpp);
|
||||
for (y = 0; y < mwp->height; y++)
|
||||
{
|
||||
gimp_pixel_rgn_get_row (&pr, drawableBits,
|
||||
0, (gint) (y * mwp->scale), drawable->width);
|
||||
|
||||
for (x = 0; x < mwp->width; x++)
|
||||
{
|
||||
for (b = 0; b < mwp->bpp; b++)
|
||||
*bc++ = *(drawableBits +
|
||||
((gint) (x * mwp->scale) * drawable->bpp) +
|
||||
b % drawable->bpp);
|
||||
}
|
||||
}
|
||||
g_free (drawableBits);
|
||||
|
||||
return mwp;
|
||||
waves_do_preview ();
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
mw_preview_new (GtkWidget *parent,
|
||||
mwPreview *mwp)
|
||||
mw_preview_new (GtkWidget *parent, GimpDrawable *drawable)
|
||||
{
|
||||
GtkWidget *preview;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *pframe;
|
||||
GtkWidget *vbox;
|
||||
|
@ -557,10 +463,9 @@ mw_preview_new (GtkWidget *parent,
|
|||
gtk_box_pack_start (GTK_BOX (vbox), pframe, FALSE, FALSE, 0);
|
||||
gtk_widget_show (pframe);
|
||||
|
||||
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||
gtk_preview_size (GTK_PREVIEW (preview), mwp->width, mwp->height);
|
||||
gtk_container_add (GTK_CONTAINER (pframe), preview);
|
||||
gtk_widget_show (preview);
|
||||
preview = gimp_fixme_preview_new (drawable, FALSE);
|
||||
gtk_container_add (GTK_CONTAINER (pframe), preview->widget);
|
||||
gtk_widget_show (preview->widget);
|
||||
|
||||
button = gtk_check_button_new_with_mnemonic (_("_Do Preview"));
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), do_preview);
|
||||
|
@ -571,9 +476,24 @@ mw_preview_new (GtkWidget *parent,
|
|||
G_CALLBACK (mw_preview_toggle_callback),
|
||||
&do_preview);
|
||||
|
||||
return preview;
|
||||
return preview->widget;
|
||||
}
|
||||
|
||||
/* Wave the image. For each pixel in the destination image
|
||||
* which is inside the selection, we compute the corresponding
|
||||
* waved location in the source image. We use bilinear
|
||||
* interpolation to avoid ugly jaggies.
|
||||
*
|
||||
* Let's assume that we are operating on a circular area.
|
||||
* Every point within <radius> distance of the wave center is
|
||||
* waveed to its destination position.
|
||||
*
|
||||
* Basically, introduce a wave into the image. I made up the
|
||||
* forumla initially, but it looks good. Quartic added the
|
||||
* wavelength etc. to it while I was asleep :) Just goes to show
|
||||
* we should work with people in different time zones more.
|
||||
*
|
||||
*/
|
||||
|
||||
static void
|
||||
wave (guchar *src,
|
||||
|
@ -624,22 +544,6 @@ wave (guchar *src,
|
|||
x2 = width;
|
||||
y2 = height;
|
||||
|
||||
/* Wave the image. For each pixel in the destination image
|
||||
* which is inside the selection, we compute the corresponding
|
||||
* waved location in the source image. We use bilinear
|
||||
* interpolation to avoid ugly jaggies.
|
||||
*
|
||||
* Let's assume that we are operating on a circular area.
|
||||
* Every point within <radius> distance of the wave center is
|
||||
* waveed to its destination position.
|
||||
*
|
||||
* Basically, introduce a wave into the image. I made up the
|
||||
* forumla initially, but it looks good. Quartic added the
|
||||
* wavelength etc. to it while I was asleep :) Just goes to show
|
||||
* we should work with people in different time zones more.
|
||||
*
|
||||
*/
|
||||
|
||||
/* Center of selection */
|
||||
cen_x = (double) (x2 - 1 + x1) / 2.0;
|
||||
cen_y = (double) (y2 - 1 + y1) / 2.0;
|
||||
|
@ -721,27 +625,15 @@ wave (guchar *src,
|
|||
|
||||
/* Calculations complete; now copy the proper pixel */
|
||||
|
||||
xi = needx;
|
||||
yi = needy;
|
||||
|
||||
if (smear)
|
||||
{
|
||||
if (xi > width - 2)
|
||||
{
|
||||
xi = width - 2;
|
||||
}
|
||||
else if (xi < 0)
|
||||
{
|
||||
xi = 0;
|
||||
}
|
||||
if (yi > height - 2)
|
||||
{
|
||||
yi = height - 2;
|
||||
}
|
||||
else if (yi < 0)
|
||||
{
|
||||
yi = 0;
|
||||
}
|
||||
xi = CLAMP (needx, 0, width - 2);
|
||||
yi = CLAMP (needy, 0, height - 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
xi = needx;
|
||||
yi = needy;
|
||||
}
|
||||
|
||||
p = src + rowsiz * yi + xi * bypp;
|
||||
|
@ -768,13 +660,8 @@ wave (guchar *src,
|
|||
else
|
||||
values[2] = 0;
|
||||
|
||||
if (x2_in)
|
||||
{
|
||||
if (y2_in)
|
||||
values[3] = *(p + bypp + k + rowsiz);
|
||||
else
|
||||
values[3] = 0;
|
||||
}
|
||||
if (x2_in && y2_in)
|
||||
values[3] = *(p + bypp + k + rowsiz);
|
||||
else
|
||||
values[3] = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue