logo       


Choosing A Webhost:
A web hosting service is a type of Internet hosting service that allows individuals and organizations to provide their own website accessible via the World Wide Web. Web hosts are companies that provide space on a server they own for use by their clients as well as providing Internet connectivity, typically in a data center. Web hosts can also provide data center space and connectivity to the Internet for servers they do not own to be located in their data center, called colocation. more...

rev 230 - trunk: msg#00002

Subject: rev 230 - trunk
Author: giles
Date: 2003-04-01 13:57:40 -0800 (Tue, 01 Apr 2003)
New Revision: 230

Modified:
   trunk/jbig2dec.c
Log:
Implement the '-t' option for setting the output file format.
Useful for forcing pbm output even when compiled with png support.


Modified: trunk/jbig2dec.c
==============================================================================
--- trunk/jbig2dec.c    (original)
+++ trunk/jbig2dec.c    Tue Apr  1 13:57:40 2003
@@ -36,11 +36,19 @@
     usage,dump,render
 } jbig2dec_mode;
 
+typedef enum {
+    jbig2dec_format_jbig2,
+    jbig2dec_format_pbm,
+    jbig2dec_format_png,
+    jbig2dec_format_none
+} jbig2dec_format;
+
 typedef struct {
        jbig2dec_mode mode;
        int verbose, hash;
         SHA1_CTX *hash_ctx;
        char *output_file;
+       jbig2dec_format output_format;
 } jbig2dec_params_t;
 
 static int print_version(void);
@@ -88,6 +96,20 @@
     params->hash_ctx = NULL;
 }
 
+static int
+set_output_format(jbig2dec_params_t *params, const char *format)
+{
+#ifdef HAVE_LIBPNG
+    if (!strncasecmp(format, "png", 3)) {
+       params->output_format=jbig2dec_format_png;
+       return 0;
+    }
+#endif
+    /* default to pbm */
+    params->output_format=jbig2dec_format_pbm;
+    
+    return 0;
+}
 
 static int
 parse_options(int argc, char *argv[], jbig2dec_params_t *params)
@@ -144,6 +166,7 @@
                                params->output_file = strdup(optarg);
                                break;
                         case 't':
+                               set_output_format(params, optarg);
                                 break;
                        default:
                                if (!params->verbose) fprintf(stdout,
@@ -181,10 +204,16 @@
     "    -d --dump      print the structure of the jbig2 file\n"
     "                   rather than explicitly decoding\n"
     "       --version   program name and version information\n"
-    "       --hash     print a hash of the decode document\n"
-    "    -o <file>     send decoded output to <file>\n"
+    "       --hash      print a hash of the decode document\n"
+    "    -o <file>      send decoded output to <file>\n"
     "                   Defaults to the the input with a different\n"
     "                   extension. Pass '-' for stdout.\n"
+    "    -t <type>      force a particular output file format\n"
+ #ifdef HAVE_LIBPNG
+    "                   supported options are 'png' and 'pbm'\n"
+ #else
+    "                   the only supported option is 'pbm'\n"
+ #endif
     "\n"
   );
   
@@ -273,24 +302,35 @@
 static int
 write_page_image(jbig2dec_params_t *params, Jbig2Image *image)
 {
+      FILE *out;
+      
       if (!strncmp(params->output_file, "-", 2))
         {
-          fprintf(stderr, "writing decoded page to stdout\n");
+         switch (params->output_format) {
 #ifdef HAVE_LIBPNG
-          jbig2_image_write_png(image, stdout);
-#else
-          jbig2_image_write_pbm(image, stdout);
+            case jbig2dec_format_png:
+              jbig2_image_write_png(image, stdout);
+              break;
 #endif
+            case jbig2dec_format_pbm:
+              jbig2_image_write_pbm(image, stdout);
+              break;
+          }
         }
       else
         {
           if (params->verbose > 1)
             fprintf(stderr, "saving decoded page as '%s'\n", 
params->output_file);
+          switch (params->output_format) {
 #ifdef HAVE_LIBPNG
-          jbig2_image_write_png_file(image, params->output_file);
-#else
-          jbig2_image_write_pbm_file(image, params->output_file);
+            case jbig2dec_format_png:
+              jbig2_image_write_png_file(image, params->output_file);
+              break;
 #endif
+            case jbig2dec_format_pbm:
+              jbig2_image_write_pbm_file(image, params->output_file);
+              break;
+          }
         }
         
   return 0;
@@ -422,8 +462,10 @@
       {
 #ifdef HAVE_LIBPNG
         params.output_file = make_output_filename(argv[filearg], ".png");
+        params.output_format = jbig2dec_format_png;
 #else
         params.output_file = make_output_filename(argv[filearg], ".pbm");
+        params.output_format = jbig2dec_format_pbm;
 #endif
       }


Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe