[comp.graphics] Patch for 'fbm': extension to 'raw2fbm' converter

hueni@optolab.pyl.unibe.ch (hermann hueni) (03/27/91)

Fbm is a very nice package for image manipulation and conversion. We
needed a way to convert our own homegrown format into different standard
image formats. 

The patch that is included at the end of this message will extend the routine
'raw2fbm' of the 'fbm'-package with a new option that allows to skip
a declared amount of "header-bytes" at the beginning of the raw file.

Maybe, that this small improvement will be useful to others...

For more information on fbm see the FAQ list of this newsgroup.

Hermann Hueni, hueni@iam.unibe.ch

----------------------------------cut here -------------------------------
*** fbm/raw2fbm.c	Mon Jun 25 07:20:11 1990
--- fbm-new/raw2fbm.c	Fri Mar 22 10:39:29 1991
***************
*** 12,17 ****
--- 12,18 ----
   * USAGE
   *	 % raw2fbm -t'title'
   *		   -c'credits'
+  *		   -s<skipBytes>
   *		   -a<aspect>
   *		   -w<width>
   *		   -h<height>
***************
*** 22,27 ****
--- 23,32 ----
   *	LastFileName = /usr2/mlm/src/misc/fbm/raw2fbm.c
   *
   * HISTORY
+  * 20-Mar-91  Hermann Hueni (hueni@iam.unibe.ch)
+  *	University of Berne, Switzerland
+  *	'-s<skipBytes>' enhancement
+  *
   * 25-Jun-90  Michael Mauldin (mlm@cs.cmu.edu) Carnegie Mellon
   *	Package for Release 1.0
   *
***************
*** 39,45 ****
  # include "fbm.h"
  
  # define USAGE \
! "Usage: raw2fbm [ -t'title' -c'credits' -a<aspect>\n\
  		 -w<width> -h<height> -d'<planes> ] < rawfile > fbm"
  
  #ifndef lint
--- 44,50 ----
  # include "fbm.h"
  
  # define USAGE \
! "Usage: raw2fbm [ -t'title' -c'credits' -s<skipBytes> -a<aspect>\n\
  		 -w<width> -h<height> -d'<planes> ] < rawfile > fbm"
  
  #ifndef lint
***************
*** 56,61 ****
--- 61,67 ----
    FBMHDR hdr;
    unsigned char *buf;
    char title[FBM_MAX_TITLE], credits[FBM_MAX_TITLE];
+   unsigned int  skipBytes = 0 ;
  
    title[0] = '\0';
    credits[0] = '\0';
***************
*** 65,70 ****
--- 71,77 ----
    { while (*++(*argv))
      { switch (**argv)
        { case 'a':	aspect  = atof (*argv+1); SKIPARG; break;
+ 	case 's':	skipBytes   = atoi (*argv+1); SKIPARG; break;
  	case 'w':	cols   = atoi (*argv+1); SKIPARG; break;
  	case 'h':	rows  = atoi (*argv+1); SKIPARG; break;
  	case 'd':	planes   = atoi (*argv+1); SKIPARG; break;
***************
*** 121,126 ****
--- 128,137 ----
    
    buf = (unsigned char *) malloc (cols);
    
+   /* skip leading header if asked for */
+   if (skipBytes > 0)
+ 	while (skipBytes--)
+ 		getchar() ;
    for (k=0; k<planes; k++)
    { for (j=0; j<rows; j++)  
      { if (! fread (buf, cols, 1, stdin))
*** fbm/raw2fbm.1	Mon Jun 25 07:20:11 1990
--- fbm-new/raw2fbm.1	Fri Mar 22 11:36:06 1991
***************
*** 4,10 ****
  raw2fbm \- convert raw image files to FBM format (especially Digi-View files)
  .SH SYNOPSIS
  .nf
! raw2fbm [ -t'title' -c'credits' -a<aspect>
            -w<width> -h<height> -d'<planes> ] < rawfile > fbm
  .fi
  .SH DESCRIPTION
--- 4,10 ----
  raw2fbm \- convert raw image files to FBM format (especially Digi-View files)
  .SH SYNOPSIS
  .nf
! raw2fbm [ -t'title' -c'credits' -s<skipBytes> -a<aspect>
            -w<width> -h<height> -d'<planes> ] < rawfile > fbm
  .fi
  .SH DESCRIPTION
***************
*** 33,38 ****
--- 33,43 ----
  the ratio of the height to width of a single pixel.  The default is 1.2
  (for Digi-View files).
  .TP
+ .BR -s
+ .I skipBytes,
+ number of bytes to skip (may be an unwanted header) once at the beginning
+ of the raw image stream.
+ .TP
  .BR -t'title'
  .I title,
  specify a character string (up to 80 characters) to describe the image.
***************
*** 64,69 ****
--- 69,77 ----
  recreational or commercial, provided that this copyright notice
  is retained unchanged.  This software is available to all free of
  charge by anonymous FTP and in the UUNET archives.
+ .TP
+ 20-Mar-91  Hermann Hueni at University of Berne
+ Extension with option -s<skipBytes> 
  .TP
  25-Jun-90  Michael Mauldin at Carnegie Mellon University
  Release 1.0 mlm@cs.cmu.edu