MCPcopy Create free account
hub / github.com/Kitware/VTK / Initialize

Method Initialize

IO/Image/vtkTIFFReader.cxx:219–332  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

217
218//------------------------------------------------------------------------------
219bool vtkTIFFReader::vtkTIFFReaderInternal::Initialize()
220{
221 if (this->Image)
222 {
223 if (!TIFFGetField(this->Image, TIFFTAG_IMAGEWIDTH, &this->Width) ||
224 !TIFFGetField(this->Image, TIFFTAG_IMAGELENGTH, &this->Height))
225 {
226 return false;
227 }
228
229 // Get the resolution in each direction
230 TIFFGetField(this->Image, TIFFTAG_XRESOLUTION, &this->XResolution);
231 TIFFGetField(this->Image, TIFFTAG_YRESOLUTION, &this->YResolution);
232 TIFFGetField(this->Image, TIFFTAG_RESOLUTIONUNIT, &this->ResolutionUnit);
233
234 // Check the number of pages. First by looking at the number of directories.
235 this->NumberOfPages = TIFFNumberOfDirectories(this->Image);
236 if (this->NumberOfPages == 0)
237 {
238 if (!TIFFGetField(this->Image, TIFFTAG_PAGENUMBER, &this->CurrentPage, &this->NumberOfPages))
239 {
240 // Check the Image Description tag to know the number of images
241 // This is used by ImageJ
242 char** description = new char*[255];
243 if (TIFFGetField(this->Image, TIFFTAG_IMAGEDESCRIPTION, description))
244 {
245 // look for the number of images
246 std::string desc = description[0];
247 std::string::size_type pos = desc.find("images=");
248 std::string::size_type pos2 = desc.find('\n');
249 if ((pos != std::string::npos) && (pos2 != std::string::npos))
250 {
251 VTK_FROM_CHARS_IF_ERROR_RETURN(
252 desc.substr(pos + 7, pos2 - pos - 7), this->NumberOfPages, false);
253 }
254 }
255 }
256 }
257
258 // If the number of pages is still zero we look if the image is tiled.
259 if (this->NumberOfPages <= 1 && TIFFIsTiled(this->Image))
260 {
261 this->NumberOfTiles = TIFFNumberOfTiles(this->Image);
262
263 if (!TIFFGetField(this->Image, TIFFTAG_TILEWIDTH, &this->TileWidth) ||
264 !TIFFGetField(this->Image, TIFFTAG_TILELENGTH, &this->TileHeight))
265 {
266 std::cerr << "Cannot read tile width and height from file" << endl;
267 }
268 else
269 {
270 TileRows = this->Height / this->TileHeight;
271 TileColumns = this->Width / this->TileWidth;
272 }
273 }
274
275 // Checking if the TIFF contains subfiles
276 if (this->NumberOfPages > 1)

Callers 15

OpenMethod · 0.95
RequestDataMethod · 0.45
RequestDataMethod · 0.45
BuildOutputGridMethod · 0.45
ReadFileMethod · 0.45
RequestDataMethod · 0.45
TestChacoReader.pyFile · 0.45
Plot3DScalars.pyFile · 0.45

Calls 8

TIFFGetFieldFunction · 0.85
TIFFNumberOfDirectoriesFunction · 0.85
TIFFIsTiledFunction · 0.85
TIFFNumberOfTilesFunction · 0.85
TIFFReadDirectoryFunction · 0.85
TIFFSetDirectoryFunction · 0.85
TIFFGetFieldDefaultedFunction · 0.85
findMethod · 0.45

Tested by 15

TestGLTFWriterFunction · 0.36
TestGL2PSScalarBarFunction · 0.36
TestGL2PSExporterRasterFunction · 0.36
TestGL2PSTextActor3DFunction · 0.36
TestStackedPlotGL2PSFunction · 0.36
TestGL2PSTextActorFunction · 0.36
TestGL2PSContextFunction · 0.36
TestGL2PSTextMapperFunction · 0.36