From 28757ba1761b7690c6d7b8b798fedacf4f776e69 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Fri, 14 Apr 2000 08:59:52 +0000 Subject: [PATCH] applied gimp-kevint-000413-0 and gimp-mattias-000414-0 --Sven --- ChangeLog | 11 +++ plug-ins/common/xpm.c | 177 ++++++++++++++++++++----------------- plug-ins/maze/algorithms.c | 50 ++++++----- plug-ins/maze/handy.c | 7 +- po-plug-ins/ChangeLog | 4 + po-plug-ins/de.po | 10 +-- 6 files changed, 149 insertions(+), 110 deletions(-) diff --git a/ChangeLog b/ChangeLog index bd3211fdff..1be3c3ab6f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2000-04-14 Sven Neumann + + * plug-ins/maze/algorithms.c + * plug-ins/maze/handy.c: applied gimp-kevint-000413-0 which + promises to really close #8568 this time + + * plug-ins/common/xpm.c: applied gimp-mattias-000414-0, which + makes XPM saving work in noninteractive mode. It also changes + the PDB call, but since it has never worked before, that should + be ok. + 2000-04-13 Matt Wilson * gimp.spec: updated for 1.1.19, reworked filespec generation diff --git a/plug-ins/common/xpm.c b/plug-ins/common/xpm.c index 3a3253115a..151eb0a625 100644 --- a/plug-ins/common/xpm.c +++ b/plug-ins/common/xpm.c @@ -16,9 +16,15 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* XPM plugin version 1.2.2 */ +/* XPM plugin version 1.2.3 */ -/* 1.2.2 fixes bug that generated bad digits on images with more than 20000 colors. (thanks, yanele) +/* +1.2.3 fixes bug when running in noninteractive mode +changes alpha_threshold range from [0, 1] to [0,255] for consistency with +the threshold_alpha plugin + +1.2.2 fixes bug that generated bad digits on images with more than 20000 +colors. (thanks, yanele) parses gtkrc (thanks, yosh) doesn't load parameter screen on images that don't have alpha @@ -53,12 +59,12 @@ ABCDEFGHIJKLMNOPQRSTUVWXYZ`"; /* Structs for the save dialog */ typedef struct { - gdouble threshold; + gint threshold; } XpmSaveVals; typedef struct { - gint run; + gint run; } XpmSaveInterface; @@ -72,7 +78,7 @@ typedef struct /* whether the image is color or not. global so I only have to pass * one user value to the GHFunc */ -gint color; +gboolean color; /* bytes per pixel. global so I only have to pass one user value * to the GHFunc @@ -80,27 +86,27 @@ gint color; gint cpp; /* Declare local functions */ -static void query (void); -static void run (gchar *name, - gint nparams, - GParam *param, - gint *nreturn_vals, - GParam **return_vals); +static void query (void); +static void run (gchar *name, + gint nparams, + GParam *param, + gint *nreturn_vals, + GParam **return_vals); -static gint32 load_image (gchar *filename); -static void parse_colors (XpmImage *xpm_image, - guchar **cmap); -static void parse_image (gint32 image_ID, - XpmImage *xpm_image, - guchar *cmap); -static gint save_image (gchar *filename, - gint32 image_ID, - gint32 drawable_ID); +static gint32 load_image (gchar *filename); +static void parse_colors (XpmImage *xpm_image, + guchar **cmap); +static void parse_image (gint32 image_ID, + XpmImage *xpm_image, + guchar *cmap); +static gboolean save_image (gchar *filename, + gint32 image_ID, + gint32 drawable_ID); -static void init_gtk (void); -static gint save_dialog (void); -static void save_ok_callback (GtkWidget *widget, - gpointer data); +static void init_gtk (void); +static gint save_dialog (void); +static void save_ok_callback (GtkWidget *widget, + gpointer data); GPlugInInfo PLUG_IN_INFO = @@ -113,7 +119,7 @@ GPlugInInfo PLUG_IN_INFO = static XpmSaveVals xpmvals = { - 0.50 /* alpha threshold */ + 127 /* alpha threshold */ }; static XpmSaveInterface xpmint = @@ -148,6 +154,7 @@ query (void) { PARAM_DRAWABLE, "drawable", "Drawable to save" }, { PARAM_STRING, "filename", "The name of the file to save the image in" }, { PARAM_STRING, "raw_filename", "The name of the file to save the image in" }, + { PARAM_INT32, "threshold", "Alpha threshold (0-255)" } }; static gint nsave_args = sizeof (save_args) / sizeof (save_args[0]); @@ -267,16 +274,16 @@ run (gchar *name, case RUN_NONINTERACTIVE: /* Make sure all the arguments are there! */ - if (nparams != 4) + if (nparams != 6) { status = STATUS_CALLING_ERROR; } else { - xpmvals.threshold = param[4].data.d_float; + xpmvals.threshold = param[5].data.d_int32; - if (xpmvals.threshold < 0.0 || - xpmvals.threshold > 1.0) + if (xpmvals.threshold < 0 || + xpmvals.threshold > 255) status = STATUS_CALLING_ERROR; } break; @@ -360,7 +367,7 @@ parse_colors (XpmImage *xpm_image, { Display *display; Colormap colormap; - int i, j; + gint i, j; /* open the display and get the default color map */ display = XOpenDisplay (NULL); @@ -377,7 +384,7 @@ parse_colors (XpmImage *xpm_image, /* parse each color in the file */ for (i = 0, j = 0; i < xpm_image->ncolors; i++) { - char *colorspec = "None"; + gchar *colorspec = "None"; XpmColor *xpm_color; XColor xcolor; @@ -395,7 +402,7 @@ parse_colors (XpmImage *xpm_image, /* parse if it's not transparent. the assumption is that g_new will memset the buffer to zeros */ - if (strcmp(colorspec, "None") != 0) + if (strcmp (colorspec, "None") != 0) { XParseColor (display, colormap, colorspec, &xcolor); (*cmap)[j++] = xcolor.red >> 8; @@ -418,16 +425,16 @@ parse_image (gint32 image_ID, XpmImage *xpm_image, guchar *cmap) { - int tile_height; - int scanlines; - int val; + gint tile_height; + gint scanlines; + gint val; guchar *buf; guchar *dest; - unsigned int *src; + guint *src; GPixelRgn pixel_rgn; GDrawable *drawable; gint32 layer_ID; - int i,j; + gint i, j; layer_ID = gimp_layer_new (image_ID, _("Color"), @@ -494,7 +501,7 @@ guint compare (rgbkey *c1, rgbkey *c2) { - return (c1->r == c2->r)&&(c1->g == c2->g)&&(c1->b == c2->b); + return (c1->r == c2->r) && (c1->g == c2->g) && (c1->b == c2->b); } void @@ -506,22 +513,23 @@ set_XpmImage (XpmColor *array, gint i, charnum, indtemp; indtemp=index; - array[index].string = p = g_new(char, cpp+1); + array[index].string = p = g_new (gchar, cpp+1); /*convert the index number to base sizeof(linenoise)-1 */ - for(i=0; ibpp)) == NULL) + if ((buffer = g_new (guchar, + gimp_tile_height()*width*drawable->bpp)) == NULL) return 0; gimp_pixel_rgn_init (&pixel_rgn, drawable, @@ -660,11 +670,11 @@ save_image (gchar *filename, /* process each row of tiles */ for (i = 0; i < height; i+=gimp_tile_height()) { - int scanlines; + gint scanlines; /* read the next row of tiles */ - scanlines = MIN(gimp_tile_height(), height - i); - gimp_pixel_rgn_get_rect(&pixel_rgn, buffer, 0, i, width, scanlines); + scanlines = MIN (gimp_tile_height(), height - i); + gimp_pixel_rgn_get_rect (&pixel_rgn, buffer, 0, i, width, scanlines); data = buffer; /* process each pixel row */ @@ -677,7 +687,7 @@ save_image (gchar *filename, /* do each pixel in the row */ for (k=0; kdata = ibuff; /* do the save */ - XpmWriteFileFromXpmImage(filename, image, NULL); + XpmWriteFileFromXpmImage (filename, image, NULL); rc = TRUE; cleanup: /* clean up resources */ gimp_drawable_detach (drawable); - if (ibuff) g_free(ibuff); + if (ibuff) + g_free (ibuff); /*if (mbuff) g_free(mbuff);*/ - if (hash) g_hash_table_destroy(hash); + if (hash) + g_hash_table_destroy (hash); return rc; } @@ -824,11 +838,12 @@ save_dialog (void) scale_data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0, _("Alpha Threshold:"), SCALE_WIDTH, 0, - xpmvals.threshold, 0.0, 1.0, 0.01, 0.1, 2, + xpmvals.threshold, 0, 255, 1, 8, 0, TRUE, 0, 0, NULL, NULL); + gtk_signal_connect (GTK_OBJECT (scale_data), "value_changed", - GTK_SIGNAL_FUNC (gimp_double_adjustment_update), + GTK_SIGNAL_FUNC (gimp_int_adjustment_update), &xpmvals.threshold); gtk_widget_show (dlg); diff --git a/plug-ins/maze/algorithms.c b/plug-ins/maze/algorithms.c index f14fe5ce5b..128083b4db 100644 --- a/plug-ins/maze/algorithms.c +++ b/plug-ins/maze/algorithms.c @@ -59,7 +59,7 @@ void mazegen_tileable(gint pos, gint x, gint y, gint rnd); -void prim(guint pos, +void prim(gint pos, gchar *maz, guint x, guint y, @@ -273,7 +273,7 @@ print_glist(gpointer data, gpointer user_data) does break, let me know, and I'll go cry in a corner for a while before I get up the strength to re-code it. */ void -prim(guint pos, gchar *maz, guint x, guint y, gint rnd) +prim(gint pos, gchar *maz, guint x, guint y, gint rnd) { GSList *front_cells=NULL; guint current; @@ -303,19 +303,19 @@ prim(guint pos, gchar *maz, guint x, guint y, gint rnd) if (up >= 0) { maz[up]=FRONTIER; - front_cells=g_slist_append(front_cells,(gpointer)up); + front_cells=g_slist_append(front_cells,GINT_TO_POINTER(up)); } if (down >= 0) { - maz[up]=FRONTIER; - front_cells=g_slist_append(front_cells,(gpointer)down); + maz[down]=FRONTIER; + front_cells=g_slist_append(front_cells,GINT_TO_POINTER(down)); } if (left >= 0) { - maz[up]=FRONTIER; - front_cells=g_slist_append(front_cells,(gpointer)left); + maz[left]=FRONTIER; + front_cells=g_slist_append(front_cells,GINT_TO_POINTER(left)); } if (right >= 0) { - maz[up]=FRONTIER; - front_cells=g_slist_append(front_cells,(gpointer)right); + maz[right]=FRONTIER; + front_cells=g_slist_append(front_cells,GINT_TO_POINTER(right)); } /* While frontier is not empty do the following... */ @@ -323,9 +323,9 @@ prim(guint pos, gchar *maz, guint x, guint y, gint rnd) /* Remove one cell at random from frontier and place it in IN. */ current = rand() % g_slist_length(front_cells); - pos = (guint)g_slist_nth(front_cells,current)->data; + pos = GPOINTER_TO_INT(g_slist_nth(front_cells,current)->data); - front_cells=g_slist_remove(front_cells,(gpointer)pos); + front_cells=g_slist_remove(front_cells,GINT_TO_POINTER(pos)); maz[pos]=IN; /* If the cell has any neighbors in OUT, remove them from @@ -341,7 +341,8 @@ prim(guint pos, gchar *maz, guint x, guint y, gint rnd) switch (maz[up]) { case OUT: maz[up]=FRONTIER; - front_cells=g_slist_prepend(front_cells,(gpointer)up); + front_cells=g_slist_prepend(front_cells, + GINT_TO_POINTER(up)); break; case IN: d=1; @@ -354,7 +355,8 @@ prim(guint pos, gchar *maz, guint x, guint y, gint rnd) switch (maz[down]) { case OUT: maz[down]=FRONTIER; - front_cells=g_slist_prepend(front_cells,(gpointer)down); + front_cells=g_slist_prepend(front_cells, + GINT_TO_POINTER(down)); break; case IN: d=d|2; @@ -367,7 +369,8 @@ prim(guint pos, gchar *maz, guint x, guint y, gint rnd) switch (maz[left]) { case OUT: maz[left]=FRONTIER; - front_cells=g_slist_prepend(front_cells,(gpointer)left); + front_cells=g_slist_prepend(front_cells, + GINT_TO_POINTER(left)); break; case IN: d=d|4; @@ -380,7 +383,8 @@ prim(guint pos, gchar *maz, guint x, guint y, gint rnd) switch (maz[right]) { case OUT: maz[right]=FRONTIER; - front_cells=g_slist_prepend(front_cells,(gpointer)right); + front_cells=g_slist_prepend(front_cells, + GINT_TO_POINTER(right)); break; case IN: d=d|8; @@ -414,16 +418,16 @@ prim(guint pos, gchar *maz, guint x, guint y, gint rnd) switch (i) { case 0: - maz[WALL_UP(pos)]=1; + maz[WALL_UP(pos)]=IN; break; case 1: - maz[WALL_DOWN(pos)]=1; + maz[WALL_DOWN(pos)]=IN; break; case 2: - maz[WALL_LEFT(pos)]=1; + maz[WALL_LEFT(pos)]=IN; break; case 3: - maz[WALL_RIGHT(pos)]=1; + maz[WALL_RIGHT(pos)]=IN; break; case 99: break; @@ -564,16 +568,16 @@ prim_tileable(gchar *maz, guint x, guint y, gint rnd) switch (i) { case 0: - maz[WALL_UP_TILEABLE(pos)]=1; + maz[WALL_UP_TILEABLE(pos)]=IN; break; case 1: - maz[WALL_DOWN_TILEABLE(pos)]=1; + maz[WALL_DOWN_TILEABLE(pos)]=IN; break; case 2: - maz[WALL_LEFT_TILEABLE(pos)]=1; + maz[WALL_LEFT_TILEABLE(pos)]=IN; break; case 3: - maz[WALL_RIGHT_TILEABLE(pos)]=1; + maz[WALL_RIGHT_TILEABLE(pos)]=IN; break; case 99: break; diff --git a/plug-ins/maze/handy.c b/plug-ins/maze/handy.c index 6b168f7f25..6704891de2 100644 --- a/plug-ins/maze/handy.c +++ b/plug-ins/maze/handy.c @@ -60,8 +60,13 @@ get_colors (GDrawable *drawable, gimp_palette_get_background (&bg[0], &bg[1], &bg[2]); break; case GRAYA_IMAGE: /* and again */ + gimp_palette_get_foreground (&fg[0], &fg[1], &fg[2]); + gimp_palette_get_background (&bg[0], &bg[1], &bg[2]); + fg[0] = INTENSITY (fg[0], fg[1], fg[2]); + bg[0] = INTENSITY (bg[0], bg[1], bg[2]); fg[1] = 255; bg[1] = 255; + break; case GRAY_IMAGE: gimp_palette_get_foreground (&fg[0], &fg[1], &fg[2]); gimp_palette_get_background (&bg[0], &bg[1], &bg[2]); @@ -133,7 +138,7 @@ drawbox( GPixelRgn *dest_rgn, if (high_size == 0) { rowbuf = g_new(guint8, rowsize); } else if (rowsize > high_size) { - g_realloc(rowbuf, rowsize * sizeof(guint8) ); + rowbuf = g_renew(guint8, rowbuf, rowsize); } high_size = MAX(high_size, rowsize); diff --git a/po-plug-ins/ChangeLog b/po-plug-ins/ChangeLog index df469d2448..976916d7fc 100644 --- a/po-plug-ins/ChangeLog +++ b/po-plug-ins/ChangeLog @@ -1,3 +1,7 @@ +2000-04-14 Sven Neumann + + * de.po: small correction + Thu Apr 13 23:11:27 CEST 2000 Stanislav Brabec * cs.po: Updated translation. diff --git a/po-plug-ins/de.po b/po-plug-ins/de.po index 8834139928..b5ec9e2cc2 100644 --- a/po-plug-ins/de.po +++ b/po-plug-ins/de.po @@ -7,9 +7,9 @@ # msgid "" msgstr "" -"Project-Id-Version: GIMP 1.1.18\n" +"Project-Id-Version: GIMP 1.1.19\n" "POT-Creation-Date: 2000-04-12 16:36+0200\n" -"PO-Revision-Date: 2000-04-12 16:37+02:00\n" +"PO-Revision-Date: 2000-04-13 12:15+02:00\n" "Last-Translator: Sven Neumann \n" "Language-Team: German \n" "MIME-Version: 1.0\n" @@ -4497,7 +4497,7 @@ msgstr "Zweite Zielfarbe" #: plug-ins/common/mapcolor.c:348 msgid "/Filters/Colors/Map/Adjust FG-BG" -msgstr "/Filter/Farben/Abbilden/VG-HG regeln" +msgstr "/Filter/Farben/Abbilden/VG-HG anpassen" #: plug-ins/common/mapcolor.c:363 msgid "/Filters/Colors/Map/Color Range Mapping..." @@ -4508,12 +4508,12 @@ msgid "" "Color Mapping / Adjust FG/BG:\n" "Cannot operate on gray/indexed images" msgstr "" -"Farben vertauschen / VG/HG anpassen:\n" +"Farben abbilden / VG/HG anpassen:\n" "Kann diesen Filter nicht auf Graustufenbilder / indizierte Bilder anwenden" #: plug-ins/common/mapcolor.c:436 msgid "Adjusting Foreground/Background" -msgstr "Ersetze Hintergrund-/Vordergrundfarbe" +msgstr "Vordergrund-/Hintergrundfarbe anpassen" #: plug-ins/common/mapcolor.c:484 msgid "Mapping colors"