Lines Matching refs:tif

84 	TIFF *tif;  local
118 tif = (TIFF *)_TIFFmalloc((tmsize_t)(sizeof (TIFF) + strlen(name) + 1));
119 if (tif == NULL) {
123 _TIFFmemset(tif, 0, sizeof (*tif));
124 tif->tif_name = (char *)tif + sizeof (TIFF);
125 strcpy(tif->tif_name, name);
126 tif->tif_mode = m &~ (O_CREAT|O_TRUNC);
127 tif->tif_curdir = (uint16_t) -1; /* non-existent directory */
128 tif->tif_curoff = 0;
129 tif->tif_curstrip = (uint32_t) -1; /* invalid strip */
130 tif->tif_row = (uint32_t) -1; /* read/write pre-increment */
131 tif->tif_clientdata = clientdata;
135 _TIFFfree(tif);
138 tif->tif_readproc = readproc;
139 tif->tif_writeproc = writeproc;
140 tif->tif_seekproc = seekproc;
141 tif->tif_closeproc = closeproc;
142 tif->tif_sizeproc = sizeproc;
144 tif->tif_mapproc = mapproc;
146 tif->tif_mapproc = _tiffDummyMapProc;
148 tif->tif_unmapproc = unmapproc;
150 tif->tif_unmapproc = _tiffDummyUnmapProc;
151 _TIFFSetDefaultCompressionState(tif); /* setup default state */
157 tif->tif_flags = FILLORDER_MSB2LSB;
159 tif->tif_flags |= TIFF_MAPPED;
163 tif->tif_flags |= STRIPCHOP_DEFAULT;
225 tif->tif_flags |= TIFF_SWAB;
231 tif->tif_flags |= TIFF_SWAB;
235 tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) |
239 tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) |
243 tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) |
248 tif->tif_flags |= TIFF_MAPPED;
252 tif->tif_flags &= ~TIFF_MAPPED;
256 tif->tif_flags |= TIFF_STRIPCHOP;
260 tif->tif_flags &= ~TIFF_STRIPCHOP;
263 tif->tif_flags |= TIFF_HEADERONLY;
267 tif->tif_flags |= TIFF_BIGTIFF;
270 tif->tif_flags |= TIFF_DEFERSTRILELOAD;
274 tif->tif_flags |= (TIFF_LAZYSTRILELOAD | TIFF_DEFERSTRILELOAD);
282 tif->tif_flags |= TIFF_DEFERSTRILELOAD;
289 !ReadOK(tif, &tif->tif_header, sizeof (TIFFHeaderClassic))) {
290 if (tif->tif_mode == O_RDONLY) {
291 TIFFErrorExt(tif->tif_clientdata, name,
299 tif->tif_header.common.tiff_magic = (tif->tif_flags & TIFF_SWAB)
302 tif->tif_header.common.tiff_magic = (tif->tif_flags & TIFF_SWAB)
305 if (!(tif->tif_flags&TIFF_BIGTIFF))
307 tif->tif_header.common.tiff_version = TIFF_VERSION_CLASSIC;
308 tif->tif_header.classic.tiff_diroff = 0;
309 if (tif->tif_flags & TIFF_SWAB)
310 TIFFSwabShort(&tif->tif_header.common.tiff_version);
311 tif->tif_header_size = sizeof(TIFFHeaderClassic);
315 tif->tif_header.common.tiff_version = TIFF_VERSION_BIG;
316 tif->tif_header.big.tiff_offsetsize = 8;
317 tif->tif_header.big.tiff_unused = 0;
318 tif->tif_header.big.tiff_diroff = 0;
319 if (tif->tif_flags & TIFF_SWAB)
321 TIFFSwabShort(&tif->tif_header.common.tiff_version);
322 TIFFSwabShort(&tif->tif_header.big.tiff_offsetsize);
324 tif->tif_header_size = sizeof (TIFFHeaderBig);
333 TIFFSeekFile( tif, 0, SEEK_SET );
334 if (!WriteOK(tif, &tif->tif_header, (tmsize_t)(tif->tif_header_size))) {
335 TIFFErrorExt(tif->tif_clientdata, name,
342 if (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN) {
344 tif->tif_flags |= TIFF_SWAB;
348 tif->tif_flags |= TIFF_SWAB;
354 if (!TIFFDefaultDirectory(tif))
356 tif->tif_diroff = 0;
357 tif->tif_dirlist = NULL;
358 tif->tif_dirlistsize = 0;
359 tif->tif_dirnumber = 0;
360 return (tif);
365 if (tif->tif_header.common.tiff_magic != TIFF_BIGENDIAN &&
366 tif->tif_header.common.tiff_magic != TIFF_LITTLEENDIAN
370 tif->tif_header.common.tiff_magic != MDI_BIGENDIAN
372 tif->tif_header.common.tiff_magic != MDI_LITTLEENDIAN
375 TIFFErrorExt(tif->tif_clientdata, name,
379 TIFFErrorExt(tif->tif_clientdata, name,
382 tif->tif_header.common.tiff_magic,
383 tif->tif_header.common.tiff_magic);
386 if (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN) {
388 tif->tif_flags |= TIFF_SWAB;
392 tif->tif_flags |= TIFF_SWAB;
395 if (tif->tif_flags & TIFF_SWAB)
396 TIFFSwabShort(&tif->tif_header.common.tiff_version);
397 if ((tif->tif_header.common.tiff_version != TIFF_VERSION_CLASSIC)&&
398 (tif->tif_header.common.tiff_version != TIFF_VERSION_BIG)) {
399 TIFFErrorExt(tif->tif_clientdata, name,
401 tif->tif_header.common.tiff_version,
402 tif->tif_header.common.tiff_version);
405 if (tif->tif_header.common.tiff_version == TIFF_VERSION_CLASSIC)
407 if (tif->tif_flags & TIFF_SWAB)
408 TIFFSwabLong(&tif->tif_header.classic.tiff_diroff);
409 tif->tif_header_size = sizeof(TIFFHeaderClassic);
413 …if (!ReadOK(tif, ((uint8_t*)(&tif->tif_header) + sizeof(TIFFHeaderClassic)), (sizeof(TIFFHeaderBig…
415 TIFFErrorExt(tif->tif_clientdata, name,
419 if (tif->tif_flags & TIFF_SWAB)
421 TIFFSwabShort(&tif->tif_header.big.tiff_offsetsize);
422 TIFFSwabLong8(&tif->tif_header.big.tiff_diroff);
424 if (tif->tif_header.big.tiff_offsetsize != 8)
426 TIFFErrorExt(tif->tif_clientdata, name,
428 tif->tif_header.big.tiff_offsetsize,
429 tif->tif_header.big.tiff_offsetsize);
432 if (tif->tif_header.big.tiff_unused != 0)
434 TIFFErrorExt(tif->tif_clientdata, name,
436 tif->tif_header.big.tiff_unused,
437 tif->tif_header.big.tiff_unused);
440 tif->tif_header_size = sizeof(TIFFHeaderBig);
441 tif->tif_flags |= TIFF_BIGTIFF;
443 tif->tif_flags |= TIFF_MYBUFFER;
444 tif->tif_rawcp = tif->tif_rawdata = 0;
445 tif->tif_rawdatasize = 0;
446 tif->tif_rawdataoff = 0;
447 tif->tif_rawdataloaded = 0;
451 if (!(tif->tif_flags&TIFF_BIGTIFF))
452 tif->tif_nextdiroff = tif->tif_header.classic.tiff_diroff;
454 tif->tif_nextdiroff = tif->tif_header.big.tiff_diroff;
460 if (tif->tif_flags & TIFF_MAPPED)
463 if (TIFFMapFileContents(tif,(void**)(&tif->tif_base),&n))
465 tif->tif_size=(tmsize_t)n;
466 assert((toff_t)tif->tif_size==n);
469 tif->tif_flags &= ~TIFF_MAPPED;
477 if (tif->tif_flags & TIFF_HEADERONLY)
478 return (tif);
483 if (TIFFReadDirectory(tif)) {
484 tif->tif_rawcc = (tmsize_t)-1;
485 tif->tif_flags |= TIFF_BUFFERSETUP;
486 return (tif);
495 if (!TIFFDefaultDirectory(tif))
497 return (tif);
500 tif->tif_mode = O_RDONLY; /* XXX avoid flush */
501 TIFFCleanup(tif);
514 TIFFFileName(TIFF* tif) argument
516 return (tif->tif_name);
523 TIFFSetFileName(TIFF* tif, const char *name) argument
525 const char* old_name = tif->tif_name;
526 tif->tif_name = (char *)name;
534 TIFFFileno(TIFF* tif) argument
536 return (tif->tif_fd);
543 TIFFSetFileno(TIFF* tif, int fd) argument
545 int old_fd = tif->tif_fd;
546 tif->tif_fd = fd;
554 TIFFClientdata(TIFF* tif) argument
556 return (tif->tif_clientdata);
563 TIFFSetClientdata(TIFF* tif, thandle_t newvalue) argument
565 thandle_t m = tif->tif_clientdata;
566 tif->tif_clientdata = newvalue;
574 TIFFGetMode(TIFF* tif) argument
576 return (tif->tif_mode);
583 TIFFSetMode(TIFF* tif, int mode) argument
585 int old_mode = tif->tif_mode;
586 tif->tif_mode = mode;
595 TIFFIsTiled(TIFF* tif) argument
597 return (isTiled(tif));
604 TIFFCurrentRow(TIFF* tif) argument
606 return (tif->tif_row);
613 TIFFCurrentDirectory(TIFF* tif) argument
615 return (tif->tif_curdir);
622 TIFFCurrentStrip(TIFF* tif) argument
624 return (tif->tif_curstrip);
631 TIFFCurrentTile(TIFF* tif) argument
633 return (tif->tif_curtile);
640 TIFFIsByteSwapped(TIFF* tif) argument
642 return ((tif->tif_flags & TIFF_SWAB) != 0);
649 TIFFIsUpSampled(TIFF* tif) argument
651 return (isUpSampled(tif));
658 TIFFIsMSB2LSB(TIFF* tif) argument
660 return (isFillOrder(tif, FILLORDER_MSB2LSB));
667 TIFFIsBigEndian(TIFF* tif) argument
669 return (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN);
676 TIFFGetReadProc(TIFF* tif) argument
678 return (tif->tif_readproc);
685 TIFFGetWriteProc(TIFF* tif) argument
687 return (tif->tif_writeproc);
694 TIFFGetSeekProc(TIFF* tif) argument
696 return (tif->tif_seekproc);
703 TIFFGetCloseProc(TIFF* tif) argument
705 return (tif->tif_closeproc);
712 TIFFGetSizeProc(TIFF* tif) argument
714 return (tif->tif_sizeproc);
721 TIFFGetMapFileProc(TIFF* tif) argument
723 return (tif->tif_mapproc);
730 TIFFGetUnmapFileProc(TIFF* tif) argument
732 return (tif->tif_unmapproc);