Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygentif_dumpmode.c
Go to the documentation of this file.
00001 /* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_dumpmode.c,v 1.5.2.2 2010-06-08 18:50:42 bfriesen Exp $ */ 00002 00003 /* 00004 * Copyright (c) 1988-1997 Sam Leffler 00005 * Copyright (c) 1991-1997 Silicon Graphics, Inc. 00006 * 00007 * Permission to use, copy, modify, distribute, and sell this software and 00008 * its documentation for any purpose is hereby granted without fee, provided 00009 * that (i) the above copyright notices and this permission notice appear in 00010 * all copies of the software and related documentation, and (ii) the names of 00011 * Sam Leffler and Silicon Graphics may not be used in any advertising or 00012 * publicity relating to the software without the specific, prior written 00013 * permission of Sam Leffler and Silicon Graphics. 00014 * 00015 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 00016 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 00017 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 00018 * 00019 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR 00020 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, 00021 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, 00022 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 00023 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 00024 * OF THIS SOFTWARE. 00025 */ 00026 00027 /* 00028 * TIFF Library. 00029 * 00030 * "Null" Compression Algorithm Support. 00031 */ 00032 #include "tiffiop.h" 00033 00034 /* 00035 * Encode a hunk of pixels. 00036 */ 00037 static int 00038 DumpModeEncode(TIFF* tif, tidata_t pp, tsize_t cc, tsample_t s) 00039 { 00040 (void) s; 00041 while (cc > 0) { 00042 tsize_t n; 00043 00044 n = cc; 00045 if (tif->tif_rawcc + n > tif->tif_rawdatasize) 00046 n = tif->tif_rawdatasize - tif->tif_rawcc; 00047 00048 assert( n > 0 ); 00049 00050 /* 00051 * Avoid copy if client has setup raw 00052 * data buffer to avoid extra copy. 00053 */ 00054 if (tif->tif_rawcp != pp) 00055 _TIFFmemcpy(tif->tif_rawcp, pp, n); 00056 tif->tif_rawcp += n; 00057 tif->tif_rawcc += n; 00058 pp += n; 00059 cc -= n; 00060 if (tif->tif_rawcc >= tif->tif_rawdatasize && 00061 !TIFFFlushData1(tif)) 00062 return (-1); 00063 } 00064 return (1); 00065 } 00066 00067 /* 00068 * Decode a hunk of pixels. 00069 */ 00070 static int 00071 DumpModeDecode(TIFF* tif, tidata_t buf, tsize_t cc, tsample_t s) 00072 { 00073 (void) s; 00074 /* fprintf(stderr,"DumpModeDecode: scanline %ld, expected %ld bytes, got %ld bytes\n", */ 00075 /* (long) tif->tif_row, (long) tif->tif_rawcc, (long) cc); */ 00076 if (tif->tif_rawcc < cc) { 00077 TIFFErrorExt(tif->tif_clientdata, tif->tif_name, 00078 "DumpModeDecode: Not enough data for scanline %d", 00079 tif->tif_row); 00080 return (0); 00081 } 00082 /* 00083 * Avoid copy if client has setup raw 00084 * data buffer to avoid extra copy. 00085 */ 00086 if (tif->tif_rawcp != buf) 00087 _TIFFmemcpy(buf, tif->tif_rawcp, cc); 00088 tif->tif_rawcp += cc; 00089 tif->tif_rawcc -= cc; 00090 return (1); 00091 } 00092 00093 /* 00094 * Seek forwards nrows in the current strip. 00095 */ 00096 static int 00097 DumpModeSeek(TIFF* tif, uint32 nrows) 00098 { 00099 tif->tif_rawcp += nrows * tif->tif_scanlinesize; 00100 tif->tif_rawcc -= nrows * tif->tif_scanlinesize; 00101 return (1); 00102 } 00103 00104 /* 00105 * Initialize dump mode. 00106 */ 00107 int 00108 TIFFInitDumpMode(TIFF* tif, int scheme) 00109 { 00110 (void) scheme; 00111 tif->tif_decoderow = DumpModeDecode; 00112 tif->tif_decodestrip = DumpModeDecode; 00113 tif->tif_decodetile = DumpModeDecode; 00114 tif->tif_encoderow = DumpModeEncode; 00115 tif->tif_encodestrip = DumpModeEncode; 00116 tif->tif_encodetile = DumpModeEncode; 00117 tif->tif_seek = DumpModeSeek; 00118 return (1); 00119 } 00120 /* 00121 * Local Variables: 00122 * mode: c 00123 * c-basic-offset: 8 00124 * fill-column: 78 00125 * End: 00126 */ Generated on Sat May 26 2012 04:18:23 for ReactOS by
1.7.6.1
|