about summary refs log tree commit diff
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2008-08-29 19:48:41 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2008-08-29 19:48:41 +0000
commita642bc63ae68ed4d36d592f07ac941df4d47c679 (patch)
treeddd18e8c8682bfeae8036144495382cacc24b308
parent6ca408cd6464ccab053c88cc2134dfcb7247c35a (diff)
downloadnetpbm-mirror-a642bc63ae68ed4d36d592f07ac941df4d47c679.tar.gz
netpbm-mirror-a642bc63ae68ed4d36d592f07ac941df4d47c679.tar.xz
netpbm-mirror-a642bc63ae68ed4d36d592f07ac941df4d47c679.zip
Release 10.43.04
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@719 9d0c8265-081b-0410-96cb-a4ca84ce46f8
-rw-r--r--Makefile.version2
-rw-r--r--analyzer/pgmhist.c8
-rw-r--r--doc/HISTORY17
-rw-r--r--editor/pamcomp.c21
-rw-r--r--editor/pamcut.c12
-rw-r--r--lib/libpnm3.c13
6 files changed, 65 insertions, 8 deletions
diff --git a/Makefile.version b/Makefile.version
index 32344f6c..73ad7a21 100644
--- a/Makefile.version
+++ b/Makefile.version
@@ -1,4 +1,4 @@
 NETPBM_MAJOR_RELEASE = 10
 NETPBM_MINOR_RELEASE = 43
-NETPBM_POINT_RELEASE = 3
+NETPBM_POINT_RELEASE = 4
 
diff --git a/analyzer/pgmhist.c b/analyzer/pgmhist.c
index 8f4e512e..126fe693 100644
--- a/analyzer/pgmhist.c
+++ b/analyzer/pgmhist.c
@@ -10,6 +10,8 @@
 ** implied warranty.
 */
 
+#include <limits.h>
+
 #include "pgm.h"
 #include "mallocvar.h"
 
@@ -42,6 +44,12 @@ main( argc, argv )
         pm_usage( usage );
 
     pgm_readpgminit( ifp, &cols, &rows, &maxval, &format );
+
+    if (UINT_MAX / cols < rows)
+        pm_error("Too many pixels (%u x %u) in image.  "
+                 "Maximum computable is %u",
+                 cols, rows, UINT_MAX);
+
     grayrow = pgm_allocrow( cols );
 
     /* Build histogram. */
diff --git a/doc/HISTORY b/doc/HISTORY
index 19a0cfe9..b38aa59d 100644
--- a/doc/HISTORY
+++ b/doc/HISTORY
@@ -4,7 +4,22 @@ Netpbm.
 CHANGE HISTORY 
 --------------
 
-not yet  BJH  Release 10.43.03
+08.08.29 BJH  Release 10.43.04
+
+              pnm_backgroundxel(), pnm_backgroundxelrow() (affects
+              pnmrotate, pnmshear, pnmcrop, pnmcat: correctly average
+              corner colors to determine background (fill) color.
+
+              pgmhist: arbitrary output when total pixels doesn't fit in an
+              integer.
+
+              pamcomp: fix bug: arbitrary output when combined number of rows
+              doesn't fit in an integer.
+
+              pamcut: don't crash when left > right or top > bottom with
+              -pad.  Thanks Prophet of the Way <afu@wta.att.ne.jp>.
+
+08.08.13 BJH  Release 10.43.03
 
               pamcut: don't crash when cutting a region entirely to the
               left or right of the input image, with -pad.
diff --git a/editor/pamcomp.c b/editor/pamcomp.c
index f7346483..fc43d9c5 100644
--- a/editor/pamcomp.c
+++ b/editor/pamcomp.c
@@ -306,6 +306,25 @@ warnOutOfFrame( int const originLeft,
 
 
 static void
+validateComputableHeight(int const originTop, 
+                         int const overRows) {
+
+    if (originTop < 0) {
+        if (originTop < -INT_MAX)
+            pm_error("Overlay starts too far above the underlay image to be "
+                     "computable.  Overlay can be at most %d rows above "
+                     "the underlay.", INT_MAX);
+    } else {
+        if (INT_MAX - originTop <= overRows)
+            pm_error("Too many total rows involved to be computable.  "
+                     "You must have a shorter overlay image or compose it "
+                     "higher on the underlay image.");
+    }
+}
+
+
+
+static void
 computeOverlayPosition(int                const underCols, 
                        int                const underRows,
                        int                const overCols, 
@@ -340,6 +359,8 @@ computeOverlayPosition(int                const underCols,
     *originLeftP = xalign + cmdline.xoff;
     *originTopP  = yalign + cmdline.yoff;
 
+    validateComputableHeight(*originTopP, overRows);
+
     warnOutOfFrame(*originLeftP, *originTopP, 
                    overCols, overRows, underCols, underRows);    
 }
diff --git a/editor/pamcut.c b/editor/pamcut.c
index fca5096c..a555ad58 100644
--- a/editor/pamcut.c
+++ b/editor/pamcut.c
@@ -506,7 +506,17 @@ cutOneImage(FILE *             const ifP,
     if (!cmdline.pad)
         rejectOutOfBounds(inpam.width, inpam.height, leftcol, rightcol, 
                           toprow, bottomrow);
-
+    else {
+        if (cmdline.left > cmdline.right) 
+            pm_error("You have specified a left edge (%d) that is to the right\n"
+                     "of the right edge you specified (%d)", 
+                     cmdline.left, cmdline.right);
+        
+        if (cmdline.top > cmdline.bottom) 
+            pm_error("You have specified a top edge (%d) that is below\n"
+                     "the bottom edge you specified (%d)", 
+                     cmdline.top, cmdline.bottom);
+    }
     if (cmdline.verbose) {
         pm_message("Image goes from Row 0, Column 0 through Row %d, Column %d",
                    inpam.height-1, inpam.width-1);
diff --git a/lib/libpnm3.c b/lib/libpnm3.c
index 71df0cbf..c4b9586f 100644
--- a/lib/libpnm3.c
+++ b/lib/libpnm3.c
@@ -54,9 +54,9 @@ pnm_backgroundxel( xel** xels, int cols, int rows, xelval maxval, int format )
         {
         case PPM_TYPE:
         PPM_ASSIGN( bgxel,
-        PPM_GETR(ul) + PPM_GETR(ur) + PPM_GETR(ll) + PPM_GETR(lr) / 4,
-        PPM_GETG(ul) + PPM_GETG(ur) + PPM_GETG(ll) + PPM_GETG(lr) / 4,
-        PPM_GETB(ul) + PPM_GETB(ur) + PPM_GETB(ll) + PPM_GETB(lr) / 4 );
+        (PPM_GETR(ul) + PPM_GETR(ur) + PPM_GETR(ll) + PPM_GETR(lr)) / 4,
+        (PPM_GETG(ul) + PPM_GETG(ur) + PPM_GETG(ll) + PPM_GETG(lr)) / 4,
+        (PPM_GETB(ul) + PPM_GETB(ur) + PPM_GETB(ll) + PPM_GETB(lr)) / 4 );
         break;
 
         case PGM_TYPE:
@@ -101,8 +101,11 @@ pnm_backgroundxelrow( xel* xelrow, int cols, xelval maxval, int format )
     switch ( PNM_FORMAT_TYPE(format) )
         {
         case PPM_TYPE:
-        PPM_ASSIGN( bgxel, PPM_GETR(l) + PPM_GETR(r) / 2,
-        PPM_GETG(l) + PPM_GETG(r) / 2, PPM_GETB(l) + PPM_GETB(r) / 2 );
+        PPM_ASSIGN(bgxel,
+                   (PPM_GETR(l) + PPM_GETR(r)) / 2,
+                   (PPM_GETG(l) + PPM_GETG(r)) / 2,
+                   (PPM_GETB(l) + PPM_GETB(r)) / 2
+            );
         break;
 
         case PGM_TYPE: