ReactOS 0.4.16-dev-2617-g01a0906
tif_dumpmode.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 1988-1997 Sam Leffler
3 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
4 *
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.
12 *
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.
16 *
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
22 * OF THIS SOFTWARE.
23 */
24
25/*
26 * TIFF Library.
27 *
28 * "Null" Compression Algorithm Support.
29 */
30#include "tiffiop.h"
31
32static int DumpFixupTags(TIFF *tif)
33{
34 (void)tif;
35 return (1);
36}
37
38/*
39 * Encode a hunk of pixels.
40 */
42{
43 (void)s;
44 while (cc > 0)
45 {
46 tmsize_t n;
47
48 n = cc;
49 if (tif->tif_rawcc + n > tif->tif_rawdatasize)
50 n = tif->tif_rawdatasize - tif->tif_rawcc;
51
52 assert(n > 0);
53
54 /*
55 * Avoid copy if client has setup raw
56 * data buffer to avoid extra copy.
57 */
58 if (tif->tif_rawcp != pp)
59 _TIFFmemcpy(tif->tif_rawcp, pp, n);
60 tif->tif_rawcp += n;
61 tif->tif_rawcc += n;
62 pp += n;
63 cc -= n;
64 if (tif->tif_rawcc >= tif->tif_rawdatasize && !TIFFFlushData1(tif))
65 return (0);
66 }
67 return (1);
68}
69
70/*
71 * Decode a hunk of pixels.
72 */
74{
75 static const char module[] = "DumpModeDecode";
76 (void)s;
77 if (tif->tif_rawcc < cc)
78 {
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);
84 return (0);
85 }
86 /*
87 * Avoid copy if client has setup raw
88 * data buffer to avoid extra copy.
89 */
90 if (tif->tif_rawcp != buf)
92 tif->tif_rawcp += cc;
93 tif->tif_rawcc -= cc;
94 return (1);
95}
96
97/*
98 * Seek forwards nrows in the current strip.
99 */
100static int DumpModeSeek(TIFF *tif, uint32_t nrows)
101{
102 tif->tif_rawcp += nrows * tif->tif_scanlinesize;
103 tif->tif_rawcc -= nrows * tif->tif_scanlinesize;
104 return (1);
105}
106
107/*
108 * Initialize dump mode.
109 */
111{
112 (void)scheme;
120 tif->tif_seek = DumpModeSeek;
121 return (1);
122}
UINT32 uint32_t
Definition: types.h:75
#define assert(_expr)
Definition: assert.h:32
#define PRIu32
Definition: inttypes.h:84
unsigned short uint16_t
Definition: stdint.h:35
unsigned char uint8_t
Definition: stdint.h:33
GLdouble s
Definition: gl.h:2039
GLdouble n
Definition: glext.h:7729
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
uint32_t cc
Definition: isohybrid.c:75
DWORD scheme
Definition: tiffiop.h:113
TIFFCodeMethod tif_encodestrip
Definition: tiffiop.h:208
TIFFSeekMethod tif_seek
Definition: tiffiop.h:212
TIFFCodeMethod tif_encodetile
Definition: tiffiop.h:210
tmsize_t tif_scanlinesize
Definition: tiffiop.h:218
TIFFBoolMethod tif_fixuptags
Definition: tiffiop.h:198
tmsize_t tif_rawcc
Definition: tiffiop.h:225
TIFFCodeMethod tif_decodestrip
Definition: tiffiop.h:207
TIFFCodeMethod tif_decoderow
Definition: tiffiop.h:205
TIFFCodeMethod tif_encoderow
Definition: tiffiop.h:206
uint8_t * tif_rawcp
Definition: tiffiop.h:224
tmsize_t tif_rawdatasize
Definition: tiffiop.h:221
uint32_t tif_row
Definition: tiffiop.h:162
TIFFCodeMethod tif_decodetile
Definition: tiffiop.h:209
#define TIFF_SSIZE_FORMAT
Definition: tif_config.h:176
int TIFFInitDumpMode(TIFF *tif, int scheme)
Definition: tif_dumpmode.c:110
static int DumpModeSeek(TIFF *tif, uint32_t nrows)
Definition: tif_dumpmode.c:100
static int DumpModeDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)
Definition: tif_dumpmode.c:73
static int DumpFixupTags(TIFF *tif)
Definition: tif_dumpmode.c:32
static int DumpModeEncode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)
Definition: tif_dumpmode.c:41
void TIFFErrorExtR(TIFF *tif, const char *module, const char *fmt,...)
Definition: tif_error.c:107
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Definition: tif_unix.c:355
int TIFFFlushData1(TIFF *tif)
Definition: tif_write.c:931
TIFF_SSIZE_T tmsize_t
Definition: tiffio.h:67