67 lines
1.7 KiB
Plaintext
67 lines
1.7 KiB
Plaintext
--- pnm/pnmarith.c.orig Wed Jan 5 11:04:53 1994
|
|
+++ pnm/pnmarith.c Sun Jan 10 23:48:40 1999
|
|
@@ -29,7 +29,8 @@
|
|
xelval maxval1, maxval2, maxval3;
|
|
int argn, rows1, cols1, format1, rows2, cols2, format2, format3, row, col;
|
|
char function;
|
|
- char* usage = "-add|-subtract|-multiply|-difference pnmfile1 pnmfile2";
|
|
+ char* usage =
|
|
+"-add|-subtract|-multiply|-difference|-minimum|-maximum pnmfile1 pnmfile2";
|
|
|
|
|
|
pnm_init( &argc, argv );
|
|
@@ -48,6 +49,10 @@
|
|
function = '*';
|
|
else if ( pm_keymatch( argv[argn], "-difference", 2 ) )
|
|
function = 'D';
|
|
+ else if ( pm_keymatch( argv[argn], "-minimum", 2 ) )
|
|
+ function = 'N';
|
|
+ else if ( pm_keymatch( argv[argn], "-maximum", 2 ) )
|
|
+ function = 'X';
|
|
else
|
|
pm_usage( usage );
|
|
++argn;
|
|
@@ -112,7 +117,7 @@
|
|
pnm_promoteformatrow(
|
|
xelrow2, cols1, maxval2, format2, maxval3, format3 );
|
|
|
|
- for ( col = 0, x1P = xelrow1, x2P = xelrow2;
|
|
+ for ( col = 0, x1P = xelrow1, x2P = xelrow2;
|
|
col < cols1; ++col, ++x1P, ++x2P )
|
|
{
|
|
switch ( PNM_FORMAT_TYPE(format3) )
|
|
@@ -153,6 +158,18 @@
|
|
b1 = (b1>b2)?(b1-b2):(b2-b1);
|
|
break;
|
|
|
|
+ case 'N':
|
|
+ r1 = (r1>r2)?(r2):(r1);
|
|
+ g1 = (g1>g2)?(g2):(g1);
|
|
+ b1 = (b1>b2)?(b2):(b1);
|
|
+ break;
|
|
+
|
|
+ case 'X':
|
|
+ r1 = (r1>r2)?(r1):(r2);
|
|
+ g1 = (g1>g2)?(g1):(g2);
|
|
+ b1 = (b1>b2)?(b1):(b2);
|
|
+ break;
|
|
+
|
|
default:
|
|
pm_error( "can't happen" );
|
|
}
|
|
@@ -188,6 +205,14 @@
|
|
|
|
case 'D':
|
|
g1 = (g1>g2)?(g1-g2):(g2-g1);
|
|
+ break;
|
|
+
|
|
+ case 'N':
|
|
+ g1 = (g1>g2)?(g2):(g1);
|
|
+ break;
|
|
+
|
|
+ case 'X':
|
|
+ g1 = (g1>g2)?(g1):(g2);
|
|
break;
|
|
|
|
default:
|