about summary refs log tree commit diff
path: root/editor/specialty
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2014-02-09 18:11:04 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2014-02-09 18:11:04 +0000
commit593f1795985139aabc730dc74ec3e16131d725b2 (patch)
treed70b4493cf98761300565c92b4748505c5890fd0 /editor/specialty
parent69f6a4b0348f6ed02da0da9a3ae1adb758f24e3e (diff)
downloadnetpbm-mirror-593f1795985139aabc730dc74ec3e16131d725b2.tar.gz
netpbm-mirror-593f1795985139aabc730dc74ec3e16131d725b2.tar.xz
netpbm-mirror-593f1795985139aabc730dc74ec3e16131d725b2.zip
Release 10.65.04
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@2123 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'editor/specialty')
-rw-r--r--editor/specialty/pamdeinterlace.c8
-rw-r--r--editor/specialty/ppmrelief.c18
2 files changed, 19 insertions, 7 deletions
diff --git a/editor/specialty/pamdeinterlace.c b/editor/specialty/pamdeinterlace.c
index aa1f3ff7..d6f6aee1 100644
--- a/editor/specialty/pamdeinterlace.c
+++ b/editor/specialty/pamdeinterlace.c
@@ -32,7 +32,7 @@ parseCommandLine(int argc, char ** argv,
    was passed to us as the argv array.
 -----------------------------------------------------------------------------*/
     optStruct3 opt;  /* set by OPTENT3 */
-    optEntry *option_def;
+    optEntry * option_def;
     unsigned int option_def_index;
 
     unsigned int takeeven, takeodd;
@@ -50,6 +50,8 @@ parseCommandLine(int argc, char ** argv,
     pm_optParseOptions3(&argc, argv, opt, sizeof(opt), 0);
         /* Uses and sets argc, argv, and some of *cmdlineP and others. */
 
+    free(option_def);
+
     if (takeeven && takeodd)
         pm_error("You cannot specify both -takeeven and -takeodd options.");
 
@@ -90,6 +92,10 @@ main(int argc, char *argv[]) {
     
     pnm_readpaminit(ifP, &inpam, PAM_STRUCT_SIZE(tuple_type));
 
+    if (inpam.height < 2 && cmdline.rowsToTake == ODD)
+        pm_error("You requested to take the odd rows, but there aren't "
+                 "any odd rows in the image - it has only one row - Row 0");
+
     tuplerow = pnm_allocpamrow(&inpam);
 
     outpam = inpam;    /* Initial value -- most fields should be same */
diff --git a/editor/specialty/ppmrelief.c b/editor/specialty/ppmrelief.c
index 5e0669c3..1c408aec 100644
--- a/editor/specialty/ppmrelief.c
+++ b/editor/specialty/ppmrelief.c
@@ -11,6 +11,7 @@
 */
 
 #include <stdio.h>
+#include "pm_c_util.h"
 #include "ppm.h"
 
 int
@@ -38,6 +39,11 @@ main(int argc, char * argv[]) {
         pm_usage( usage );
     
     ppm_readppminit( ifp, &cols, &rows, &maxval, &format );
+
+    if (cols < 3 || rows < 3 )
+        pm_error("Input image too small: %u x %u.  Must be at least 3x3",
+                  cols, rows);
+
     mv2 = maxval / 2;
 
     /* Allocate space for 3 input rows, plus an output row. */
@@ -67,12 +73,12 @@ main(int argc, char * argv[]) {
         ppm_readppmrow( ifp, inputbuf[rowa], cols, maxval, format );
         
         for ( col = 0; col < cols - 2; ++col ) {
-            r = PPM_GETR( inputbuf[rowa][col] ) +
-                ( mv2 - PPM_GETR( inputbuf[rowb][col + 2] ) );
-            g = PPM_GETG( inputbuf[rowa][col] ) +
-                ( mv2 - PPM_GETG( inputbuf[rowb][col + 2] ) );
-            b = PPM_GETB( inputbuf[rowa][col] ) +
-                ( mv2 - PPM_GETB( inputbuf[rowb][col + 2] ) );
+            r = MAX(0, MIN(maxval, PPM_GETR( inputbuf[rowa][col] ) +
+                           ( mv2 - PPM_GETR( inputbuf[rowb][col + 2] ) )));
+            g = MAX(0, MIN(maxval, PPM_GETG( inputbuf[rowa][col] ) +
+                           ( mv2 - PPM_GETG( inputbuf[rowb][col + 2] ) )));
+            b = MAX(0, MIN(maxval, PPM_GETB( inputbuf[rowa][col] ) +
+                           ( mv2 - PPM_GETB( inputbuf[rowb][col + 2] ) )));
             PPM_ASSIGN( outputrow[col + 1], r, g, b );
         }
         ppm_writeppmrow( stdout, outputrow, cols, maxval, 0 );