/*1* Copyright (c) 1988-1997 Sam Leffler2* Copyright (c) 1991-1997 Silicon Graphics, Inc.3*4* Permission to use, copy, modify, distribute, and sell this software and5* its documentation for any purpose is hereby granted without fee, provided6* that (i) the above copyright notices and this permission notice appear in7* all copies of the software and related documentation, and (ii) the names of8* Sam Leffler and Silicon Graphics may not be used in any advertising or9* publicity relating to the software without the specific, prior written10* permission of Sam Leffler and Silicon Graphics.11*12* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,13* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY14* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.15*16* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR17* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,18* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,19* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF20* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE21* OF THIS SOFTWARE.22*/2324/*25* TIFF Library.26*27* "Null" Compression Algorithm Support.28*/29#include "tiffiop.h"3031static int DumpFixupTags(TIFF *tif)32{33(void)tif;34return (1);35}3637/*38* Encode a hunk of pixels.39*/40static int DumpModeEncode(TIFF *tif, uint8_t *pp, tmsize_t cc, uint16_t s)41{42(void)s;43while (cc > 0)44{45tmsize_t n;4647n = cc;48if (tif->tif_rawcc + n > tif->tif_rawdatasize)49n = tif->tif_rawdatasize - tif->tif_rawcc;5051assert(n > 0);5253/*54* Avoid copy if client has setup raw55* data buffer to avoid extra copy.56*/57if (tif->tif_rawcp != pp)58_TIFFmemcpy(tif->tif_rawcp, pp, n);59tif->tif_rawcp += n;60tif->tif_rawcc += n;61pp += n;62cc -= n;63if (tif->tif_rawcc >= tif->tif_rawdatasize && !TIFFFlushData1(tif))64return (0);65}66return (1);67}6869/*70* Decode a hunk of pixels.71*/72static int DumpModeDecode(TIFF *tif, uint8_t *buf, tmsize_t cc, uint16_t s)73{74static const char module[] = "DumpModeDecode";75(void)s;76if (tif->tif_rawcc < cc)77{78TIFFErrorExtR(tif, module,79"Not enough data for scanline %" PRIu3280", expected a request for at most %" TIFF_SSIZE_FORMAT81" bytes, got a request for %" TIFF_SSIZE_FORMAT " bytes",82tif->tif_row, tif->tif_rawcc, cc);83return (0);84}85/*86* Avoid copy if client has setup raw87* data buffer to avoid extra copy.88*/89if (tif->tif_rawcp != buf)90_TIFFmemcpy(buf, tif->tif_rawcp, cc);91tif->tif_rawcp += cc;92tif->tif_rawcc -= cc;93return (1);94}9596/*97* Seek forwards nrows in the current strip.98*/99static int DumpModeSeek(TIFF *tif, uint32_t nrows)100{101tif->tif_rawcp += nrows * tif->tif_scanlinesize;102tif->tif_rawcc -= nrows * tif->tif_scanlinesize;103return (1);104}105106/*107* Initialize dump mode.108*/109int TIFFInitDumpMode(TIFF *tif, int scheme)110{111(void)scheme;112tif->tif_fixuptags = DumpFixupTags;113tif->tif_decoderow = DumpModeDecode;114tif->tif_decodestrip = DumpModeDecode;115tif->tif_decodetile = DumpModeDecode;116tif->tif_encoderow = DumpModeEncode;117tif->tif_encodestrip = DumpModeEncode;118tif->tif_encodetile = DumpModeEncode;119tif->tif_seek = DumpModeSeek;120return (1);121}122123124