|
roentgen |
b75cab |
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.14 2011-04-02 20:54:09 bfriesen Exp $ */
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
* Copyright (c) 1988-1997 Sam Leffler
|
|
roentgen |
b75cab |
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
|
roentgen |
b75cab |
*
|
|
roentgen |
b75cab |
* Permission to use, copy, modify, distribute, and sell this software and
|
|
roentgen |
b75cab |
* its documentation for any purpose is hereby granted without fee, provided
|
|
roentgen |
b75cab |
* that (i) the above copyright notices and this permission notice appear in
|
|
roentgen |
b75cab |
* all copies of the software and related documentation, and (ii) the names of
|
|
roentgen |
b75cab |
* Sam Leffler and Silicon Graphics may not be used in any advertising or
|
|
roentgen |
b75cab |
* publicity relating to the software without the specific, prior written
|
|
roentgen |
b75cab |
* permission of Sam Leffler and Silicon Graphics.
|
|
roentgen |
b75cab |
*
|
|
roentgen |
b75cab |
* THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
|
|
roentgen |
b75cab |
* EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
|
|
roentgen |
b75cab |
* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
|
|
roentgen |
b75cab |
*
|
|
roentgen |
b75cab |
* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
|
|
roentgen |
b75cab |
* ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
|
|
roentgen |
b75cab |
* OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
roentgen |
b75cab |
* WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
|
|
roentgen |
b75cab |
* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
roentgen |
b75cab |
* OF THIS SOFTWARE.
|
|
roentgen |
b75cab |
*/
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
* TIFF Library.
|
|
roentgen |
b75cab |
*
|
|
roentgen |
b75cab |
* "Null" Compression Algorithm Support.
|
|
roentgen |
b75cab |
*/
|
|
roentgen |
b75cab |
#include "tiffiop.h"
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
static int
|
|
roentgen |
b75cab |
DumpFixupTags(TIFF* tif)
|
|
roentgen |
b75cab |
{
|
|
roentgen |
b75cab |
(void) tif;
|
|
roentgen |
b75cab |
return (1);
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
* Encode a hunk of pixels.
|
|
roentgen |
b75cab |
*/
|
|
roentgen |
b75cab |
static int
|
|
roentgen |
b75cab |
DumpModeEncode(TIFF* tif, uint8* pp, tmsize_t cc, uint16 s)
|
|
roentgen |
b75cab |
{
|
|
roentgen |
b75cab |
(void) s;
|
|
roentgen |
b75cab |
while (cc > 0) {
|
|
roentgen |
b75cab |
tmsize_t n;
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
n = cc;
|
|
roentgen |
b75cab |
if (tif->tif_rawcc + n > tif->tif_rawdatasize)
|
|
roentgen |
b75cab |
n = tif->tif_rawdatasize - tif->tif_rawcc;
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
assert( n > 0 );
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
* Avoid copy if client has setup raw
|
|
roentgen |
b75cab |
* data buffer to avoid extra copy.
|
|
roentgen |
b75cab |
*/
|
|
roentgen |
b75cab |
if (tif->tif_rawcp != pp)
|
|
roentgen |
b75cab |
_TIFFmemcpy(tif->tif_rawcp, pp, n);
|
|
roentgen |
b75cab |
tif->tif_rawcp += n;
|
|
roentgen |
b75cab |
tif->tif_rawcc += n;
|
|
roentgen |
b75cab |
pp += n;
|
|
roentgen |
b75cab |
cc -= n;
|
|
roentgen |
b75cab |
if (tif->tif_rawcc >= tif->tif_rawdatasize &&
|
|
roentgen |
b75cab |
!TIFFFlushData1(tif))
|
|
roentgen |
b75cab |
return (-1);
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
return (1);
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
* Decode a hunk of pixels.
|
|
roentgen |
b75cab |
*/
|
|
roentgen |
b75cab |
static int
|
|
roentgen |
b75cab |
DumpModeDecode(TIFF* tif, uint8* buf, tmsize_t cc, uint16 s)
|
|
roentgen |
b75cab |
{
|
|
roentgen |
b75cab |
static const char module[] = "DumpModeDecode";
|
|
roentgen |
b75cab |
(void) s;
|
|
roentgen |
b75cab |
if (tif->tif_rawcc < cc) {
|
|
roentgen |
b75cab |
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
|
|
roentgen |
b75cab |
TIFFErrorExt(tif->tif_clientdata, module,
|
|
roentgen |
b75cab |
"Not enough data for scanline %lu, expected a request for at most %I64d bytes, got a request for %I64d bytes",
|
|
roentgen |
b75cab |
(unsigned long) tif->tif_row,
|
|
roentgen |
b75cab |
(signed __int64) tif->tif_rawcc,
|
|
roentgen |
b75cab |
(signed __int64) cc);
|
|
roentgen |
b75cab |
#else
|
|
roentgen |
b75cab |
TIFFErrorExt(tif->tif_clientdata, module,
|
|
roentgen |
b75cab |
"Not enough data for scanline %lu, expected a request for at most %lld bytes, got a request for %lld bytes",
|
|
roentgen |
b75cab |
(unsigned long) tif->tif_row,
|
|
roentgen |
b75cab |
(signed long long) tif->tif_rawcc,
|
|
roentgen |
b75cab |
(signed long long) cc);
|
|
roentgen |
b75cab |
#endif
|
|
roentgen |
b75cab |
return (0);
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
* Avoid copy if client has setup raw
|
|
roentgen |
b75cab |
* data buffer to avoid extra copy.
|
|
roentgen |
b75cab |
*/
|
|
roentgen |
b75cab |
if (tif->tif_rawcp != buf)
|
|
roentgen |
b75cab |
_TIFFmemcpy(buf, tif->tif_rawcp, cc);
|
|
roentgen |
b75cab |
tif->tif_rawcp += cc;
|
|
roentgen |
b75cab |
tif->tif_rawcc -= cc;
|
|
roentgen |
b75cab |
return (1);
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
* Seek forwards nrows in the current strip.
|
|
roentgen |
b75cab |
*/
|
|
roentgen |
b75cab |
static int
|
|
roentgen |
b75cab |
DumpModeSeek(TIFF* tif, uint32 nrows)
|
|
roentgen |
b75cab |
{
|
|
roentgen |
b75cab |
tif->tif_rawcp += nrows * tif->tif_scanlinesize;
|
|
roentgen |
b75cab |
tif->tif_rawcc -= nrows * tif->tif_scanlinesize;
|
|
roentgen |
b75cab |
return (1);
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
* Initialize dump mode.
|
|
roentgen |
b75cab |
*/
|
|
roentgen |
b75cab |
int
|
|
roentgen |
b75cab |
TIFFInitDumpMode(TIFF* tif, int scheme)
|
|
roentgen |
b75cab |
{
|
|
roentgen |
b75cab |
(void) scheme;
|
|
roentgen |
b75cab |
tif->tif_fixuptags = DumpFixupTags;
|
|
roentgen |
b75cab |
tif->tif_decoderow = DumpModeDecode;
|
|
roentgen |
b75cab |
tif->tif_decodestrip = DumpModeDecode;
|
|
roentgen |
b75cab |
tif->tif_decodetile = DumpModeDecode;
|
|
roentgen |
b75cab |
tif->tif_encoderow = DumpModeEncode;
|
|
roentgen |
b75cab |
tif->tif_encodestrip = DumpModeEncode;
|
|
roentgen |
b75cab |
tif->tif_encodetile = DumpModeEncode;
|
|
roentgen |
b75cab |
tif->tif_seek = DumpModeSeek;
|
|
roentgen |
b75cab |
return (1);
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
* Local Variables:
|
|
roentgen |
b75cab |
* mode: c
|
|
roentgen |
b75cab |
* c-basic-offset: 8
|
|
roentgen |
b75cab |
* fill-column: 78
|
|
roentgen |
b75cab |
* End:
|
|
roentgen |
b75cab |
*/
|