7 #include "fwDataIO/reader/GzBufferImageReader.hpp" 9 #include "fwDataIO/reader/registry/macros.hpp" 11 #include <fwData/Image.hpp> 12 #include <fwData/location/SingleFile.hpp> 14 #include <fwDataTools/helper/Image.hpp> 47 assert( ::fwData::location::SingleFile::dynamicCast(
m_location) );
48 ::boost::filesystem::path file = ::fwData::location::SingleFile::dynamicCast(
m_location)->getPath();
50 assert( file.empty() == false );
53 size_t imageSizeInBytes = image->getSizeInBytes();
57 char* ptr =
static_cast<char*
>(helper.
getBuffer());
59 gzFile rawFile = gzopen(file.string().c_str(),
"rb");
64 std::string str =
"Unable to open ";
66 throw std::ios_base::failure(str);
69 int uncompressedbytesreaded;
72 while ( (uncompressedbytesreaded = gzread(rawFile, ptr + readBytes, imageSizeInBytes - readBytes)) > 0 )
74 readBytes += uncompressedbytesreaded;
79 if ( uncompressedbytesreaded == -1 )
81 std::string str =
"Unable to read ";
83 throw std::ios_base::failure(str);
virtual FWDATAIO_API ~GzBufferImageReader()
Destructor. Do nothing.
virtual FWDATAIO_API void read() override
Read the file with zlib API.
This namespace fwDataIO contains reader and writer for several framework's data.
FWDATAIO_API GzBufferImageReader(::fwDataIO::reader::IObjectReader::Key key)
Constructor. Do nothing.
Key class used to restrict access to Object construction. See http://www.drdobbs.com/184402053.
Image Reader. Read file format .raw.gz.
#define SLM_ASSERT(message, cond)
work like 'assert' from 'cassert', with in addition a message logged by spylog (with FATAL loglevel) ...
virtual std::shared_ptr< DataType > getConcreteObject()
m_object getter.
Base class for all object readers.
Contains the representation of the data objects used in the framework.
::fwData::location::ILocation::sptr m_location
Object location ( file path, directory path, url, etc )
FWDATAIO_API std::string extension() override
Defines extension supported by this reader ".raw.gz".