Lines Matching refs:tif

37 #define	WRITECHECKSTRIPS(tif, module)				\
38 (((tif)->tif_flags&TIFF_BEENWRITING) || TIFFWriteCheck((tif),0,module))
39 #define WRITECHECKTILES(tif, module) \
40 (((tif)->tif_flags&TIFF_BEENWRITING) || TIFFWriteCheck((tif),1,module))
41 #define BUFFERCHECK(tif) \
42 ((((tif)->tif_flags & TIFF_BUFFERSETUP) && tif->tif_rawdata) || \
43 TIFFWriteBufferSetup((tif), NULL, (tsize_t) -1))
49 TIFFWriteScanline(TIFF* tif, tdata_t buf, uint32 row, tsample_t sample)
56 if (!WRITECHECKSTRIPS(tif, module))
63 if (!BUFFERCHECK(tif))
65 td = &tif->tif_dir;
72 TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
84 TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
99 if (strip >= td->td_nstrips && !TIFFGrowStrips(tif, 1, module))
101 if (strip != tif->tif_curstrip) {
105 if (!TIFFFlushData(tif))
107 tif->tif_curstrip = strip;
116 tif->tif_row =
118 if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
119 if (!(*tif->tif_setupencode)(tif))
121 tif->tif_flags |= TIFF_CODERSETUP;
124 tif->tif_rawcc = 0;
125 tif->tif_rawcp = tif->tif_rawdata;
133 tif->tif_curoff = 0;
136 if (!(*tif->tif_preencode)(tif, sample))
138 tif->tif_flags |= TIFF_POSTENCODE;
145 if (row != tif->tif_row) {
146 if (row < tif->tif_row) {
152 tif->tif_row = (strip % td->td_stripsperimage) *
154 tif->tif_rawcp = tif->tif_rawdata;
159 if (!(*tif->tif_seek)(tif, row - tif->tif_row))
161 tif->tif_row = row;
165 tif->tif_postdecode( tif, (tidata_t) buf, tif->tif_scanlinesize );
167 status = (*tif->tif_encoderow)(tif, (tidata_t) buf,
168 tif->tif_scanlinesize, sample);
171 tif->tif_row = row + 1;
182 TIFFWriteEncodedStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc)
185 TIFFDirectory *td = &tif->tif_dir;
188 if (!WRITECHECKSTRIPS(tif, module))
201 TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
205 if (!TIFFGrowStrips(tif, 1, module))
215 if (!BUFFERCHECK(tif))
217 tif->tif_curstrip = strip;
218 tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;
219 if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
220 if (!(*tif->tif_setupencode)(tif))
222 tif->tif_flags |= TIFF_CODERSETUP;
225 tif->tif_rawcc = 0;
226 tif->tif_rawcp = tif->tif_rawdata;
232 tif->tif_curoff = 0;
235 tif->tif_flags &= ~TIFF_POSTENCODE;
237 if (!(*tif->tif_preencode)(tif, sample))
241 tif->tif_postdecode( tif, (tidata_t) data, cc );
243 if (!(*tif->tif_encodestrip)(tif, (tidata_t) data, cc, sample))
245 if (!(*tif->tif_postencode)(tif))
247 if (!isFillOrder(tif, td->td_fillorder) &&
248 (tif->tif_flags & TIFF_NOBITREV) == 0)
249 TIFFReverseBits(tif->tif_rawdata, tif->tif_rawcc);
250 if (tif->tif_rawcc > 0 &&
251 !TIFFAppendToStrip(tif, strip, tif->tif_rawdata, tif->tif_rawcc))
253 tif->tif_rawcc = 0;
254 tif->tif_rawcp = tif->tif_rawdata;
264 TIFFWriteRawStrip(TIFF* tif, tstrip_t strip, tdata_t data, tsize_t cc)
267 TIFFDirectory *td = &tif->tif_dir;
269 if (!WRITECHECKSTRIPS(tif, module))
282 TIFFErrorExt(tif->tif_clientdata, tif->tif_name,
294 if (!TIFFGrowStrips(tif, 1, module))
297 tif->tif_curstrip = strip;
298 tif->tif_row = (strip % td->td_stripsperimage) * td->td_rowsperstrip;
299 return (TIFFAppendToStrip(tif, strip, (tidata_t) data, cc) ?
308 TIFFWriteTile(TIFF* tif,
311 if (!TIFFCheckTile(tif, x, y, z, s))
319 return (TIFFWriteEncodedTile(tif,
320 TIFFComputeTile(tif, x, y, z, s), buf, (tsize_t) -1));
336 TIFFWriteEncodedTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc)
342 if (!WRITECHECKTILES(tif, module))
344 td = &tif->tif_dir;
346 TIFFErrorExt(tif->tif_clientdata, module, "%s: Tile %lu out of range, max %lu",
347 tif->tif_name, (unsigned long) tile, (unsigned long) td->td_nstrips);
355 if (!BUFFERCHECK(tif))
357 tif->tif_curtile = tile;
359 tif->tif_rawcc = 0;
360 tif->tif_rawcp = tif->tif_rawdata;
366 tif->tif_curoff = 0;
373 tif->tif_row = (tile % TIFFhowmany(td->td_imagelength, td->td_tilelength))
375 tif->tif_col = (tile % TIFFhowmany(td->td_imagewidth, td->td_tilewidth))
378 if ((tif->tif_flags & TIFF_CODERSETUP) == 0) {
379 if (!(*tif->tif_setupencode)(tif))
381 tif->tif_flags |= TIFF_CODERSETUP;
383 tif->tif_flags &= ~TIFF_POSTENCODE;
385 if (!(*tif->tif_preencode)(tif, sample))
392 if ( cc < 1 || cc > tif->tif_tilesize)
393 cc = tif->tif_tilesize;
396 tif->tif_postdecode( tif, (tidata_t) data, cc );
398 if (!(*tif->tif_encodetile)(tif, (tidata_t) data, cc, sample))
400 if (!(*tif->tif_postencode)(tif))
402 if (!isFillOrder(tif, td->td_fillorder) &&
403 (tif->tif_flags & TIFF_NOBITREV) == 0)
404 TIFFReverseBits((unsigned char *)tif->tif_rawdata, tif->tif_rawcc);
405 if (tif->tif_rawcc > 0 && !TIFFAppendToStrip(tif, tile,
406 tif->tif_rawdata, tif->tif_rawcc))
408 tif->tif_rawcc = 0;
409 tif->tif_rawcp = tif->tif_rawdata;
423 TIFFWriteRawTile(TIFF* tif, ttile_t tile, tdata_t data, tsize_t cc)
427 if (!WRITECHECKTILES(tif, module))
429 if (tile >= tif->tif_dir.td_nstrips) {
430 TIFFErrorExt(tif->tif_clientdata, module, "%s: Tile %lu out of range, max %lu",
431 tif->tif_name, (unsigned long) tile,
432 (unsigned long) tif->tif_dir.td_nstrips);
435 return (TIFFAppendToStrip(tif, tile, (tidata_t) data, cc) ?
439 #define isUnspecified(tif, f) \
440 (TIFFFieldSet(tif,f) && (tif)->tif_dir.td_imagelength == 0)
443 TIFFSetupStrips(TIFF* tif)
445 TIFFDirectory* td = &tif->tif_dir;
447 if (isTiled(tif))
449 isUnspecified(tif, FIELD_TILEDIMENSIONS) ?
450 td->td_samplesperpixel : TIFFNumberOfTiles(tif);
453 isUnspecified(tif, FIELD_ROWSPERSTRIP) ?
454 td->td_samplesperpixel : TIFFNumberOfStrips(tif);
470 TIFFSetFieldBit(tif, FIELD_STRIPOFFSETS);
471 TIFFSetFieldBit(tif, FIELD_STRIPBYTECOUNTS);
483 TIFFWriteCheck(TIFF* tif, int tiles, const char* module)
485 if (tif->tif_mode == O_RDONLY) {
486 TIFFErrorExt(tif->tif_clientdata, module, "%s: File not open for writing",
487 tif->tif_name);
490 if (tiles ^ isTiled(tif)) {
491 TIFFErrorExt(tif->tif_clientdata, tif->tif_name, tiles ?
507 if (!TIFFFieldSet(tif, FIELD_IMAGEDIMENSIONS)) {
508 TIFFErrorExt(tif->tif_clientdata, module,
510 tif->tif_name);
513 if (tif->tif_dir.td_samplesperpixel == 1) {
520 if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG))
521 tif->tif_dir.td_planarconfig = PLANARCONFIG_CONTIG;
523 if (!TIFFFieldSet(tif, FIELD_PLANARCONFIG)) {
524 TIFFErrorExt(tif->tif_clientdata, module,
526 tif->tif_name);
530 if (tif->tif_dir.td_stripoffset == NULL && !TIFFSetupStrips(tif)) {
531 tif->tif_dir.td_nstrips = 0;
532 TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for %s arrays",
533 tif->tif_name, isTiled(tif) ? "tile" : "strip");
536 tif->tif_tilesize = isTiled(tif) ? TIFFTileSize(tif) : (tsize_t) -1;
537 tif->tif_scanlinesize = TIFFScanlineSize(tif);
538 tif->tif_flags |= TIFF_BEENWRITING;
546 TIFFWriteBufferSetup(TIFF* tif, tdata_t bp, tsize_t size)
550 if (tif->tif_rawdata) {
551 if (tif->tif_flags & TIFF_MYBUFFER) {
552 _TIFFfree(tif->tif_rawdata);
553 tif->tif_flags &= ~TIFF_MYBUFFER;
555 tif->tif_rawdata = NULL;
558 size = (isTiled(tif) ?
559 tif->tif_tilesize : TIFFStripSize(tif));
570 TIFFErrorExt(tif->tif_clientdata, module, "%s: No space for output buffer",
571 tif->tif_name);
574 tif->tif_flags |= TIFF_MYBUFFER;
576 tif->tif_flags &= ~TIFF_MYBUFFER;
577 tif->tif_rawdata = (tidata_t) bp;
578 tif->tif_rawdatasize = size;
579 tif->tif_rawcc = 0;
580 tif->tif_rawcp = tif->tif_rawdata;
581 tif->tif_flags |= TIFF_BUFFERSETUP;
589 TIFFGrowStrips(TIFF* tif, int delta, const char* module)
591 TIFFDirectory *td = &tif->tif_dir;
605 TIFFErrorExt(tif->tif_clientdata, module, "%s: No space to expand strip arrays",
606 tif->tif_name);
623 TIFFAppendToStrip(TIFF* tif, tstrip_t strip, tidata_t data, tsize_t cc)
626 TIFFDirectory *td = &tif->tif_dir;
628 if (td->td_stripoffset[strip] == 0 || tif->tif_curoff == 0) {
642 if (!SeekOK(tif, td->td_stripoffset[strip])) {
643 TIFFErrorExt(tif->tif_clientdata, module,
645 (unsigned long)tif->tif_row);
655 td->td_stripoffset[strip] = TIFFSeekFile(tif, 0, SEEK_END);
658 tif->tif_curoff = td->td_stripoffset[strip];
666 if (!WriteOK(tif, data, cc)) {
667 TIFFErrorExt(tif->tif_clientdata, module, "Write error at scanline %lu",
668 (unsigned long) tif->tif_row);
671 tif->tif_curoff = tif->tif_curoff+cc;
682 TIFFFlushData1(TIFF* tif)
684 if (tif->tif_rawcc > 0) {
685 if (!isFillOrder(tif, tif->tif_dir.td_fillorder) &&
686 (tif->tif_flags & TIFF_NOBITREV) == 0)
687 TIFFReverseBits((unsigned char *)tif->tif_rawdata,
688 tif->tif_rawcc);
689 if (!TIFFAppendToStrip(tif,
690 isTiled(tif) ? tif->tif_curtile : tif->tif_curstrip,
691 tif->tif_rawdata, tif->tif_rawcc))
693 tif->tif_rawcc = 0;
694 tif->tif_rawcp = tif->tif_rawdata;
706 TIFFSetWriteOffset(TIFF* tif, toff_t off)
708 tif->tif_curoff = off;