1092 int use_rawdata, tiled_image, breaklen =
MAXLINE;
1093 uint32 chunk_no, num_chunks, *bc;
1094 unsigned char *buf_data, *cp;
1095 tsize_t chunk_size, byte_count;
1097 #if defined( EXP_ASCII85ENCODER )
1099 uint8 * ascii85_p = 0;
1106 #ifdef ENABLE_BROKEN_BEGINENDDATA
1107 fputs(
"%%BeginData:\n", ctx->
fd);
1109 fputs(
"exec\n", ctx->
fd);
1111 tiled_image = TIFFIsTiled(tif);
1113 num_chunks = TIFFNumberOfTiles(tif);
1114 TIFFGetField(tif, TIFFTAG_TILEBYTECOUNTS, &bc);
1116 num_chunks = TIFFNumberOfStrips(tif);
1117 TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &bc);
1121 chunk_size = (tsize_t) bc[0];
1122 for (chunk_no = 1; chunk_no < num_chunks; chunk_no++)
1123 if ((tsize_t) bc[chunk_no] > chunk_size)
1124 chunk_size = (tsize_t) bc[chunk_no];
1127 chunk_size = TIFFTileSize(tif);
1129 chunk_size = TIFFStripSize(tif);
1131 buf_data = (
unsigned char *)_TIFFmalloc(chunk_size);
1133 TIFFError(ctx->
filename,
"Can't alloc %u bytes for %s.",
1134 (
unsigned int) chunk_size, tiled_image ?
"tiles" :
"strips");
1138 #if defined( EXP_ASCII85ENCODER )
1149 ascii85_p = _TIFFmalloc( (chunk_size+(chunk_size/2)) + 8 );
1152 _TIFFfree( buf_data );
1155 "Cannot allocate ASCII85 encoding buffer." );
1161 TIFFGetFieldDefaulted(tif, TIFFTAG_FILLORDER, &fillorder);
1162 for (chunk_no = 0; chunk_no < num_chunks; chunk_no++) {
1169 byte_count = TIFFReadRawTile(tif, chunk_no,
1170 buf_data, chunk_size);
1172 byte_count = TIFFReadRawStrip(tif, chunk_no,
1173 buf_data, chunk_size);
1174 if (fillorder == FILLORDER_LSB2MSB)
1175 TIFFReverseBits(buf_data, byte_count);
1178 byte_count = TIFFReadEncodedTile(tif,
1182 byte_count = TIFFReadEncodedStrip(tif,
1186 if (byte_count < 0) {
1187 TIFFError(ctx->
filename,
"Can't read %s %d.",
1188 tiled_image ?
"tile" :
"strip", chunk_no);
1200 int adjust, i, j = 0;
1203 adjust = 255 - buf_data[i + ncomps];
1206 buf_data[j++] = buf_data[i] + adjust;
1209 buf_data[j++] = buf_data[i] + adjust;
1210 buf_data[j++] = buf_data[i+1] + adjust;
1213 buf_data[j++] = buf_data[i] + adjust;
1214 buf_data[j++] = buf_data[i+1] + adjust;
1215 buf_data[j++] = buf_data[i+2] + adjust;
1223 #if defined( EXP_ASCII85ENCODER )
1225 buf_data, byte_count);
1227 if ( ascii85_l > 0 )
1228 fwrite( ascii85_p, ascii85_l, 1, ctx->
fd );
1230 for (cp = buf_data; byte_count > 0; byte_count--)
1236 for (cp = buf_data; byte_count > 0; byte_count--) {
1237 putc(
hex[((*cp)>>4)&0xf], ctx->
fd);
1238 putc(
hex[(*cp)&0xf], ctx->
fd);
1241 if (--breaklen <= 0) {
1242 putc(
'\n', ctx->
fd);
1250 putc(
'>', ctx->
fd );
1251 putc(
'\n', ctx->
fd);
1253 #if !defined( EXP_ASCII85ENCODER )
1259 #if defined( EXP_ASCII85ENCODER )
1261 _TIFFfree( ascii85_p );
1263 _TIFFfree(buf_data);
1264 #ifdef ENABLE_BROKEN_BEGINENDDATA
1265 fputs(
"%%EndData\n", ctx->
fd);