| Bsoft 1.9 Bernard's software package

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

tif_dumpmode.c
Go to the documentation of this file.
1 /* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.5.2.2 2010-06-08 18:50:42 bfriesen Exp $ */
2
3 /*
4 * Copyright (c) 1988-1997 Sam Leffler
5 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
6 *
7 * Permission to use, copy, modify, distribute, and sell this software and
8 * its documentation for any purpose is hereby granted without fee, provided
9 * that (i) the above copyright notices and this permission notice appear in
10 * all copies of the software and related documentation, and (ii) the names of
11 * Sam Leffler and Silicon Graphics may not be used in any advertising or
12 * publicity relating to the software without the specific, prior written
13 * permission of Sam Leffler and Silicon Graphics.
14 *
15 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
17 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
18 *
19 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
20 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
21 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
22 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
23 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24 * OF THIS SOFTWARE.
25 */
26
27 /*
28 * TIFF Library.
29 *
30 * "Null" Compression Algorithm Support.
31 */
32 #include "tiffiop.h"
33
34 /*
35 * Encode a hunk of pixels.
36 */
37 static int
38 DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s)
39 {
40 (void) s;
41 while (cc > 0) {
42 tsize_t n;
43
44 n = cc;
45 if (tif->tif_rawcc + n > tif->tif_rawdatasize)
46 n = tif->tif_rawdatasize - tif->tif_rawcc;
47
48 assert( n > 0 );
49
50 /*
51 * Avoid copy if client has setup raw
52 * data buffer to avoid extra copy.
53 */
54 if (tif->tif_rawcp != pp)
55 _TIFFmemcpy(tif->tif_rawcp, pp, n);
56 tif->tif_rawcp += n;
57 tif->tif_rawcc += n;
58 pp += n;
59 cc -= n;
60 if (tif->tif_rawcc >= tif->tif_rawdatasize &&
61 !TIFFFlushData1(tif))
62 return (-1);
63 }
64 return (1);
65 }
66
67 /*
68 * Decode a hunk of pixels.
69 */
70 static int
71 DumpModeDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
72 {
73 (void) s;
74 /* fprintf(stderr,"DumpModeDecode: scanline %ld, expected %ld bytes, got %ld bytes\n", */
75 /* (long) tif->tif_row, (long) tif->tif_rawcc, (long) cc); */
76 if (tif->tif_rawcc < cc) {
77 TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
78 "DumpModeDecode: Not enough data for scanline %d",
79 tif->tif_row);
80 return (0);
81 }
82 /*
83 * Avoid copy if client has setup raw
84 * data buffer to avoid extra copy.
85 */
86 if (tif->tif_rawcp != buf)
87 _TIFFmemcpy(buf, tif->tif_rawcp, cc);
88 tif->tif_rawcp += cc;
89 tif->tif_rawcc -= cc;
90 return (1);
91 }
92
93 /*
94 * Seek forwards nrows in the current strip.
95 */
96 static int
97 DumpModeSeek(TIFF* tif, uint32 nrows)
98 {
99 tif->tif_rawcp += nrows * tif->tif_scanlinesize;
100 tif->tif_rawcc -= nrows * tif->tif_scanlinesize;
101 return (1);
102 }
103
104 /*
105 * Initialize dump mode.
106 */
107 int
108 TIFFInitDumpMode(TIFF* tif, int scheme)
109 {
110 (void) scheme;
111 tif->tif_decoderow = DumpModeDecode;
112 tif->tif_decodestrip = DumpModeDecode;
113 tif->tif_decodetile = DumpModeDecode;
114 tif->tif_encoderow = DumpModeEncode;
115 tif->tif_encodestrip = DumpModeEncode;
116 tif->tif_encodetile = DumpModeEncode;
117 tif->tif_seek = DumpModeSeek;
118 return (1);
119 }
120 /*
121 * Local Variables:
122 * mode: c
123 * c-basic-offset: 8
124 * fill-column: 78
125 * End:
126 */
tsize_t
int32 tsize_t
Definition: tiffio.h:67
tsample_t
uint16 tsample_t
Definition: tiffio.h:63
tiff::tif_decoderow
TIFFCodeMethod tif_decoderow
Definition: tiffiop.h:159
tiff::tif_encodestrip
TIFFCodeMethod tif_encodestrip
Definition: tiffiop.h:162
tiff::tif_encoderow
TIFFCodeMethod tif_encoderow
Definition: tiffiop.h:160
tiff::tif_clientdata
thandle_t tif_clientdata
Definition: tiffiop.h:185
tiffiop.h
tiff::tif_name
char * tif_name
Definition: tiffiop.h:103
tiff
Definition: tiffiop.h:102
_TIFFmemcpy
void _TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c)
Definition: tif_acorn.c:485
tiff::tif_rawcp
tidata_t tif_rawcp
Definition: tiffiop.h:176
tiff::tif_decodestrip
TIFFCodeMethod tif_decodestrip
Definition: tiffiop.h:161
tiff::tif_encodetile
TIFFCodeMethod tif_encodetile
Definition: tiffiop.h:164
tiff::tif_seek
TIFFSeekMethod tif_seek
Definition: tiffiop.h:166
TIFFErrorExt
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:63
tiff::tif_rawdatasize
tsize_t tif_rawdatasize
Definition: tiffiop.h:175
tiff::tif_rawcc
tsize_t tif_rawcc
Definition: tiffiop.h:177
tiff::tif_decodetile
TIFFCodeMethod tif_decodetile
Definition: tiffiop.h:163
tidata_t
tidataval_t * tidata_t
Definition: tiffiop.h:91
TIFFInitDumpMode
int TIFFInitDumpMode(TIFF *tif, int scheme)
Definition: tif_dumpmode.c:108
tiff::tif_row
uint32 tif_row
Definition: tiffiop.h:139
tiff::tif_scanlinesize
tsize_t tif_scanlinesize
Definition: tiffiop.h:172
TIFFFlushData1
int TIFFFlushData1(TIFF *tif)
Definition: tif_write.c:682