pbmtog3 -stretch, final version

Gert Doering (gert@greenie.muc.de)
Wed, 9 Mar 1994 10:54:02 +0100


Hello,

I've incoporated Steven Work's patch into my version of g3topbm.c, with
some changes. Here's the final version:
------------------
--- g3topbm.c.old	Wed Mar  9 10:22:26 1994
+++ g3topbm.c	Wed Mar  9 10:51:02 1994
@@ -25,6 +25,7 @@
 #endif
 
 static int byte_tab[ 256 ];
+static int o_stretch;			/* -stretch: double each line */
 
 struct g3_tree * black, * white;
 
@@ -67,6 +68,10 @@
 	{
 	    init_byte_tab( 1, byte_tab );
 	}
+	else if (argv[i][1] == 's')
+	{
+	    o_stretch++;		/* -stretch this normal-res g3 */
+	}
 	i++;
     }
 
@@ -252,15 +257,24 @@
     fprintf( stderr, "consecutive EOLs: %d, max columns: %d\n", cons_eol, hcol );
 #endif
 
-    sprintf( rbuf, "P4\n%d %d\n", hcol, row );
+    sprintf( rbuf, "P4\n%d %d\n", hcol, ( o_stretch? row*2 : row ) );
     write( 1, rbuf, strlen( rbuf ));
 
-    if ( hcol == MAX_COLS )
+    if ( hcol == MAX_COLS && !o_stretch )
         write( 1, bitmap, (MAX_COLS/8) * row );
     else
     {
-	for ( i=0; i<row; i++ )
-	  write( 1, &bitmap[ i*(MAX_COLS/8) ], (hcol+7)/8 );
+	if ( !o_stretch )
+	  for ( i=0; i<row; i++ )
+	{
+	    write( 1, &bitmap[ i*(MAX_COLS/8) ], (hcol+7)/8 );
+	}
+	else				/* Double each row */
+	  for ( i=0; i<row; i++ )
+        {
+	    write( 1, &bitmap[ i*(MAX_COLS/8) ], (hcol+7)/8 );
+	    write( 1, &bitmap[ i*(MAX_COLS/8) ], (hcol+7)/8 );
+	}
     }
 
     return 0;
-- 
It can hardly be a coincidence that no language on Earth has ever
produced the expression `as pretty as an airport'.        -- D.Adams