home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0040 - 0049 / ibm0040-0049 / ibm0040.tar / ibm0040 / IMGPROC.ZIP / C6TIFF.ZIP / DUMPMODE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-30  |  1.5 KB  |  73 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. "Null" Compression Algorithm Support.
  13. */
  14.  
  15. #include <mem.h>
  16. #include "tiffio.h"
  17.  
  18.  
  19. /*
  20. Encode a scanline of pixels.
  21. */
  22. static
  23. CompletionCode DumpModeEncode(TIFF *tif, char *pp, long cc)
  24. {
  25.    if (tif->tif_rawcc + cc > tif->tif_rawdatasize)
  26.       if (!TIFFFlushData(tif))
  27.          return (-1);
  28.    memcpy(tif->tif_rawcp, pp, (unsigned) cc);
  29.    tif->tif_rawcp += (unsigned) cc;
  30.    tif->tif_rawcc += cc;
  31.    return (TRUE);
  32. }
  33.  
  34. /*
  35. Seek forwards nrows in the current strip.
  36. */
  37. static
  38. CompletionCode DumpModeSeek(TIFF *tif, long nrows)
  39. {
  40.    tif->tif_rawcp += (unsigned)(nrows * tif->tif_scanlinesize);
  41.    tif->tif_rawcc -= nrows * tif->tif_scanlinesize;
  42.    return(TRUE);
  43. }
  44.  
  45. /*
  46. Decode a scanline of pixels.
  47. */
  48. static
  49. CompletionCode DumpModeDecode(TIFF *tif, char *buf, long cc)
  50. {
  51.    if (tif->tif_rawcc < cc)
  52.    {
  53.       TIFFError(tif->tif_name,"DumpModeDecode: Not enough data for scanline %d",
  54.                 tif->tif_row);
  55.       return (FALSE);
  56.    }
  57.    memcpy(buf,tif->tif_rawcp, (unsigned) cc);
  58.    DumpModeSeek(tif, 1);
  59.    return(TRUE);
  60. }
  61.  
  62.  
  63. /*
  64. Initialize dump mode.
  65. */
  66.  
  67. void TIFFInitDumpMode(TIFF *tif)
  68. {
  69.    tif->tif_decoderow = DumpModeDecode;
  70.    tif->tif_encoderow = DumpModeEncode;
  71.    tif->tif_seek      = DumpModeSeek;
  72. }
  73.