/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.15 2015-12-12 18:04:26 erouault Exp $ */12/*3* Copyright (c) 1988-1997 Sam Leffler4* Copyright (c) 1991-1997 Silicon Graphics, Inc.5*6* Permission to use, copy, modify, distribute, and sell this software and7* its documentation for any purpose is hereby granted without fee, provided8* that (i) the above copyright notices and this permission notice appear in9* all copies of the software and related documentation, and (ii) the names of10* Sam Leffler and Silicon Graphics may not be used in any advertising or11* publicity relating to the software without the specific, prior written12* permission of Sam Leffler and Silicon Graphics.13*14* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,15* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY16* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.17*18* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR19* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,20* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,21* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF22* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE23* OF THIS SOFTWARE.24*/2526/*27* TIFF Library.28*29* "Null" Compression Algorithm Support.30*/31#include "tiffiop.h"3233static int34DumpFixupTags(TIFF* tif)35{36(void) tif;37return (1);38}3940/*41* Encode a hunk of pixels.42*/43static int44DumpModeEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)45{46(void) s;47while (cc > 0) {48tmsize_t n;4950n = cc;51if (tif->tif_rawcc + n > tif->tif_rawdatasize)52n = tif->tif_rawdatasize - tif->tif_rawcc;5354assert( n > 0 );5556/*57* Avoid copy if client has setup raw58* data buffer to avoid extra copy.59*/60if (tif->tif_rawcp != pp)61_TIFFmemcpy(tif->tif_rawcp, pp, n);62tif->tif_rawcp += n;63tif->tif_rawcc += n;64pp += n;65cc -= n;66if (tif->tif_rawcc >= tif->tif_rawdatasize &&67!TIFFFlushData1(tif))68return (0);69}70return (1);71}7273/*74* Decode a hunk of pixels.75*/76static int77DumpModeDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)78{79static const char module[] = "DumpModeDecode";80(void) s;81if (tif->tif_rawcc < cc) {82#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))83TIFFErrorExt(tif->tif_clientdata, module,84"Not enough data for scanline %lu, expected a request for at most %I64d bytes, got a request for %I64d bytes",85(unsigned long) tif->tif_row,86(signed __int64) tif->tif_rawcc,87(signed __int64) cc);88#else89TIFFErrorExt(tif->tif_clientdata, module,90"Not enough data for scanline %lu, expected a request for at most %lld bytes, got a request for %lld bytes",91(unsigned long) tif->tif_row,92(signed long long) tif->tif_rawcc,93(signed long long) cc);94#endif95return (0);96}97/*98* Avoid copy if client has setup raw99* data buffer to avoid extra copy.100*/101if (tif->tif_rawcp != buf)102_TIFFmemcpy(buf, tif->tif_rawcp, cc);103tif->tif_rawcp += cc;104tif->tif_rawcc -= cc;105return (1);106}107108/*109* Seek forwards nrows in the current strip.110*/111static int112DumpModeSeek(TIFF* tif, uint32 nrows)113{114tif->tif_rawcp += nrows * tif->tif_scanlinesize;115tif->tif_rawcc -= nrows * tif->tif_scanlinesize;116return (1);117}118119/*120* Initialize dump mode.121*/122int123TIFFInitDumpMode(TIFF* tif, int scheme)124{125(void) scheme;126tif->tif_fixuptags = DumpFixupTags;127tif->tif_decoderow = DumpModeDecode;128tif->tif_decodestrip = DumpModeDecode;129tif->tif_decodetile = DumpModeDecode;130tif->tif_encoderow = DumpModeEncode;131tif->tif_encodestrip = DumpModeEncode;132tif->tif_encodetile = DumpModeEncode;133tif->tif_seek = DumpModeSeek;134return (1);135}136/*137* Local Variables:138* mode: c139* c-basic-offset: 8140* fill-column: 78141* End:142*/143144145