about summary refs log tree commit diff
path: root/converter/other
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2013-12-26 06:13:41 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2013-12-26 06:13:41 +0000
commit51ffbae51ba9379bad460566cdf9babaa63b14c3 (patch)
tree441f6e9297c478261bdce544497decaf6abc31a4 /converter/other
parentd6f45222d7b29adb9defdd79dd8ad1dbc97bb3e1 (diff)
downloadnetpbm-mirror-51ffbae51ba9379bad460566cdf9babaa63b14c3.tar.gz
netpbm-mirror-51ffbae51ba9379bad460566cdf9babaa63b14c3.tar.xz
netpbm-mirror-51ffbae51ba9379bad460566cdf9babaa63b14c3.zip
Update to current Development release - 10.65.00
git-svn-id: http://svn.code.sf.net/p/netpbm/code/advanced@2083 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/other')
-rw-r--r--converter/other/cameratopam/Makefile4
-rw-r--r--converter/other/jpeg2000/libjasper/common.mk3
-rw-r--r--converter/other/pnmtopalm/Makefile2
-rw-r--r--converter/other/pnmtops.c55
-rw-r--r--converter/other/pstopnm.c80
5 files changed, 108 insertions, 36 deletions
diff --git a/converter/other/cameratopam/Makefile b/converter/other/cameratopam/Makefile
index 20a95aa2..4470d472 100644
--- a/converter/other/cameratopam/Makefile
+++ b/converter/other/cameratopam/Makefile
@@ -9,7 +9,7 @@ EXTERN_INCLUDES =
 ifneq ($(JPEGLIB),NONE)
   ifneq ($(JPEGHDR_DIR)x,x)
     EXTERN_INCLUDES += -I$(JPEGHDR_DIR)
-    CFLAGS += -DHAVE_JPEG
+    HAVE_JPEG_DEFINE = -DHAVE_JPEG
   endif
 endif
 
@@ -22,6 +22,8 @@ all: cameratopam
 OBJECTS = util.o identify.o cameratopam.o camera.o foveon.o decode.o \
 	canon.o ljpeg.o dng.o
 
+camera.o camera.o2: CFLAGS_TARGET = $(HAVE_JPEG_DEFINE)
+
 MERGE_OBJECTS =
 
 BINARIES = cameratopam
diff --git a/converter/other/jpeg2000/libjasper/common.mk b/converter/other/jpeg2000/libjasper/common.mk
index b31b1209..a333f5d6 100644
--- a/converter/other/jpeg2000/libjasper/common.mk
+++ b/converter/other/jpeg2000/libjasper/common.mk
@@ -13,8 +13,7 @@ partlist: $(SUBDIRS:%=%/partlist)
 	cat /dev/null $(SUBDIRS:%=%/partlist) >$@
 	echo $(LIB_OBJECTS:%=$(CURDIR)/%) >>$@
 
-.PHONY: $(SUBDIRS:%=%/partlist)
-$(SUBDIRS:%=%/partlist): %/partlist: $(CURDIR)/%
+$(SUBDIRS:%=%/partlist):
 	$(MAKE) -C $(dir $@) -f $(SRCDIR)/$(SUBDIR)/$(dir $@)Makefile \
 	    SRCDIR=$(SRCDIR) BUILDDIR=$(BUILDDIR) $(notdir $@) 
 
diff --git a/converter/other/pnmtopalm/Makefile b/converter/other/pnmtopalm/Makefile
index 7f99f95a..65790002 100644
--- a/converter/other/pnmtopalm/Makefile
+++ b/converter/other/pnmtopalm/Makefile
@@ -25,7 +25,7 @@ $(BINARIES): %: %.o palmcolormap.o $(NETPBMLIB) $(LIBOPT)
 	  $(MATHLIB) $(LDFLAGS) $(LDLIBS) $(RPATH) $(LADD)
 
 gen_palm_colormap : % : %.c palmcolormap.o
-	$(CC) -I importinc $(CPPFLAGS) $(CFLAGS) -o $@ \
+	$(CC) -I importinc $(CFLAGS_ALL) -o $@ \
 	  $< palmcolormap.o \
 	  $(LIBOPTS) $(MATHLIB) $(LDFLAGS) $(LDLIBS) $(LADD)
 
diff --git a/converter/other/pnmtops.c b/converter/other/pnmtops.c
index 150331a1..316b7626 100644
--- a/converter/other/pnmtops.c
+++ b/converter/other/pnmtops.c
@@ -114,8 +114,10 @@ struct cmdlineInfo {
     unsigned int dict;
     unsigned int vmreclaim;
     unsigned int verbose;
+    unsigned int debug;
 };
 
+static bool debug;
 static bool verbose;
 
 
@@ -248,6 +250,7 @@ parseCommandLine(int argc, const char ** argv,
     OPTENT3(0, "vmreclaim",   OPT_FLAG,  NULL, &cmdlineP->vmreclaim,     0);
     OPTENT3(0, "showpage",    OPT_FLAG,  NULL, &showpage,                0);
     OPTENT3(0, "verbose",     OPT_FLAG,  NULL, &cmdlineP->verbose,       0);
+    OPTENT3(0, "debug",       OPT_FLAG,  NULL, &cmdlineP->debug,         0);
     OPTENT3(0, "level",       OPT_UINT, &cmdlineP->level, 
             &cmdlineP->levelSpec,              0);
     
@@ -395,6 +398,16 @@ writeFileChar(const char * const buffer,
 
 
 
+static void
+writeFileByte(unsigned char const byte,
+              const char *  const name,
+              FILE *        const ofP) {
+
+    writeFile(&byte, 1, name, ofP);
+}
+
+
+
 #define MAX_FILTER_CT 10
     /* The maximum number of filters this code is capable of applying */
 
@@ -621,17 +634,28 @@ flateFilter(FILE *          const ifP,
 
 
 static void
-rlePutBuffer (unsigned int    const repeat,
+rlePutBuffer (bool            const repeatMode,
               unsigned int    const count,
-              unsigned int    const repeatitem,
+              unsigned char   const repeatitem,
               unsigned char * const itembuf,
               FILE *          const fP) {
+/*----------------------------------------------------------------------------
+   Output some RLE data.  There are two forms of output:
 
-    if (repeat) {
-        fputc(257 - count,  fP);
-        fputc(repeatitem, fP);
+     'repeatMode' true: output a repeat sequence, indicating to repeat byte
+     'repeatitem' 'count' times.
+
+     'repeatMode' false: output a non-repeat sequence indicating the
+     'count' characters in itembuf[].
+-----------------------------------------------------------------------------*/
+    assert(count > 0);
+    assert(count <= 128);
+
+    if (repeatMode) {
+        writeFileByte((257 - count) % 256, "rlePutBuffer", fP);
+        writeFileByte(repeatitem, "rlePutBuffer", fP);
     } else {
-        fputc(count - 1, fP);
+        writeFileByte(count - 1, "rlePutBuffer", fP);
         writeFile(itembuf, count, "rlePutBuffer", fP);
     }
 }
@@ -975,6 +999,12 @@ addFilter(const char *    const description,
         pm_message("%s filter spawned: pid %u",
                    description, (unsigned)pid);
     
+    if (debug) {
+        int const outFd    = fileno(oldFeedFileP);
+        int const supplyFd = fileno(newFeedFileP);
+        pm_message("PID %u writes to FD %u, its supplier writes to FD %u",
+                   (unsigned)pid, outFd, supplyFd);
+    }
     fclose(oldFeedFileP);  /* Child keeps this open now */
 
     addToPidList(pidList, pid);
@@ -1937,7 +1967,17 @@ convertRaster(struct pam * const inpamP,
               unsigned int const bitsPerSample,
               bool         const psFilter,
               FILE *       const fP) {
+/*----------------------------------------------------------------------------
+   Read the raster described by *inpamP, and write a bit stream of samples
+   to *fP.  This stream has to be compressed and converted to text before it
+   can be part of a Postscript program.
+   
+   'psFilter' means to do the conversion using built in Postscript filters, as
+   opposed to our own filters via /readstring.
 
+   'bitsPerSample' is how many bits each sample is to take in the Postscript
+   output.
+-----------------------------------------------------------------------------*/
     if (PAM_FORMAT_TYPE(inpamP->format) == PBM_TYPE && bitsPerSample == 1)  {
         unsigned char * bitrow;
         unsigned int row;
@@ -2097,7 +2137,8 @@ main(int argc, const char * argv[]) {
 
     parseCommandLine(argc, argv, &cmdline);
 
-    verbose = cmdline.verbose;
+    verbose = cmdline.verbose || cmdline.debug;
+    debug   = cmdline.debug;
 
     if (cmdline.flate && !progIsFlateCapable())
         pm_error("This program cannot do flate compression.  "
diff --git a/converter/other/pstopnm.c b/converter/other/pstopnm.c
index f4081464..c0d6a4ee 100644
--- a/converter/other/pstopnm.c
+++ b/converter/other/pstopnm.c
@@ -496,42 +496,72 @@ computeBoxToExtract(struct Box const cmdlineExtractBox,
 static enum Orientation
 computeOrientation(struct CmdlineInfo const cmdline, 
                    struct Box         const extractBox) {
-
-    unsigned int const inputWidth  = extractBox.urx - extractBox.llx;
-    unsigned int const inputHeight = extractBox.ury - extractBox.lly;
+/*----------------------------------------------------------------------------
+   The proper orientation of the image on the page, given the user's
+   parameters 'cmdline' and the image dimensions 'extractBox'.
+-----------------------------------------------------------------------------*/
+    /* We're putting an _image_ on a _page_.  Either one can have portrait or
+       landscape aspect ratio.  In our return value, orientation just means
+       whether the image is rotated on the page: Portrait means it isn't
+       Landscape means it is.  The result can be confusing: Consider an image
+       which is a landscape, wider than it is tall, being printed on a page
+       which is also wider than it is tall.  The orientation we would return
+       for that case is Portrait.
+
+       The decision is simple: if the user didn't request a particular
+       orientation, we return the value that makes the image orientation match
+       the page orientation.  If both possibilities match equally (because the
+       image or the page is square), we return Portrait.
+    */
 
     enum Orientation retval;
 
     if (cmdline.orientation != UNSPECIFIED)
         retval = cmdline.orientation;
     else {
-        if ((!cmdline.xsize || !cmdline.ysize) &
-            (cmdline.xsize || cmdline.ysize)) {
-            /* User specified one output dimension, but not the other,
-               so we can't use output dimensions to make the decision.  So
-               just use the input dimensions.
-            */
-            if (inputHeight > inputWidth) retval = PORTRAIT;
-            else retval = LANDSCAPE;
+        /* Dimensions of image to print, in points */
+        unsigned int const imageWidPt = extractBox.urx - extractBox.llx;
+        unsigned int const imageHgtPt = extractBox.ury - extractBox.lly;
+        
+        /* Dimensions of image to print, in pixels (possibly of assumed
+           resolution)
+        */
+        unsigned int imageWidXel;
+        unsigned int imageHgtXel;
+
+        /* We have to deal with the awkward case that the printed pixels are
+           not square.  We match up the aspect ratio of the image in _pixels_
+           and the aspect ratio of the page in _pixels_.  But only the ratio
+           matters; we don't care what the absolute size of the pixels is.
+           And that's good, because if the user didn't specify xsize/ysize, we
+           don't know the absolute size in pixels.  In that case, fortunately,
+           the pixels are guaranteed to be square so we can just pretend it is
+           one point per pixel and get the right result.
+        */
+
+        if (cmdline.xsize && cmdline.ysize) {
+            imageWidXel = cmdline.xsize;
+            imageHgtXel = cmdline.ysize;
         } else {
-            unsigned int outputWidth, outputHeight;
-            if (cmdline.xsize) {
-                /* He gave xsize and ysize, so that's the output size */
-                outputWidth  = cmdline.xsize;
-                outputHeight = cmdline.ysize;
-            } else {
-                /* Well then we'll just use his (or default) xmax, ymax */
-                outputWidth  = cmdline.xmax;
-                outputHeight = cmdline.ymax;
-            }
+            /* Pixels are square, so it doesn't matter what the resolution
+               is; just call it one pixel per point.
+            */
+            imageWidXel = imageWidPt;
+            imageHgtXel = imageHgtPt;
 
-            if (inputHeight > inputWidth && outputHeight > outputWidth)
+            if (imageHgtXel >= imageWidXel && cmdline.ymax >= cmdline.xmax) {
+                /* Both image and page are higher than wide, so no rotation */
                 retval = PORTRAIT;
-            else if (inputHeight < inputWidth && 
-                     outputHeight < outputWidth)
+            } else if (imageHgtXel < imageWidXel &&
+                       cmdline.ymax < cmdline.xmax) {
+                /* Both image and page are wider than high, so no rotation */
                 retval = PORTRAIT;
-            else 
+            } else {
+                /* Image and pixel have opposite aspect ratios, so rotate
+                   for best fit.
+                */
                 retval = LANDSCAPE;
+            }
         }
     }
     return retval;