home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume36 / chiaro / part01 < prev    next >
Encoding:
Text File  |  1993-03-24  |  53.7 KB  |  1,684 lines

  1. Newsgroups: comp.sources.misc
  2. From: jwbirdsa@picarefy.picarefy.com (James W. Birdsall)
  3. Subject: v36i071:  chiaro - Image Utilities, Part01/18
  4. Message-ID: <csm-v36i071=chiaro.120734@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: 44932c7988c6e4dfa938da66229ec2ea
  6. Date: Thu, 25 Mar 1993 18:09:04 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: jwbirdsa@picarefy.picarefy.com (James W. Birdsall)
  10. Posting-number: Volume 36, Issue 71
  11. Archive-name: chiaro/part01
  12. Environment: UNIX, Sun, DECstation, 3B1
  13.  
  14. This is the Chiaro Suite, a group of image analysis programs covering
  15. several popular formats (GIF, IMG, JFIF, PCX, PBM/PGM/PPM, SunRaster,
  16. Targa, XBM, and BMP). At present, only the GIF format is extensively
  17. supported; additional formats will be added in future releases. The Chiaro
  18. Suite is currently comprised of three programs: chils, gifstrip, and
  19. gifcheck. A manual page for each is provided.
  20.  
  21. This version of the Chiaro Suite is intended for computers running UNIX
  22. and UNIX-like operating systems. It requires that the "char" type be
  23. exactly eight bits. It works on machines where type "int" is 16 or 32 bits,
  24. and type "long int" is 32 bits. It should work on machines with more bits,
  25. but has not been tested on such.
  26.  
  27. ------------
  28. #! /bin/sh
  29. # This is a shell archive.  Remove anything before this line, then feed it
  30. # into a shell via "sh file" or similar.  To overwrite existing files,
  31. # type "sh file -c".
  32. # Contents:  README src src/chidisp.c templates
  33. # Wrapped by kent@sparky on Thu Mar 25 11:20:00 1993
  34. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  35. echo If this archive is complete, you will see the following message:
  36. echo '          "shar: End of archive 1 (of 18)."'
  37. if test -f 'README' -a "${1}" != "-c" ; then 
  38.   echo shar: Will not clobber existing file \"'README'\"
  39. else
  40.   echo shar: Extracting \"'README'\" \(4250 characters\)
  41.   sed "s/^X//" >'README' <<'END_OF_FILE'
  42. XTHE CHIARO SUITE
  43. XJames W. Birdsall
  44. Xrelease: 03/19/93
  45. X
  46. XINTRO:
  47. X   This is the Chiaro Suite, a group of image analysis programs covering
  48. Xseveral popular formats. At present, only the GIF format is extensively
  49. Xsupported; additional formats will be added in future releases. The Chiaro
  50. XSuite is currently comprised of three programs: chils, gifstrip, and
  51. Xgifcheck. A manual page for each is provided.
  52. X
  53. XREQUIREMENTS:
  54. X   This version of the Chiaro Suite is intended for computers running UNIX
  55. Xand UNIX-like operating systems. It requires that the "char" type be
  56. Xexactly eight bits. It works on machines where type "int" is 16 or 32 bits,
  57. Xand type "long int" is 32 bits. It should work on machines with more bits,
  58. Xbut has not been tested on such.
  59. X
  60. X   If your compiler does not support long identifiers, you will have to run
  61. Xthe "Shorten" utility. If you do not know whether your compiler supports
  62. Xlong identifiers, attempt to compile without running the Shorten utility.
  63. XIf you see many error messages stating that symbols have been redeclared,
  64. Xyour compiler does not support long identifiers. You can use the 'clean'
  65. Xtarget in the makefile ("make clean") to clean up any object files or other
  66. Xtemporary files already created.
  67. X
  68. XINSTALLATION:
  69. X   This version of the Chiaro Suite is intended for computers running UNIX
  70. Xand UNIX-like operating systems. Installation is relatively simple:
  71. X
  72. X    1)  Go into the templates directory and follow the directions
  73. X        in the README there.
  74. X    1a) If your compiler does not support long identifiers, go into the
  75. X        src directory and run the Shorten utility by "make -f Shorten".
  76. X        This usually takes a while to run. If it fails, see "NOTES ON
  77. X        MAKE" below.
  78. X    2)  In the src directory, type "make". The programs will automatically
  79. X        be compiled and linked. 
  80. X    3)  Move the executables, the manual pages, and the file chils.cfg
  81. X        wherever you want them to live permanently. The executables and
  82. X        manual pages do not have to be in the same directory. See the
  83. X        manual page for chils for restrictions on placement of the
  84. X        file chils.cfg.
  85. X    4)  You may customize the file chils.cfg for your preferences and
  86. X        environment. See the manual page for chils for the format and
  87. X        contents of chils.cfg.
  88. X
  89. XCHANGES:
  90. X   If you have to create new template files because your system is not
  91. Xalready supported, the author would appreciate it very much if you would
  92. Xmail him your template files, along with as detailed a description of your
  93. Xsystem (hardware, OS, versions, etc.) as possible. Template files sent in
  94. Xwill probably be included in the next release, with appropriate credits.
  95. XInformation on contacting the author is included toward the end of each
  96. Xmanual page.
  97. X
  98. X   If you have to make changes to the source code itself, the author would
  99. Xlike to hear about it as soon as possible, preferably in the form of
  100. Xcontext diffs (and a detailed description of your system). Such changes
  101. Xwill probably be included in the next release, with appropriate credits.
  102. X
  103. XNOTES ON MAKE:
  104. X   Most "make" utilities use the Bourne shell (sh) to execute commands.
  105. XHowever, some use whatever shell is specified by the SHELL environment
  106. Xvariable. If the Shorten utility fails, try adjusting the SHELL environment
  107. Xvariable (the Bourne shell is typically found in /bin/sh). The easiest way
  108. Xto do this, which works in most environments, is: start a Bourne shell as a
  109. Xsubshell of your current one by "sh", change the SHELL environment variable
  110. Xby "SHELL=/bin/sh; export SHELL", then do "make -f Shorten" again. When it
  111. Xis complete, exit the subshell (hitting control-D works on most systems).
  112. X
  113. XMISC:
  114. X   The Chiaro Suite is also available for IBM PCs and compatibles running
  115. XDOS.
  116. X
  117. XCOPYRIGHT AND WARRANTY:
  118. X   Copyright (c) 1993 by James W. Birdsall, all rights reserved.
  119. XPermission is granted to any individual or institution to use, copy, or
  120. Xredistribute this software so long as all of the original files are included
  121. Xunmodified, that it is not sold for profit, and that this copyright notice
  122. Xis retained.
  123. X
  124. XLIKE ANYTHING ELSE THAT'S FREE, THE CHIARO SUITE IS PROVIDED AS IS AND COMES
  125. XWITH NO WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED. IN NO EVENT WILL
  126. XTHE AUTHOR BE LIABLE FOR ANY DAMAGES RESULTING FROM THE USE OF THIS SOFTWARE.
  127. END_OF_FILE
  128.   if test 4250 -ne `wc -c <'README'`; then
  129.     echo shar: \"'README'\" unpacked with wrong size!
  130.   fi
  131.   # end of 'README'
  132. fi
  133. if test ! -d 'src' ; then
  134.     echo shar: Creating directory \"'src'\"
  135.     mkdir 'src'
  136. fi
  137. if test -f 'src/chidisp.c' -a "${1}" != "-c" ; then 
  138.   echo shar: Will not clobber existing file \"'src/chidisp.c'\"
  139. else
  140.   echo shar: Extracting \"'src/chidisp.c'\" \(46063 characters\)
  141.   sed "s/^X//" >'src/chidisp.c' <<'END_OF_FILE'
  142. X/***************************************************************************
  143. X*   CHIDISP.C                                                              *
  144. X*   MODULE:  -                                                             *
  145. X*   OS:      UNIX                                                          *
  146. X*                                                                          *
  147. X*   Copyright (c) 1993 James W. Birdsall. All Rights Reserved.             *
  148. X*                                                                          *
  149. X*   The Graphics Interchange Format(c) is the Copyright property of        *
  150. X*   CompuServe Incorporated. GIF(sm) is a Service Mark property of         *
  151. X*   CompuServe Incorporated.                                               *
  152. X*                                                                          *
  153. X*   $Id: chidisp.c,v 1.6 1993/03/12 21:01:31 jwbirdsa Exp $
  154. X*                                                                          *
  155. X*   Display functions for Chiaro suite LS program.                         *
  156. X*                                                                          *
  157. X***************************************************************************/
  158. X
  159. X#include "config.h"
  160. X
  161. X/*
  162. X** system includes <>
  163. X*/
  164. X
  165. X#include <stdio.h>
  166. X#include <ctype.h>
  167. X#ifndef NO_STDLIB
  168. X#include <stdlib.h>
  169. X#endif
  170. X#ifndef NO_STR_INC
  171. X#ifdef STRING_PLURAL
  172. X#include <strings.h>
  173. X#else
  174. X#include <string.h>
  175. X#endif
  176. X#endif
  177. X
  178. X
  179. X/*
  180. X** custom includes ""
  181. X*/
  182. X
  183. X#include "depend.h"
  184. X
  185. X#include "fb.h"
  186. X#include "formats.h"
  187. X#include "gif.h"
  188. X#include "img.h"
  189. X#include "jfif.h"
  190. X#include "sr.h"
  191. X#include "tga.h"
  192. X#include "pnm.h"
  193. X#include "xbm.h"
  194. X#include "bmp.h"
  195. X#include "pcx.h"
  196. X
  197. X#include "chils.h"
  198. X#include "chidisp.h"
  199. X
  200. X
  201. X/*
  202. X** local #defines
  203. X*/
  204. X
  205. X#define PRINT_FMT(f,d)         printf("%-8s ", ((fm_name(f) != NULL) ? \
  206. X                                                fm_name(f) : (d)))
  207. X
  208. X
  209. X/*
  210. X** misc: copyright strings, version macros, etc.
  211. X*/
  212. X
  213. Xstatic char CONST rcsid[] = "$Id: chidisp.c,v 1.6 1993/03/12 21:01:31 jwbirdsa Exp $";
  214. X
  215. X
  216. X/*
  217. X** typedefs
  218. X*/
  219. X
  220. X/*
  221. X** global variables
  222. X*/
  223. X
  224. Xint screencols = 0;
  225. X
  226. X/*
  227. X** function prototypes
  228. X*/
  229. X
  230. X#ifdef  __STDC__
  231. X# define P_(s) s
  232. X#else
  233. X# define P_(s) ()
  234. X#endif
  235. X
  236. Xstatic VOID printname P_((char *origname, int printed));
  237. X
  238. X#undef P_
  239. X
  240. X#ifdef NO_STDLIB
  241. Xextern char *getenv();
  242. X#endif
  243. X
  244. X#ifdef NO_STR_INC
  245. Xextern int strlen();
  246. Xextern char *strrchr();
  247. X#endif
  248. X
  249. X
  250. X/*
  251. X** functions
  252. X*/
  253. X
  254. X/***************************************************************************
  255. X*   FUNCTION:  setcols                                                     *
  256. X*                                                                          *
  257. X*   DESCRIPTION:                                                           *
  258. X*                                                                          *
  259. X*       Sets the value of the screencols variable (unless less than 80,    *
  260. X*       which is adjusted to 80).                                          *
  261. X*                                                                          *
  262. X*   ENTRY:                                                                 *
  263. X*                                                                          *
  264. X*       Nothing.                                                           *
  265. X*                                                                          *
  266. X*   EXIT:                                                                  *
  267. X*                                                                          *
  268. X*       Nothing.                                                           *
  269. X*                                                                          *
  270. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  271. X*                                                                          *
  272. X***************************************************************************/
  273. XVOID
  274. X#ifdef __STDC__
  275. Xsetcols(int cols)
  276. X#else
  277. Xsetcols(cols)
  278. Xint cols;
  279. X#endif
  280. X{
  281. X    screencols = ((cols < 80) ? 80 : cols);
  282. X
  283. X    return;
  284. X} /* end of setcols() */
  285. X
  286. X
  287. X/***************************************************************************
  288. X*   FUNCTION:  getcols                                                     *
  289. X*                                                                          *
  290. X*   DESCRIPTION:                                                           *
  291. X*                                                                          *
  292. X*       Retrieves the number of columns on the screen and stores it in     *
  293. X*       the screencols variable.                                           *
  294. X*                                                                          *
  295. X*   ENTRY:                                                                 *
  296. X*                                                                          *
  297. X*       Nothing.                                                           *
  298. X*                                                                          *
  299. X*   EXIT:                                                                  *
  300. X*                                                                          *
  301. X*       Nothing.                                                           *
  302. X*                                                                          *
  303. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  304. X*                                                                          *
  305. X***************************************************************************/
  306. XVOID
  307. Xgetcols()
  308. X{
  309. X#ifdef HAS_TERMINFO
  310. X    FILE *pipe;
  311. X#endif
  312. X#ifndef HAS_TERMCAP
  313. X    char scratch[80];
  314. X#else
  315. X    char scratch[1024];
  316. X#endif
  317. X
  318. X    if (screencols != 0)
  319. X    {
  320. X        /* Has already been set, do nothing. */
  321. X
  322. X        return;
  323. X    }
  324. X
  325. X#ifdef HAS_TERMINFO
  326. X    /* Run the terminfo tput program and read its output. */
  327. X
  328. X    sprintf(scratch, "%s cols", TERMINFO_PATH);
  329. X    if ((pipe = popen(scratch, "r")) != ((FILE *) NULL))
  330. X    {
  331. X        int c;
  332. X
  333. X        while (isdigit(c = fgetc(pipe)))
  334. X        {
  335. X            screencols *= 10;
  336. X            screencols += (c - '0');
  337. X        }
  338. X    }
  339. X#endif
  340. X
  341. X#ifdef HAS_TERMCAP
  342. X    /* Only do termcap if not already set by terminfo. */
  343. X
  344. X    if (0 == screencols)
  345. X    {
  346. X        char *termname = getenv("TERM");
  347. X
  348. X        if ((termname) && (tgetent(scratch, termname) == 1))
  349. X        {
  350. X            /* Returns -1 on error, which will be adjusted to 80 below. */
  351. X
  352. X            screencols = tgetnum("co");
  353. X        }
  354. X    }
  355. X#endif
  356. X
  357. X    /* If not set by now, or less than 80, arbitrarily set to 80. */
  358. X
  359. X    if (screencols < 80)
  360. X    {
  361. X        screencols = 80;
  362. X    }
  363. X
  364. X    return;
  365. X} /* end of getcols() */
  366. X
  367. X
  368. X/***************************************************************************
  369. X*   FUNCTION:  gif_display                                                 *
  370. X*                                                                          *
  371. X*   DESCRIPTION:                                                           *
  372. X*                                                                          *
  373. X*       Display function for GIF files.                                    *
  374. X*                                                                          *
  375. X*   ENTRY:                                                                 *
  376. X*                                                                          *
  377. X*       gifinfo  - contains header info from GIF file                      *
  378. X*       infile   - file pointer for GIF file, to do fast terminator check  *
  379. X*       filename - name of GIF file                                        *
  380. X*       filesize - size of GIF file                                        *
  381. X*                                                                          *
  382. X*   EXIT:                                                                  *
  383. X*                                                                          *
  384. X*       Nothing.                                                           *
  385. X*                                                                          *
  386. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  387. X*                                                                          *
  388. X***************************************************************************/
  389. XVOID
  390. X#ifdef __STDC__
  391. Xgif_display(GIF_LSD *gifinfo, FILE *infile, char *filename, long filesize)
  392. X#else
  393. Xgif_display(gifinfo, infile, filename, filesize)
  394. XGIF_LSD *gifinfo;
  395. XFILE *infile;
  396. Xchar *filename;
  397. Xlong filesize;
  398. X#endif
  399. X{
  400. X    char c;
  401. X    long uncsize;
  402. X    int printed = 0;
  403. X
  404. X    /* Print out format identifier. */
  405. X
  406. X    PRINT_FMT(gifinfo->version, GIF_MAIN);
  407. X
  408. X    /* 
  409. X    ** Perform a fast check for junk on the end.
  410. X    ** GIF files should end with a semicolon (GIF_TERMINATOR).
  411. X    */
  412. X
  413. X    if (fseek(infile, -1L, SEEK_END))
  414. X    {
  415. X        printf("\nERROR: Error seeking in file %s\n", filename);
  416. X        return;
  417. X    }
  418. X    if (fread(&c, 1, 1, infile) != 1)
  419. X    {
  420. X        printf("\nERROR: Error reading file %s\n", filename);
  421. X        return;
  422. X    }
  423. X    printf(((GIF_TERMINATOR == c) ? "-" : "E"));
  424. X
  425. X    /* Print global color table flag. */
  426. X
  427. X    printf(((gifinfo->gct_flag) ? "G" : "-"));
  428. X
  429. X    /* Print global color table sort flag if 89a. */
  430. X
  431. X    if (GIF_89A == gifinfo->version)
  432. X    {
  433. X        printf(((gifinfo->sort_flag) ? "S" : "-"));
  434. X    }
  435. X    else
  436. X    {
  437. X        printf(" ");
  438. X    }
  439. X
  440. X    /* Print some spaces and filesize. */
  441. X
  442. X    printf("  %6ld", filesize);
  443. X
  444. X    /* Print logical screen height, width, and size of color table. */
  445. X
  446. X    printf(" %4u x %4u @ ", gifinfo->scr_wid, gifinfo->scr_hi);
  447. X    if (gifinfo->gct_flag)
  448. X    {
  449. X        printf("%-3d", (0x1 << gifinfo->gct_size));
  450. X    }
  451. X    else
  452. X    {
  453. X        printf("---");
  454. X    }
  455. X    printf("   ");
  456. X    printed++;
  457. X
  458. X    /*
  459. X    ** Calculate and print approximate compression ratio,
  460. X    ** but only if there is a global color table!
  461. X    */
  462. X
  463. X    printf("C~");
  464. X    if (gifinfo->gct_flag)
  465. X    {
  466. X        uncsize = ((long) gifinfo->scr_wid) * ((long) gifinfo->scr_hi);
  467. X        uncsize *= (long) gifinfo->gct_size;
  468. X        uncsize /= 8L;
  469. X        printf("%-3ld", ((filesize * 100L) / uncsize));
  470. X    }
  471. X    else
  472. X    {
  473. X        printf("-- ");
  474. X    }
  475. X    printed += 5;
  476. X
  477. X    /* Print aspect ratio if 89a. */
  478. X
  479. X    if (GIF_89A == gifinfo->version)
  480. X    {
  481. X        printf(" AS");
  482. X
  483. X        /* If gifinfo->aspect is 0, then no aspect ratio data present. */
  484. X
  485. X        if (0 == gifinfo->aspect)
  486. X        {
  487. X            printf("none ");
  488. X        }
  489. X        else
  490. X        {
  491. X            printf("%02d/64", gifinfo->aspect);
  492. X        }
  493. X        printed += 8;
  494. X    }
  495. X
  496. X    /* Finally, print filename. */
  497. X
  498. X    printname(filename, printed);
  499. X
  500. X    return;
  501. X} /* end of gif_display() */
  502. X
  503. X
  504. X/***************************************************************************
  505. X*   FUNCTION:  img_display                                                 *
  506. X*                                                                          *
  507. X*   DESCRIPTION:                                                           *
  508. X*                                                                          *
  509. X*       Display function for IMG files.                                    *
  510. X*                                                                          *
  511. X*   ENTRY:                                                                 *
  512. X*                                                                          *
  513. X*       imginfo  - contains header info from IMG file                      *
  514. X*       filename - name of IMG file                                        *
  515. X*       filesize - size of IMG file                                        *
  516. X*                                                                          *
  517. X*   EXIT:                                                                  *
  518. X*                                                                          *
  519. X*       Nothing.                                                           *
  520. X*                                                                          *
  521. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  522. X*                                                                          *
  523. X***************************************************************************/
  524. XVOID
  525. X#ifdef __STDC__
  526. Ximg_display(IMG_HDR *imginfo, char *filename, long filesize)
  527. X#else
  528. Ximg_display(imginfo, filename, filesize)
  529. XIMG_HDR *imginfo;
  530. Xchar *filename;
  531. Xlong filesize;
  532. X#endif
  533. X{
  534. X    long uncsize;
  535. X    int printed = 0;
  536. X
  537. X    /* Print out format identifier. */
  538. X
  539. X    PRINT_FMT(imginfo->version, IMG_MAIN);
  540. X
  541. X    /* Print 'L' if long header, '-' if normal length. */
  542. X
  543. X    printf("%c", (((imginfo->headerlen * 2) > IMG_HDR_LEN) ? 'L' : '-'));
  544. X
  545. X    /* Print some spaces and filesize. */
  546. X
  547. X    printf("    %6ld", filesize);
  548. X
  549. X    /* Print image height, width, and maximum number of colors. */
  550. X
  551. X    printf(" %4u x %4u @ ", imginfo->imwid, imginfo->imhi);
  552. X    printf("%-3u   ", (0x1 << imginfo->planes));
  553. X    printed++;
  554. X
  555. X    /* Calculate and print approximate compression ratio. */
  556. X
  557. X    printf("C~");
  558. X    uncsize = ((long) imginfo->imwid) * ((long) imginfo->imhi);
  559. X    uncsize *= (long) imginfo->planes;
  560. X    uncsize /= 8L;
  561. X    printf("%-3ld", (((filesize - (imginfo->headerlen * 2)) * 100L) /
  562. X                     uncsize));
  563. X    printed += 5;
  564. X
  565. X    /* Print aspect ratio. */
  566. X
  567. X    printf(" AS%3u/%-3u", imginfo->pixwid, imginfo->pixhi);
  568. X    printed += 10;
  569. X
  570. X    /* Print pattern length. */
  571. X
  572. X    printf(" P%1u", imginfo->patternlen);
  573. X    printed += 3;
  574. X
  575. X    /* Finally, print filename. */
  576. X
  577. X    printname(filename, printed);
  578. X
  579. X    return;
  580. X} /* end of img_display() */
  581. X
  582. X
  583. X/***************************************************************************
  584. X*   FUNCTION:  jfif_display                                                *
  585. X*                                                                          *
  586. X*   DESCRIPTION:                                                           *
  587. X*                                                                          *
  588. X*       Display function for JFIF files.                                   *
  589. X*                                                                          *
  590. X*   ENTRY:                                                                 *
  591. X*                                                                          *
  592. X*       jfifinfo  - contains header info from JFIF file                    *
  593. X*       filename - name of IMG file                                        *
  594. X*       filesize - size of IMG file                                        *
  595. X*                                                                          *
  596. X*   EXIT:                                                                  *
  597. X*                                                                          *
  598. X*       Nothing.                                                           *
  599. X*                                                                          *
  600. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  601. X*                                                                          *
  602. X***************************************************************************/
  603. XVOID
  604. X#ifdef __STDC__
  605. Xjfif_display(JFIF_HDR *jfifinfo, char *filename, long filesize)
  606. X#else
  607. Xjfif_display(jfifinfo, filename, filesize)
  608. XJFIF_HDR *jfifinfo;
  609. Xchar *filename;
  610. Xlong filesize;
  611. X#endif
  612. X{
  613. X    long uncsize;
  614. X    int printed = 0;
  615. X
  616. X    /* Print out format identifier. */
  617. X
  618. X    PRINT_FMT(jfifinfo->version, JFIF_MAIN);
  619. X
  620. X    /* Print 'T' if thumbnail present, '-' if not. */
  621. X
  622. X    if ((jfifinfo->xthumb != 0) && (jfifinfo->ythumb != 0))
  623. X    {
  624. X        printf("T");
  625. X    }
  626. X    else
  627. X    {
  628. X        printf("-");
  629. X    }
  630. X
  631. X    /* Print some spaces and filesize. */
  632. X
  633. X    printf("    %6ld", filesize);
  634. X
  635. X    /* Print image height, width, components, and bits per sample. */
  636. X
  637. X    printf(" %4u x %4u", jfifinfo->width, jfifinfo->height);
  638. X    printf(", %1d @%2d  ", jfifinfo->components, jfifinfo->bits);
  639. X    printed++;
  640. X
  641. X    /* Calculate and print approximate compression ratio. */
  642. X
  643. X    printf("C~");
  644. X    uncsize = ((long) jfifinfo->height) * ((long) jfifinfo->height);
  645. X    uncsize *= (((long) jfifinfo->components) * ((long) jfifinfo->bits));
  646. X    uncsize /= 8L;
  647. X    printf("%-3ld", ((filesize * 100L) / uncsize));
  648. X    printed += 5;
  649. X
  650. X    /* Print aspect ratio or density. */
  651. X
  652. X    if (jfifinfo->densunit != JFIF_DENS_ASPECT)
  653. X    {
  654. X        printf(" %3u x%3u ", jfifinfo->xdens, jfifinfo->ydens);
  655. X        if (JFIF_DENS_DPI == jfifinfo->densunit)
  656. X        {
  657. X            printf("dpi ");
  658. X        }
  659. X        else if (JFIF_DENS_DPCM == jfifinfo->densunit)
  660. X        {
  661. X            printf("dpcm");
  662. X        }
  663. X        else
  664. X        {
  665. X            printf("????");
  666. X        }
  667. X        printed += 14;
  668. X    }
  669. X    else
  670. X    {
  671. X        printf(" AS%3u/%3u", jfifinfo->xdens, jfifinfo->ydens);
  672. X        printed += 10;
  673. X    }
  674. X
  675. X    /* Finally, print filename. */
  676. X
  677. X    printname(filename, printed);
  678. X
  679. X    return;
  680. X} /* end of jfif_display() */
  681. X
  682. X
  683. X/***************************************************************************
  684. X*   FUNCTION:  sr_display                                                  *
  685. X*                                                                          *
  686. X*   DESCRIPTION:                                                           *
  687. X*                                                                          *
  688. X*       Display function for SR files.                                     *
  689. X*                                                                          *
  690. X*   ENTRY:                                                                 *
  691. X*                                                                          *
  692. X*       srinfo   - contains header info from SR file                       *
  693. X*       filename - name of SR file                                         *
  694. X*       filesize - size of SR file                                         *
  695. X*                                                                          *
  696. X*   EXIT:                                                                  *
  697. X*                                                                          *
  698. X*       Nothing.                                                           *
  699. X*                                                                          *
  700. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  701. X*                                                                          *
  702. X***************************************************************************/
  703. XVOID
  704. X#ifdef __STDC__
  705. Xsr_display(SR_HDR *srinfo, char *filename, long filesize)
  706. X#else
  707. Xsr_display(srinfo, filename, filesize)
  708. XSR_HDR *srinfo;
  709. Xchar *filename;
  710. Xlong filesize;
  711. X#endif
  712. X{
  713. X    char type;
  714. X    int printed = 0;
  715. X    ULONG uncsize;
  716. X
  717. X    /* Print format ID. */
  718. X
  719. X    PRINT_FMT(SR_1, SR_MAIN);
  720. X
  721. X    /* Print type flag. */
  722. X
  723. X    switch (srinfo->rastype)
  724. X    {
  725. X        /* Old format. */
  726. X        case 0:
  727. X            type = 'O';
  728. X            break;
  729. X
  730. X        /* Standard format. */
  731. X        case 1:
  732. X            type = 'S';
  733. X            break;
  734. X
  735. X        /* Byte-encoded (compressed) format. */
  736. X        case 2:
  737. X            type = 'C';
  738. X            break;
  739. X
  740. X        /* 24-bit format in (X)RGB order (instead of (X)BGR). */
  741. X        case 3:
  742. X            type = 'R';
  743. X            break;
  744. X
  745. X        /* "tiff <-> standard rasterfile" */
  746. X        case 4:
  747. X            type = 'T';
  748. X            break;
  749. X
  750. X        /* "iff (TAAC format) <-> standard rasterfile" */
  751. X        case 5:
  752. X            type = 'I';
  753. X            break;
  754. X
  755. X        /* Experimental. */
  756. X        case 0xFFFF:
  757. X            type = 'E';
  758. X            break;
  759. X
  760. X        /* Unknown. */
  761. X        default:
  762. X            type = '?';
  763. X            break;
  764. X    }
  765. X    printf("%c", type);
  766. X
  767. X    /* Print colormap type. */
  768. X
  769. X    switch (srinfo->maptype)
  770. X    {
  771. X        /* No colormap. */
  772. X        case 0:
  773. X            type = '-';
  774. X            break;
  775. X
  776. X        /* R,G,B vector map (all R's together, etc.) */
  777. X        case 1:
  778. X            type = 'V';
  779. X            break;
  780. X
  781. X        /* Raw colormap (usually RGB triples) */
  782. X        case 2:
  783. X            type = 'R';
  784. X            break;
  785. X
  786. X        /* Unknown. */
  787. X        default:
  788. X            type = '?';
  789. X            break;
  790. X    }
  791. X    printf("%c   ", type);
  792. X
  793. X    /* Print filesize. */
  794. X
  795. X    printf("%6ld ", filesize);
  796. X
  797. X    /* Print height and width of image. */
  798. X
  799. X    printf("%4ld x %4ld", srinfo->imwid, srinfo->imhi);
  800. X
  801. X    /* Print number of colors in image, depending. */
  802. X
  803. X    if (srinfo->pixelbits < 20)
  804. X    {
  805. X        printf(" @ %-5u ", (0x1L << srinfo->pixelbits));
  806. X    }
  807. X    else
  808. X    {
  809. X        printf(", %2d bit ", srinfo->pixelbits);
  810. X    }
  811. X    printed++;
  812. X
  813. X    /* If is compressed format, print compression ratio. */
  814. X
  815. X    if (2 == srinfo->rastype)
  816. X    {
  817. X        uncsize = srinfo->imwid * srinfo->imhi * srinfo->pixelbits;
  818. X        uncsize /= 8;
  819. X        printf("C~%-3ld  ", ((100L * srinfo->rasterlen) / uncsize));
  820. X        printed += 7;
  821. X    }
  822. X
  823. X    /* If has colormap, print colormap length. */
  824. X
  825. X    if (srinfo->maptype != 0)
  826. X    {
  827. X        printf("ML=%-5ld  ", srinfo->maplen);
  828. X        printed += 10;
  829. X    }
  830. X
  831. X    /* Finally, print filename. */
  832. X
  833. X    printname(filename, printed);
  834. X
  835. X    return;
  836. X} /* end of sr_display() */
  837. X
  838. X
  839. X/***************************************************************************
  840. X*   FUNCTION:  tga_display                                                 *
  841. X*                                                                          *
  842. X*   DESCRIPTION:                                                           *
  843. X*                                                                          *
  844. X*       Display function for TGA files.                                    *
  845. X*                                                                          *
  846. X*   ENTRY:                                                                 *
  847. X*                                                                          *
  848. X*       tgainfo   - contains header info from TGA file                     *
  849. X*       filename - name of TGA file                                        *
  850. X*       filesize - size of TGA file                                        *
  851. X*                                                                          *
  852. X*   EXIT:                                                                  *
  853. X*                                                                          *
  854. X*       Nothing.                                                           *
  855. X*                                                                          *
  856. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  857. X*                                                                          *
  858. X***************************************************************************/
  859. XVOID
  860. X#ifdef __STDC__
  861. Xtga_display(TGA_HDR *tgainfo, char *filename, long filesize)
  862. X#else
  863. Xtga_display(tgainfo, filename, filesize)
  864. XTGA_HDR *tgainfo;
  865. Xchar *filename;
  866. Xlong filesize;
  867. X#endif
  868. X{
  869. X    char flag;
  870. X    int printed = 0;
  871. X    ULONG uncsize;
  872. X
  873. X    /* Print format ID. */
  874. X
  875. X    PRINT_FMT(TGA_1, TGA_MAIN);
  876. X
  877. X    /* Print image-present flag. */
  878. X
  879. X    printf("%c", ((0 == tgainfo->type) ? 'N' : '-'));
  880. X
  881. X    /* Print compression flag. */
  882. X
  883. X    switch (tgainfo->type)
  884. X    {
  885. X        /* No image. */
  886. X        case 0:
  887. X            flag = '-';
  888. X            break;
  889. X
  890. X        /* Uncompressed image. */
  891. X        case 1:
  892. X        case 2:
  893. X        case 3:
  894. X            flag = 'U';
  895. X            break;
  896. X
  897. X        /* Runlength-encoded image. */
  898. X        case 9:
  899. X        case 10:
  900. X            flag = 'R';
  901. X            break;
  902. X
  903. X        /* Compressed image. */
  904. X        case 11:
  905. X        case 32:
  906. X        case 33:
  907. X            flag = 'C';
  908. X            break;
  909. X
  910. X        /* Unknown format. */
  911. X        default:
  912. X            flag = '?';
  913. X            break;
  914. X    }
  915. X    printf("%c", flag);
  916. X
  917. X    /* Print color type flag. */
  918. X
  919. X    switch (tgainfo->type)
  920. X    {
  921. X        /* No image. */
  922. X        case 0:
  923. X            flag = '-';
  924. X            break;
  925. X
  926. X        /* Colormapped image. */
  927. X        case 1:
  928. X        case 9:
  929. X        case 32:
  930. X        case 33:
  931. X            flag = 'M';
  932. X            break;
  933. X
  934. X        /* Black and white image. */
  935. X        case 3:
  936. X        case 11:
  937. X            flag = 'B';
  938. X            break;
  939. X
  940. X        /* RGB image. */
  941. X        case 2:
  942. X        case 10:
  943. X            flag = 'C';
  944. X            break;
  945. X
  946. X        /* Unknown format. */
  947. X        default:
  948. X            flag = '?';
  949. X            break;
  950. X    }
  951. X    printf("%c", flag);
  952. X
  953. X    /* Print interleave type flag. */
  954. X
  955. X    switch (tgainfo->interleave)
  956. X    {
  957. X        case 1:
  958. X            flag = '2';
  959. X            break;
  960. X
  961. X        case 2:
  962. X            flag = '4';
  963. X            break;
  964. X
  965. X        case 3:
  966. X            flag = 'R';
  967. X            break;
  968. X
  969. X        default:
  970. X        case 0:
  971. X            flag = '-';
  972. X            break;
  973. X    }
  974. X    printf("%c ", flag);
  975. X
  976. X    /* Print filesize. */
  977. X
  978. X    printf("%6ld ", filesize);
  979. X
  980. X    /* Print height and width of image. */
  981. X
  982. X    printf("%4u x %4u", tgainfo->imwid, tgainfo->imhi);
  983. X
  984. X    /* Print number of colors in image, depending. */
  985. X
  986. X    switch (tgainfo->type)
  987. X    {
  988. X        case 1:
  989. X        case 9:
  990. X        case 32:
  991. X        case 33:
  992. X            /* Color-mapped image. */
  993. X            printf(" @ %-5u ", tgainfo->maplen);
  994. X            break;
  995. X
  996. X        case 2:
  997. X        case 3:
  998. X        case 10:
  999. X        case 11:
  1000. X            /* True-color image. */
  1001. X            if (tgainfo->pixelbits < 20)
  1002. X            {
  1003. X                printf(" @ %-5ld ", (0x1L << tgainfo->pixelbits));
  1004. X            }
  1005. X            else
  1006. X            {
  1007. X                printf(", %2u bit ", tgainfo->pixelbits);
  1008. X            }
  1009. X            break;
  1010. X
  1011. X        default:
  1012. X        case 0:
  1013. X            printf(" @ ---   ");
  1014. X            break;
  1015. X    }
  1016. X    printed++;
  1017. X
  1018. X    /* If is compressed format, print compression ratio. */
  1019. X
  1020. X    switch (tgainfo->type)
  1021. X    {
  1022. X        case 9:
  1023. X        case 10:
  1024. X        case 11:
  1025. X        case 32:
  1026. X        case 33:
  1027. X            uncsize = tgainfo->imwid * tgainfo->imhi * tgainfo->pixelbits;
  1028. X            uncsize /= 8;
  1029. X            printf(" C~%-3ld  ", ((100L * (filesize - TGA_HDR_LEN -
  1030. X                                           tgainfo->idfieldlen - 
  1031. X                                           ((tgainfo->maplen * 
  1032. X                                             tgainfo->mapentsize) / 8))) / 
  1033. X                                  uncsize));
  1034. X            printed += 8;
  1035. X            break;
  1036. X
  1037. X        default:
  1038. X            break;
  1039. X    }
  1040. X
  1041. X    /* Print format type. */
  1042. X
  1043. X    printf("T%-2d ", tgainfo->type);
  1044. X    printed += 4;
  1045. X
  1046. X    /* Print attribute bits. */
  1047. X
  1048. X    printf("A%1d ", tgainfo->attrbits);
  1049. X    printed += 3;
  1050. X
  1051. X    /* If unnecessary colormap included, print M */
  1052. X
  1053. X    switch (tgainfo->type)
  1054. X    {
  1055. X        case 2:
  1056. X        case 3:
  1057. X        case 10:
  1058. X        case 11:
  1059. X            if (tgainfo->maptype != 0)
  1060. X            {
  1061. X                printf("M ");
  1062. X                printed += 2;
  1063. X            }
  1064. X            break;
  1065. X
  1066. X        default:
  1067. X            break;
  1068. X    }
  1069. X
  1070. X    /* If file has an ID field (nonzero length), print I */
  1071. X
  1072. X    if (tgainfo->idfieldlen != 0)
  1073. X    {
  1074. X        printf("I ");
  1075. X        printed += 2;
  1076. X    }
  1077. X
  1078. X    /* Finally, print filename. */
  1079. X
  1080. X    printname(filename, printed);
  1081. X
  1082. X    return;
  1083. X} /* end of tga_display() */
  1084. X
  1085. X
  1086. X/***************************************************************************
  1087. X*   FUNCTION:  pnm_display                                                 *
  1088. X*                                                                          *
  1089. X*   DESCRIPTION:                                                           *
  1090. X*                                                                          *
  1091. X*       Display function for PBM, PGM, and PPM files.                      *
  1092. X*                                                                          *
  1093. X*   ENTRY:                                                                 *
  1094. X*                                                                          *
  1095. X*       pnminfo   - contains header info from P?M file                     *
  1096. X*       filename - name of file                                            *
  1097. X*       filesize - size of file                                            *
  1098. X*                                                                          *
  1099. X*   EXIT:                                                                  *
  1100. X*                                                                          *
  1101. X*       Nothing.                                                           *
  1102. X*                                                                          *
  1103. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  1104. X*                                                                          *
  1105. X***************************************************************************/
  1106. XVOID
  1107. X#ifdef __STDC__
  1108. Xpnm_display(PNM_HDR *pnminfo, char *filename, long filesize)
  1109. X#else
  1110. Xpnm_display(pnminfo, filename, filesize)
  1111. XPNM_HDR *pnminfo;
  1112. Xchar *filename;
  1113. Xlong filesize;
  1114. X#endif
  1115. X{
  1116. X    char flag;
  1117. X    int printed = 0;
  1118. X    ULONG colors;
  1119. X    int loop;
  1120. X
  1121. X    /* Print format ID. */
  1122. X
  1123. X    switch FORMAT_TYPE(pnminfo->version)
  1124. X    {
  1125. X        case FORMAT_TYPE(FORMAT_PBM):
  1126. X            PRINT_FMT(pnminfo->version, PBM_MAIN);
  1127. X            break;
  1128. X
  1129. X        case FORMAT_TYPE(FORMAT_PGM):
  1130. X            PRINT_FMT(pnminfo->version, PGM_MAIN);
  1131. X            break;
  1132. X
  1133. X        case FORMAT_TYPE(FORMAT_PPM):
  1134. X            PRINT_FMT(pnminfo->version, PPM_MAIN);
  1135. X            break;
  1136. X
  1137. X        default:
  1138. X            printf("PNM      ");
  1139. X            break;
  1140. X    }
  1141. X
  1142. X    /* Print raw/normal flag. */
  1143. X
  1144. X    switch FORMAT_TYPE(pnminfo->version)
  1145. X    {
  1146. X        case FORMAT_TYPE(FORMAT_PBM):
  1147. X            flag = ((PBM_NORM == pnminfo->version) ? 'N' : 'R');
  1148. X            break;
  1149. X
  1150. X        case FORMAT_TYPE(FORMAT_PGM):
  1151. X            flag = ((PGM_NORM == pnminfo->version) ? 'N' : 'R');
  1152. X            break;
  1153. X
  1154. X        case FORMAT_TYPE(FORMAT_PPM):
  1155. X            flag = ((PPM_NORM == pnminfo->version) ? 'N' : 'R');
  1156. X            break;
  1157. X
  1158. X        default:
  1159. X            flag = '-';
  1160. X            break;
  1161. X    }
  1162. X    printf ("%c    ", flag);
  1163. X
  1164. X    /* Print filesize. */
  1165. X
  1166. X    printf("%6ld ", filesize);
  1167. X
  1168. X    /* Print height and width of image. */
  1169. X
  1170. X    printf("%4ld x %4ld", pnminfo->imwid, pnminfo->imhi);
  1171. X
  1172. X    /* Print number of colors in image, depending. */
  1173. X
  1174. X    switch FORMAT_TYPE(pnminfo->version)
  1175. X    {
  1176. X        case FORMAT_TYPE(FORMAT_PBM):
  1177. X            printf(" @ 2     ");
  1178. X            break;
  1179. X
  1180. X        case FORMAT_TYPE(FORMAT_PGM):
  1181. X            printf(" @ %-3d   ", pnminfo->maxpix + 1);
  1182. X            break;
  1183. X
  1184. X        case FORMAT_TYPE(FORMAT_PPM):
  1185. X            colors = (pnminfo->maxpix + 1);
  1186. X            colors = colors * colors * colors;
  1187. X            if (colors <= 99999)
  1188. X            {
  1189. X                printf(" @ %-5ld ", colors);
  1190. X            }
  1191. X            else
  1192. X            {
  1193. X                for (loop = 0; (colors & 0x1L) == 0; loop++, colors >>= 1) ;
  1194. X                if ((colors >> 1) == 0)
  1195. X                {
  1196. X                    printf(", %2d bit ", loop);
  1197. X                }
  1198. X                else
  1199. X                {
  1200. X                    printf(" @ %ld ", (colors << loop));
  1201. X                    printed += 3;          /* a guess */
  1202. X                }
  1203. X            }
  1204. X            break;
  1205. X
  1206. X        default:
  1207. X            printf(" @ ---   ");
  1208. X            break;
  1209. X    }
  1210. X    printed++;
  1211. X
  1212. X    /* If PGM or PBM, print bits. */
  1213. X
  1214. X    if ((FORMAT_TYPE(pnminfo->version) == FORMAT_TYPE(FORMAT_PGM)) ||
  1215. X        (FORMAT_TYPE(pnminfo->version) == FORMAT_TYPE(FORMAT_PPM)))
  1216. X    {
  1217. X        printf("MaxVal = %3d ", pnminfo->maxpix);
  1218. X        printed += 13;
  1219. X    }
  1220. X
  1221. X    /* Finally, print filename. */
  1222. X
  1223. X    printname(filename, printed);
  1224. X
  1225. X    return;
  1226. X} /* end of pnm_display() */
  1227. X
  1228. X
  1229. X/***************************************************************************
  1230. X*   FUNCTION:  xbm_display                                                 *
  1231. X*                                                                          *
  1232. X*   DESCRIPTION:                                                           *
  1233. X*                                                                          *
  1234. X*       Display function for XBM files.                                    *
  1235. X*                                                                          *
  1236. X*   ENTRY:                                                                 *
  1237. X*                                                                          *
  1238. X*       xbminfo   - contains header info from XBM file                     *
  1239. X*       filename - name of file                                            *
  1240. X*       filesize - size of file                                            *
  1241. X*                                                                          *
  1242. X*   EXIT:                                                                  *
  1243. X*                                                                          *
  1244. X*       Nothing.                                                           *
  1245. X*                                                                          *
  1246. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  1247. X*                                                                          *
  1248. X***************************************************************************/
  1249. XVOID
  1250. X#ifdef __STDC__
  1251. Xxbm_display(XBM_HDR *xbminfo, char *filename, long filesize)
  1252. X#else
  1253. Xxbm_display(xbminfo, filename, filesize)
  1254. XXBM_HDR *xbminfo;
  1255. Xchar *filename;
  1256. Xlong filesize;
  1257. X#endif
  1258. X{
  1259. X    int printed = 0;
  1260. X
  1261. X    /* Print format ID. */
  1262. X
  1263. X    PRINT_FMT(XBM_1, XBM_MAIN);
  1264. X
  1265. X    /* No flags. */
  1266. X
  1267. X    printf("     ");
  1268. X
  1269. X    /* Print filesize. */
  1270. X
  1271. X    printf("%6ld ", filesize);
  1272. X
  1273. X    /* Print height and width and number of colors of image. */
  1274. X
  1275. X    printf("%4ld x %4ld @ 2     ", xbminfo->imwid, xbminfo->imhi);
  1276. X    printed++;
  1277. X
  1278. X    /* Print embedded name. */
  1279. X
  1280. X    printf("'%s' ", xbminfo->imname);
  1281. X    printed += (strlen(xbminfo->imname) + 3);
  1282. X    free(xbminfo->imname);
  1283. X
  1284. X    /* Finally, print filename. */
  1285. X
  1286. X    printname(filename, printed);
  1287. X
  1288. X    return;
  1289. X} /* end of xbm_display() */
  1290. X
  1291. X
  1292. X/***************************************************************************
  1293. X*   FUNCTION:  bmp_display                                                 *
  1294. X*                                                                          *
  1295. X*   DESCRIPTION:                                                           *
  1296. X*                                                                          *
  1297. X*       Display function for BMP files.                                    *
  1298. X*                                                                          *
  1299. X*   ENTRY:                                                                 *
  1300. X*                                                                          *
  1301. X*       bmpinfo   - contains header info from BMP file                     *
  1302. X*       filename - name of file                                            *
  1303. X*       filesize - size of file                                            *
  1304. X*                                                                          *
  1305. X*   EXIT:                                                                  *
  1306. X*                                                                          *
  1307. X*       Nothing.                                                           *
  1308. X*                                                                          *
  1309. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  1310. X*                                                                          *
  1311. X***************************************************************************/
  1312. XVOID
  1313. X#ifdef __STDC__
  1314. Xbmp_display(BMP_HDR *bmpinfo, char *filename, long filesize)
  1315. X#else
  1316. Xbmp_display(bmpinfo, filename, filesize)
  1317. XBMP_HDR *bmpinfo;
  1318. Xchar *filename;
  1319. Xlong filesize;
  1320. X#endif
  1321. X{
  1322. X    char flag;
  1323. X    int printed = 0;
  1324. X    ULONG colors;
  1325. X    int loop;
  1326. X    BMP_H2 *hdr2 = (BMP_H2 *) bmpinfo->more;
  1327. X    BMP_H11 *hdr11 = (BMP_H11 *) bmpinfo->more;
  1328. X    BMP_H3 *hdr3 = (BMP_H3 *) bmpinfo->more;
  1329. X    BMP_H20 *hdr20 = (BMP_H20 *) bmpinfo->more;
  1330. X
  1331. X    /* Print format ID. */
  1332. X
  1333. X    PRINT_FMT(bmpinfo->version, BMP_MAIN);
  1334. X
  1335. X    /* Print flags by type. */
  1336. X
  1337. X    switch (FORMAT_VERS(bmpinfo->version))
  1338. X    {
  1339. X        case FORMAT_VERS(BMP_WIN2):
  1340. X            printf("%c    ", ((hdr2 != NULL) ? 
  1341. X                              ((hdr2->discardable != 0) ? 'D' : '-') : '-'));
  1342. X            break;
  1343. X
  1344. X        case FORMAT_VERS(BMP_OS2_11):
  1345. X            printf("%c    ", 
  1346. X                   ((hdr11 != NULL) ? 
  1347. X                    ((hdr11->filesize != filesize) ? 'E' : '-') : '-'));
  1348. X            break;
  1349. X
  1350. X        case FORMAT_VERS(BMP_WIN3):
  1351. X            if (hdr3 != NULL)
  1352. X            {
  1353. X                printf("%c", ((hdr3->more.filesize != filesize) ? 'E' : '-'));
  1354. X                switch (hdr3->compression)
  1355. X                {
  1356. X                    case 1:
  1357. X                        flag = '8';
  1358. X                        break;
  1359. X
  1360. X                    case 2:
  1361. X                        flag = '4';
  1362. X                        break;
  1363. X                       
  1364. X                    default:
  1365. X                    case 0:
  1366. X                        flag = '-';
  1367. X                        break;
  1368. X                }
  1369. X                printf("%c", flag);
  1370. X            }
  1371. X            else
  1372. X            {
  1373. X                printf("--");
  1374. X            }
  1375. X            printf("   ");
  1376. X            break;
  1377. X
  1378. X        case FORMAT_VERS(BMP_OS2_20):
  1379. X            if (hdr20 != NULL)
  1380. X            {
  1381. X                printf("%c",
  1382. X                       ((hdr20->more.more.filesize != filesize) ? 'E' : '-'));
  1383. X                printf("%c", ((hdr20->more.compression != 0) ? 'C' : '-'));
  1384. X                printf("%c", ((hdr20->clrencode != 0) ? '?' : 'R'));
  1385. X                printf("%c ", ((hdr20->halfalg != 0) ? 'H' : '-'));
  1386. X            }
  1387. X            else
  1388. X            {
  1389. X                printf("---- ");
  1390. X            }
  1391. X            break;
  1392. X
  1393. X        default:
  1394. X            break;
  1395. X    }
  1396. X
  1397. X    /* Print filesize. */
  1398. X
  1399. X    printf("%6ld ", filesize);
  1400. X
  1401. X    /* Print height and width of image. */
  1402. X
  1403. X    printf("%4ld x %4ld", bmpinfo->imwid, bmpinfo->imhi);
  1404. X
  1405. X    /* Print colors. */
  1406. X
  1407. X    colors = 0x1L << (bmpinfo->planes * bmpinfo->pixbits);
  1408. X    if (((BMP_WIN3 == bmpinfo->version) || (BMP_OS2_20 == bmpinfo->version)) &&
  1409. X        ((bmpinfo->planes * bmpinfo->pixbits) != 24) &&
  1410. X        (bmpinfo->more != NULL))
  1411. X    {
  1412. X        ULONG temp;
  1413. X
  1414. X        temp = ((BMP_WIN3 == bmpinfo->version) ? hdr3->clrused :
  1415. X                                                 hdr20->more.clrused);
  1416. X        if (temp != 0)
  1417. X        {
  1418. X            colors = temp;
  1419. X        }
  1420. X    }
  1421. X    if (colors <= 99999)
  1422. X    {
  1423. X        printf(" @ %-5ld ", colors);
  1424. X    }
  1425. X    else
  1426. X    {
  1427. X        ULONG temp = colors;
  1428. X
  1429. X        for (loop = 0; (temp & 0x1L) == 0; loop++, temp >>= 1) ;
  1430. X        if ((temp >> 1) == 0)
  1431. X        {
  1432. X            printf(", %2d bit ", loop);
  1433. X        }
  1434. X        else
  1435. X        {
  1436. X            printf(" @ %ld ", temp);
  1437. X            printed += 3;          /* a guess */
  1438. X        }
  1439. X    }
  1440. X    printed++;
  1441. X
  1442. X    /* Print assorted stuff by type. */
  1443. X
  1444. X    if ((BMP_WIN3 == bmpinfo->version) && (hdr3 != NULL))
  1445. X    {
  1446. X        if ((hdr3->compression != 0) && (hdr3->compsize != 0))
  1447. X        {
  1448. X            /* Print compression ratio. */
  1449. X
  1450. X            printf("C~%-3ld ", ((100L * hdr3->compsize) /
  1451. X                                ((bmpinfo->imwid * bmpinfo->imhi *
  1452. X                                  bmpinfo->planes * bmpinfo->pixbits) / 8L)));
  1453. X            printed += 6;
  1454. X        }
  1455. X        if ((hdr3->xres != 0) || (hdr3->yres != 0))
  1456. X        {
  1457. X            printf("X%3ld,Y%3ld ", hdr3->xres, hdr3->yres);
  1458. X            printed += 10;
  1459. X        }
  1460. X        if ((hdr3->clrimp != 0) && (hdr3->clrimp != colors))
  1461. X        {
  1462. X            printf("I-%3ld ", hdr3->clrimp);
  1463. X            printed += 5;
  1464. X        }
  1465. X    }
  1466. X    else if ((BMP_OS2_20 == bmpinfo->version) && (hdr20 != NULL))
  1467. X    {
  1468. X        if ((hdr20->more.compression != 0) &&
  1469. X            (hdr20->more.compsize != 0))
  1470. X        {
  1471. X            /* Print compression ratio. */
  1472. X
  1473. X            printf("C~%-3ld ", ((100L * hdr20->more.compsize) /
  1474. X                                ((bmpinfo->imwid * bmpinfo->imhi *
  1475. X                                  bmpinfo->planes * bmpinfo->pixbits) / 8L)));
  1476. X            printed += 6;
  1477. X            printed += 6;
  1478. X        }
  1479. X        if ((hdr20->more.xres != 0) || (hdr20->more.yres != 0))
  1480. X        {
  1481. X            printf("X%3ld,Y%3ld dp%c ", hdr20->more.xres, hdr20->more.yres,
  1482. X                   ((0 == hdr20->resunits) ? 'm' : '?'));
  1483. X            printed += 14;
  1484. X        }
  1485. X        if ((hdr20->more.clrimp != 0) && (hdr20->more.clrimp != colors))
  1486. X        {
  1487. X            printf("I%-3ld ", hdr20->more.clrimp);
  1488. X            printed += 5;
  1489. X        }
  1490. X    }
  1491. X
  1492. X    /* Finally, print filename. */
  1493. X
  1494. X    printname(filename, printed);
  1495. X
  1496. X    if (bmpinfo->more != NULL)
  1497. X    {
  1498. X        free(bmpinfo->more);
  1499. X    }
  1500. X
  1501. X    return;
  1502. X} /* end of bmp_display() */
  1503. X
  1504. X
  1505. X/***************************************************************************
  1506. X*   FUNCTION:  pcx_display                                                  *
  1507. X*                                                                          *
  1508. X*   DESCRIPTION:                                                           *
  1509. X*                                                                          *
  1510. X*       Display function for PCX files.                                     *
  1511. X*                                                                          *
  1512. X*   ENTRY:                                                                 *
  1513. X*                                                                          *
  1514. X*       pcxinfo   - contains header info from PCX file                       *
  1515. X*       filename - name of PCX file                                         *
  1516. X*       filesize - size of PCX file                                         *
  1517. X*                                                                          *
  1518. X*   EXIT:                                                                  *
  1519. X*                                                                          *
  1520. X*       Nothing.                                                           *
  1521. X*                                                                          *
  1522. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  1523. X*                                                                          *
  1524. X***************************************************************************/
  1525. XVOID
  1526. X#ifdef __STDC__
  1527. Xpcx_display(PCX_HDR *pcxinfo, char *filename, long filesize)
  1528. X#else
  1529. Xpcx_display(pcxinfo, filename, filesize)
  1530. XPCX_HDR *pcxinfo;
  1531. Xchar *filename;
  1532. Xlong filesize;
  1533. X#endif
  1534. X{
  1535. X    int printed = 0;
  1536. X    ULONG uncsize;
  1537. X    char flag;
  1538. X
  1539. X    /* Print format ID. */
  1540. X
  1541. X    PRINT_FMT(pcxinfo->version, PCX_MAIN);
  1542. X
  1543. X    /* Print encoding and palette-format flags. */
  1544. X
  1545. X    printf("%c", ((1 == pcxinfo->encoding) ? 'R' : '?'));
  1546. X    switch (pcxinfo->palfmt)
  1547. X    {
  1548. X        case 2:
  1549. X            flag = 'G';
  1550. X            break;
  1551. X
  1552. X        case 1:
  1553. X            flag = 'C';
  1554. X            break;
  1555. X
  1556. X        default:
  1557. X            flag = '?';
  1558. X            break;
  1559. X    }
  1560. X    printf("%c   ", flag);
  1561. X
  1562. X    /* Print filesize. */
  1563. X
  1564. X    printf("%6ld ", filesize);
  1565. X
  1566. X    /* Print height and width of image. */
  1567. X
  1568. X    printf("%4u x %4u", pcxinfo->imwid, pcxinfo->imhi);
  1569. X
  1570. X    /* Print number of colors in image, depending. */
  1571. X
  1572. X    if ((pcxinfo->pixbits * pcxinfo->planes) < 20)
  1573. X    {
  1574. X        printf(" @ %-5u ", (0x1L << (pcxinfo->pixbits * pcxinfo->planes)));
  1575. X    }
  1576. X    else
  1577. X    {
  1578. X        printf(", %2d bit ", (pcxinfo->pixbits * pcxinfo->planes));
  1579. X    }
  1580. X    printed++;
  1581. X
  1582. X    /* If is compressed format, print compression ratio. */
  1583. X
  1584. X    if (1 == pcxinfo->encoding)
  1585. X    {
  1586. X        uncsize = pcxinfo->imwid * pcxinfo->imhi * pcxinfo->pixbits *
  1587. X                  pcxinfo->planes;
  1588. X        uncsize /= 8;
  1589. X        printf("C~%-3ld  ", ((100L * (filesize - PCX_HDR_MAXLEN)) / uncsize));
  1590. X        printed += 7;
  1591. X    }
  1592. X
  1593. X    /* Print horizontal and vertical resolution of creator. */
  1594. X
  1595. X    printf("CX%3u,CY%3u ", pcxinfo->hres, pcxinfo->vres);
  1596. X    printed += 12;
  1597. X
  1598. X    /* Finally, print filename. */
  1599. X
  1600. X    printname(filename, printed);
  1601. X
  1602. X    return;
  1603. X} /* end of pcx_display() */
  1604. X
  1605. X
  1606. X/***************************************************************************
  1607. X*   FUNCTION:  printname  STATIC                                           *
  1608. X*                                                                          *
  1609. X*   DESCRIPTION:                                                           *
  1610. X*                                                                          *
  1611. X*       Prints the name of the file on the end of the information line     *
  1612. X*       or on the next line, depending on how many characters have been    *
  1613. X*       printed already, the length of the filename, and the setting of    *
  1614. X*       the fullname flag.                                                 *
  1615. X*                                                                          *
  1616. X*   ENTRY:                                                                 *
  1617. X*                                                                          *
  1618. X*       origname - Full name of the file, including path if any.           *
  1619. X*       printed  - Number of characters beyond 40 already printed.         *
  1620. X*                                                                          *
  1621. X*   EXIT:                                                                  *
  1622. X*                                                                          *
  1623. X*       Nothing.                                                           *
  1624. X*                                                                          *
  1625. X*   CONSTRAINTS/SIDE EFFECTS:                                              *
  1626. X*                                                                          *
  1627. X***************************************************************************/
  1628. Xstatic VOID
  1629. X#ifdef __STDC__
  1630. Xprintname(char *origname, int printed)
  1631. X#else
  1632. Xprintname(origname, printed)
  1633. Xchar *origname;
  1634. Xint printed;
  1635. X#endif
  1636. X{
  1637. X    char *finalname = origname;
  1638. X    char *temp;
  1639. X
  1640. X    if ((flags & NAMETRUNC) && ((temp = strrchr(origname, '/')) != NULL))
  1641. X    {
  1642. X        finalname = temp + 1;
  1643. X    }
  1644. X
  1645. X    if (strlen(finalname) < (screencols - 41 - printed))
  1646. X    {
  1647. X        printf("%*s\n", (screencols - 41 - printed), finalname);
  1648. X    }
  1649. X    else
  1650. X    {
  1651. X        printf("\n     %*s\n", (screencols - 6), finalname);
  1652. X    }
  1653. X            
  1654. X    return;
  1655. X} /* end of static printname() */
  1656. X
  1657. END_OF_FILE
  1658.   if test 46063 -ne `wc -c <'src/chidisp.c'`; then
  1659.     echo shar: \"'src/chidisp.c'\" unpacked with wrong size!
  1660.   fi
  1661.   # end of 'src/chidisp.c'
  1662. fi
  1663. if test ! -d 'templates' ; then
  1664.     echo shar: Creating directory \"'templates'\"
  1665.     mkdir 'templates'
  1666. fi
  1667. echo shar: End of archive 1 \(of 18\).
  1668. cp /dev/null ark1isdone
  1669. MISSING=""
  1670. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ; do
  1671.     if test ! -f ark${I}isdone ; then
  1672.     MISSING="${MISSING} ${I}"
  1673.     fi
  1674. done
  1675. if test "${MISSING}" = "" ; then
  1676.     echo You have unpacked all 18 archives.
  1677.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1678. else
  1679.     echo You still must unpack the following archives:
  1680.     echo "        " ${MISSING}
  1681. fi
  1682. exit 0
  1683. exit 0 # Just in case...
  1684.