]> git.saurik.com Git - wxWidgets.git/blame - src/tiff/tif_dumpmode.c
use GTK-specific GUI lock
[wxWidgets.git] / src / tiff / tif_dumpmode.c
CommitLineData
b47c832e
RR
1/* $Header$ */
2
3/*
4 * Copyright (c) 1988-1997 Sam Leffler
5 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
6 *
00cb87b4 7 * Permission to use, copy, modify, distribute, and sell this software and
b47c832e
RR
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.
00cb87b4
VZ
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 *
b47c832e
RR
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,
00cb87b4
VZ
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
b47c832e
RR
24 * OF THIS SOFTWARE.
25 */
26
27/*
28 * TIFF Library.
29 *
30 * "Null" Compression Algorithm Support.
31 */
32#include "tiffiop.h"
00cb87b4 33#include <assert.h>
b47c832e
RR
34
35/*
36 * Encode a hunk of pixels.
37 */
00cb87b4 38static int
b47c832e
RR
39DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s)
40{
41 (void) s;
42 while (cc > 0) {
43 tsize_t n;
44
45 n = cc;
46 if (tif->tif_rawcc + n > tif->tif_rawdatasize)
47 n = tif->tif_rawdatasize - tif->tif_rawcc;
00cb87b4
VZ
48
49 assert( n > 0 );
50
b47c832e
RR
51 /*
52 * Avoid copy if client has setup raw
53 * data buffer to avoid extra copy.
54 */
55 if (tif->tif_rawcp != pp)
56 _TIFFmemcpy(tif->tif_rawcp, pp, n);
57 tif->tif_rawcp += n;
58 tif->tif_rawcc += n;
59 pp += n;
60 cc -= n;
61 if (tif->tif_rawcc >= tif->tif_rawdatasize &&
62 !TIFFFlushData1(tif))
63 return (-1);
64 }
65 return (1);
66}
67
68/*
69 * Decode a hunk of pixels.
70 */
00cb87b4 71static int
b47c832e
RR
72DumpModeDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s)
73{
74 (void) s;
75 if (tif->tif_rawcc < cc) {
76 TIFFError(tif->tif_name,
77 "DumpModeDecode: Not enough data for scanline %d",
78 tif->tif_row);
79 return (0);
80 }
81 /*
82 * Avoid copy if client has setup raw
83 * data buffer to avoid extra copy.
84 */
85 if (tif->tif_rawcp != buf)
86 _TIFFmemcpy(buf, tif->tif_rawcp, cc);
87 tif->tif_rawcp += cc;
88 tif->tif_rawcc -= cc;
89 return (1);
90}
91
92/*
93 * Seek forwards nrows in the current strip.
94 */
00cb87b4 95static int
b47c832e
RR
96DumpModeSeek(TIFF* tif, uint32 nrows)
97{
98 tif->tif_rawcp += nrows * tif->tif_scanlinesize;
99 tif->tif_rawcc -= nrows * tif->tif_scanlinesize;
100 return (1);
101}
102
103/*
104 * Initialize dump mode.
105 */
106int
107TIFFInitDumpMode(TIFF* tif, int scheme)
108{
109 (void) scheme;
110 tif->tif_decoderow = DumpModeDecode;
111 tif->tif_decodestrip = DumpModeDecode;
112 tif->tif_decodetile = DumpModeDecode;
113 tif->tif_encoderow = DumpModeEncode;
114 tif->tif_encodestrip = DumpModeEncode;
115 tif->tif_encodetile = DumpModeEncode;
116 tif->tif_seek = DumpModeSeek;
117 return (1);
118}