home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / IMGPROC.ZIP / C6TIFF.ZIP / COMPRESS.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-30  |  1.8 KB  |  63 lines

  1. /*
  2.  * Copyright (c) 1988 by Sam Leffler.
  3.  * All rights reserved.
  4.  *
  5.  * This file is provided for unrestricted use provided that this
  6.  * legend is included on all tape media and as a part of the
  7.  * software program in whole or part.  Users may copy, modify or
  8.  * distribute this file at will.
  9.  */
  10.  
  11. /*
  12. Compression Scheme Configuration Support.
  13. */
  14.  
  15. #define NSCHEMES (sizeof (CompressionSchemes) / sizeof (CompressionSchemes[0]))
  16.  
  17. #include "tiffio.h"
  18.  
  19. extern void TIFFInitDumpMode(TIFF *);
  20. extern void TIFFInitLZW(TIFF *);
  21. extern void TIFFInitPackBits(TIFF *);
  22. extern void TIFFInitCCITTRLE(TIFF *);
  23. extern void TIFFInitCCITTRLEW(TIFF *);
  24. extern void TIFFInitCCITTFax3(TIFF *);
  25. extern void TIFFInitCCITTFax4(TIFF *);
  26.  
  27. static  struct cscheme
  28. {
  29.    unsigned scheme;
  30.    void (*init)(TIFF *);
  31. } CompressionSchemes[] =
  32. {
  33.    { COMPRESSION_NONE,      TIFFInitDumpMode },
  34.    { COMPRESSION_LZW,       TIFFInitLZW },
  35.    { COMPRESSION_PACKBITS,  TIFFInitPackBits },
  36.    { COMPRESSION_CCITTRLE,  TIFFInitCCITTRLE },
  37.    { COMPRESSION_CCITTRLEW, TIFFInitCCITTRLEW },
  38.    { COMPRESSION_CCITTFAX3, TIFFInitCCITTFax3 },
  39.    { COMPRESSION_CCITTFAX4, TIFFInitCCITTFax4 }
  40. };
  41.  
  42.  
  43. CompletionCode TIFFSetCompressionScheme(TIFF *tif, unsigned scheme)
  44. {
  45.    register struct cscheme *c;
  46.  
  47.    for (c = CompressionSchemes; c < &CompressionSchemes[NSCHEMES]; c++)
  48.       if (c->scheme == scheme)
  49.       {
  50.      tif->tif_stripdecode = NULL;
  51.          tif->tif_stripencode = NULL;
  52.          tif->tif_encodestrip = NULL;
  53.          tif->tif_seek = NULL;
  54.          tif->tif_cleanup = NULL;
  55.      /* install compression/expansion scheme */
  56.      (*c->init)(tif);
  57.          return(TRUE);
  58.       }
  59.    TIFFError(tif->tif_name, "Unknown data compression algorithm %u",
  60.          scheme);
  61.    return (FALSE);
  62. }
  63.