Пример #1
0
OutputFile::OutputFile
    (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os,
     const Header &header,
     int numThreads)
:
    _data (new Data (numThreads))
{
    _data->_streamData=new OutputStreamMutex ();
    _data->_deleteStream=false;
    try
    {
        header.sanityCheck();
        _data->_streamData->os = &os;
        _data->multiPart=false;
        initialize (header);
        _data->_streamData->currentPosition = _data->_streamData->os->tellp();

        // Write header and empty offset table to the file.
        writeMagicNumberAndVersionField(*_data->_streamData->os, _data->header);
        _data->previewPosition =
            _data->header.writeTo (*_data->_streamData->os);
        _data->lineOffsetsPosition =
            writeLineOffsets (*_data->_streamData->os, _data->lineOffsets);
    }
    catch (IEX_NAMESPACE::BaseExc &e)
    {
        // ~OutputFile will not run, so free memory here
        if (_data)
        {
            if (_data->_streamData)
                delete _data->_streamData;
            delete _data;
        }

        REPLACE_EXC (e, "Cannot open image file "
                     "\"" << os.fileName() << "\". " << e.what());
        throw;
    }
    catch (...)
    {
        // ~OutputFile will not run, so free memory here
        if (_data)
        {
            if (_data->_streamData)
                delete _data->_streamData;
            delete _data;
        }

        throw;
    }
}
Пример #2
0
TiledOutputFile::TiledOutputFile
    (OPENEXR_IMF_INTERNAL_NAMESPACE::OStream &os,
     const Header &header,
     int numThreads)
:
    _data (new Data (numThreads)),
    _streamData (new OutputStreamMutex()),
    _deleteStream (false)
{
    try
    {
	header.sanityCheck(true);
	_streamData->os = &os;
        _data->multipart=false; // since we opened with one header we can't be multipart
	initialize (header);
	_streamData->currentPosition = _streamData->os->tellp();

	// Write header and empty offset table to the file.
	writeMagicNumberAndVersionField(*_streamData->os, _data->header);
	_data->previewPosition = _data->header.writeTo (*_streamData->os, true);
        _data->tileOffsetsPosition = _data->tileOffsets.writeTo (*_streamData->os);
	
    }
    catch (IEX_NAMESPACE::BaseExc &e)
    {
        delete _streamData;
	delete _data;

	REPLACE_EXC (e, "Cannot open image file "
			"\"" << os.fileName() << "\". " << e);
	throw;
    }
    catch (...)
    {
        delete _streamData;
	delete _data;
        throw;
    }
}