2 * Copyright (c) 1988-1997 Sam Leffler
3 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
5 * Permission to use, copy, modify, distribute, and sell this software and
6 * its documentation for any purpose is hereby granted without fee, provided
7 * that (i) the above copyright notices and this permission notice appear in
8 * all copies of the software and related documentation, and (ii) the names of
9 * Sam Leffler and Silicon Graphics may not be used in any advertising or
10 * publicity relating to the software without the specific, prior written
11 * permission of Sam Leffler and Silicon Graphics.
13 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
17 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
18 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
28 * "Null" Compression Algorithm Support.
32 static int DumpFixupTags(TIFF
*tif
)
39 * Encode a hunk of pixels.
41 static int DumpModeEncode(TIFF
*tif
, uint8_t *pp
, tmsize_t cc
, uint16_t s
)
49 if (tif
->tif_rawcc
+ n
> tif
->tif_rawdatasize
)
50 n
= tif
->tif_rawdatasize
- tif
->tif_rawcc
;
55 * Avoid copy if client has setup raw
56 * data buffer to avoid extra copy.
58 if (tif
->tif_rawcp
!= pp
)
59 _TIFFmemcpy(tif
->tif_rawcp
, pp
, n
);
64 if (tif
->tif_rawcc
>= tif
->tif_rawdatasize
&& !TIFFFlushData1(tif
))
71 * Decode a hunk of pixels.
73 static int DumpModeDecode(TIFF
*tif
, uint8_t *buf
, tmsize_t cc
, uint16_t s
)
75 static const char module
[] = "DumpModeDecode";
77 if (tif
->tif_rawcc
< cc
)
79 TIFFErrorExtR(tif
, module
,
80 "Not enough data for scanline %" PRIu32
81 ", expected a request for at most %" TIFF_SSIZE_FORMAT
82 " bytes, got a request for %" TIFF_SSIZE_FORMAT
" bytes",
83 tif
->tif_row
, tif
->tif_rawcc
, cc
);
87 * Avoid copy if client has setup raw
88 * data buffer to avoid extra copy.
90 if (tif
->tif_rawcp
!= buf
)
91 _TIFFmemcpy(buf
, tif
->tif_rawcp
, cc
);
98 * Seek forwards nrows in the current strip.
100 static int DumpModeSeek(TIFF
*tif
, uint32_t nrows
)
102 tif
->tif_rawcp
+= nrows
* tif
->tif_scanlinesize
;
103 tif
->tif_rawcc
-= nrows
* tif
->tif_scanlinesize
;
108 * Initialize dump mode.
110 int TIFFInitDumpMode(TIFF
*tif
, int scheme
)
113 tif
->tif_fixuptags
= DumpFixupTags
;
114 tif
->tif_decoderow
= DumpModeDecode
;
115 tif
->tif_decodestrip
= DumpModeDecode
;
116 tif
->tif_decodetile
= DumpModeDecode
;
117 tif
->tif_encoderow
= DumpModeEncode
;
118 tif
->tif_encodestrip
= DumpModeEncode
;
119 tif
->tif_encodetile
= DumpModeEncode
;
120 tif
->tif_seek
= DumpModeSeek
;