diff --git a/ChangeLog b/ChangeLog index 25346b079f..935a05bf0d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-07-25 Shlomi Fish + + * plug-ins/gimpressionist/: placed all the orientation map-related + public functions in orientmap.h. Now we're freeing the PPM's that it + is allocating by a call to orientation_map_free_resources(). + 2004-07-26 Michael Natterer * app/tools/gimpeditselectiontool.[ch]: renamed init_edit_selection() diff --git a/plug-ins/gimpressionist/Makefile.am b/plug-ins/gimpressionist/Makefile.am index 62ac9c6183..36bbb9f594 100644 --- a/plug-ins/gimpressionist/Makefile.am +++ b/plug-ins/gimpressionist/Makefile.am @@ -40,6 +40,7 @@ gimpressionist_sources = \ infile.h \ orientation.h \ orientation.c \ + orientmap.h \ orientmap.c \ paper.c \ paper.h \ diff --git a/plug-ins/gimpressionist/brush.c b/plug-ins/gimpressionist/brush.c index 2fff204e32..d44a20ff07 100644 --- a/plug-ins/gimpressionist/brush.c +++ b/plug-ins/gimpressionist/brush.c @@ -204,7 +204,7 @@ static void savebrush (GtkWidget *wg, gpointer data) { - static GtkWidget *dialog = NULL; + GtkWidget *dialog = NULL; GList *thispath = parsepath (); gchar *path; diff --git a/plug-ins/gimpressionist/gimp.c b/plug-ins/gimpressionist/gimp.c index ea9b736315..f6f23bddb0 100644 --- a/plug-ins/gimpressionist/gimp.c +++ b/plug-ins/gimpressionist/gimp.c @@ -13,6 +13,7 @@ #include "brush.h" #include "presets.h" #include "random.h" +#include "orientmap.h" #include "libgimp/stdplugins-intl.h" @@ -200,6 +201,7 @@ run (const gchar *name, preview_free_resources(); brush_free(); preset_free(); + orientation_map_free_resources(); values[0].data.d_status = status; diff --git a/plug-ins/gimpressionist/gimpressionist.h b/plug-ins/gimpressionist/gimpressionist.h index 1da22bd2c5..be4bf27972 100644 --- a/plug-ins/gimpressionist/gimpressionist.h +++ b/plug-ins/gimpressionist/gimpressionist.h @@ -133,8 +133,6 @@ GtkWidget *create_one_column_list (GtkWidget *parent, void brush_reload (const gchar *fn, struct ppm *p); -void create_orientmap_dialog (void); -void update_orientmap_dialog (void); double get_direction (double x, double y, int from); void create_sizemap_dialog (void); diff --git a/plug-ins/gimpressionist/orientation.c b/plug-ins/gimpressionist/orientation.c index 333a91f595..9189b79355 100644 --- a/plug-ins/gimpressionist/orientation.c +++ b/plug-ins/gimpressionist/orientation.c @@ -7,6 +7,7 @@ #include "gimpressionist.h" #include "orientation.h" +#include "orientmap.h" #include "libgimp/stdplugins-intl.h" diff --git a/plug-ins/gimpressionist/orientation.h b/plug-ins/gimpressionist/orientation.h index ad5e2b325f..78cb78b3c9 100644 --- a/plug-ins/gimpressionist/orientation.h +++ b/plug-ins/gimpressionist/orientation.h @@ -18,5 +18,5 @@ enum ORIENTATION_ENUM void create_orientationpage (GtkNotebook *); void orientation_restore (void); int orientation_type_input (int in); - + #endif /* #ifndef __ORIENTATION_H */ diff --git a/plug-ins/gimpressionist/orientmap.c b/plug-ins/gimpressionist/orientmap.c index 44565e1575..39106a774b 100644 --- a/plug-ins/gimpressionist/orientmap.c +++ b/plug-ins/gimpressionist/orientmap.c @@ -16,6 +16,8 @@ #include "preview.h" +#include "orientmap.h" + #include "libgimp/stdplugins-intl.h" #define NUMVECTYPES 4 @@ -124,18 +126,19 @@ double get_direction (double x, double y, int from) return 90-(gimp_rad_to_deg(atan2(dy,dx))+angoff); } +static ppm_t update_om_preview_nbuffer = {0,0,NULL}; + static void update_orient_map_preview_prev (void) { int x, y; - static ppm_t nbuffer = {0,0,NULL}; guchar black[3] = {0,0,0}; guchar gray[3] = {120,120,120}; guchar white[3] = {255,255,255}; - if (!PPM_IS_INITED (&nbuffer)) - ppm_new (&nbuffer,OMWIDTH,OMHEIGHT); + if (!PPM_IS_INITED (&update_om_preview_nbuffer)) + ppm_new (&update_om_preview_nbuffer,OMWIDTH,OMHEIGHT); - fill (&nbuffer, black); + fill (&update_om_preview_nbuffer, black); for (y = 6; y < OMHEIGHT-4; y += 10) for (x = 6; x < OMWIDTH-4; x += 10) @@ -143,13 +146,15 @@ static void update_orient_map_preview_prev (void) double dir = gimp_deg_to_rad(get_direction(x/(double)OMWIDTH,y/(double)OMHEIGHT,0)); double xo = sin(dir)*4.0; double yo = cos(dir)*4.0; - ppm_drawline (&nbuffer, x-xo, y-yo, x+xo, y+yo, gray); - ppm_put_rgb (&nbuffer, x-xo, y-yo, white); + ppm_drawline (&update_om_preview_nbuffer, x-xo, y-yo, x+xo, + y+yo, gray); + ppm_put_rgb (&update_om_preview_nbuffer, x-xo, y-yo, white); } for (y = 0; y < OMHEIGHT; y++) gtk_preview_draw_row (GTK_PREVIEW (orient_map_preview_prev), - (guchar *) nbuffer.col + y * OMWIDTH * 3, 0, y, + (guchar *) update_om_preview_nbuffer.col + + y * OMWIDTH * 3, 0, y, OMWIDTH); gtk_widget_queue_draw (orient_map_preview_prev); @@ -162,10 +167,11 @@ static void update_orient_map_preview_prev (void) static int selectedvector = 0; +static ppm_t update_vector_preview_backup = {0,0,NULL}; +static ppm_t update_vector_preview_buffer = {0,0,NULL}; + static void update_vector_prev(void) { - static ppm_t backup = {0,0,NULL}; - static ppm_t buffer = {0,0,NULL}; static int ok = 0; int i, x, y; double dir, xo, yo; @@ -181,13 +187,14 @@ static void update_vector_prev(void) val = 0.5; if (!ok || (val != last_val)) { - infile_copy_to_ppm (&backup); - ppm_apply_brightness (&backup, val, 1,1,1); - if ((backup.width != OMWIDTH) || (backup.height != OMHEIGHT)) - resize_fast (&backup, OMWIDTH, OMHEIGHT); + infile_copy_to_ppm (&update_vector_preview_backup); + ppm_apply_brightness (&update_vector_preview_backup, val, 1,1,1); + if ((update_vector_preview_backup.width != OMWIDTH) || + (update_vector_preview_backup.height != OMHEIGHT)) + resize_fast (&update_vector_preview_backup, OMWIDTH, OMHEIGHT); ok = 1; } - ppm_copy (&backup, &buffer); + ppm_copy (&update_vector_preview_backup, &update_vector_preview_buffer); for(i = 0; i < num_vectors; i++) { double s; @@ -198,20 +205,29 @@ static void update_vector_prev(void) xo = sin(dir)*(6.0+100*s); yo = cos(dir)*(6.0+100*s); if(i == selectedvector) - ppm_drawline (&buffer, x-xo, y-yo, x+xo, y+yo, red); + ppm_drawline (&update_vector_preview_buffer, x-xo, y-yo, x+xo, + y+yo, red); else - ppm_drawline (&buffer, x-xo, y-yo, x+xo, y+yo, gray); - ppm_put_rgb (&buffer, x-xo, y-yo, white); + ppm_drawline (&update_vector_preview_buffer, x-xo, y-yo, + x+xo, y+yo, gray); + ppm_put_rgb (&update_vector_preview_buffer, x-xo, y-yo, white); } for (y = 0; y < OMHEIGHT; y++) gtk_preview_draw_row (GTK_PREVIEW (vector_preview), - (guchar *) buffer.col + y * OMWIDTH * 3, + (guchar *) update_vector_preview_buffer.col + + y * OMWIDTH * 3, 0, y, OMWIDTH); gtk_widget_queue_draw (vector_preview); } +void orientation_map_free_resources() +{ + ppm_kill(&update_om_preview_nbuffer); + ppm_kill(&update_vector_preview_backup); + ppm_kill(&update_vector_preview_buffer); +} static gboolean adjignore = FALSE; static void update_slides(void) diff --git a/plug-ins/gimpressionist/orientmap.h b/plug-ins/gimpressionist/orientmap.h new file mode 100644 index 0000000000..2410198bb6 --- /dev/null +++ b/plug-ins/gimpressionist/orientmap.h @@ -0,0 +1,7 @@ +#ifndef __ORIENTMAP_H +#define __ORIENTMAP_H +void create_orientmap_dialog (void); +void update_orientmap_dialog (void); +void orientation_map_free_resources(void); + +#endif