X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0b72db08a78016b2cf89a454b307fb71942e8704..0240e8b1aa935d43689b0b8ec36de3c06c1a4758:/src/common/imagtiff.cpp diff --git a/src/common/imagtiff.cpp b/src/common/imagtiff.cpp index 1ca0a0d0f7..b182648068 100644 --- a/src/common/imagtiff.cpp +++ b/src/common/imagtiff.cpp @@ -119,7 +119,7 @@ TIFFwxOpen(wxInputStream &stream, const char* name, const char* mode) } -bool wxTIFFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose ) +bool wxTIFFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose, int index ) { image->Destroy(); @@ -132,6 +132,16 @@ bool wxTIFFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbos return FALSE; } + + if (!TIFFSetDirectory( tif, (tdir_t)index )) + { + if (verbose) + wxLogError( _("Invalid TIFF image index.") ); + + TIFFClose( tif ); + + return FALSE; + } uint32 w, h; size_t npixels; @@ -216,9 +226,24 @@ bool wxTIFFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbos return TRUE; } +int wxTIFFHandler::GetImageCount( wxInputStream& stream ) +{ + TIFF *tif = TIFFwxOpen( stream, "image", "r" ); + + if (!tif) + return 0; + int dircount = 0; // according to the libtiff docs, dircount should be set to 1 here??? + do { + dircount++; + } while (TIFFReadDirectory(tif)); + + TIFFClose( tif ); + + return dircount; +} -bool wxTIFFHandler::SaveFile( wxImage *image, wxOutputStream& stream, bool verbose ) +bool wxTIFFHandler::SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSED(stream), bool WXUNUSED(verbose) ) { return FALSE; }