7 #include "fwDataIO/writer/GzBufferImageWriter.hpp" 9 #include "fwDataIO/writer/registry/macros.hpp" 11 #include <fwData/Image.hpp> 13 #include <fwDataTools/helper/ImageGetter.hpp> 44 assert(
getFile().empty() ==
false );
47 OSLM_TRACE(
"GzBufferImageWriter::write()" << image.get() <<
" " << image->getClassname());
50 gzFile rawFile = gzopen(
getFile().
string().c_str(),
"wb1");
54 std::string str =
"GzBufferImageWriter::write unable to open ";
57 throw std::ios_base::failure(str);
63 const size_t imageSizeInBytes = image->getSizeInBytes();
65 const char* ptr =
static_cast<char*
>(imageHelper.
getBuffer());
66 size_t writtenBytes = 0;
68 int uncompressedbyteswrited;
70 while ( writtenBytes < imageSizeInBytes
71 && (uncompressedbyteswrited = gzwrite(rawFile, ptr+writtenBytes, imageSizeInBytes-writtenBytes)) > 0 )
73 writtenBytes += uncompressedbyteswrited;
78 assert( uncompressedbyteswrited != 0 && writtenBytes == imageSizeInBytes);
80 if ( uncompressedbyteswrited != 0 && writtenBytes == imageSizeInBytes)
82 std::string str =
"GzBufferImageWriter::write unable to write ";
84 throw std::ios_base::failure(str);
virtual FWDATAIO_API std::string extension() override
Defines extension supported by this writer ".raw.gz".
virtual FWDATAIO_API void write() override
Read the file with zlib API.
This namespace fwDataIO contains reader and writer for several framework's data.
FWDATAIO_API GzBufferImageWriter(::fwDataIO::writer::IObjectWriter::Key key)
Constructor. Do nothing.
virtual std::shared_ptr< const DataType > getConcreteObject() const
m_object getter.
#define OSLM_TRACE(message)
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
Base class for all object writers.
Image Writer. Write file format .raw.gz.
ILocation::PathType getFile()
Get file system path.
Contains the representation of the data objects used in the framework.
virtual FWDATAIO_API ~GzBufferImageWriter()
Destructor. Do nothing.