1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
$NetBSD: patch-am,v 1.1 1999/01/10 23:52:16 tron Exp $
--- 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:
|