home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume06 / tif2rast.p2 < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  6.1 KB

  1. From decwrl!ucbvax!tut.cis.ohio-state.edu!mailrus!cornell!batcomputer!itsgw!steinmetz!uunet!allbery Fri Mar 24 22:24:03 PST 1989
  2. Article 815 of comp.sources.misc:
  3. Path: decwrl!ucbvax!tut.cis.ohio-state.edu!mailrus!cornell!batcomputer!itsgw!steinmetz!uunet!allbery
  4. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5. Newsgroups: comp.sources.misc
  6. Subject: v06i050: Source Code for TIFF->SunRaster (Part 2)
  7. Message-ID: <50591@uunet.UU.NET>
  8. Date: 7 Mar 89 02:28:05 GMT
  9. Sender: allbery@uunet.UU.NET
  10. Reply-To: nobody@cs.buffalo.edu
  11. Organization: SUNY/Buffalo Computer Science
  12. Lines: 206
  13. Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  14.  
  15. Posting-number: Volume 6, Issue 50
  16. Submitted-by: nobody@cs.buffalo.edu
  17. Archive-name: tif2rast-p2
  18.  
  19. [Here we go again.  PLEASE MARK MULTIPART SUBMISSIONS IN ALL SUBJECT LINES!!!
  20. It makes things a lot easier for me and for people searching the archives
  21. ++bsa]
  22.  
  23. # This is a shell archive.  Remove anything before this line, then
  24. # unpack it by saving it in a file and typing "sh file".  (Files
  25. # unpacked will be owned by you and have default permissions.)
  26. #
  27. # This archive contains:
  28. # genrast.c getopt.c version.c tif2rast.1
  29.  
  30. echo x - genrast.c
  31. sed -e 's/^X//' > "genrast.c" << '//E*O*F genrast.c//'
  32. X
  33. X#include <rasterfile.h>
  34. X#include <stdio.h>
  35. X#include "defs.h"
  36. X#include "tif.h"
  37. X
  38. Xstruct rasterfile ras;
  39. X
  40. Xint bytes_per_row = 0;
  41. X
  42. Xgenrast(filename, picts)
  43. X     char    *filename;
  44. X     PICTURE *picts;
  45. X{
  46. X  int i;
  47. X
  48. X  /* calculate raster header and swap bytes */
  49. X  bytes_per_row = (int) (picts[0].image.imWidth / 8);
  50. X  ras.ras_magic = RAS_MAGIC;
  51. X  ras.ras_width = picts[0].image.imWidth;
  52. X  ras.ras_height = picts[0].image.imLength;
  53. X  ras.ras_depth = 1;
  54. X  ras.ras_length = (bytes_per_row * picts[0].image.imLength);
  55. X  ras.ras_type = 1;
  56. X  ras.ras_maptype = 0;
  57. X  ras.ras_maplength = 0;
  58. X  
  59. X  /* write out rasterfile header */
  60. X  fwrite((char *) &ras,sizeof(struct rasterfile),1,stdout);
  61. X  for (i = 0; i < picts[0].image.strips[0].byteCount; i++) 
  62. X    printf("%c", picts[0].image.strips[0].data[i]);
  63. X}
  64. X
  65. X
  66. //E*O*F genrast.c//
  67.  
  68. echo x - getopt.c
  69. sed -e 's/^X//' > "getopt.c" << '//E*O*F getopt.c//'
  70. X/*
  71. X *    I got this off net.sources from Henry Spencer.
  72. X *    It is a public domain getopt(3) like in System V.
  73. X *
  74. X *    I made some minor modifications while porting it to MS-DOS.
  75. X *        andy@coma
  76. X */
  77. X#include <stdio.h>
  78. X#include <string.h>
  79. X
  80. X#define    ARGCH    (int)':'
  81. X#define BADCH     (int)'?'
  82. X#define EMSG     ""
  83. X#define    ENDARGS  "--"
  84. X
  85. X/*
  86. X * get option letter from argument vector
  87. X */
  88. Xint    optind = 1,        /* index into parent argv vector */
  89. X    optopt;            /* character checked for validity */
  90. Xchar    *optarg;        /* argument associated with option */
  91. X
  92. X#define tell(s)    fputs(*nargv,stderr);fputs(s,stderr); \
  93. X        (void)fputc(optopt,stderr);(void)fputc('\n',stderr); \
  94. X                return(BADCH);
  95. X
  96. Xint getopt(nargc,nargv,ostr)
  97. Xint    nargc;
  98. Xchar    **nargv,
  99. X    *ostr;
  100. X{
  101. X    static char    *place = EMSG;    /* option letter processing */
  102. X    register char    *oli;        /* option letter list index */
  103. X
  104. X    if(!*place) {            /* update scanning pointer */
  105. X        if(optind >= nargc || *(place = nargv[optind]) != '-' || !*++place) return(EOF);
  106. X        if (*place == '-') {    /* found "--" */
  107. X            ++optind;
  108. X            return(EOF);
  109. X        }
  110. X    }                /* option letter okay? */
  111. X    if ((optopt = (int)*place++) == ARGCH || !(oli = strchr (ostr,optopt))) {
  112. X        if(!*place) ++optind;
  113. X        tell(": illegal option -- ");
  114. X    }
  115. X    if (*++oli != ARGCH) {        /* don't need argument */
  116. X        optarg = NULL;
  117. X        if (!*place) ++optind;
  118. X    }
  119. X    else {                /* need an argument */
  120. X        if (*place) optarg = place;    /* no white space */
  121. X        else if (nargc <= ++optind) {    /* no arg */
  122. X            place = EMSG;
  123. X            tell(": option requires an argument -- ");
  124. X        }
  125. X         else optarg = nargv[optind];    /* white space */
  126. X        place = EMSG;
  127. X        ++optind;
  128. X    }
  129. X    return(optopt);            /* dump back option letter */
  130. X}
  131. //E*O*F getopt.c//
  132.  
  133. echo x - version.c
  134. sed -e 's/^X//' > "version.c" << '//E*O*F version.c//'
  135. X#include "defs.h"
  136. XCHAR *version () {
  137. X  STATIC CHAR ConfID[] =  "1.0 (Sun Feb 12 21:55:10 1989 by wu@sunybcs)";
  138. X  return ConfID;
  139. X}
  140. //E*O*F version.c//
  141.  
  142. echo x - tif2rast.1
  143. sed -e 's/^X//' > "tif2rast.1" << '//E*O*F tif2rast.1//'
  144. X...
  145. X... tif2rast/tifdump -- convert TIFF to Sun raster
  146. X...
  147. X... written by:
  148. X... Andreas Lampen, TU-Berlin (andy@coma.UUCP)
  149. X...                 (andy@db0tui62.BITNET)
  150. X... William W.C. Wu, State University of New York at Buffalo
  151. X...                  (wu@sunybcs.bitnet)
  152. X...                  (wu@cs.buffalo.edu)
  153. X...
  154. X... Copyright (C) 1988 by the author.
  155. X... Permission is granted to copy and distribute this program
  156. X... without charge, provided this copyright notice is included
  157. X... in the copy.
  158. X... This Software is distributed on an as-is basis. There will be
  159. X... ABSOLUTELY NO WARRANTY for any part of this software to work
  160. X... correct. In no case will the author be liable to you for damages
  161. X... caused by the usage of this software.
  162. X...
  163. X.TH TIF2RAST 1
  164. X.SH NAME
  165. Xtif2Rast, tifdump \- convert TIFF files to Sun Raster
  166. X.SH SYNOPSIS
  167. X.B tif2rast
  168. X.RB [ \-h
  169. X.IR height ]
  170. X.RB [ \-s ]
  171. X.IR scalefactor ]
  172. X.RB [ \-v ]
  173. X.RB [ \-x
  174. X.IR x-offset ]
  175. X.RB [ \-y
  176. X.IR y-offset ]
  177. Xfile1 ...
  178. X.LP
  179. X.B tifdump 
  180. X.RB [ \-v ]
  181. Xfile1 ...
  182. X.SH DESCRIPTION
  183. X\fITif2rast\fR converts a TIFF file to Sun Raster file, and writes the result
  184. Xto standard output.
  185. X\fITif2rast\fR recognizes the following options:
  186. X.TP
  187. X.BI \-v
  188. Xprints the version identification of \fItif2rast\fR.
  189. X.LP
  190. X\fITifdump\fR produces a human readable dump of the given TIFF-files.
  191. XThe result is written to standard output.
  192. X.SH BUGS
  193. XThis version of \fItif2rast\fR has not been tested very extensively yet.
  194. XSo don't be too angry if it produces core dumps or incorrect Sun Raster
  195. Xfiles.
  196. XIn that case, please drop a short error report to the author.
  197. X.br
  198. X.PP
  199. XData compression is not yet supported.
  200. X.PP
  201. X.SH AUTHOR 1
  202. XAndreas Lampen, TU Berlin
  203. X.sp
  204. X.ta 0.7i 
  205. XUUCP:    unido!coma!andy
  206. X.br
  207. XBITNET:    andy@db0tui62
  208. X.PP
  209. X.SH AUTHOR 2
  210. XWilliam W.C. Wu, State University of New York at Buffalo
  211. X.sp
  212. X.ta 0.7i 
  213. XUUCP:    ..!{boulder,decvax,rutgers}!sunybcs!wu
  214. X.br
  215. XBITNET:    wu@sunybcs.bitnet
  216. X.br
  217. XINTERNET: wu@cs.buffalo.edu
  218. //E*O*F tif2rast.1//
  219.  
  220. exit 0
  221.  
  222.  
  223.