--- OLD/pnm/pnmpaste.c Thu Jan 1 00:00:00 1970 +++ NEW/pnm/pnmpaste.c Thu Jan 1 00:00:00 1970 @@ -46,6 +46,10 @@ function = 'a'; else if ( pm_keymatch( argv[argn], "-xor", 2 ) ) function = 'x'; + else if ( pm_keymatch( argv[argn], "-min", 3 ) ) + function = '<'; + else if ( pm_keymatch( argv[argn], "-max", 3 ) ) + function = '>'; else pm_usage( usage ); ++argn; @@ -113,8 +117,11 @@ newformat = max( PNM_FORMAT_TYPE(format1), PNM_FORMAT_TYPE(format2) ); newmaxval = max( maxval1, maxval2 ); - if ( function != 'r' && newformat != PBM_TYPE ) - pm_error( "no logical operations allowed for non-bitmaps" ); + switch (function) + { case 'a': case 'o': case 'x': + pm_error( "no logical operations allowed for non-bitmaps" ); + break; + } pnm_writepnminit( stdout, cols2, rows2, newmaxval, newformat, 0 ); @@ -138,6 +145,30 @@ { case 'r': *x2P = *x1P; + break; + + case '<': + { xel p; + xel p2; + p = *x1P; + p2 = *x2P; + PPM_ASSIGN(*x2P, + (PPM_GETR(p) < PPM_GETR(p2)) ? PPM_GETR(p) : PPM_GETR(p2), + (PPM_GETG(p) < PPM_GETG(p2)) ? PPM_GETG(p) : PPM_GETG(p2), + (PPM_GETB(p) < PPM_GETB(p2)) ? PPM_GETB(p) : PPM_GETB(p2)); + } + break; + + case '>': + { xel p; + xel p2; + p = *x1P; + p2 = *x2P; + PPM_ASSIGN(*x2P, + (PPM_GETR(p) > PPM_GETR(p2)) ? PPM_GETR(p) : PPM_GETR(p2), + (PPM_GETG(p) > PPM_GETG(p2)) ? PPM_GETG(p) : PPM_GETG(p2), + (PPM_GETB(p) > PPM_GETB(p2)) ? PPM_GETB(p) : PPM_GETB(p2)); + } break; case 'o':