From 2f5a1d8a7bdf2d0df80764a1f5e1b938e084af41 Mon Sep 17 00:00:00 2001 From: Shlomi Fish Date: Thu, 15 Jul 2004 11:58:47 +0000 Subject: [PATCH] normalized the ppmtools.c and ppmtool.h identifiers. Also fixed some (but * plug-ins/gimpressionist/: normalized the ppmtools.c and ppmtool.h identifiers. Also fixed some (but not all) of the syntax. --- ChangeLog | 6 ++ plug-ins/gimpressionist/brush.c | 34 +++++------ plug-ins/gimpressionist/gimp.c | 8 +-- plug-ins/gimpressionist/orientmap.c | 32 +++++----- plug-ins/gimpressionist/paper.c | 4 +- plug-ins/gimpressionist/ppmtool.c | 93 +++++++++++++++-------------- plug-ins/gimpressionist/ppmtool.h | 24 ++++---- plug-ins/gimpressionist/preview.c | 16 ++--- plug-ins/gimpressionist/repaint.c | 78 ++++++++++++------------ plug-ins/gimpressionist/sizemap.c | 26 ++++---- 10 files changed, 165 insertions(+), 156 deletions(-) diff --git a/ChangeLog b/ChangeLog index 77792cda15..aac2a6edb6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2004-07-15 Shlomi Fish + + * plug-ins/gimpressionist/: normalized the ppmtools.c and + ppmtool.h identifiers. Also fixed some (but not all) of the + syntax. + 2004-07-15 Philip Lafleur * plug-ins/winicon/icoload.c: diff --git a/plug-ins/gimpressionist/brush.c b/plug-ins/gimpressionist/brush.c index b3d1cb4e34..fc62d90606 100644 --- a/plug-ins/gimpressionist/brush.c +++ b/plug-ins/gimpressionist/brush.c @@ -60,16 +60,16 @@ void brush_free(void) void brush_get_selected (ppm_t *p) { if(brush_from_file) - brush_reload(pcvals.selectedbrush, p); + brush_reload (pcvals.selectedbrush, p); else - copyppm(&brushppm, p); + ppm_copy (&brushppm, p); } static void update_brush_preview (const char *fn); static gboolean file_is_color (const char *fn) { - return fn && strstr(fn, ".ppm"); + return fn && strstr (fn, ".ppm"); } void set_colorbrushes (const gchar *fn) @@ -121,8 +121,8 @@ brushdmenuselect (GtkWidget *widget, alpha = (has_alpha) ? bpp - 1 : bpp; if(brushppm.col) - killppm(&brushppm); - newppm(&brushppm, x2-x1, y2-y1); + ppm_kill (&brushppm); + ppm_new (&brushppm, x2-x1, y2-y1); p = &brushppm; rowstride = p->width * 3; @@ -170,10 +170,10 @@ brushdmenuselect (GtkWidget *widget, void dummybrushdmenuselect(GtkWidget *w, gpointer data) { if(brushppm.col) - killppm(&brushppm); - newppm(&brushppm, 10,10); + ppm_kill (&brushppm); + ppm_new (&brushppm, 10,10); brush_from_file = 0; - update_brush_preview(NULL); + update_brush_preview (NULL); } #endif @@ -193,7 +193,7 @@ savebrush_response (GtkWidget *dialog, { gchar *name = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); - saveppm (&brushppm, name); + ppm_save (&brushppm, name); brushlistrefresh (); g_free (name); @@ -264,7 +264,7 @@ brush_reload (const gchar *fn, if (fn == NULL) { - killppm(&cache); + ppm_kill (&cache); lastfn[0] = '\0'; return; } @@ -272,11 +272,11 @@ brush_reload (const gchar *fn, if (strcmp(fn, lastfn)) { g_strlcpy (lastfn, fn, sizeof (lastfn)); - killppm(&cache); - loadppm (fn, &cache); + ppm_kill (&cache); + ppm_load (fn, &cache); } - copyppm(&cache, p); - set_colorbrushes(fn); + ppm_copy (&cache, p); + set_colorbrushes (fn); } static void @@ -313,9 +313,9 @@ update_brush_preview (const gchar *fn) int newheight; if (brush_from_file) - brush_reload(fn, &p); + brush_reload (fn, &p); else if (brushppm.col) - copyppm(&brushppm, &p); + ppm_copy (&brushppm, &p); set_colorbrushes (fn); @@ -340,7 +340,7 @@ update_brush_preview (const gchar *fn) buf[j] = gammatable[p.col[k + j * 3]]; gtk_preview_draw_row (GTK_PREVIEW (brush_preview), buf, 0, i, 100); } - killppm(&p); + ppm_kill(&p); } gtk_widget_queue_draw (brush_preview); } diff --git a/plug-ins/gimpressionist/gimp.c b/plug-ins/gimpressionist/gimp.c index 7af69f6aa2..ae06282371 100644 --- a/plug-ins/gimpressionist/gimp.c +++ b/plug-ins/gimpressionist/gimp.c @@ -45,12 +45,12 @@ void infile_copy_to_ppm(ppm_t * p) #if 0 updatepreview (NULL, (void *)2); /* Force grabarea() */ #endif - copyppm(&infile, p); + ppm_copy (&infile, p); } void infile_copy_alpha_to_ppm(ppm_t * p) { - copyppm(&inalpha, p); + ppm_copy (&inalpha, p); } MAIN() @@ -224,10 +224,10 @@ void grabarea(void) has_alpha = gimp_drawable_has_alpha (drawable->drawable_id); alpha = (has_alpha) ? bpp - 1 : bpp; - newppm(&infile, x2-x1, y2-y1); + ppm_new (&infile, x2-x1, y2-y1); p = &infile; if(has_alpha) { - newppm(&inalpha, x2-x1, y2-y1); + ppm_new (&inalpha, x2-x1, y2-y1); } rowstride = p->width * 3; diff --git a/plug-ins/gimpressionist/orientmap.c b/plug-ins/gimpressionist/orientmap.c index 8651e1eb4c..394247b871 100644 --- a/plug-ins/gimpressionist/orientmap.c +++ b/plug-ins/gimpressionist/orientmap.c @@ -133,17 +133,17 @@ static void updateompreviewprev(void) guchar white[3] = {255,255,255}; if(!nbuffer.col) { - newppm(&nbuffer,OMWIDTH,OMHEIGHT); + ppm_new (&nbuffer,OMWIDTH,OMHEIGHT); } - fill(&nbuffer, black); + fill (&nbuffer, black); for(y = 6; y < OMHEIGHT-4; y += 10) for(x = 6; x < OMWIDTH-4; x += 10) { double dir = gimp_deg_to_rad(getdir(x/(double)OMWIDTH,y/(double)OMHEIGHT,0)); double xo = sin(dir)*4.0; double yo = cos(dir)*4.0; - drawline(&nbuffer, x-xo, y-yo, x+xo, y+yo, gray); - putrgb(&nbuffer, x-xo, y-yo, white); + ppm_drawline (&nbuffer, x-xo, y-yo, x+xo, y+yo, gray); + ppm_put_rgb (&nbuffer, x-xo, y-yo, white); } for (y = 0; y < OMHEIGHT; y++) @@ -174,17 +174,19 @@ static void updatevectorprev(void) guchar red[3] = {255,0,0}; guchar white[3] = {255,255,255}; - if(vectprevbrightadjust) val = 1.0 - GTK_ADJUSTMENT(vectprevbrightadjust)->value / 100.0; - else val = 0.5; + if (vectprevbrightadjust) + val = 1.0 - GTK_ADJUSTMENT(vectprevbrightadjust)->value / 100.0; + else + val = 0.5; - if(!ok || (val != lastval)) { - infile_copy_to_ppm(&backup); - ppmbrightness(&backup, val, 1,1,1); - if((backup.width != OMWIDTH) || (backup.height != OMHEIGHT)) - resize_fast(&backup, OMWIDTH, OMHEIGHT); + if (!ok || (val != lastval)) { + 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); ok = 1; } - copyppm(&backup, &buffer); + ppm_copy (&backup, &buffer); for(i = 0; i < numvect; i++) { double s; @@ -195,10 +197,10 @@ static void updatevectorprev(void) xo = sin(dir)*(6.0+100*s); yo = cos(dir)*(6.0+100*s); if(i == selectedvector) - drawline(&buffer, x-xo, y-yo, x+xo, y+yo, red); + ppm_drawline (&buffer, x-xo, y-yo, x+xo, y+yo, red); else - drawline(&buffer, x-xo, y-yo, x+xo, y+yo, gray); - putrgb(&buffer, x-xo, y-yo, white); + ppm_drawline (&buffer, x-xo, y-yo, x+xo, y+yo, gray); + ppm_put_rgb(&buffer, x-xo, y-yo, white); } for (y = 0; y < OMHEIGHT; y++) diff --git a/plug-ins/gimpressionist/paper.c b/plug-ins/gimpressionist/paper.c index a25bf3a8cd..3afc28f8b9 100644 --- a/plug-ins/gimpressionist/paper.c +++ b/plug-ins/gimpressionist/paper.c @@ -34,7 +34,7 @@ static void updatepaperprev(void) gdouble sc; ppm_t p = {0,0,NULL}; - loadppm(pcvals.selectedpaper, &p); + ppm_load(pcvals.selectedpaper, &p); sc = p.width > p.height ? p.width : p.height; sc = 100.0 / sc; resize(&p, p.width*sc,p.height*sc); @@ -50,7 +50,7 @@ static void updatepaperprev(void) } gtk_preview_draw_row (GTK_PREVIEW (paperprev), buf, 0, i, 100); } - killppm(&p); + ppm_kill(&p); gtk_widget_queue_draw (paperprev); } diff --git a/plug-ins/gimpressionist/ppmtool.c b/plug-ins/gimpressionist/ppmtool.c index a5ec33d58d..e00284a89b 100644 --- a/plug-ins/gimpressionist/ppmtool.c +++ b/plug-ins/gimpressionist/ppmtool.c @@ -34,14 +34,14 @@ void fatal(char *s) exit(1); } -void killppm(ppm_t *p) +void ppm_kill(ppm_t *p) { g_free(p->col); p->col = NULL; p->height = p->width = 0; } -void newppm(ppm_t *p, int xs, int ys) +void ppm_new(ppm_t *p, int xs, int ys) { int x; guchar bgcol[3] = {0,0,0}; @@ -61,7 +61,7 @@ void newppm(ppm_t *p, int xs, int ys) } } -void getrgb(ppm_t *s, float xo, float yo, guchar *d) +void get_rgb(ppm_t *s, float xo, float yo, guchar *d) { float ix, iy; int x1, x2, y1, y2; @@ -145,14 +145,14 @@ void resize(ppm_t *p, int nx, int ny) float ys = p->height/(float)ny; ppm_t tmp = {0,0,NULL}; - newppm(&tmp, nx, ny); + ppm_new(&tmp, nx, ny); for(y = 0; y < ny; y++) { guchar *row = tmp.col + y * tmp.width * 3; for(x = 0; x < nx; x++) { - getrgb(p, x*xs, y*ys, &row[x*3]); + get_rgb(p, x*xs, y*ys, &row[x*3]); } } - killppm(p); + ppm_kill(p); p->width = tmp.width; p->height = tmp.height; p->col = tmp.col; @@ -170,14 +170,14 @@ void resize_fast(ppm_t *p, int nx, int ny) float ys = p->height/(float)ny; ppm_t tmp = {0,0,NULL}; - newppm(&tmp, nx, ny); + ppm_new(&tmp, nx, ny); for(y = 0; y < ny; y++) { for(x = 0; x < nx; x++) { int rx = x*xs, ry = y*ys; memcpy(&tmp.col[y*tmp.width*3+x*3], &p->col[ry*p->width*3+rx*3], 3); } } - killppm(p); + ppm_kill(p); p->width = tmp.width; p->height = tmp.height; p->col = tmp.col; @@ -215,7 +215,7 @@ static FILE * fopen_from_search_path(const gchar * fn, const char * mode) return f; } -void loadgbr(const gchar *fn, ppm_t *p) +void load_gimp_brush(const gchar *fn, ppm_t *p) { FILE *f; struct _BrushHeader hdr; @@ -223,11 +223,11 @@ void loadgbr(const gchar *fn, ppm_t *p) int x, y; f = fopen_from_search_path(fn, "rb"); - if(p->col) killppm(p); + if(p->col) ppm_kill(p); if(!f) { - fprintf(stderr, "loadgbr: Unable to open file \"%s\"!\n", fn); - newppm(p, 10,10); + fprintf(stderr, "load_gimp_brush: Unable to open file \"%s\"!\n", fn); + ppm_new(p, 10,10); return; } @@ -236,7 +236,7 @@ void loadgbr(const gchar *fn, ppm_t *p) for(x = 0; x < 7; x++) msb2lsb(&((unsigned int *)&hdr)[x]); - newppm(p, hdr.width, hdr.height); + ppm_new(p, hdr.width, hdr.height); ptr = g_malloc(hdr.width); fseek(f, hdr.header_size, SEEK_SET); @@ -251,24 +251,24 @@ void loadgbr(const gchar *fn, ppm_t *p) free(ptr); } -void loadppm(const char *fn, ppm_t *p) +void ppm_load(const char *fn, ppm_t *p) { char line[200]; int y, pgm = 0; FILE *f; if(!strcmp(&fn[strlen(fn)-4], ".gbr")) { - loadgbr(fn, p); + load_gimp_brush(fn, p); return; } f = fopen_from_search_path(fn, "rb"); - if(p->col) killppm(p); + if(p->col) ppm_kill(p); if(!f) { - fprintf(stderr, "loadppm: Unable to open file \"%s\"!\n", fn); - newppm(p, 10,10); + fprintf(stderr, "ppm_load: Unable to open file \"%s\"!\n", fn); + ppm_new(p, 10,10); return; #if 0 fatal("Aborting!"); @@ -279,8 +279,8 @@ void loadppm(const char *fn, ppm_t *p) if(strcmp(line, "P6")) { if(strcmp(line, "P5")) { fclose(f); - printf( "loadppm: File \"%s\" not PPM/PGM? (line=\"%s\")%c\n", fn, line, 7); - newppm(p, 10,10); + printf( "ppm_load: File \"%s\" not PPM/PGM? (line=\"%s\")%c\n", fn, line, 7); + ppm_new(p, 10,10); return; #if 0 fatal("Aborting!"); @@ -293,8 +293,8 @@ void loadppm(const char *fn, ppm_t *p) p->height = atoi(strchr(line, ' ')+1); readline(f, line, 200); if(strcmp(line, "255")) { - printf ("loadppm: File \"%s\" not valid PPM/PGM? (line=\"%s\")%c\n", fn, line, 7); - newppm(p, 10,10); + printf ("ppm_load: File \"%s\" not valid PPM/PGM? (line=\"%s\")%c\n", fn, line, 7); + ppm_new(p, 10,10); return; #if 0 fatal("Aborting!"); @@ -336,16 +336,16 @@ void fill(ppm_t *p, guchar *c) } } -void copyppm(ppm_t *s, ppm_t *p) +void ppm_copy(ppm_t *s, ppm_t *p) { if(p->col) - killppm(p); + ppm_kill(p); p->width = s->width; p->height = s->height; p->col = g_memdup(s->col, p->width * 3 * p->height); } -void freerotate(ppm_t *p, double amount) +void free_rotate(ppm_t *p, double amount) { int x, y; double nx, ny; @@ -357,7 +357,7 @@ void freerotate(ppm_t *p, double amount) a = p->width/(float)p->height; R = p->widthheight?p->width/2:p->height/2; - newppm(&tmp, p->width, p->height); + ppm_new(&tmp, p->width, p->height); for(y = 0; y < p->height; y++) { for(x = 0; x < p->width; x++) { double r, d; @@ -369,10 +369,10 @@ void freerotate(ppm_t *p, double amount) nx = (p->width/2.0 + cos(d-f) * r); ny = (p->height/2.0 + sin(d-f) * r); - getrgb(p, nx, ny, tmp.col + y*rowstride+x*3); + get_rgb(p, nx, ny, tmp.col + y*rowstride+x*3); } } - killppm(p); + ppm_kill(p); p->width = tmp.width; p->height = tmp.height; p->col = tmp.col; @@ -385,13 +385,13 @@ void crop(ppm_t *p, int lx, int ly, int hx, int hy) int srowstride = p->width * 3; int drowstride; - newppm(&tmp, hx-lx, hy-ly); + ppm_new(&tmp, hx-lx, hy-ly); drowstride = tmp.width * 3; for(y = ly; y < hy; y++) for(x = lx; x < hx; x++) memcpy(&tmp.col[(y-ly)*drowstride+(x-lx)*3], &p->col[y*srowstride+x*3], 3); - killppm(p); + ppm_kill(p); p->col = tmp.col; p->width = tmp.width; p->height = tmp.height; @@ -468,13 +468,13 @@ void autocrop(ppm_t *p, int room) hx += room; if(hx>=p->width) hx = p->width-1; hy += room; if(hy>=p->height) hy = p->height-1; - newppm(&tmp, hx-lx, hy-ly); + ppm_new(&tmp, hx-lx, hy-ly); drowstride = tmp.width * 3; for(y = ly; y < hy; y++) for(x = lx; x < hx; x++) memcpy(&tmp.col[(y-ly)*drowstride+(x-lx)*3], &p->col[y*rowstride+x*3], 3); - killppm(p); + ppm_kill(p); p->col = tmp.col; p->width = tmp.width; p->height = tmp.height; @@ -485,7 +485,7 @@ void ppm_pad(ppm_t *p, int left,int right, int top, int bottom, guchar *bg) int x, y; ppm_t tmp = {0,0,NULL}; - newppm(&tmp, p->width+left+right, p->height+top+bottom); + ppm_new(&tmp, p->width+left+right, p->height+top+bottom); for(y = 0; y < tmp.height; y++) { guchar *row, *srcrow; row = tmp.col + y * tmp.width * 3; @@ -518,13 +518,13 @@ void ppm_pad(ppm_t *p, int left,int right, int top, int bottom, guchar *bg) row[k+2] = bg[2]; } } - killppm(p); + ppm_kill(p); p->width = tmp.width; p->height = tmp.height; p->col = tmp.col; } -void saveppm(ppm_t *p, const char *fn) +void ppm_save(ppm_t *p, const char *fn) { FILE *f = fopen (fn, "wb"); @@ -551,7 +551,7 @@ void edgepad(ppm_t *p, int left,int right, int top, int bottom) guchar testcol[3] = {0,255,0}; int srowstride, drowstride; - newppm(&tmp, p->width+left+right, p->height+top+bottom); + ppm_new(&tmp, p->width+left+right, p->height+top+bottom); fill(&tmp, testcol); srowstride = p->width * 3; @@ -580,13 +580,13 @@ void edgepad(ppm_t *p, int left,int right, int top, int bottom) memcpy(&tmprow[(x+tmp.width-right-1)*3], col, 3); } } - killppm(p); + ppm_kill(p); p->width = tmp.width; p->height = tmp.height; p->col = tmp.col; } -void ppmgamma(ppm_t *p, float e, int r, int g, int b) +void ppm_apply_gamma(ppm_t *p, float e, int r, int g, int b) { int x, l = p->width * 3 * p->height; guchar xlat[256], *pix; @@ -602,7 +602,7 @@ void ppmgamma(ppm_t *p, float e, int r, int g, int b) if(b) for(x = 2; x < l; x += 3) pix[x] = xlat[pix[x]]; } -void ppmbrightness(ppm_t *p, float e, int r, int g, int b) +void ppm_apply_brightness(ppm_t *p, float e, int r, int g, int b) { int x, l = p->width * 3 * p->height; guchar xlat[256], *pix; @@ -625,7 +625,7 @@ void blur(ppm_t *p, int xrad, int yrad) int r, g, b, n; int rowstride = p->width * 3; - newppm(&tmp, p->width, p->height); + ppm_new(&tmp, p->width, p->height); for(y = 0; y < p->height; y++) { for(x = 0; x < p->width; x++) { r = g = b = n = 0; @@ -648,13 +648,13 @@ void blur(ppm_t *p, int xrad, int yrad) tmp.col[k+2] = b / n; } } - killppm(p); + ppm_kill(p); p->width = tmp.width; p->height = tmp.height; p->col = tmp.col; } -void putrgb_fast(ppm_t *s, float xo, float yo, guchar *d) +void ppm_put_rgb_fast(ppm_t *s, float xo, float yo, guchar *d) { guchar *tp; tp = s->col + s->width * 3 * (int)(yo+0.5) + 3 * (int)(xo+0.5); @@ -663,7 +663,7 @@ void putrgb_fast(ppm_t *s, float xo, float yo, guchar *d) tp[2] = d[2]; } -void putrgb(ppm_t *s, float xo, float yo, guchar *d) +void ppm_put_rgb(ppm_t *s, float xo, float yo, guchar *d) { int x, y; float aa, ab, ba, bb; @@ -714,7 +714,8 @@ void putrgb(ppm_t *s, float xo, float yo, guchar *d) s->col[k+rowstride+5] += bb * d[2]; } -void drawline(ppm_t *p, float fx, float fy, float tx, float ty, guchar *col) +void ppm_drawline(ppm_t *p, float fx, float fy, float tx, float ty, + guchar *col) { float i; float d, x, y; @@ -723,7 +724,7 @@ void drawline(ppm_t *p, float fx, float fy, float tx, float ty, guchar *col) d = (ty-fy)/(tx-fx); y = fy; for(x = fx; x <= tx; x+=1.0) { - putrgb(p, x, y, col); + ppm_put_rgb(p, x, y, col); y += d; } } else { @@ -731,7 +732,7 @@ void drawline(ppm_t *p, float fx, float fy, float tx, float ty, guchar *col) d = (tx-fx)/(ty-fy); x = fx; for(y = fy; y <= ty; y+=1.0) { - putrgb(p, x, y, col); + ppm_put_rgb(p, x, y, col); x += d; } } diff --git a/plug-ins/gimpressionist/ppmtool.h b/plug-ins/gimpressionist/ppmtool.h index 6dee213996..35be755a97 100644 --- a/plug-ins/gimpressionist/ppmtool.h +++ b/plug-ins/gimpressionist/ppmtool.h @@ -10,26 +10,26 @@ typedef struct ppm { } ppm_t; void fatal(char *s); -void killppm(ppm_t *p); -void newppm(ppm_t *p, int xs, int ys); -void getrgb(ppm_t *s, float xo, float yo, unsigned char *d); +void ppm_kill(ppm_t *p); +void ppm_new(ppm_t *p, int xs, int ys); +void get_rgb(ppm_t *s, float xo, float yo, unsigned char *d); void resize(ppm_t *p, int nx, int ny); void rescale(ppm_t *p, double scale); void resize_fast(ppm_t *p, int nx, int ny); -void loadppm(const char *fn, ppm_t *p); -void saveppm(ppm_t *p, const char *fn); -void copyppm(ppm_t *s, ppm_t *p); +void ppm_load(const char *fn, ppm_t *p); +void ppm_save(ppm_t *p, const char *fn); +void ppm_copy(ppm_t *s, ppm_t *p); void fill(ppm_t *p, guchar *c); -void freerotate(ppm_t *p, double amount); +void free_rotate(ppm_t *p, double amount); void ppm_pad(ppm_t *p, int left,int right, int top, int bottom, guchar *); void edgepad(ppm_t *p, int left,int right, int top, int bottom); void autocrop(ppm_t *p, int room); void crop(ppm_t *p, int lx, int ly, int hx, int hy); -void ppmgamma(ppm_t *p, float e, int r, int g, int b); -void ppmbrightness(ppm_t *p, float e, int r, int g, int b); -void putrgb_fast(ppm_t *s, float xo, float yo, guchar *d); -void putrgb(ppm_t *s, float xo, float yo, guchar *d); -void drawline(ppm_t *p, float fx, float fy, float tx, float ty, guchar *col); +void ppm_apply_gamma(ppm_t *p, float e, int r, int g, int b); +void ppm_apply_brightness(ppm_t *p, float e, int r, int g, int b); +void ppm_put_rgb_fast(ppm_t *s, float xo, float yo, guchar *d); +void ppm_put_rgb(ppm_t *s, float xo, float yo, guchar *d); +void ppm_drawline(ppm_t *p, float fx, float fy, float tx, float ty, guchar *col); void repaint(ppm_t *p, ppm_t *a); diff --git a/plug-ins/gimpressionist/preview.c b/plug-ins/gimpressionist/preview.c index f9f63d6ed5..1b9bcd7f4f 100644 --- a/plug-ins/gimpressionist/preview.c +++ b/plug-ins/gimpressionist/preview.c @@ -59,10 +59,10 @@ static ppm_t alpha_backup_ppm = {0,0,NULL}; void preview_free_resources (void) { - killppm (&preview_ppm); - killppm (&alpha_ppm); - killppm (&backup_ppm); - killppm (&alpha_backup_ppm); + ppm_kill (&preview_ppm); + ppm_kill (&alpha_ppm); + ppm_kill (&backup_ppm); + ppm_kill (&alpha_backup_ppm); } void @@ -112,9 +112,9 @@ updatepreview (GtkWidget *wg, gpointer d) } if(!preview_ppm.col) { - copyppm(&backup_ppm, &preview_ppm); + ppm_copy(&backup_ppm, &preview_ppm); if(img_has_alpha) - copyppm(&alpha_backup_ppm, &alpha_ppm); + ppm_copy(&alpha_backup_ppm, &alpha_ppm); } if(d) { @@ -132,9 +132,9 @@ updatepreview (GtkWidget *wg, gpointer d) (guchar*) &preview_ppm.col[i * PREVIEWSIZE * 3], 0, i, PREVIEWSIZE); } - killppm(&preview_ppm); + ppm_kill(&preview_ppm); if(img_has_alpha) - killppm(&alpha_ppm); + ppm_kill(&alpha_ppm); } gtk_widget_queue_draw (preview); diff --git a/plug-ins/gimpressionist/repaint.c b/plug-ins/gimpressionist/repaint.c index 389804a318..141d8ca87a 100644 --- a/plug-ins/gimpressionist/repaint.c +++ b/plug-ins/gimpressionist/repaint.c @@ -324,7 +324,7 @@ void repaint(ppm_t *p, ppm_t *a) scale = runningvals.sizelast / MAX(brushes[0].width, brushes[0].height); if(bgamma != 1.0) - ppmgamma(&brushes[0], 1.0/bgamma, 1,1,1); + ppm_apply_gamma(&brushes[0], 1.0/bgamma, 1,1,1); resize(&brushes[0], brushes[0].width * scale, brushes[0].height * scale); i = 1 + sqrt(brushes[0].width * brushes[0].width + @@ -334,7 +334,7 @@ void repaint(ppm_t *p, ppm_t *a) for(i = 1; i < numbrush; i++) { brushes[i].col = NULL; - copyppm(&brushes[0], &brushes[i]); + ppm_copy(&brushes[0], &brushes[i]); } for(i = 0; i < runningvals.sizenum; i++) { @@ -344,7 +344,7 @@ void repaint(ppm_t *p, ppm_t *a) else sv = 1.0; for(j = 0; j < runningvals.orientnum; j++) { h = j + i * runningvals.orientnum; - freerotate(&brushes[h], + free_rotate(&brushes[h], startangle + j * anglespan / runningvals.orientnum); rescale(&brushes[h], (sv * runningvals.sizefirst + (1.0-sv) * runningvals.sizelast) / runningvals.sizelast); autocrop(&brushes[h],1); @@ -356,7 +356,7 @@ void repaint(ppm_t *p, ppm_t *a) for(i = 0; i < numbrush; i++) { char tmp[1000]; g_snprintf (tmp, sizeof (tmp), "/tmp/_brush%03d.ppm", i); - saveppm(&brushes[i], tmp); + ppm_save(&brushes[i], tmp); } #endif @@ -388,8 +388,8 @@ void repaint(ppm_t *p, ppm_t *a) if(dropshadow) { for(i = 0; i < numbrush; i++) { shadows[i].col = NULL; - copyppm(&brushes[i], &shadows[i]); - ppmgamma(&shadows[i], 0, 1,1,0); + ppm_copy(&brushes[i], &shadows[i]); + ppm_apply_gamma(&shadows[i], 0, 1,1,0); ppm_pad(&shadows[i], shadowblur*2, shadowblur*2, shadowblur*2, shadowblur*2, back); for(j = 0; j < shadowblur; j++) @@ -406,8 +406,8 @@ void repaint(ppm_t *p, ppm_t *a) /* For extra annoying debugging :-) */ #if 0 - saveppm(brushes, "/tmp/__brush.ppm"); - if(shadows) saveppm(shadows, "/tmp/__shadow.ppm"); + ppm_save(brushes, "/tmp/__brush.ppm"); + if(shadows) ppm_save(shadows, "/tmp/__shadow.ppm"); system("xv /tmp/__brush.ppm & xv /tmp/__shadow.ppm & "); #endif @@ -421,27 +421,27 @@ void repaint(ppm_t *p, ppm_t *a) /* Initially fully transparent */ if(runningvals.generalbgtype == BG_TYPE_TRANSPARENT) { guchar tmpcol[3] = {255,255,255}; - newppm(&atmp, a->width, a->height); + ppm_new(&atmp, a->width, a->height); fill(&atmp, tmpcol); } else { - copyppm(a, &atmp); + ppm_copy(a, &atmp); } } if(runningvals.generalbgtype == BG_TYPE_SOLID) { guchar tmpcol[3]; - newppm(&tmp, p->width, p->height); + ppm_new(&tmp, p->width, p->height); gimp_rgb_get_uchar(&runningvals.color, &tmpcol[0], &tmpcol[1], &tmpcol[2]); fill(&tmp, tmpcol); } else if(runningvals.generalbgtype == BG_TYPE_KEEP_ORIGINAL) { - copyppm(p, &tmp); + ppm_copy(p, &tmp); } else { scale = runningvals.paperscale / 100.0; - newppm(&tmp, p->width, p->height); - loadppm(runningvals.selectedpaper, &paperppm); + ppm_new(&tmp, p->width, p->height); + ppm_load(runningvals.selectedpaper, &paperppm); resize(&paperppm, paperppm.width * scale, paperppm.height * scale); if(runningvals.paperinvert) - ppmgamma(&paperppm, -1.0, 1, 1, 1); + ppm_apply_gamma(&paperppm, -1.0, 1, 1, 1); for(x = 0; x < tmp.width; x++) { int rx = x % paperppm.width; for(y = 0; y < tmp.height; y++) { @@ -458,7 +458,7 @@ void repaint(ppm_t *p, ppm_t *a) switch(runningvals.orienttype) { case ORIENTATION_VALUE: - newppm(&dirmap, p->width, p->height); + ppm_new(&dirmap, p->width, p->height); for(y = 0; y < dirmap.height; y++) { guchar *dstrow = &dirmap.col[y*dirmap.width*3]; guchar *srcrow = &p->col[y*p->width*3]; @@ -468,7 +468,7 @@ void repaint(ppm_t *p, ppm_t *a) } break; case ORIENTATION_RADIUS: - newppm(&dirmap, p->width, p->height); + ppm_new(&dirmap, p->width, p->height); for(y = 0; y < dirmap.height; y++) { guchar *dstrow = &dirmap.col[y*dirmap.width*3]; double ysqr = (cy-y)*(cy-y); @@ -478,7 +478,7 @@ void repaint(ppm_t *p, ppm_t *a) } break; case ORIENTATION_RADIAL: - newppm(&dirmap, p->width, p->height); + ppm_new(&dirmap, p->width, p->height); for(y = 0; y < dirmap.height; y++) { guchar *dstrow = &dirmap.col[y*dirmap.width*3]; for(x = 0; x < dirmap.width; x++) { @@ -487,7 +487,7 @@ void repaint(ppm_t *p, ppm_t *a) } break; case ORIENTATION_FLOWING: - newppm(&dirmap, p->width / 6 + 5, p->height / 6 + 5); + ppm_new(&dirmap, p->width / 6 + 5, p->height / 6 + 5); mkgrayplasma(&dirmap, 15); blur(&dirmap, 2, 2); blur(&dirmap, 2, 2); @@ -497,7 +497,7 @@ void repaint(ppm_t *p, ppm_t *a) edgepad(&dirmap, maxbrushwidth, maxbrushheight,maxbrushwidth, maxbrushheight); break; case ORIENTATION_HUE: - newppm(&dirmap, p->width, p->height); + ppm_new(&dirmap, p->width, p->height); for(y = 0; y < dirmap.height; y++) { guchar *dstrow = &dirmap.col[y*dirmap.width*3]; guchar *srcrow = &p->col[y*p->width*3]; @@ -509,12 +509,12 @@ void repaint(ppm_t *p, ppm_t *a) case ORIENTATION_ADAPTIVE: { guchar tmpcol[3] = {0,0,0}; - newppm(&dirmap, p->width, p->height); + ppm_new(&dirmap, p->width, p->height); fill(&dirmap, tmpcol); } break; case ORIENTATION_MANUAL: - newppm(&dirmap, p->width-maxbrushwidth*2, p->height-maxbrushheight*2); + ppm_new(&dirmap, p->width-maxbrushwidth*2, p->height-maxbrushheight*2); for(y = 0; y < dirmap.height; y++) { guchar *dstrow = &dirmap.col[y*dirmap.width*3]; double tmpy = y / (double)dirmap.height; @@ -528,7 +528,7 @@ void repaint(ppm_t *p, ppm_t *a) if(runningvals.sizetype == SIZE_TYPE_VALUE) { - newppm(&sizmap, p->width, p->height); + ppm_new(&sizmap, p->width, p->height); for(y = 0; y < sizmap.height; y++) { guchar *dstrow = &sizmap.col[y*sizmap.width*3]; guchar *srcrow = &p->col[y*p->width*3]; @@ -539,7 +539,7 @@ void repaint(ppm_t *p, ppm_t *a) } else if(runningvals.sizetype == SIZE_TYPE_RADIUS) { - newppm(&sizmap, p->width, p->height); + ppm_new(&sizmap, p->width, p->height); for(y = 0; y < sizmap.height; y++) { guchar *dstrow = &sizmap.col[y*sizmap.width*3]; double ysqr = (cy-y)*(cy-y); @@ -550,7 +550,7 @@ void repaint(ppm_t *p, ppm_t *a) } else if(runningvals.sizetype == SIZE_TYPE_RADIAL) { - newppm(&sizmap, p->width, p->height); + ppm_new(&sizmap, p->width, p->height); for(y = 0; y < sizmap.height; y++) { guchar *dstrow = &sizmap.col[y*sizmap.width*3]; for(x = 0; x < sizmap.width; x++) { @@ -560,7 +560,7 @@ void repaint(ppm_t *p, ppm_t *a) } else if(runningvals.sizetype == SIZE_TYPE_FLOWING) { - newppm(&sizmap, p->width / 6 + 5, p->height / 6 + 5); + ppm_new(&sizmap, p->width / 6 + 5, p->height / 6 + 5); mkgrayplasma(&sizmap, 15); blur(&sizmap, 2, 2); blur(&sizmap, 2, 2); @@ -571,7 +571,7 @@ void repaint(ppm_t *p, ppm_t *a) } else if(runningvals.sizetype == SIZE_TYPE_HUE) { - newppm(&sizmap, p->width, p->height); + ppm_new(&sizmap, p->width, p->height); for(y = 0; y < sizmap.height; y++) { guchar *dstrow = &sizmap.col[y*sizmap.width*3]; guchar *srcrow = &p->col[y*p->width*3]; @@ -583,13 +583,13 @@ void repaint(ppm_t *p, ppm_t *a) else if(runningvals.sizetype == SIZE_TYPE_ADAPTIVE) { guchar tmpcol[3] = {0,0,0}; - newppm(&sizmap, p->width, p->height); + ppm_new(&sizmap, p->width, p->height); fill(&sizmap, tmpcol); } else if(runningvals.sizetype == SIZE_TYPE_MANUAL) { - newppm(&sizmap, p->width-maxbrushwidth*2, p->height-maxbrushheight*2); + ppm_new(&sizmap, p->width-maxbrushwidth*2, p->height-maxbrushheight*2); for(y = 0; y < sizmap.height; y++) { guchar *dstrow = &sizmap.col[y*sizmap.width*3]; double tmpy = y / (double)sizmap.height; @@ -600,7 +600,7 @@ void repaint(ppm_t *p, ppm_t *a) edgepad(&sizmap, maxbrushwidth, maxbrushwidth, maxbrushheight, maxbrushheight); } #if 0 - saveppm(&sizmap, "/tmp/_sizmap.ppm"); + ppm_save(&sizmap, "/tmp/_sizmap.ppm"); #endif if(runningvals.placetype == PLACEMENT_TYPE_RANDOM) { i = tmp.width * tmp.height / (maxbrushwidth * maxbrushheight); @@ -827,7 +827,7 @@ void repaint(ppm_t *p, ppm_t *a) } } for(i = 0; i < numbrush; i++) { - killppm(&brushes[i]); + ppm_kill(&brushes[i]); } g_free(brushes); g_free(shadows); @@ -842,13 +842,13 @@ void repaint(ppm_t *p, ppm_t *a) crop(&atmp, maxbrushwidth, maxbrushheight, atmp.width - maxbrushwidth, atmp.height - maxbrushheight); } - killppm(p); + ppm_kill(p); p->width = tmp.width; p->height = tmp.height; p->col = tmp.col; if(img_has_alpha) { - killppm(a); + ppm_kill(a); a->width = atmp.width; a->height = atmp.height; a->col = atmp.col; @@ -863,10 +863,10 @@ void repaint(ppm_t *p, ppm_t *a) paperppm.col = NULL; } else { tmp.col = NULL; - loadppm(runningvals.selectedpaper, &tmp); + ppm_load(runningvals.selectedpaper, &tmp); resize(&tmp, tmp.width * scale, tmp.height * scale); if(runningvals.paperinvert) - ppmgamma(&tmp, -1.0, 1,1,1); + ppm_apply_gamma(&tmp, -1.0, 1,1,1); } for(x = 0; x < p->width; x++) { double h, v; @@ -893,12 +893,12 @@ void repaint(ppm_t *p, ppm_t *a) } } } - killppm(&tmp); + ppm_kill(&tmp); } - if(paperppm.col) killppm(&paperppm); - if(dirmap.col) killppm(&dirmap); - if(sizmap.col) killppm(&sizmap); + if(paperppm.col) ppm_kill(&paperppm); + if(dirmap.col) ppm_kill(&dirmap); + if(sizmap.col) ppm_kill(&sizmap); if(runningvals.run) { gimp_progress_update(0.8); } else { diff --git a/plug-ins/gimpressionist/sizemap.c b/plug-ins/gimpressionist/sizemap.c index 20aa6eb9ce..2b3ec97621 100644 --- a/plug-ins/gimpressionist/sizemap.c +++ b/plug-ins/gimpressionist/sizemap.c @@ -61,7 +61,7 @@ static void updatesmpreviewprev(void) if (!nsbuffer.col) { - newppm(&nsbuffer,OMWIDTH,OMHEIGHT); + ppm_new(&nsbuffer,OMWIDTH,OMHEIGHT); } fill(&nsbuffer, black); @@ -71,10 +71,10 @@ static void updatesmpreviewprev(void) { gdouble siz = 5 * getsiz_from_gui(x/(double)OMWIDTH, y/(double)OMHEIGHT); - drawline (&nsbuffer, x-siz, y-siz, x+siz, y-siz, gray); - drawline (&nsbuffer, x+siz, y-siz, x+siz, y+siz, gray); - drawline (&nsbuffer, x+siz, y+siz, x-siz, y+siz, gray); - drawline (&nsbuffer, x-siz, y+siz, x-siz, y-siz, gray); + ppm_drawline (&nsbuffer, x-siz, y-siz, x+siz, y-siz, gray); + ppm_drawline (&nsbuffer, x+siz, y-siz, x+siz, y+siz, gray); + ppm_drawline (&nsbuffer, x+siz, y+siz, x-siz, y+siz, gray); + ppm_drawline (&nsbuffer, x-siz, y+siz, x-siz, y-siz, gray); } } @@ -110,16 +110,16 @@ static void updatesmvectorprev(void) #if 0 if(!infile.col) updatepreview (NULL, (void *)2); /* Force grabarea() */ - copyppm(&infile, &backup); + ppm_copy(&infile, &backup); #else infile_copy_to_ppm (&backup); #endif - ppmbrightness(&backup, val, 1,1,1); + ppm_apply_brightness(&backup, val, 1,1,1); if (backup.width != OMWIDTH || backup.height != OMHEIGHT) resize_fast(&backup, OMWIDTH, OMHEIGHT); ok = 1; } - copyppm(&backup, &sbuffer); + ppm_copy(&backup, &sbuffer); for (i = 0; i < numsmvect; i++) { @@ -127,15 +127,15 @@ static void updatesmvectorprev(void) y = smvector[i].y * OMHEIGHT; if (i == selectedsmvector) { - drawline (&sbuffer, x-5, y, x+5, y, red); - drawline (&sbuffer, x, y-5, x, y+5, red); + ppm_drawline (&sbuffer, x-5, y, x+5, y, red); + ppm_drawline (&sbuffer, x, y-5, x, y+5, red); } else { - drawline (&sbuffer, x-5, y, x+5, y, gray); - drawline (&sbuffer, x, y-5, x, y+5, gray); + ppm_drawline (&sbuffer, x-5, y, x+5, y, gray); + ppm_drawline (&sbuffer, x, y-5, x, y+5, gray); } - putrgb (&sbuffer, x, y, white); + ppm_put_rgb (&sbuffer, x, y, white); } for (y = 0; y < OMHEIGHT; y++)