fix The GAP!

--Sven
This commit is contained in:
Sven Neumann 1999-10-27 11:09:38 +00:00
parent 664b4ed687
commit 1b31ca310c
4 changed files with 267 additions and 38 deletions

View file

@ -1,3 +1,10 @@
Wed Oct 27 13:05:09 MEST 1999 Sven Neumann <sven@gimp.org>
* plug-ins/gap/gap_main.c
* plug-ins/gap/gap_range_ops.c
* plug-ins/gap/gap_range_ops.h: applied a patch from Wolfgang Hofer
that adapts the GAP to the new gimp_convert_indexed interface
Tue Oct 26 18:58:44 PDT 1999 Manish Singh <yosh@gimp.org>
* app/xcf.c: add "(GIMP)" to the menu entry for XCF, in an attempt
@ -11,7 +18,8 @@ Wed Oct 27 02:03:47 MEST 1999 Sven Neumann <sven@gimp.org>
* app/info_window.c
* app/ops_buttons.c: cosmetic changes
* pixmaps/*.xpm: cropped most of the icons to their minimum size
* pixmaps/*.xpm: cropped most of the icons to their minimum size,
changed the dropper icon to be the same as the toolbox icon
1999-10-26 Michael Natterer <mitch@gimp.org>

View file

@ -38,9 +38,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
static char *gap_main_version = "1.1.8a; 1999/08/31";
static char *gap_main_version = "1.1.10a; 1999/10/23";
/* revision history:
* gimp 1.1.10a; 1999/10/22 hof: extended dither options for gap_range_convert
* gimp 1.1.8a; 1999/08/31 hof: updated main version
* version 0.99.00; 1999/03/17 hof: updated main version
* version 0.98.02; 1999/01/27 hof: updated main version
@ -229,13 +230,33 @@ query ()
{PARAM_INT32, "flatten", "0 .. dont flatten image before save"},
{PARAM_INT32, "dest_type", "0=RGB, 1=GRAY, 2=INDEXED"},
{PARAM_INT32, "dest_colors", "1 upto 256 (used only for dest_type INDEXED)"},
{PARAM_INT32, "dest_dither", "0=no, 1=floyd-steinberg (used only for dest_type INDEXED)"},
{PARAM_INT32, "dest_dither", "0=no, 1=floyd-steinberg 2=fs/low-bleed, 3=fixed (used only for dest_type INDEXED)"},
{PARAM_STRING, "extension", "extension for the destination filetype (jpg, tif ...or any other gimp supported type)"},
{PARAM_STRING, "basename", "(optional parameter) here you may specify the basename of the destination frames \"/my_dir/myframe\" _0001.ext is added)"},
};
static int nargs_rconv = sizeof(args_rconv) / sizeof(args_rconv[0]);
static GParamDef args_rconv2[] =
{
{PARAM_INT32, "run_mode", "Interactive, non-interactive"},
{PARAM_IMAGE, "image", "Input image (one of the Anim Frames)"},
{PARAM_DRAWABLE, "drawable", "Input drawable (unused)"},
{PARAM_INT32, "range_from", "frame nr to start"},
{PARAM_INT32, "range_to", "frame nr to stop (can be lower than range_from)"},
{PARAM_INT32, "flatten", "0 .. dont flatten image before save"},
{PARAM_INT32, "dest_type", "0=RGB, 1=GRAY, 2=INDEXED"},
{PARAM_INT32, "dest_colors", "1 upto 256 (used only for dest_type INDEXED)"},
{PARAM_INT32, "dest_dither", "0=no, 1=floyd-steinberg 2=fs/low-bleed, 3=fixed(used only for dest_type INDEXED)"},
{PARAM_STRING, "extension", "extension for the destination filetype (jpg, tif ...or any other gimp supported type)"},
{PARAM_STRING, "basename", "(optional parameter) here you may specify the basename of the destination frames \"/my_dir/myframe\" _0001.ext is added)"},
{PARAM_INT32, "palette_type", "0 == MAKE_PALETTE, 2 == WEB_PALETTE, 3 == MONO_PALETTE (bw) 4 == CUSTOM_PALETTE (used only for dest_type INDEXED)"},
{PARAM_INT32, "alpha_dither", "dither transparency to fake partial opacity (used only for dest_type INDEXED)"},
{PARAM_INT32, "remove_unused", "remove unused or double colors from final palette (used only for dest_type INDEXED)"},
{PARAM_STRING, "palette", "name of the cutom palette to use (used only for dest_type INDEXED and palette_type == CUSTOM_PALETTE) "},
};
static int nargs_rconv2 = sizeof(args_rconv2) / sizeof(args_rconv2[0]);
/* resize and crop share the same parameters */
static GParamDef args_resize[] =
{
@ -464,6 +485,18 @@ query ()
args_rlayerdel, return_vals);
gimp_install_procedure("plug_in_gap_range_convert",
_("This plugin converts the given range of frame-images to other fileformats (on disk) depending on extension"),
"WARNING this procedure is obsolete, please use plug_in_gap_range_convert2",
"Wolfgang Hofer (hof@hotbot.com)",
"Wolfgang Hofer",
gap_main_version,
NULL, /* do not appear in menus */
"RGB*, INDEXED*, GRAY*",
PROC_PLUG_IN,
nargs_rconv, nreturn_vals,
args_rconv, return_vals);
gimp_install_procedure("plug_in_gap_range_convert2",
_("This plugin converts the given range of frame-images to other fileformats (on disk) depending on extension"),
"",
"Wolfgang Hofer (hof@hotbot.com)",
@ -472,8 +505,8 @@ query ()
_("<Image>/AnimFrames/Frames Convert"),
"RGB*, INDEXED*, GRAY*",
PROC_PLUG_IN,
nargs_rconv, nreturn_vals,
args_rconv, return_vals);
nargs_rconv2, nreturn_vals,
args_rconv2, return_vals);
gimp_install_procedure("plug_in_gap_anim_resize",
_("This plugin resizes all anim_frames (images on disk) to the given new_width/new_height"),
@ -481,7 +514,7 @@ query ()
"Wolfgang Hofer (hof@hotbot.com)",
"Wolfgang Hofer",
gap_main_version,
_("<Image>/AnimFrames/Frames Resize"),
_("<Image>/AnimFrames/Frames Resize"),
"RGB*, INDEXED*, GRAY*",
PROC_PLUG_IN,
nargs_resize, nreturn_vals,
@ -598,6 +631,7 @@ run (char *name,
char l_sel_str[MAX_LAYERNAME];
char l_layername[MAX_LAYERNAME];
char *l_basename_ptr;
char *l_palette_ptr;
static GParam values[2];
GRunModeType run_mode;
GStatusType status = STATUS_SUCCESS;
@ -607,6 +641,9 @@ run (char *name,
GImageType dest_type;
gint32 dest_colors;
gint32 dest_dither;
gint32 palette_type;
gint32 alpha_dither;
gint32 remove_unused;
gint32 mode;
long new_width;
long new_height;
@ -952,12 +989,17 @@ run (char *name,
}
}
else if (strcmp (name, "plug_in_gap_range_convert") == 0)
else if ((strcmp (name, "plug_in_gap_range_convert") == 0)
|| (strcmp (name, "plug_in_gap_range_convert2") == 0))
{
l_basename_ptr = NULL;
l_palette_ptr = NULL;
palette_type = GIMP_MAKE_PALETTE;
alpha_dither = 0;
remove_unused = 1;
if (run_mode == RUN_NONINTERACTIVE)
{
if ((n_params != 10) && (n_params != 11))
if ((n_params != 10) && (n_params != 11) && (n_params != 15))
{
status = STATUS_CALLING_ERROR;
}
@ -965,16 +1007,22 @@ run (char *name,
{
strncpy(l_extension, param[9].data.d_string, sizeof(l_extension) -1);
l_extension[sizeof(l_extension) -1] = '\0';
if (n_params == 11)
if (n_params >= 11)
{
l_basename_ptr = param[10].data.d_string;
}
if (n_params >= 15)
{
l_palette_ptr = param[14].data.d_string;
palette_type = param[11].data.d_int32;
alpha_dither = param[12].data.d_int32;
remove_unused = param[13].data.d_int32;
}
}
}
if (status == STATUS_SUCCESS)
{
image_id = param[1].data.d_image;
range_from = param[3].data.d_int32; /* frame nr to start */
range_to = param[4].data.d_int32; /* frame nr to stop */
@ -985,7 +1033,11 @@ run (char *name,
l_rc = gap_range_conv(run_mode, image_id, range_from, range_to, nr,
dest_type, dest_colors, dest_dither,
l_basename_ptr, l_extension);
l_basename_ptr, l_extension,
palette_type,
alpha_dither,
remove_unused,
l_palette_ptr);
}
}

View file

@ -32,6 +32,9 @@
*/
/* revision history
* 1.1.10a 1999/10/22 hof: bugfix: have to use the changed PDB-Interface
* for gimp_convert_indexed
* (with extended dither options and extra dialog window)
* 1.1.9a 1999/09/21 hof: bugfix RUN_NONINTERACTIVE did not work in
* plug_in_gap_range_convert
* plug_in_gap_range_layer_del
@ -270,6 +273,126 @@ p_range_dialog(t_anim_info *ainfo_ptr,
} /* end p_range_dialog */
/* ============================================================================
* p_convert_indexed_dialog
*
* extra dialog with dither options (when converting to indexed image type)
* return 0 .. OK
* -1 .. in case of Error or cancel
* ============================================================================
*/
static long
p_convert_indexed_dialog(gint32 *dest_colors, gint32 *dest_dither,
gint32 *palette_type, gint32 *alpha_dither, gint32 *remove_unused,
char *palette, gint len_palette)
{
#define ARGC_INDEXED 6
static t_arr_arg argv[ARGC_INDEXED];
static char *radio_paltype[4] = { N_("Generate optimal palette")
, N_("WEB palette")
, N_("Use custom palette")
, N_("Use black/white (1-bit) palette")
};
static char *radio_dither[4] = { N_("Floyd-Steinberg colour dithering (normal)")
, N_("Floyd-Steinberg colour dithering (reduced colour bleeding)")
, N_("Positioned colour dithering")
, N_("No colour dithering")
};
static int gettextize_loop = 0;
for (;gettextize_loop < 4; gettextize_loop++)
radio_paltype[gettextize_loop] = gettext(radio_paltype[gettextize_loop]);
for (;gettextize_loop < 4; gettextize_loop++)
radio_dither[gettextize_loop] = gettext(radio_dither[gettextize_loop]);
p_init_arr_arg(&argv[0], WGT_RADIO);
argv[0].label_txt = _("Palette Type");
argv[0].help_txt = NULL;
argv[0].radio_argc = 4;
argv[0].radio_argv = radio_paltype;
argv[0].radio_ret = 0;
p_init_arr_arg(&argv[1], WGT_TEXT);
argv[1].label_txt = _("Custom Palette");
argv[1].help_txt = _("name of a cutom palette\n(is ignored if Palette Type is not custom)");
argv[1].text_buf_len = len_palette;
argv[1].text_buf_ret = palette;
p_init_arr_arg(&argv[2], WGT_TOGGLE);
argv[2].label_txt = _("Remove unused");
argv[2].help_txt = _("Remove unused or double colors\n(is ignored if Palette Type is not custom)");
argv[2].int_ret = 1;
p_init_arr_arg(&argv[3], WGT_INT_PAIR);
argv[3].constraint = TRUE;
argv[3].label_txt = _("Number ofColors");
argv[3].help_txt = _("Number of resulting Colors \n(ignored if Palette Type is not Generate optimal palette)");
argv[3].int_min = 2;
argv[3].int_max = 256;
argv[3].int_ret = 255;
p_init_arr_arg(&argv[4], WGT_RADIO);
argv[4].label_txt = _("Dither Options");
argv[4].help_txt = NULL;
argv[4].radio_argc = 4;
argv[4].radio_argv = radio_dither;
argv[4].radio_ret = 0;
p_init_arr_arg(&argv[5], WGT_TOGGLE);
argv[5].label_txt = _("Enable transparency");
argv[5].help_txt = _("Enable dithering of transparency");
argv[5].int_ret = 0;
if(TRUE == p_array_dialog( _("Convert Frames to Indexed"),
_("Palette and Dither Settings :"),
ARGC_INDEXED, argv))
{
switch(argv[0].radio_ret)
{
case 3:
*palette_type = GIMP_MONO_PALETTE;
break;
case 2:
*palette_type = GIMP_CUSTOM_PALETTE;
break;
case 1:
*palette_type = GIMP_WEB_PALETTE;
break;
default:
*palette_type = GIMP_MAKE_PALETTE;
break;
}
*remove_unused = (gint32)(argv[2].int_ret);;
*dest_colors = (gint32)(argv[3].int_ret);
switch(argv[4].radio_ret)
{
case 3:
*dest_dither = GIMP_NO_DITHER;
break;
case 2:
*dest_dither = GIMP_FIXED_DITHER;
break;
case 1:
*dest_dither = GIMP_FSLOWBLEED_DITHER;
break;
default:
*dest_dither = GIMP_FS_DITHER;
break;
}
*alpha_dither = (gint32)(argv[5].int_ret);
return 0;
}
else
{
return -1;
}
}
/* ============================================================================
* p_convert_dialog
*
@ -282,9 +405,11 @@ p_convert_dialog(t_anim_info *ainfo_ptr,
long *range_from, long *range_to, long *flatten,
GImageType *dest_type, gint32 *dest_colors, gint32 *dest_dither,
char *basename, gint len_base,
char *extension, gint len_ext)
char *extension, gint len_ext,
gint32 *palette_type, gint32 *alpha_dither, gint32 *remove_unused,
char *palette, gint len_palette)
{
static t_arr_arg argv[9];
static t_arr_arg argv[7];
static char *radio_args[4] = { N_("KEEP_TYPE"), N_("Conv to RGB"), N_("Conv to GRAY"), N_("Conv to INDEXED") };
static int gettextize_loop = 0;
@ -335,24 +460,11 @@ p_convert_dialog(t_anim_info *ainfo_ptr,
argv[6].help_txt = _("Flatten all resulting frames \n(most fileformats need flattened frames)");
argv[6].int_ret = 1;
p_init_arr_arg(&argv[7], WGT_INT_PAIR);
argv[7].constraint = TRUE;
argv[7].label_txt = _("Colors :");
argv[7].help_txt = _("Number of resulting Colors \n(ignored if not converted to indexed)");
argv[7].int_min = 2;
argv[7].int_max = 256;
argv[7].int_ret = 255;
p_init_arr_arg(&argv[8], WGT_TOGGLE);
argv[8].label_txt = _("Dither :");
argv[8].help_txt = _("Enable Floyd-Steinberg dithering \n(ignored if not converted to indexed)");
argv[8].int_ret = 1;
if(0 != p_chk_framerange(ainfo_ptr)) return -1;
if(TRUE == p_array_dialog( _("Convert Frames to other Formats"),
_("Convert Settings :"),
9, argv))
7, argv))
{
*range_from = (long)(argv[0].int_ret);
*range_to = (long)(argv[1].int_ret);
@ -372,9 +484,29 @@ p_convert_dialog(t_anim_info *ainfo_ptr,
break;
}
*flatten = (long)(argv[6].int_ret);
*dest_colors = (gint32)(argv[7].int_ret);
*dest_dither = (long)(argv[8].int_ret);
*dest_colors = 255;
*dest_dither = 0;
*palette_type = 2; /* WEB palette */
*alpha_dither = 0;
*remove_unused = 0;
if(*dest_type == INDEXED)
{
/* Open a 2.nd dialog for the Dither Options */
if(0 != p_convert_indexed_dialog(dest_colors,
dest_dither,
palette_type,
alpha_dither,
remove_unused,
palette,
len_palette
))
{
return -1;
}
}
if(0 != p_chk_framechange(ainfo_ptr))
{
return -1;
@ -847,7 +979,8 @@ gint32 gap_range_to_multilayer(GRunModeType run_mode, gint32 image_id,
* ============================================================================
*/
static int
p_type_convert(gint32 image_id, GImageType dest_type, gint32 dest_colors, gint32 dest_dither)
p_type_convert(gint32 image_id, GImageType dest_type, gint32 dest_colors, gint32 dest_dither,
gint32 palette_type, gint32 alpha_dither, gint32 remove_unused, char *palette)
{
GParam *l_params;
gint l_retvals;
@ -859,12 +992,17 @@ p_type_convert(gint32 image_id, GImageType dest_type, gint32 dest_colors, gint32
switch(dest_type)
{
case INDEXED:
if(gap_debug) fprintf(stderr, "DEBUG: p_type_convert to INDEXED ncolors=%d'\n", (int)dest_colors);
if(gap_debug) fprintf(stderr, "DEBUG: p_type_convert to INDEXED ncolors=%d, palette_type=%d palette_name=%s'\n",
(int)dest_colors, (int)palette_type, palette);
l_params = gimp_run_procedure ("gimp_convert_indexed",
&l_retvals,
PARAM_IMAGE, image_id,
PARAM_INT32, dest_dither, /* value 1== floyd-steinberg */
PARAM_INT32, palette_type, /* value 0: MAKE_PALETTE, 2: WEB_PALETTE 4:CUSTOM_PALETTE */
PARAM_INT32, dest_colors,
PARAM_INT32, alpha_dither,
PARAM_INT32, remove_unused,
PARAM_STRING, palette, /* name of custom palette */
PARAM_END);
break;
case GRAY:
@ -914,7 +1052,8 @@ p_frames_convert(t_anim_info *ainfo_ptr,
long range_from, long range_to,
char *save_proc_name, char *new_basename, char *new_extension,
int flatten,
GImageType dest_type, gint32 dest_colors, gint32 dest_dither)
GImageType dest_type, gint32 dest_colors, gint32 dest_dither,
gint32 palette_type, gint32 alpha_dither, gint32 remove_unused, char *palette)
{
GRunModeType l_run_mode;
gint32 l_tmp_image_id;
@ -1011,7 +1150,8 @@ p_frames_convert(t_anim_info *ainfo_ptr,
if(dest_type != gimp_image_base_type(l_tmp_image_id))
{
/* have to convert to desired type (RGB, INDEXED, GRAYSCALE) */
p_type_convert(l_tmp_image_id, dest_type, dest_colors, dest_dither);
p_type_convert(l_tmp_image_id, dest_type, dest_colors, dest_dither,
palette_type, alpha_dither, remove_unused, palette);
}
@ -1260,7 +1400,7 @@ int gap_range_flatten(GRunModeType run_mode, gint32 image_id,
l_rc = p_save_named_frame(ainfo_ptr->image_id, ainfo_ptr->old_filename);
if(l_rc >= 0)
{
l_rc = p_frames_convert(ainfo_ptr, l_from, l_to, NULL, NULL, NULL, 1, 0,0,0);
l_rc = p_frames_convert(ainfo_ptr, l_from, l_to, NULL, NULL, NULL, 1, 0,0,0, 0,0,0, "");
p_load_named_frame(ainfo_ptr->image_id, ainfo_ptr->old_filename);
}
}
@ -1465,13 +1605,20 @@ gint32 gap_range_conv(GRunModeType run_mode, gint32 image_id,
gint32 dest_colors,
gint32 dest_dither,
char *basename,
char *extension)
char *extension,
gint32 palette_type,
gint32 alpha_dither,
gint32 remove_unused,
char *palette)
{
gint32 l_rc;
long l_from, l_to;
long l_flatten;
gint32 l_dest_colors;
gint32 l_dest_dither;
gint32 l_palette_type;
gint32 l_alpha_dither;
gint32 l_remove_unused;
GImageType l_dest_type;
t_anim_info *ainfo_ptr;
@ -1480,6 +1627,7 @@ gint32 gap_range_conv(GRunModeType run_mode, gint32 image_id,
char *l_basename_ptr;
long l_number;
char l_extension[32];
char l_palette[256];
strcpy(l_save_proc_name, "gimp_file_save");
strcpy(l_extension, ".tif");
@ -1500,10 +1648,13 @@ gint32 gap_range_conv(GRunModeType run_mode, gint32 image_id,
/* p_convert_dialog : select destination type
* to find out extension
*/
strcpy(l_palette, "Default");
l_rc = p_convert_dialog (ainfo_ptr, &l_from, &l_to, &l_flatten,
&l_dest_type, &l_dest_colors, &l_dest_dither,
&l_basename[0], sizeof(l_basename),
&l_extension[0], sizeof(l_extension));
&l_extension[0], sizeof(l_extension),
&l_palette_type, &l_alpha_dither, &l_remove_unused,
&l_palette[0], sizeof(l_palette));
}
else
@ -1515,11 +1666,19 @@ gint32 gap_range_conv(GRunModeType run_mode, gint32 image_id,
l_dest_type = dest_type;
l_dest_colors = dest_colors;
l_dest_dither = dest_dither;
l_palette_type = palette_type;
l_alpha_dither = alpha_dither;
l_remove_unused = remove_unused;
if(basename != NULL)
{
strncpy(l_basename, basename, sizeof(l_basename) -1);
l_basename[sizeof(l_basename) -1] = '\0';
}
if(palette != NULL)
{
strncpy(l_palette, palette, sizeof(l_palette) -1);
l_palette[sizeof(l_palette) -1] = '\0';
}
strncpy(l_extension, extension, sizeof(l_extension) -1);
l_extension[sizeof(l_extension) -1] = '\0';
@ -1539,7 +1698,11 @@ gint32 gap_range_conv(GRunModeType run_mode, gint32 image_id,
l_flatten,
l_dest_type,
l_dest_colors,
l_dest_dither);
l_dest_dither,
l_palette_type,
l_alpha_dither,
l_remove_unused,
l_palette);
g_free(l_basename_ptr);
}
}

View file

@ -25,6 +25,7 @@
*/
/* revision history:
* 1.1.10a; 1999/10/22 hof: extended dither options in gap_range_conv
* 0.97.00; 1998/10/19 hof: extended gap_range_to_multilayer layer seletion
* 0.96.03; 1998/08/31 hof: gap_range_to_multilayer: all params available
* in non-interactive runmode
@ -78,7 +79,12 @@ int gap_range_conv(GRunModeType run_mode,
gint32 dest_colors,
gint32 dest_dither,
char *basename,
char *extension);
char *extension,
gint32 palette_type,
gint32 alpha_dither,
gint32 remove_unused,
char *palette
);
int gap_anim_sizechange(GRunModeType run_mode,
t_gap_asiz asiz_mode,