Alien-FreeImage
view release on metacpan or search on metacpan
src/Source/OpenEXR/IlmImf/ImfTileOffsets.cpp view on Meta::CPAN
Xdr::skip <StreamIO> (is, dataSize);
}
if (skipOnly) continue;
if (!isValidTile(tileX, tileY, levelX, levelY))
return;
operator () (tileX, tileY, levelX, levelY) = tileOffset;
}
}
}
}
void
TileOffsets::reconstructFromFile (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is,bool isMultiPart,bool isDeep)
{
//
// Try to reconstruct a missing tile offset table by sequentially
// scanning through the file, and recording the offsets in the file
// of the tiles we find.
//
Int64 position = is.tellg();
try
{
findTiles (is,isMultiPart,isDeep,false);
}
catch (...)
{
//
// Suppress all exceptions. This function is called only to
// reconstruct the tile offset table for incomplete files,
// and exceptions are likely.
//
}
is.clear();
is.seekg (position);
}
void
TileOffsets::readFrom (OPENEXR_IMF_INTERNAL_NAMESPACE::IStream &is, bool &complete,bool isMultiPartFile, bool isDeep)
{
//
// Read in the tile offsets from the file's tile offset table
//
for (unsigned int l = 0; l < _offsets.size(); ++l)
for (unsigned int dy = 0; dy < _offsets[l].size(); ++dy)
for (unsigned int dx = 0; dx < _offsets[l][dy].size(); ++dx)
OPENEXR_IMF_INTERNAL_NAMESPACE::Xdr::read <OPENEXR_IMF_INTERNAL_NAMESPACE::StreamIO> (is, _offsets[l][dy][dx]);
//
// Check if any tile offsets are invalid.
//
// Invalid offsets mean that the file is probably incomplete
// (the offset table is the last thing written to the file).
// Either some process is still busy writing the file, or
// writing the file was aborted.
//
// We should still be able to read the existing parts of the
// file. In order to do this, we have to make a sequential
// scan over the scan tile to reconstruct the tile offset
// table.
//
if (anyOffsetsAreInvalid())
{
complete = false;
reconstructFromFile (is,isMultiPartFile,isDeep);
}
else
{
complete = true;
}
}
void
TileOffsets::readFrom (std::vector<Int64> chunkOffsets,bool &complete)
{
size_t totalSize = 0;
for (unsigned int l = 0; l < _offsets.size(); ++l)
for (unsigned int dy = 0; dy < _offsets[l].size(); ++dy)
totalSize += _offsets[l][dy].size();
if (chunkOffsets.size() != totalSize)
throw IEX_NAMESPACE::ArgExc ("Wrong offset count, not able to read from this array");
int pos = 0;
for (size_t l = 0; l < _offsets.size(); ++l)
for (size_t dy = 0; dy < _offsets[l].size(); ++dy)
for (size_t dx = 0; dx < _offsets[l][dy].size(); ++dx)
{
_offsets[l][dy][dx] = chunkOffsets[pos];
pos++;
}
complete = !anyOffsetsAreInvalid();
}
Int64
TileOffsets::writeTo (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os) const
{
//
// Write the tile offset table to the file, and
// return the position of the start of the table
// in the file.
//
Int64 pos = os.tellp();
( run in 0.659 second using v1.01-cache-2.11-cpan-5a3173703d6 )