diff --git a/src/modules/Image/colortable.c b/src/modules/Image/colortable.c index 2fa41aec5cd10b2c864de4fd7235b535f1d418e1..c335530420f50c80cccf0ecf581805b6b3887aa5 100644 --- a/src/modules/Image/colortable.c +++ b/src/modules/Image/colortable.c @@ -1,11 +1,11 @@ #include <config.h> -/* $Id: colortable.c,v 1.36 1998/01/25 08:26:38 hubbe Exp $ */ +/* $Id: colortable.c,v 1.37 1998/01/25 10:44:41 mirar Exp $ */ /* **! module Image **! note -**! $Id: colortable.c,v 1.36 1998/01/25 08:26:38 hubbe Exp $ +**! $Id: colortable.c,v 1.37 1998/01/25 10:44:41 mirar Exp $ **! class colortable **! **! This object keeps colortable information, @@ -21,7 +21,7 @@ #undef COLORTABLE_REDUCE_DEBUG #include "global.h" -RCSID("$Id: colortable.c,v 1.36 1998/01/25 08:26:38 hubbe Exp $"); +RCSID("$Id: colortable.c,v 1.37 1998/01/25 10:44:41 mirar Exp $"); #include <sys/types.h> #include <sys/stat.h> @@ -432,19 +432,16 @@ static int reduce_recurse(struct nct_flat_entry *src, diff.b*=DIFF_B_MULT; gdiff=(gdiff*DIFF_GREY_MULT)/(sq(sf.r+sf.g+sf.b)); - if (diff.r > diff.g) { - if (diff.r > diff.b) { + if (diff.r > diff.g) + if (diff.r > diff.b) if (diff.r > gdiff) st=SORT_R; else st=SORT_GREY; - } else { + else if (diff.b > gdiff) st=SORT_B; else st=SORT_GREY; - } - } else { - if (diff.g > diff.b) { + else + if (diff.g > diff.b) if (diff.g > gdiff) st=SORT_G; else st=SORT_GREY; - } else { + else if (diff.b > gdiff) st=SORT_B; else st=SORT_GREY; - } - } #ifdef COLORTABLE_REDUCE_DEBUG fprintf(stderr,"COLORTABLE%*s diff=%d,%d,%d,%ld sort=%d\n",level,"",diff.r,diff.g,diff.b,gdiff,st); #endif @@ -528,14 +525,13 @@ static int reduce_recurse(struct nct_flat_entry *src, #endif n=reduce_recurse(src,dest,left,i,level+2,sf,newpos1,space,type); - if (n!=oldn) { + if (n!=oldn) if (n<oldn) /* i certainly hope so */ MEMMOVE(dest+n,dest+oldn,sizeof(struct nct_flat_entry)*m); else /* huh? */ /* this is the only case we don't have them already */ m=reduce_recurse(src+left,dest+n,src_size-left, target_size-n,level+2,sf,newpos2,space,type); - } #ifdef COLORTABLE_REDUCE_DEBUG fprintf(stderr,"COLORTABLE%*s ->%d+%d=%d (retried for %d+%d=%d)\n",level,"",n,m,n+m,i,target_size-i,target_size); #endif @@ -2028,7 +2024,7 @@ static void image_colortable_add(INT32 args) get_storage(sp[-args].u.object,image_program))) { /* get colors from image */ - if (args>=2) { + if (args>=2) if (sp[1-args].type==T_INT) { int numcolors=sp[1-args].u.integer; @@ -2083,7 +2079,6 @@ static void image_colortable_add(INT32 args) } else error("Illegal argument 2 to Image.colortable->add|create\n"); - } else { THIS->u.flat=_img_get_flat_from_image(img,256); @@ -2493,7 +2488,7 @@ void image_colortable_cubicles(INT32 args) colortable_free_lookup_stuff(THIS); THIS->lookup_mode=NCT_CUBICLES; } - if (args) { + if (args) if (args>=3 && sp[-args].type==T_INT && sp[2-args].type==T_INT && @@ -2510,7 +2505,6 @@ void image_colortable_cubicles(INT32 args) } else error("Illegal arguments to colortable->cubicles()\n"); - } else { THIS->lu.cubicles.r=CUBICLE_DEFAULT_R; @@ -3293,22 +3287,20 @@ void image_colortable_floyd_steinberg(INT32 args) float factor=0.95; THIS->dither_type=NCTD_NONE; - if (args>=1) { + if (args>=1) if (sp[-args].type!=T_INT) error("colortable->spacefactors(): Illegal argument 1\n"); else THIS->du.floyd_steinberg.dir=sp[-args].u.integer; - } else { + else THIS->du.floyd_steinberg.dir=0; - } - if (args>=6) { + if (args>=6) if (sp[5-args].type==T_FLOAT) factor=(float)sp[5-args].u.float_number; else if (sp[5-args].type==T_INT) factor=(float)sp[5-args].u.integer; else error("colortable->spacefactors(): Illegal argument 6\n"); - } if (args>=5) { if (sp[1-args].type==T_FLOAT) @@ -3443,7 +3435,7 @@ void image_colortable_randomcube(INT32 args) { THIS->dither_type=NCTD_NONE; - if (args>=3) { + if (args>=3) if (sp[-args].type!=T_INT|| sp[1-args].type!=T_INT|| sp[2-args].type!=T_INT) @@ -3454,7 +3446,6 @@ void image_colortable_randomcube(INT32 args) THIS->du.randomcube.g=sp[1-args].u.integer; THIS->du.randomcube.b=sp[2-args].u.integer; } - } else if (THIS->type==NCT_CUBE && THIS->u.cube.r && THIS->u.cube.g && THIS->u.cube.b) { @@ -3479,12 +3470,12 @@ void image_colortable_randomgrey(INT32 args) { THIS->dither_type=NCTD_NONE; - if (args) { + if (args) if (sp[-args].type!=T_INT) error("Image.colortable->randomgrey(): illegal argument(s)\n"); else THIS->du.randomcube.r=sp[-args].u.integer; - } else if (THIS->type==NCT_CUBE && THIS->u.cube.r) + else if (THIS->type==NCT_CUBE && THIS->u.cube.r) THIS->du.randomcube.r=256/THIS->u.cube.r; else THIS->du.randomcube.r=32; @@ -3705,7 +3696,7 @@ void image_colortable_ordered(INT32 args) THIS->dither_type=NCTD_NONE; - if (args>=3) { + if (args>=3) if (sp[-args].type!=T_INT|| sp[1-args].type!=T_INT|| sp[2-args].type!=T_INT) @@ -3716,7 +3707,7 @@ void image_colortable_ordered(INT32 args) g=sp[1-args].u.integer; b=sp[2-args].u.integer; } - } else if (THIS->type==NCT_CUBE && THIS->u.cube.r && + else if (THIS->type==NCT_CUBE && THIS->u.cube.r && THIS->u.cube.g && THIS->u.cube.b) { r=256/THIS->u.cube.r; diff --git a/src/modules/Image/image.c b/src/modules/Image/image.c index b9e8a79032a4cb6f8f9bd06b6bf0f82c5ad38dc4..9adc366ca3905e9be593d818c1684a9ba3722dbe 100644 --- a/src/modules/Image/image.c +++ b/src/modules/Image/image.c @@ -1,9 +1,9 @@ -/* $Id: image.c,v 1.77 1998/01/21 20:02:24 hubbe Exp $ */ +/* $Id: image.c,v 1.78 1998/01/25 10:44:44 mirar Exp $ */ /* **! module Image **! note -**! $Id: image.c,v 1.77 1998/01/21 20:02:24 hubbe Exp $ +**! $Id: image.c,v 1.78 1998/01/25 10:44:44 mirar Exp $ **! class image **! **! The main object of the <ref>Image</ref> module, this object @@ -82,7 +82,7 @@ #include "stralloc.h" #include "global.h" -RCSID("$Id: image.c,v 1.77 1998/01/21 20:02:24 hubbe Exp $"); +RCSID("$Id: image.c,v 1.78 1998/01/25 10:44:44 mirar Exp $"); #include "pike_macros.h" #include "object.h" #include "constants.h" @@ -204,12 +204,12 @@ static INLINE void getrgb(struct image *img, img->rgb.r=(unsigned char)sp[-args+args_start].u.integer; img->rgb.g=(unsigned char)sp[1-args+args_start].u.integer; img->rgb.b=(unsigned char)sp[2-args+args_start].u.integer; - if (args-args_start>=4) { + if (args-args_start>=4) if (sp[3-args+args_start].type!=T_INT) error("Illegal alpha argument to %s\n",name); else img->alpha=sp[3-args+args_start].u.integer; - } else + else img->alpha=0; } @@ -799,12 +799,11 @@ void image_autocrop(INT32 args) struct image *img; int left=1,right=1,top=1,bottom=1; - if (args) { + if (args) if (sp[-args].type!=T_INT) error("Illegal argument to Image.image->autocrop()\n"); else border=sp[-args].u.integer; - } if (args>=5) { @@ -2107,12 +2106,12 @@ void image_select_from(INT32 args) || sp[1-args].type!=T_INT) error("Illegal argument(s) to Image.image->select_from()\n"); - if (args>=3) { + if (args>=3) if (sp[2-args].type!=T_INT) error("Illegal argument 3 (edge value) to Image.image->select_from()\n"); else low_limit=MAXIMUM(0,sp[2-args].u.integer); - } else + else low_limit=30; low_limit=low_limit*low_limit; @@ -2292,7 +2291,7 @@ CHRONO("apply_matrix"); sp[-args].type!=T_ARRAY) error("Illegal arguments to Image.image->apply_matrix()\n"); - if (args>3) { + if (args>3) if (sp[1-args].type!=T_INT || sp[2-args].type!=T_INT || sp[3-args].type!=T_INT) @@ -2303,7 +2302,8 @@ CHRONO("apply_matrix"); default_rgb.g=sp[1-args].u.integer; default_rgb.b=sp[1-args].u.integer; } - } else { + else + { default_rgb.r=0; default_rgb.g=0; default_rgb.b=0;