mirror of https://github.com/GNOME/gimp.git
New routine in gimpmiscui and some code clean-up
This commit is contained in:
parent
416049f460
commit
9984145f49
13
ChangeLog
13
ChangeLog
|
@ -1,3 +1,16 @@
|
|||
2003-01-27 Maurits Rijk <lpeek.mrijk@consunet.nl>
|
||||
|
||||
* plug-ins/common/sample_colorize.c: code clean-up, added a few more
|
||||
mnemonics to dialogs.
|
||||
|
||||
* plug-ins/gfig/gfig.c
|
||||
* plug-ins/gflare/gflare.c
|
||||
* plug-ins/FractalExplorer/FractalExplorer.c: use new
|
||||
gimp_plug_in_parse_path routine.
|
||||
|
||||
* libgimp/gimpmiscui.[ch] (gimp_plug_in_parse_path): new routine used
|
||||
in several plug-ins.
|
||||
|
||||
2003-01-27 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/gui/preferences-dialog.c: commented out debugging output.
|
||||
|
|
|
@ -280,3 +280,64 @@ gimp_fixme_preview_fill (GimpFixMePreview *preview,
|
|||
|
||||
g_free (src);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (!path)
|
||||
{
|
||||
gchar *gimprc = gimp_personal_rc_file ("gimprc");
|
||||
gchar *full_path;
|
||||
gchar *esc_path;
|
||||
|
||||
full_path = g_strconcat
|
||||
("${gimp_dir}", G_DIR_SEPARATOR_S, dir_name,
|
||||
G_SEARCHPATH_SEPARATOR_S,
|
||||
"${gimp_data_dir}", G_DIR_SEPARATOR_S, dir_name,
|
||||
NULL);
|
||||
esc_path = g_strescape (full_path, NULL);
|
||||
|
||||
g_message (_("No %s in gimprc:\n"
|
||||
"You need to add an entry like\n"
|
||||
"(%s \"%s\")\n"
|
||||
"to your %s file."), path_name, path_name, esc_path,
|
||||
gimprc);
|
||||
|
||||
g_free (gimprc);
|
||||
g_free (full_path);
|
||||
g_free (esc_path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
path_list = gimp_path_parse (path, 16, TRUE, &fail_list);
|
||||
|
||||
g_free (path);
|
||||
|
||||
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);
|
||||
gimp_path_free (fail_list);
|
||||
}
|
||||
|
||||
return path_list;
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ void gimp_fixme_preview_do_row (GimpFixMePreview *preview,
|
|||
gint width,
|
||||
guchar *src);
|
||||
|
||||
GList *gimp_plug_in_parse_path (gchar *path_name, const gchar *dir_name);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -711,11 +711,9 @@ delete_dialog_callback (GtkWidget *widget,
|
|||
}
|
||||
|
||||
delete_dialog = NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
static gint
|
||||
static gboolean
|
||||
delete_fractal_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
|
@ -765,10 +763,7 @@ fractalexplorer_list_ok_callback (GtkWidget *widget,
|
|||
list = options->list_entry;
|
||||
|
||||
/* Set the new layer name */
|
||||
if (options->obj->draw_name)
|
||||
{
|
||||
g_free(options->obj->draw_name);
|
||||
}
|
||||
g_free(options->obj->draw_name);
|
||||
options->obj->draw_name =
|
||||
g_strdup (gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
|
||||
|
||||
|
@ -785,7 +780,6 @@ fractalexplorer_list_ok_callback (GtkWidget *widget,
|
|||
|
||||
gtk_widget_destroy (options->query_box);
|
||||
g_free (options);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -795,7 +789,7 @@ fractalexplorer_list_cancel_callback (GtkWidget *widget,
|
|||
fractalexplorerListOptions *options;
|
||||
|
||||
options = (fractalexplorerListOptions *) data;
|
||||
if(options->created)
|
||||
if (options->created)
|
||||
{
|
||||
/* We are creating an entry so if cancelled
|
||||
* must del the list item as well
|
||||
|
@ -909,9 +903,8 @@ new_button_press (GtkWidget *widget,
|
|||
}
|
||||
|
||||
/*
|
||||
* Load all fractalexplorer, which are founded in fractalexplorer-path-list, into fractalexplorer_list.
|
||||
* fractalexplorer-path-list must be initialized first. (plug_in_parse_fractalexplorer_path ())
|
||||
* based on code from Gflare.
|
||||
* Load all fractalexplorer, which are founded in fractalexplorer-path-list,
|
||||
* into fractalexplorer_list.
|
||||
*/
|
||||
|
||||
static gint
|
||||
|
@ -932,7 +925,6 @@ fractalexplorer_list_pos (fractalexplorerOBJ *fractalexplorer)
|
|||
|
||||
n++;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -1043,17 +1035,13 @@ static void
|
|||
list_button_update (fractalexplorerOBJ *obj)
|
||||
{
|
||||
g_return_if_fail (obj != NULL);
|
||||
pic_obj = (fractalexplorerOBJ *)obj;
|
||||
pic_obj = obj;
|
||||
}
|
||||
|
||||
fractalexplorerOBJ *
|
||||
fractalexplorer_new (void)
|
||||
{
|
||||
fractalexplorerOBJ * new;
|
||||
|
||||
new = g_new0 (fractalexplorerOBJ, 1);
|
||||
|
||||
return new;
|
||||
return g_new0 (fractalexplorerOBJ, 1);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1127,62 +1115,11 @@ list_button_press (GtkWidget *widget,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Query gimprc for fractalexplorer-path, and parse it.
|
||||
* This code is based on script_fu_find_scripts ()
|
||||
* and the Gflare plugin.
|
||||
*/
|
||||
void
|
||||
plug_in_parse_fractalexplorer_path (void)
|
||||
{
|
||||
GList *fail_list = NULL;
|
||||
GList *list;
|
||||
gchar *fractalexplorer_path;
|
||||
|
||||
gimp_path_free (fractalexplorer_path_list);
|
||||
fractalexplorer_path_list = NULL;
|
||||
|
||||
fractalexplorer_path = gimp_gimprc_query ("fractalexplorer-path");
|
||||
|
||||
if (!fractalexplorer_path)
|
||||
{
|
||||
gchar *gimprc = gimp_personal_rc_file ("gimprc");
|
||||
gchar *path = g_strescape
|
||||
("${gimp_dir}" G_DIR_SEPARATOR_S "fractalexplorer"
|
||||
G_SEARCHPATH_SEPARATOR_S
|
||||
"${gimp_data_dir}" G_DIR_SEPARATOR_S "fractalexplorer",
|
||||
NULL);
|
||||
g_message (_("No fractalexplorer-path in gimprc:\n"
|
||||
"You need to add an entry like\n"
|
||||
"(fractalexplorer-path \"%s\")\n"
|
||||
"to your %s file."), path, gimprc);
|
||||
g_free (gimprc);
|
||||
g_free (path);
|
||||
return;
|
||||
}
|
||||
|
||||
fractalexplorer_path_list = gimp_path_parse (fractalexplorer_path,
|
||||
16, TRUE, &fail_list);
|
||||
|
||||
g_free (fractalexplorer_path);
|
||||
|
||||
if (fail_list)
|
||||
{
|
||||
GString *err =
|
||||
g_string_new (_("fractalexplorer-path 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);
|
||||
gimp_path_free (fail_list);
|
||||
}
|
||||
fractalexplorer_path_list =
|
||||
gimp_plug_in_parse_path ("fractalexplorer-path", "fractalexplorer");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1201,7 +1138,7 @@ fractalexplorer_free_everything (fractalexplorerOBJ *fractalexplorer)
|
|||
{
|
||||
g_assert (fractalexplorer != NULL);
|
||||
|
||||
if(fractalexplorer->filename)
|
||||
if (fractalexplorer->filename)
|
||||
{
|
||||
remove (fractalexplorer->filename);
|
||||
}
|
||||
|
@ -1211,15 +1148,7 @@ fractalexplorer_free_everything (fractalexplorerOBJ *fractalexplorer)
|
|||
static void
|
||||
fractalexplorer_list_free_all (void)
|
||||
{
|
||||
GList * list;
|
||||
fractalexplorerOBJ * fractalexplorer;
|
||||
|
||||
for (list = fractalexplorer_list; list; list = g_list_next (list))
|
||||
{
|
||||
fractalexplorer = (fractalexplorerOBJ *) list->data;
|
||||
fractalexplorer_free (fractalexplorer);
|
||||
}
|
||||
|
||||
g_list_foreach (fractalexplorer_list, (GFunc) fractalexplorer_free, NULL);
|
||||
g_list_free (fractalexplorer_list);
|
||||
fractalexplorer_list = NULL;
|
||||
}
|
||||
|
@ -1332,7 +1261,7 @@ fractalexplorer_list_load_all (GList *plist)
|
|||
}
|
||||
}
|
||||
|
||||
if(!fractalexplorer_list)
|
||||
if (!fractalexplorer_list)
|
||||
{
|
||||
/* lets have at least one! */
|
||||
fractalexplorer = fractalexplorer_new ();
|
||||
|
@ -1340,7 +1269,6 @@ fractalexplorer_list_load_all (GList *plist)
|
|||
fractalexplorer_list_insert (fractalexplorer);
|
||||
}
|
||||
pic_obj = current_obj = fractalexplorer_list->data; /* set to first entry */
|
||||
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
@ -1457,7 +1385,6 @@ fractalexplorer_rescan_list (void)
|
|||
return;
|
||||
}
|
||||
|
||||
/* the dialog */
|
||||
dlg = gimp_dialog_new (_("Rescan for Fractals"), "fractalexplorer",
|
||||
gimp_standard_help_func, "filters/fractalexplorer.html",
|
||||
GTK_WIN_POS_MOUSE,
|
||||
|
|
|
@ -191,6 +191,7 @@ typedef struct {
|
|||
* Some globals
|
||||
*/
|
||||
|
||||
static GimpRunMode run_mode;
|
||||
static t_samp_interface g_di; /* global dialog interface varables */
|
||||
static t_values g_values = { -1, -1, 1, 1, 0, 1, 0, 255, 1.0, 0, 255, 5.5 };
|
||||
static t_samp_table_elem g_lum_tab[256];
|
||||
|
@ -322,7 +323,6 @@ run (gchar *name,
|
|||
{
|
||||
static GimpParam values[1];
|
||||
GimpDrawable *dst_drawable;
|
||||
GimpRunMode run_mode;
|
||||
GimpPDBStatusType status = GIMP_PDB_SUCCESS;
|
||||
const gchar *l_env;
|
||||
|
||||
|
@ -1117,8 +1117,6 @@ p_levels_update (gint update)
|
|||
}
|
||||
} /* end p_levels_update */
|
||||
|
||||
|
||||
|
||||
static gint
|
||||
p_level_in_events (GtkWidget *widget,
|
||||
GdkEvent *event,
|
||||
|
@ -2019,8 +2017,6 @@ p_get_pixel( t_GDRW *gdrw, gint32 x, gint32 y, guchar *pixel )
|
|||
return;
|
||||
}
|
||||
|
||||
/* gimp_pixel_rgn_get_pixel(&gdrw->pr, pixel, x, y); */
|
||||
|
||||
col = x / gdrw->tile_width;
|
||||
row = y / gdrw->tile_height;
|
||||
offx = x % gdrw->tile_width;
|
||||
|
@ -2528,7 +2524,7 @@ p_get_gradient (gint mode)
|
|||
g_free (f_samples);
|
||||
} /* end p_get_gradient */
|
||||
|
||||
gint32
|
||||
static gint32
|
||||
p_is_layer_alive(gint32 drawable_id)
|
||||
{
|
||||
/* return -1 if layer has become invalid */
|
||||
|
@ -2539,9 +2535,9 @@ p_is_layer_alive(gint32 drawable_id)
|
|||
gint l_idi, l_idl;
|
||||
gint l_found;
|
||||
|
||||
if(drawable_id < 0)
|
||||
if (drawable_id < 0)
|
||||
{
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* gimp_layer_get_image_id: crash in gimp 1.1.2 if called with invalid drawable_id
|
||||
|
@ -2555,69 +2551,59 @@ p_is_layer_alive(gint32 drawable_id)
|
|||
* }
|
||||
*/
|
||||
|
||||
images = gimp_image_list(&nimages);
|
||||
images = gimp_image_list (&nimages);
|
||||
l_idi = nimages -1;
|
||||
l_found = FALSE;
|
||||
while((l_idi >= 0) && images)
|
||||
while ((l_idi >= 0) && images)
|
||||
{
|
||||
layers = gimp_image_get_layers (images[l_idi], &nlayers);
|
||||
l_idl = nlayers -1;
|
||||
while((l_idl >= 0) && layers)
|
||||
l_idl = nlayers - 1;
|
||||
while ((l_idl >= 0) && layers)
|
||||
{
|
||||
if(drawable_id == layers[l_idl])
|
||||
if (drawable_id == layers[l_idl])
|
||||
{
|
||||
l_found = TRUE;
|
||||
break;
|
||||
}
|
||||
l_idl--;
|
||||
}
|
||||
g_free(layers);
|
||||
g_free (layers);
|
||||
l_idi--;
|
||||
}
|
||||
if(images) g_free(images);
|
||||
if(!l_found)
|
||||
g_free(images);
|
||||
if (!l_found)
|
||||
{
|
||||
printf("sample colorize: unknown layer_id %d (Image closed?)\n", (int)drawable_id);
|
||||
return (-1);
|
||||
printf("sample colorize: unknown layer_id %d (Image closed?)\n",
|
||||
(int)drawable_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return(drawable_id);
|
||||
return drawable_id;
|
||||
} /* end p_is_layer_alive */
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
p_end_gdrw(t_GDRW *gdrw)
|
||||
{
|
||||
t_GDRW *l_sel_gdrw;
|
||||
t_GDRW *sel_gdrw;
|
||||
|
||||
if(g_Sdebug) printf("\np_end_gdrw: drawable %p ID: %d\n", gdrw->drawable, (int)gdrw->drawable->drawable_id);
|
||||
|
||||
if(gdrw->tile)
|
||||
if (gdrw->tile)
|
||||
{
|
||||
if(g_Sdebug) printf("p_end_gdrw: tile unref\n");
|
||||
gimp_tile_unref( gdrw->tile, gdrw->tile_dirty);
|
||||
gimp_tile_unref (gdrw->tile, gdrw->tile_dirty);
|
||||
gdrw->tile = NULL;
|
||||
}
|
||||
|
||||
l_sel_gdrw = (t_GDRW *)(gdrw->sel_gdrw);
|
||||
if(l_sel_gdrw)
|
||||
sel_gdrw = (t_GDRW*)(gdrw->sel_gdrw);
|
||||
if (sel_gdrw)
|
||||
{
|
||||
if(l_sel_gdrw->tile)
|
||||
if(sel_gdrw->tile)
|
||||
{
|
||||
if(g_Sdebug) printf("p_end_gdrw: sel_tile unref\n");
|
||||
gimp_tile_unref( l_sel_gdrw->tile, l_sel_gdrw->tile_dirty);
|
||||
l_sel_gdrw->tile = NULL;
|
||||
if(g_Sdebug) printf("p_end_gdrw:SEL_TILE_SWAPCOUNT: %d\n", (int)l_sel_gdrw->tile_swapcount);
|
||||
gimp_tile_unref (sel_gdrw->tile, sel_gdrw->tile_dirty);
|
||||
sel_gdrw->tile = NULL;
|
||||
}
|
||||
gdrw->sel_gdrw = NULL;
|
||||
}
|
||||
|
||||
if(g_Sdebug) printf("p_end_gdrw:TILE_SWAPCOUNT: %d\n", (int)gdrw->tile_swapcount);
|
||||
}
|
||||
|
||||
} /* end p_end_gdrw */
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
p_init_gdrw(t_GDRW *gdrw, GimpDrawable *drawable, gint dirty, gint shadow)
|
||||
{
|
||||
gint32 l_image_id;
|
||||
|
@ -2643,13 +2629,6 @@ p_init_gdrw(t_GDRW *gdrw, GimpDrawable *drawable, gint dirty, gint shadow)
|
|||
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id, &gdrw->x1, &gdrw->y1, &gdrw->x2, &gdrw->y2);
|
||||
|
||||
/*
|
||||
* gimp_pixel_rgn_init (&gdrw->pr, drawable,
|
||||
* gdrw->x1, gdrw->y1, gdrw->x2 - gdrw->x1, gdrw->y2 - gdrw->y1,
|
||||
* dirty, shadow);
|
||||
*/
|
||||
|
||||
|
||||
gdrw->bpp = drawable->bpp;
|
||||
if (gimp_drawable_has_alpha(drawable->drawable_id))
|
||||
{
|
||||
|
@ -2660,8 +2639,7 @@ p_init_gdrw(t_GDRW *gdrw, GimpDrawable *drawable, gint dirty, gint shadow)
|
|||
{
|
||||
gdrw->index_alpha = 0; /* there is no alpha channel */
|
||||
}
|
||||
|
||||
|
||||
|
||||
l_image_id = gimp_layer_get_image_id(drawable->drawable_id);
|
||||
|
||||
/* check and see if we have a selection mask */
|
||||
|
@ -2719,12 +2697,11 @@ p_init_gdrw(t_GDRW *gdrw, GimpDrawable *drawable, gint dirty, gint shadow)
|
|||
else
|
||||
{
|
||||
gdrw->sel_gdrw = NULL; /* selection is FALSE */
|
||||
}
|
||||
|
||||
}
|
||||
} /* end p_init_gdrw */
|
||||
|
||||
/* analyze the colors in the sample_drawable */
|
||||
int
|
||||
static int
|
||||
p_sample_analyze(t_GDRW *sample_gdrw)
|
||||
{
|
||||
gint32 l_sample_pixels;
|
||||
|
@ -2748,8 +2725,6 @@ p_sample_analyze(t_GDRW *sample_gdrw)
|
|||
l_progress = 0.0;
|
||||
if(g_show_progress) gimp_progress_init (_("Sample Analyze..."));
|
||||
|
||||
|
||||
|
||||
prot_fp = NULL;
|
||||
if(g_Sdebug) prot_fp = fopen("sample_colors.dump", "w");
|
||||
p_print_values(prot_fp);
|
||||
|
@ -2837,7 +2812,7 @@ p_sample_analyze(t_GDRW *sample_gdrw)
|
|||
if(prot_fp) fclose(prot_fp);
|
||||
|
||||
/* check if there was at least one visible pixel */
|
||||
if(l_sample_pixels == 0)
|
||||
if (l_sample_pixels == 0)
|
||||
{
|
||||
printf("Error: Source sample has no visible Pixel\n");
|
||||
return -1;
|
||||
|
@ -2845,7 +2820,7 @@ p_sample_analyze(t_GDRW *sample_gdrw)
|
|||
return 0;
|
||||
} /* end p_sample_analyze */
|
||||
|
||||
void
|
||||
static void
|
||||
p_rnd_remap(gint32 lum, guchar *mapped_color)
|
||||
{
|
||||
t_samp_color_elem *l_col_ptr;
|
||||
|
@ -2853,7 +2828,7 @@ p_rnd_remap(gint32 lum, guchar *mapped_color)
|
|||
gint l_ct;
|
||||
gint l_idx;
|
||||
|
||||
if(g_lum_tab[lum].all_samples > 1)
|
||||
if (g_lum_tab[lum].all_samples > 1)
|
||||
{
|
||||
l_rnd = g_random_int_range (0, g_lum_tab[lum].all_samples);
|
||||
l_ct = 0;
|
||||
|
@ -2879,8 +2854,7 @@ p_rnd_remap(gint32 lum, guchar *mapped_color)
|
|||
memcpy(mapped_color, &g_sample_color_tab[lum + lum + lum], 3);
|
||||
} /* end p_rnd_remap */
|
||||
|
||||
|
||||
void
|
||||
static void
|
||||
p_remap_pixel(guchar *pixel, guchar *original, gint bpp2)
|
||||
{
|
||||
guchar mapped_color[4];
|
||||
|
@ -2891,24 +2865,30 @@ p_remap_pixel(guchar *pixel, guchar *original, gint bpp2)
|
|||
double l_dg, l_dr, l_db;
|
||||
double l_dlum;
|
||||
|
||||
|
||||
l_lum = g_out_trans_tab[g_lvl_trans_tab[LUMINOSITY_1(original)]]; /* get brightness from (uncolorized) original */
|
||||
if(g_values.rnd_subcolors)
|
||||
/* get brightness from (uncolorized) original */
|
||||
l_lum = g_out_trans_tab[g_lvl_trans_tab[LUMINOSITY_1(original)]];
|
||||
if (g_values.rnd_subcolors)
|
||||
{
|
||||
p_rnd_remap(l_lum, mapped_color);
|
||||
p_rnd_remap (l_lum, mapped_color);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(mapped_color, &g_sample_color_tab[l_lum + l_lum + l_lum], 3);
|
||||
memcpy (mapped_color, &g_sample_color_tab[l_lum + l_lum + l_lum], 3);
|
||||
}
|
||||
|
||||
if(g_values.hold_inten)
|
||||
if (g_values.hold_inten)
|
||||
{
|
||||
if(g_values.orig_inten) { l_orig_lum = LUMINOSITY_0(original); }
|
||||
else { l_orig_lum = 100.0 * g_lvl_trans_tab[LUMINOSITY_1(original)]; }
|
||||
if (g_values.orig_inten)
|
||||
{
|
||||
l_orig_lum = LUMINOSITY_0(original);
|
||||
}
|
||||
else
|
||||
{
|
||||
l_orig_lum = 100.0 * g_lvl_trans_tab[LUMINOSITY_1(original)];
|
||||
}
|
||||
l_mapped_lum = LUMINOSITY_0(mapped_color);
|
||||
|
||||
if(l_mapped_lum == 0)
|
||||
if (l_mapped_lum == 0)
|
||||
{
|
||||
/* convert black to greylevel with desired brightness value */
|
||||
mapped_color[0] = l_orig_lum / 100.0;
|
||||
|
@ -3028,12 +3008,12 @@ p_remap_pixel(guchar *pixel, guchar *original, gint bpp2)
|
|||
{
|
||||
/* overflow in the blue channel (compensate with green and red) */
|
||||
l_dlum = (l_blu - 255.0) * 11.0;
|
||||
if(l_mg > 0)
|
||||
if (l_mg > 0)
|
||||
{
|
||||
l_dg = l_dlum / (59.0 + (30.0 * l_mr / l_mg));
|
||||
l_dr = l_dg * l_mr / l_mg;
|
||||
}
|
||||
else if(l_mr > 0)
|
||||
else if (l_mr > 0)
|
||||
{
|
||||
l_dr = l_dlum / (30.0 + (59.0 * l_mg / l_mr));
|
||||
l_dg = l_dr * l_mg / l_mr;
|
||||
|
@ -3061,10 +3041,9 @@ p_remap_pixel(guchar *pixel, guchar *original, gint bpp2)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
mapped_color[0] = CLAMP(l_red + 0.5, 0, 255);
|
||||
mapped_color[1] = CLAMP(l_grn + 0.5, 0, 255);
|
||||
mapped_color[2] = CLAMP(l_blu + 0.5, 0, 255);
|
||||
mapped_color[0] = CLAMP0255(l_red + 0.5);
|
||||
mapped_color[1] = CLAMP0255(l_grn + 0.5);
|
||||
mapped_color[2] = CLAMP0255(l_blu + 0.5);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3073,96 +3052,40 @@ p_remap_pixel(guchar *pixel, guchar *original, gint bpp2)
|
|||
memcpy(pixel, &mapped_color[0], bpp2);
|
||||
} /* end p_remap_pixel */
|
||||
|
||||
static void
|
||||
colorize_func(guchar *src, guchar *dest, gint bpp, gpointer data)
|
||||
{
|
||||
gboolean has_alpha = (gboolean) data;
|
||||
|
||||
void
|
||||
if (has_alpha)
|
||||
{
|
||||
bpp--;
|
||||
dest[bpp] = src[bpp];
|
||||
}
|
||||
p_remap_pixel(dest, src, bpp);
|
||||
}
|
||||
|
||||
static void
|
||||
p_colorize_drawable(gint32 drawable_id)
|
||||
{
|
||||
GimpDrawable *drawable;
|
||||
GimpPixelRgn pixel_rgn;
|
||||
GimpPixelRgn shadow_rgn;
|
||||
gpointer pr;
|
||||
gint l_row, l_col;
|
||||
gint l_bpp2;
|
||||
gint l_has_alpha;
|
||||
gint l_idx_alpha;
|
||||
guchar *l_ptr;
|
||||
guchar *l_row_ptr;
|
||||
guchar *l_sh_ptr;
|
||||
guchar *l_sh_row_ptr;
|
||||
gint32 l_x1, l_x2, l_y1, l_y2;
|
||||
float l_progress_step;
|
||||
float l_progress;
|
||||
gboolean has_alpha;
|
||||
|
||||
if(drawable_id < 1) return;
|
||||
drawable = gimp_drawable_get (drawable_id);
|
||||
if(drawable == NULL) return;
|
||||
has_alpha = gimp_drawable_has_alpha(drawable->drawable_id);
|
||||
|
||||
gimp_drawable_mask_bounds (drawable->drawable_id, &l_x1, &l_y1, &l_x2, &l_y2);
|
||||
gimp_pixel_rgn_init (&pixel_rgn, drawable,
|
||||
l_x1, l_y1, l_x2 - l_x1, l_y2 - l_y1,
|
||||
FALSE, /* dirty */
|
||||
FALSE /* shadow */
|
||||
);
|
||||
gimp_pixel_rgn_init (&shadow_rgn, drawable,
|
||||
l_x1, l_y1, l_x2 - l_x1, l_y2 - l_y1,
|
||||
TRUE, /* dirty */
|
||||
TRUE /* shadow */
|
||||
);
|
||||
/* init progress */
|
||||
l_progress_step = 1.0 / ((1 + l_y2 - l_y1) * (1+ ((l_x2 - l_x1)/gimp_tile_width ())));
|
||||
l_progress = 0.0;
|
||||
if(g_show_progress) gimp_progress_init (_("Remap Colorized..."));
|
||||
if (g_show_progress)
|
||||
gimp_progress_init (_("Remap Colorized..."));
|
||||
|
||||
l_bpp2 = pixel_rgn.bpp;
|
||||
l_idx_alpha = pixel_rgn.bpp -1;
|
||||
l_has_alpha = gimp_drawable_has_alpha(drawable->drawable_id);
|
||||
if(l_has_alpha)
|
||||
{
|
||||
l_bpp2--; /* do not remap the alpha channel bytes */
|
||||
}
|
||||
|
||||
for (pr = gimp_pixel_rgns_register (2, &pixel_rgn, &shadow_rgn);
|
||||
pr != NULL; pr = gimp_pixel_rgns_process (pr))
|
||||
{
|
||||
l_row_ptr = pixel_rgn.data;
|
||||
l_sh_row_ptr = shadow_rgn.data;
|
||||
for ( l_row = 0; l_row < pixel_rgn.h; l_row++ )
|
||||
{
|
||||
l_ptr = l_row_ptr;
|
||||
l_sh_ptr = l_sh_row_ptr;
|
||||
for( l_col = 0; l_col < pixel_rgn.w; l_col++)
|
||||
{
|
||||
/* if this is a visible (non-transparent) pixel */
|
||||
if(l_has_alpha)
|
||||
{
|
||||
l_sh_ptr[l_idx_alpha] = l_ptr[l_idx_alpha];
|
||||
}
|
||||
p_remap_pixel(l_sh_ptr, l_ptr, l_bpp2); /* set colorized pixel in shadow pr */
|
||||
gimp_rgn_iterate2 (drawable, run_mode, colorize_func,
|
||||
GINT_TO_POINTER (has_alpha));
|
||||
|
||||
l_ptr += pixel_rgn.bpp;
|
||||
l_sh_ptr += shadow_rgn.bpp;
|
||||
}
|
||||
l_row_ptr += pixel_rgn.rowstride;
|
||||
l_sh_row_ptr += shadow_rgn.rowstride;
|
||||
if(g_show_progress) gimp_progress_update (l_progress += l_progress_step);
|
||||
|
||||
}
|
||||
|
||||
if(g_Sdebug) printf ("ROWS done, progress :%f\n", (float)l_progress);
|
||||
}
|
||||
|
||||
/* reset the progress to zero to indiciate that the plug-in has done its job */
|
||||
if (g_show_progress)
|
||||
gimp_progress_update (0.0);
|
||||
|
||||
gimp_drawable_flush (drawable);
|
||||
gimp_drawable_merge_shadow (drawable->drawable_id, TRUE);
|
||||
gimp_drawable_update (drawable->drawable_id, l_x1, l_y1, l_x2 - l_x1, l_y2 - l_y1);
|
||||
|
||||
} /* end p_colorize_drawable */
|
||||
}
|
||||
|
||||
/* colorize dst_drawable like sample_drawable */
|
||||
int
|
||||
static int
|
||||
p_main_colorize(gint mc_flags)
|
||||
{
|
||||
GimpDrawable *dst_drawable;
|
||||
|
@ -3183,41 +3106,47 @@ p_main_colorize(gint mc_flags)
|
|||
|
||||
l_rc = 0;
|
||||
|
||||
if(mc_flags & MC_GET_SAMPLE_COLORS)
|
||||
if (mc_flags & MC_GET_SAMPLE_COLORS)
|
||||
{
|
||||
l_id = g_values.sample_id;
|
||||
if((l_id == SMP_GRADIENT) || (l_id == SMP_INV_GRADIENT))
|
||||
if ((l_id == SMP_GRADIENT) || (l_id == SMP_INV_GRADIENT))
|
||||
{
|
||||
p_get_gradient(l_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(p_is_layer_alive(l_id) < 0) { return (-1); }
|
||||
if (p_is_layer_alive(l_id) < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
sample_drawable = gimp_drawable_get (l_id);
|
||||
p_init_gdrw(&l_sample_gdrw, sample_drawable, FALSE, FALSE);
|
||||
p_free_colors();
|
||||
l_rc = p_sample_analyze(&l_sample_gdrw);
|
||||
p_init_gdrw (&l_sample_gdrw, sample_drawable, FALSE, FALSE);
|
||||
p_free_colors ();
|
||||
l_rc = p_sample_analyze (&l_sample_gdrw);
|
||||
}
|
||||
}
|
||||
|
||||
if((mc_flags & MC_DST_REMAP) && (l_rc == 0))
|
||||
|
||||
if ((mc_flags & MC_DST_REMAP) && (l_rc == 0))
|
||||
{
|
||||
if(p_is_layer_alive(g_values.dst_id) < 0) { return (-1); }
|
||||
if (p_is_layer_alive(g_values.dst_id) < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
dst_drawable = gimp_drawable_get (g_values.dst_id);
|
||||
if(gimp_drawable_is_gray(g_values.dst_id))
|
||||
if (gimp_drawable_is_gray (g_values.dst_id))
|
||||
{
|
||||
if(mc_flags & MC_DST_REMAP)
|
||||
if (mc_flags & MC_DST_REMAP)
|
||||
{
|
||||
gimp_convert_rgb(gimp_layer_get_image_id(g_values.dst_id));
|
||||
gimp_convert_rgb (gimp_layer_get_image_id (g_values.dst_id));
|
||||
}
|
||||
}
|
||||
p_colorize_drawable(dst_drawable->drawable_id);
|
||||
}
|
||||
|
||||
if(sample_drawable)
|
||||
{
|
||||
p_end_gdrw(&l_sample_gdrw);
|
||||
p_colorize_drawable (dst_drawable->drawable_id);
|
||||
}
|
||||
|
||||
return (l_rc);
|
||||
if (sample_drawable)
|
||||
{
|
||||
p_end_gdrw (&l_sample_gdrw);
|
||||
}
|
||||
|
||||
return l_rc;
|
||||
} /* end p_main_colorize */
|
||||
|
|
|
@ -769,66 +769,6 @@ run (gchar *name,
|
|||
gimp_drawable_detach (drawable);
|
||||
}
|
||||
|
||||
/*
|
||||
* Query gimprc for gfig-path, and parse it.
|
||||
*/
|
||||
|
||||
static void
|
||||
plug_in_parse_gfig_path (void)
|
||||
{
|
||||
GList *fail_list = NULL;
|
||||
GList *list;
|
||||
gchar *gfig_path;
|
||||
|
||||
if (gfig_path_list)
|
||||
gimp_path_free (gfig_path_list);
|
||||
|
||||
gfig_path_list = NULL;
|
||||
|
||||
gfig_path = gimp_gimprc_query ("gfig-path");
|
||||
|
||||
if (!gfig_path)
|
||||
{
|
||||
gchar *gimprc = gimp_personal_rc_file ("gimprc");
|
||||
gchar *path = g_strescape
|
||||
("${gimp_dir}" G_DIR_SEPARATOR_S "gfig"
|
||||
G_SEARCHPATH_SEPARATOR_S
|
||||
"${gimp_data_dir}" G_DIR_SEPARATOR_S "gfig",
|
||||
NULL);
|
||||
g_message (_("No gfig-path in gimprc:\n"
|
||||
"You need to add an entry like\n"
|
||||
"(gfig-path \"%s\")\n"
|
||||
"to your %s file."),
|
||||
path, gimprc);
|
||||
g_free (gimprc);
|
||||
g_free (path);
|
||||
return;
|
||||
}
|
||||
|
||||
gfig_path_list = gimp_path_parse (gfig_path, 16, TRUE, &fail_list);
|
||||
|
||||
g_free (gfig_path);
|
||||
|
||||
if (fail_list)
|
||||
{
|
||||
GString *err =
|
||||
g_string_new (_("gfig-path 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);
|
||||
gimp_path_free (fail_list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Translate SPACE to "\\040", etc.
|
||||
Taken from gflare plugin
|
||||
|
@ -901,27 +841,22 @@ gfig_list_pos (GFigObj *gfig)
|
|||
|
||||
n++;
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert gfigs in alphabetical order
|
||||
*/
|
||||
|
||||
static gint
|
||||
gfig_list_insert (GFigObj *gfig)
|
||||
{
|
||||
gint n;
|
||||
|
||||
/*
|
||||
* Insert gfigs in alphabetical order
|
||||
*/
|
||||
|
||||
n = gfig_list_pos (gfig);
|
||||
|
||||
gfig_list = g_list_insert (gfig_list, gfig, n);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf ("gfig_list_insert %s => %d\n", gfig->draw_name, n);
|
||||
#endif /* DEBUG */
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
@ -930,8 +865,7 @@ gfig_free (GFigObj *gfig)
|
|||
{
|
||||
g_assert (gfig != NULL);
|
||||
|
||||
if (gfig->obj_list)
|
||||
free_all_objs (gfig->obj_list);
|
||||
free_all_objs (gfig->obj_list);
|
||||
|
||||
g_free (gfig->name);
|
||||
g_free (gfig->filename);
|
||||
|
@ -947,28 +881,15 @@ gfig_free_everything (GFigObj *gfig)
|
|||
|
||||
if (gfig->filename)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
printf ("Removing filename '%s'\n", gfig->filename);
|
||||
#endif /* DEBUG */
|
||||
|
||||
remove (gfig->filename);
|
||||
}
|
||||
|
||||
gfig_free (gfig);
|
||||
}
|
||||
|
||||
static void
|
||||
gfig_list_free_all (void)
|
||||
{
|
||||
GList *list;
|
||||
GFigObj *gfig;
|
||||
|
||||
for (list = gfig_list; list; list = g_list_next (list))
|
||||
{
|
||||
gfig = (GFigObj *) list->data;
|
||||
gfig_free (gfig);
|
||||
}
|
||||
|
||||
g_list_foreach (gfig_list, (GFunc) gfig_free, NULL);
|
||||
g_list_free (gfig_list);
|
||||
gfig_list = NULL;
|
||||
}
|
||||
|
@ -1040,11 +961,7 @@ gfig_list_load_all (GList *plist)
|
|||
static GFigObj *
|
||||
gfig_new (void)
|
||||
{
|
||||
GFigObj * new;
|
||||
|
||||
new = g_new0 (GFigObj, 1);
|
||||
|
||||
return new;
|
||||
return g_new0 (GFigObj, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1409,13 +1326,10 @@ gfig_obj_counts (DAllObjs *objs)
|
|||
{
|
||||
gint count = 0;
|
||||
|
||||
while (objs)
|
||||
{
|
||||
count++;
|
||||
objs = objs->next;
|
||||
}
|
||||
for (; objs; objs = objs->next)
|
||||
count++;
|
||||
|
||||
return (count);
|
||||
return count;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1626,16 +1540,7 @@ cache_preview (void)
|
|||
img_bpp = real_img_bpp;
|
||||
}
|
||||
|
||||
switch (gimp_drawable_type (gfig_select_drawable->drawable_id))
|
||||
{
|
||||
case GIMP_GRAYA_IMAGE:
|
||||
case GIMP_GRAY_IMAGE:
|
||||
isgrey = 1;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
/*memset (p,-1, preview_width*preview_height*4); return;*/
|
||||
isgrey = gimp_drawable_is_gray (gfig_select_drawable->drawable_id);
|
||||
|
||||
for (y = 0; y < preview_height; y++)
|
||||
{
|
||||
|
@ -1748,13 +1653,8 @@ select_button_clicked (GtkWidget *widget,
|
|||
|
||||
if (current_obj)
|
||||
{
|
||||
objs = current_obj->obj_list;
|
||||
|
||||
while (objs)
|
||||
{
|
||||
objs = objs->next;
|
||||
count++;
|
||||
}
|
||||
for (objs = current_obj->obj_list; objs; objs = objs->next)
|
||||
count++;
|
||||
}
|
||||
|
||||
switch (type)
|
||||
|
@ -2398,10 +2298,7 @@ gfig_brush_fill_preview (GtkWidget *pw,
|
|||
GimpDrawable *brushdrawable;
|
||||
gint bcount = 3;
|
||||
|
||||
if (bdesc->pv_buf)
|
||||
{
|
||||
g_free (bdesc->pv_buf); /* Free old area */
|
||||
}
|
||||
g_free (bdesc->pv_buf); /* Free old area */
|
||||
|
||||
brushdrawable = gimp_drawable_get (layer_ID);
|
||||
|
||||
|
@ -3909,7 +3806,7 @@ gfig_dialog (void)
|
|||
yyy = gdk_rgb_get_visual ();
|
||||
xxx = gdk_rgb_get_colormap ();
|
||||
|
||||
plug_in_parse_gfig_path ();
|
||||
gfig_path_list = gimp_plug_in_parse_path ("gfig-path", "gfig");
|
||||
|
||||
/*cache_preview (); Get the preview image and store it also set has_alpha */
|
||||
|
||||
|
@ -4279,11 +4176,9 @@ gfig_preview_events (GtkWidget *widget,
|
|||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* The edit gfig name attributes dialog
|
||||
* Modified from Gimp source - layer edit.
|
||||
|
@ -4338,29 +4233,15 @@ gfig_list_ok_callback (GtkWidget *widget,
|
|||
list = options->list_entry;
|
||||
|
||||
/* Set the new layer name */
|
||||
#ifdef DEBUG
|
||||
printf ("Found obj %s\n", options->obj->draw_name);
|
||||
#endif /* DEBUG */
|
||||
|
||||
if (options->obj->draw_name)
|
||||
g_free (options->obj->draw_name);
|
||||
|
||||
g_free (options->obj->draw_name);
|
||||
options->obj->draw_name =
|
||||
g_strdup (gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
|
||||
|
||||
#ifdef DEBUG
|
||||
printf ("NEW name %s\n", options->obj->draw_name);
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* Need to reorder the list */
|
||||
/* gtk_label_set_text (GTK_LABEL (options->layer_widget->label), layer->name);*/
|
||||
|
||||
pos = gtk_list_child_position (GTK_LIST (gfig_gtk_list), list);
|
||||
|
||||
#ifdef DEBUG
|
||||
printf ("pos = %d\n", pos);
|
||||
#endif /* DEBUG */
|
||||
|
||||
gtk_list_clear_items (GTK_LIST (gfig_gtk_list), pos, pos + 1);
|
||||
|
||||
/* remove/Add again */
|
||||
|
@ -6197,8 +6078,7 @@ clear_undo (void)
|
|||
|
||||
for (lv = undo_water_mark; lv >= 0; lv--)
|
||||
{
|
||||
if (undo_table[lv])
|
||||
free_all_objs (undo_table[lv]);
|
||||
free_all_objs (undo_table[lv]);
|
||||
undo_table[lv] = NULL;
|
||||
}
|
||||
|
||||
|
@ -6504,23 +6384,16 @@ get_diffs (Dobject *obj,
|
|||
|
||||
g_assert (obj != NULL);
|
||||
|
||||
spnt = obj->points;
|
||||
|
||||
if (!spnt)
|
||||
return (NULL); /* no-line */
|
||||
|
||||
/* Slow slow slowwwwww....*/
|
||||
while (spnt)
|
||||
for (spnt = obj->points; spnt; spnt = spnt->next)
|
||||
{
|
||||
if (spnt->found_me)
|
||||
{
|
||||
*xdiff = spnt->pnt.x - to_pnt->x;
|
||||
*ydiff = spnt->pnt.y - to_pnt->y;
|
||||
return (spnt);
|
||||
return spnt;
|
||||
}
|
||||
spnt = spnt->next;
|
||||
}
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -6533,58 +6406,42 @@ update_pnts (Dobject *obj,
|
|||
g_assert (obj != NULL);
|
||||
|
||||
/* Update all pnts */
|
||||
spnt = obj->points;
|
||||
|
||||
if (!spnt)
|
||||
return; /* no-line */
|
||||
|
||||
/* Go around all the points drawing a line from one to the next */
|
||||
while (spnt)
|
||||
for (spnt = obj->points; spnt; spnt = spnt->next)
|
||||
{
|
||||
spnt->pnt.x = spnt->pnt.x - xdiff;
|
||||
spnt->pnt.y = spnt->pnt.y - ydiff;
|
||||
spnt = spnt->next;
|
||||
spnt->pnt.x -= xdiff;
|
||||
spnt->pnt.y -= ydiff;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
do_move_all_obj (GdkPoint *to_pnt)
|
||||
{
|
||||
/* Move all objects in one go */
|
||||
/* Undraw/then draw in new pos */
|
||||
DAllObjs *all;
|
||||
Dobject *obj;
|
||||
gint16 xdiff = 0;
|
||||
gint16 ydiff = 0;
|
||||
gint16 xdiff = move_all_pnt->x - to_pnt->x;
|
||||
gint16 ydiff = move_all_pnt->y - to_pnt->y;
|
||||
|
||||
xdiff = move_all_pnt->x - to_pnt->x;
|
||||
ydiff = move_all_pnt->y - to_pnt->y;
|
||||
|
||||
if (!xdiff && !ydiff)
|
||||
return;
|
||||
|
||||
all = current_obj->obj_list;
|
||||
|
||||
while (all)
|
||||
if (xdiff || ydiff)
|
||||
{
|
||||
obj = all->obj;
|
||||
|
||||
/* undraw ! */
|
||||
draw_one_obj (obj);
|
||||
DAllObjs *all;
|
||||
|
||||
for (all = current_obj->obj_list; all; all = all->next)
|
||||
{
|
||||
Dobject *obj = all->obj;
|
||||
|
||||
/* undraw ! */
|
||||
draw_one_obj (obj);
|
||||
|
||||
update_pnts (obj, xdiff, ydiff);
|
||||
|
||||
/* Draw in new pos */
|
||||
draw_one_obj (obj);
|
||||
}
|
||||
|
||||
update_pnts (obj, xdiff, ydiff);
|
||||
|
||||
/* Draw in new pos */
|
||||
draw_one_obj (obj);
|
||||
|
||||
all = all->next;
|
||||
*move_all_pnt = *to_pnt;
|
||||
}
|
||||
|
||||
*move_all_pnt = *to_pnt; /* Structure copy */
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
do_move_obj (Dobject *obj,
|
||||
GdkPoint *to_pnt)
|
||||
|
@ -6596,17 +6453,16 @@ do_move_obj (Dobject *obj,
|
|||
|
||||
get_diffs (obj, &xdiff, &ydiff, to_pnt);
|
||||
|
||||
if (!xdiff && !ydiff)
|
||||
return;
|
||||
|
||||
/* undraw ! */
|
||||
draw_one_obj (obj);
|
||||
|
||||
update_pnts (obj, xdiff, ydiff);
|
||||
|
||||
/* Draw in new pos */
|
||||
draw_one_obj (obj);
|
||||
|
||||
if (xdiff || ydiff)
|
||||
{
|
||||
/* undraw ! */
|
||||
draw_one_obj (obj);
|
||||
|
||||
update_pnts (obj, xdiff, ydiff);
|
||||
|
||||
/* Draw in new pos */
|
||||
draw_one_obj (obj);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -6703,7 +6559,7 @@ d_copy_line (Dobject *obj)
|
|||
Dobject *nl;
|
||||
|
||||
if (!obj)
|
||||
return (NULL);
|
||||
return NULL;
|
||||
|
||||
g_assert (obj->type == LINE);
|
||||
|
||||
|
@ -6711,7 +6567,7 @@ d_copy_line (Dobject *obj)
|
|||
|
||||
nl->points->next = d_copy_dobjpoints (obj->points->next);
|
||||
|
||||
return (nl);
|
||||
return nl;
|
||||
}
|
||||
|
||||
/* Draw the given line -- */
|
||||
|
@ -6772,29 +6628,19 @@ d_paint_line (Dobject *obj)
|
|||
gint seg_count = 0;
|
||||
gint i = 0;
|
||||
|
||||
spnt = obj->points;
|
||||
for (spnt = obj->points; spnt; spnt = spnt->next)
|
||||
seg_count++;
|
||||
|
||||
/* count */
|
||||
|
||||
while (spnt)
|
||||
{
|
||||
seg_count++;
|
||||
spnt = spnt->next;
|
||||
}
|
||||
|
||||
spnt = obj->points;
|
||||
|
||||
if (!spnt || !seg_count)
|
||||
if (!seg_count)
|
||||
return; /* no-line */
|
||||
|
||||
line_pnts = g_new0 (gdouble, 2 * seg_count + 1);
|
||||
|
||||
/* Go around all the points drawing a line from one to the next */
|
||||
while (spnt)
|
||||
for (spnt = obj->points; spnt; spnt = spnt->next)
|
||||
{
|
||||
line_pnts[i++] = spnt->pnt.x;
|
||||
line_pnts[i++] = spnt->pnt.y;
|
||||
spnt = spnt->next;
|
||||
}
|
||||
|
||||
/* Reverse line if approp */
|
||||
|
@ -6827,7 +6673,6 @@ d_paint_line (Dobject *obj)
|
|||
g_free (line_pnts);
|
||||
}
|
||||
|
||||
|
||||
/* Create a new line object. starting at the x, y point might add styles
|
||||
* later.
|
||||
*/
|
||||
|
@ -6861,7 +6706,7 @@ d_new_line (gint x,
|
|||
nobj->paintfunc = d_paint_line;
|
||||
nobj->copyfunc = d_copy_line;
|
||||
|
||||
return (nobj);
|
||||
return nobj;
|
||||
}
|
||||
|
||||
/* You guessed it delete the object !*/
|
||||
|
@ -7252,10 +7097,6 @@ d_copy_circle (Dobject * obj)
|
|||
{
|
||||
Dobject *nc;
|
||||
|
||||
#if DEBUG
|
||||
printf ("Copy circle\n");
|
||||
#endif /*DEBUG*/
|
||||
|
||||
if (!obj)
|
||||
return NULL;
|
||||
|
||||
|
@ -7265,13 +7106,6 @@ d_copy_circle (Dobject * obj)
|
|||
|
||||
nc->points->next = d_copy_dobjpoints (obj->points->next);
|
||||
|
||||
#if DEBUG
|
||||
printf ("Circle (%x,%x) to (%x,%x)\n",
|
||||
nc->points->pnt.x, obj->points->pnt.y,
|
||||
nc->points->next->pnt.x, obj->points->next->pnt.y);
|
||||
printf ("Done copy\n");
|
||||
#endif /*DEBUG*/
|
||||
|
||||
return nc;
|
||||
}
|
||||
|
||||
|
@ -7287,10 +7121,6 @@ d_new_circle (gint x,
|
|||
/* Start point */
|
||||
npnt = g_new0 (DobjPoints, 1);
|
||||
|
||||
#if DEBUG
|
||||
printf ("New circle start at (%x,%x)\n", x, y);
|
||||
#endif /* DEBUG */
|
||||
|
||||
npnt->pnt.x = x;
|
||||
npnt->pnt.y = y;
|
||||
|
||||
|
@ -7405,13 +7235,8 @@ d_save_ellipse (Dobject *obj,
|
|||
|
||||
fprintf (to, "<ELLIPSE>\n");
|
||||
|
||||
while (spnt)
|
||||
{
|
||||
fprintf (to, "%d %d\n",
|
||||
spnt->pnt.x,
|
||||
spnt->pnt.y);
|
||||
spnt = spnt->next;
|
||||
}
|
||||
for (; spnt; spnt = spnt->next)
|
||||
fprintf (to, "%d %d\n", spnt->pnt.x, spnt->pnt.y);
|
||||
|
||||
fprintf (to, "</ELLIPSE>\n");
|
||||
}
|
||||
|
@ -7604,8 +7429,7 @@ d_paint_approx_ellipse (Dobject *obj)
|
|||
|
||||
if (first)
|
||||
{
|
||||
first_pnt.x = calc_pnt.x;
|
||||
first_pnt.y = calc_pnt.y;
|
||||
first_pnt = calc_pnt;
|
||||
first = 0;
|
||||
}
|
||||
}
|
||||
|
@ -7732,10 +7556,6 @@ d_copy_ellipse (Dobject * obj)
|
|||
{
|
||||
Dobject *nc;
|
||||
|
||||
#if DEBUG
|
||||
printf ("Copy ellipse\n");
|
||||
#endif /*DEBUG*/
|
||||
|
||||
if (!obj)
|
||||
return (NULL);
|
||||
|
||||
|
@ -7745,14 +7565,7 @@ d_copy_ellipse (Dobject * obj)
|
|||
|
||||
nc->points->next = d_copy_dobjpoints (obj->points->next);
|
||||
|
||||
#if DEBUG
|
||||
printf ("Ellipse (%x,%x) to (%x,%x)\n",
|
||||
nc->points->pnt.x, obj->points->pnt.y,
|
||||
nc->points->next->pnt.x, obj->points->next->pnt.y);
|
||||
printf ("Done copy\n");
|
||||
#endif /* DEBUG */
|
||||
|
||||
return (nc);
|
||||
return nc;
|
||||
}
|
||||
|
||||
static Dobject *
|
||||
|
@ -7913,7 +7726,6 @@ d_save_poly (Dobject * obj, FILE *to)
|
|||
fprintf (to, "<EXTRA>\n");
|
||||
fprintf (to, "%d\n</EXTRA>\n", obj->type_data);
|
||||
fprintf (to, "</POLY>\n");
|
||||
|
||||
}
|
||||
|
||||
/* Load a circle from the specified stream */
|
||||
|
@ -8597,7 +8409,7 @@ dist (gdouble x1,
|
|||
double s1 = x1 - x2;
|
||||
double s2 = y1 - y2;
|
||||
|
||||
return (sqrt ((s1*s1) + (s2*s2)));
|
||||
return sqrt (s1 * s1 + s2 * s2);
|
||||
}
|
||||
|
||||
/* Mid point of line returned */
|
||||
|
@ -8625,10 +8437,7 @@ line_grad (gdouble x1,
|
|||
dx = x1 - x2;
|
||||
dy = y1 - y2;
|
||||
|
||||
if (dx == 0.0)
|
||||
return (0.0); /* Infinite ! */
|
||||
|
||||
return (dy/dx);
|
||||
return (dx == 0.0) ? 0.0 : dy / dx;
|
||||
}
|
||||
|
||||
/* Constant of line that goes through x, y with grad lgrad */
|
||||
|
@ -8637,7 +8446,7 @@ line_cons (gdouble x,
|
|||
gdouble y,
|
||||
gdouble lgrad)
|
||||
{
|
||||
return (y - lgrad*x);
|
||||
return y - lgrad * x;
|
||||
}
|
||||
|
||||
/*Get grad & const for perpend. line to given points */
|
||||
|
@ -9145,8 +8954,7 @@ d_paint_arc (Dobject *obj)
|
|||
|
||||
if (first)
|
||||
{
|
||||
first_pnt.x = calc_pnt.x;
|
||||
first_pnt.y = calc_pnt.y;
|
||||
first_pnt = calc_pnt;
|
||||
first = 0;
|
||||
}
|
||||
}
|
||||
|
@ -9328,7 +9136,7 @@ static void
|
|||
d_save_star (Dobject *obj,
|
||||
FILE *to)
|
||||
{
|
||||
DobjPoints * spnt;
|
||||
DobjPoints *spnt;
|
||||
|
||||
spnt = obj->points;
|
||||
|
||||
|
@ -9671,8 +9479,7 @@ d_paint_star (Dobject *obj)
|
|||
|
||||
if (first)
|
||||
{
|
||||
first_pnt.x = calc_pnt.x;
|
||||
first_pnt.y = calc_pnt.y;
|
||||
first_pnt = calc_pnt;
|
||||
first = 0;
|
||||
}
|
||||
}
|
||||
|
@ -9734,7 +9541,7 @@ d_copy_star (Dobject * obj)
|
|||
printf ("Done star copy\n");
|
||||
#endif /* DEBUG */
|
||||
|
||||
return (np);
|
||||
return np;
|
||||
}
|
||||
|
||||
static Dobject *
|
||||
|
@ -9767,7 +9574,7 @@ d_new_star (gint x,
|
|||
nobj->paintfunc = d_paint_star;
|
||||
nobj->copyfunc = d_copy_star;
|
||||
|
||||
return (nobj);
|
||||
return nobj;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -10555,28 +10362,20 @@ d_draw_bezier (Dobject *obj)
|
|||
spnt = obj->points;
|
||||
|
||||
/* First count the number of points */
|
||||
for (spnt = obj->points; spnt; spnt = spnt->next)
|
||||
seg_count++;
|
||||
|
||||
/* count */
|
||||
while (spnt)
|
||||
{
|
||||
seg_count++;
|
||||
spnt = spnt->next;
|
||||
}
|
||||
|
||||
spnt = obj->points;
|
||||
|
||||
if (!spnt || !seg_count)
|
||||
if (!seg_count)
|
||||
return; /* no-line */
|
||||
|
||||
line_pnts = (fp_pnt) g_new0 (gdouble, 2 * seg_count + 1);
|
||||
|
||||
/* Go around all the points drawing a line from one to the next */
|
||||
while (spnt)
|
||||
for (spnt = obj->points; spnt; spnt = spnt->next)
|
||||
{
|
||||
draw_sqr (&spnt->pnt);
|
||||
line_pnts[i][0] = spnt->pnt.x;
|
||||
line_pnts[i++][1] = spnt->pnt.y;
|
||||
spnt = spnt->next;
|
||||
}
|
||||
|
||||
/* Generate an array of doubles which are the control points */
|
||||
|
@ -10603,33 +10402,22 @@ d_paint_bezier (Dobject *obj)
|
|||
gdouble (*bz_line_pnts)[2];
|
||||
DobjPoints *spnt;
|
||||
gint seg_count = 0;
|
||||
|
||||
gint i = 0;
|
||||
|
||||
spnt = obj->points;
|
||||
|
||||
/* First count the number of points */
|
||||
for (spnt = obj->points; spnt; spnt = spnt->next)
|
||||
seg_count++;
|
||||
|
||||
/* count */
|
||||
while (spnt)
|
||||
{
|
||||
seg_count++;
|
||||
spnt = spnt->next;
|
||||
}
|
||||
|
||||
spnt = obj->points;
|
||||
|
||||
if (!spnt || !seg_count)
|
||||
if (!seg_count)
|
||||
return; /* no-line */
|
||||
|
||||
bz_line_pnts = (fp_pnt) g_new0 (gdouble, 2 * seg_count + 1);
|
||||
|
||||
/* Go around all the points drawing a line from one to the next */
|
||||
while (spnt)
|
||||
for (spnt = obj->points; spnt; spnt = spnt->next)
|
||||
{
|
||||
bz_line_pnts[i][0] = spnt->pnt.x;
|
||||
bz_line_pnts[i++][1] = spnt->pnt.y;
|
||||
spnt = spnt->next;
|
||||
}
|
||||
|
||||
fp_pnt_start ();
|
||||
|
@ -10723,7 +10511,7 @@ d_new_bezier (gint x, gint y)
|
|||
nobj->paintfunc = d_paint_bezier;
|
||||
nobj->copyfunc = d_copy_bezier;
|
||||
|
||||
return (nobj);
|
||||
return nobj;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue