diff --git a/ChangeLog b/ChangeLog index ebcf788bb5..47fa0619cb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2004-07-25 Shlomi Fish + + * plug-ins/gimpressionist/: converted checks for initialization of + ppm's done by checking the "col" buffer, to macro calls. + 2004-07-25 Shlomi Fish * plug-ins/gimpressionist/: fixed bug #148088: ("Gimpressioinst crashes if diff --git a/plug-ins/gimpressionist/brush.c b/plug-ins/gimpressionist/brush.c index fc62d90606..2fff204e32 100644 --- a/plug-ins/gimpressionist/brush.c +++ b/plug-ins/gimpressionist/brush.c @@ -120,8 +120,7 @@ brushdmenuselect (GtkWidget *widget, has_alpha = gimp_drawable_has_alpha (drawable->drawable_id); alpha = (has_alpha) ? bpp - 1 : bpp; - if(brushppm.col) - ppm_kill (&brushppm); + ppm_kill (&brushppm); ppm_new (&brushppm, x2-x1, y2-y1); p = &brushppm; @@ -169,8 +168,7 @@ brushdmenuselect (GtkWidget *widget, #if 0 void dummybrushdmenuselect(GtkWidget *w, gpointer data) { - if(brushppm.col) - ppm_kill (&brushppm); + ppm_kill (&brushppm); ppm_new (&brushppm, 10,10); brush_from_file = 0; update_brush_preview (NULL); @@ -210,7 +208,7 @@ savebrush (GtkWidget *wg, GList *thispath = parsepath (); gchar *path; - if (! brushppm.col) + if (! PPM_IS_INITED (&brushppm)) { g_message( _("Can only save drawables!")); return; @@ -314,7 +312,7 @@ update_brush_preview (const gchar *fn) if (brush_from_file) brush_reload (fn, &p); - else if (brushppm.col) + else if (PPM_IS_INITED (&brushppm)) ppm_copy (&brushppm, &p); set_colorbrushes (fn); diff --git a/plug-ins/gimpressionist/gimp.c b/plug-ins/gimpressionist/gimp.c index ae06282371..ea9b736315 100644 --- a/plug-ins/gimpressionist/gimp.c +++ b/plug-ins/gimpressionist/gimp.c @@ -40,7 +40,7 @@ static ppm_t inalpha = {0,0,NULL}; void infile_copy_to_ppm(ppm_t * p) { - if(!infile.col) + if (!PPM_IS_INITED (&infile)) grabarea(); #if 0 updatepreview (NULL, (void *)2); /* Force grabarea() */ @@ -311,7 +311,7 @@ static void gimpressionist_main(void) gimp_progress_init (_("Painting...")); - if(!infile.col) { + if (!PPM_IS_INITED (&infile)) { grabarea(); } diff --git a/plug-ins/gimpressionist/orientmap.c b/plug-ins/gimpressionist/orientmap.c index c670bc312b..44565e1575 100644 --- a/plug-ins/gimpressionist/orientmap.c +++ b/plug-ins/gimpressionist/orientmap.c @@ -132,9 +132,9 @@ static void update_orient_map_preview_prev (void) guchar gray[3] = {120,120,120}; guchar white[3] = {255,255,255}; - if (!nbuffer.col) { + if (!PPM_IS_INITED (&nbuffer)) ppm_new (&nbuffer,OMWIDTH,OMHEIGHT); - } + fill (&nbuffer, black); for (y = 6; y < OMHEIGHT-4; y += 10) diff --git a/plug-ins/gimpressionist/ppmtool.c b/plug-ins/gimpressionist/ppmtool.c index 854e952bbd..d2eb140e17 100644 --- a/plug-ins/gimpressionist/ppmtool.c +++ b/plug-ins/gimpressionist/ppmtool.c @@ -217,7 +217,7 @@ void load_gimp_brush(const gchar *fn, ppm_t *p) int x, y; f = fopen_from_search_path(fn, "rb"); - if(p->col) ppm_kill(p); + ppm_kill(p); if(!f) { fprintf(stderr, "load_gimp_brush: Unable to open file \"%s\"!\n", fn); @@ -258,7 +258,7 @@ void ppm_load(const char *fn, ppm_t *p) f = fopen_from_search_path(fn, "rb"); - if(p->col) ppm_kill(p); + ppm_kill(p); if(!f) { fprintf(stderr, "ppm_load: Unable to open file \"%s\"!\n", fn); @@ -323,8 +323,7 @@ void fill(ppm_t *p, guchar *c) void ppm_copy(ppm_t *s, ppm_t *p) { - if(p->col) - ppm_kill(p); + ppm_kill(p); p->width = s->width; p->height = s->height; p->col = g_memdup(s->col, p->width * 3 * p->height); diff --git a/plug-ins/gimpressionist/ppmtool.h b/plug-ins/gimpressionist/ppmtool.h index 35be755a97..824bc357e8 100644 --- a/plug-ins/gimpressionist/ppmtool.h +++ b/plug-ins/gimpressionist/ppmtool.h @@ -37,5 +37,7 @@ void blur(ppm_t *p, int xrad, int yrad); void mkgrayplasma(ppm_t *p, float turb); +#define PPM_IS_INITED(ppm_ptr) ((ppm_ptr)->col != NULL) + #endif /* #ifndef __PPM_TOOL_H */ diff --git a/plug-ins/gimpressionist/preview.c b/plug-ins/gimpressionist/preview.c index 1b9bcd7f4f..4a8814feb2 100644 --- a/plug-ins/gimpressionist/preview.c +++ b/plug-ins/gimpressionist/preview.c @@ -77,7 +77,7 @@ updatepreview (GtkWidget *wg, gpointer d) #if 0 guchar buf[PREVIEWSIZE*3]; - if(!infile.col && d) + if (!PPM_IS_INITED (&infile) && d) grabarea(); #endif @@ -87,7 +87,7 @@ updatepreview (GtkWidget *wg, gpointer d) * -- Shlomi Fish * */ #if 0 - if(!infile.col && !d) { + if (!PPM_IS_INITED (&infile) && !d) { memset(buf, 0, sizeof(buf)); for(i = 0; i < PREVIEWSIZE; i++) @@ -98,7 +98,7 @@ updatepreview (GtkWidget *wg, gpointer d) else #endif { - if(!backup_ppm.col) + if (!PPM_IS_INITED (&backup_ppm)) { infile_copy_to_ppm (&backup_ppm); if((backup_ppm.width != PREVIEWSIZE) || (backup_ppm.height != PREVIEWSIZE)) @@ -110,7 +110,7 @@ updatepreview (GtkWidget *wg, gpointer d) resize_fast(&alpha_backup_ppm, PREVIEWSIZE, PREVIEWSIZE); } } - if(!preview_ppm.col) + if (!PPM_IS_INITED (&preview_ppm)) { ppm_copy(&backup_ppm, &preview_ppm); if(img_has_alpha) diff --git a/plug-ins/gimpressionist/repaint.c b/plug-ins/gimpressionist/repaint.c index f6dc1e7dfe..04742e2f2d 100644 --- a/plug-ins/gimpressionist/repaint.c +++ b/plug-ins/gimpressionist/repaint.c @@ -859,7 +859,7 @@ void repaint(ppm_t *p, ppm_t *a) if(relief > 0.001) { scale = runningvals.paperscale / 100.0; - if(paper_ppm.col) { + if (PPM_IS_INITED (&paper_ppm)) { tmp = paper_ppm; paper_ppm.col = NULL; } else { diff --git a/plug-ins/gimpressionist/sizemap.c b/plug-ins/gimpressionist/sizemap.c index d3fef899ee..867626648c 100644 --- a/plug-ins/gimpressionist/sizemap.c +++ b/plug-ins/gimpressionist/sizemap.c @@ -59,7 +59,7 @@ static void updatesmpreviewprev(void) guchar black[3] = {0,0,0}; guchar gray[3] = {120,120,120}; - if (!nsbuffer.col) + if (! PPM_IS_INITED (&nsbuffer)) { ppm_new(&nsbuffer,OMWIDTH,OMHEIGHT); } @@ -108,7 +108,7 @@ static void updatesmvectorprev(void) if(!ok || (val != last_val)) { #if 0 - if(!infile.col) + if (!PPM_IS_INITED (&infile)) updatepreview (NULL, (void *)2); /* Force grabarea() */ ppm_copy(&infile, &backup); #else