X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=common%2FclitkHisImageIO.cxx;h=7d1ab14a9695707623883d075f9a19de6e8ae7f2;hb=8973673f3f984656ec3552b5d963ba7b18119d39;hp=009d282428546ae2fdd18e29cbd4a41b8a7790f2;hpb=33b0605f7f0b0b8bb2a6d90c3fec771487b29744;p=clitk.git diff --git a/common/clitkHisImageIO.cxx b/common/clitkHisImageIO.cxx index 009d282..7d1ab14 100755 --- a/common/clitkHisImageIO.cxx +++ b/common/clitkHisImageIO.cxx @@ -31,6 +31,8 @@ * -------------------------------------------------*/ +// Based on a true story by the Nederlands Kanker Instituut (AVS_HEIMANN.CPP from the 20090608) + // std include #include @@ -81,7 +83,6 @@ void clitk::HisImageIO::ReadImageInformation() { SetDimensions(1, brx-ulx+1); if (nrframes>1) SetDimensions(2, nrframes); - file.close(); } //// //-------------------------------------------------------------------- @@ -97,7 +98,6 @@ bool clitk::HisImageIO::CanReadFile(const char* FileNameToRead) //-------------------------------------------------------------------- // Read Image Content void clitk::HisImageIO::Read(void * buffer) { - // open file std::ifstream file(m_FileName.c_str(), std::ios::in | std::ios::binary); if ( file.fail() ) @@ -117,10 +117,18 @@ void clitk::HisImageIO::Read(void * buffer) { << file.gcount() << " bytes. The current state is: " << file.rdstate()); } + +//-------------------------------------------------------------------- +bool clitk::HisImageIO::CanWriteFile(const char* FileNameToWrite) +{ std::string filename(FileNameToWrite); + std::string filenameext = GetExtension(filename); + if (filenameext != std::string("his")) return false; + return true; +} //-------------------------------------------------------------------- -// Write Image Information -void clitk::HisImageIO::WriteImageInformation(bool keepOfStream) +// Write Image +void clitk::HisImageIO::Write(const void* buffer) { std::ofstream file(m_FileName.c_str(), std::ios::out | std::ios::binary); if ( file.fail() ) @@ -168,28 +176,8 @@ void clitk::HisImageIO::WriteImageInformation(bool keepOfStream) itkExceptionMacro(<< "Unsupported field type"); break; } + file.write(szHeader, m_HeaderSize); - file.close(); -} - -//-------------------------------------------------------------------- -// Write Image Information -bool clitk::HisImageIO::CanWriteFile(const char* FileNameToWrite) -{ - std::string filename(FileNameToWrite); - std::string filenameext = GetExtension(filename); - if (filenameext != std::string("his")) return false; - return true; -} - -//-------------------------------------------------------------------- -// Write Image -void clitk::HisImageIO::Write(const void * buffer) -{ - std::ofstream file(m_FileName.c_str(), std::ios::out | std::ios::binary | std::ios::ate); - if ( file.fail() ) - itkGenericExceptionMacro(<< "Could not open file (for writing): " << m_FileName); - file.write((const char *)buffer, GetImageSizeInBytes()); file.close(); } ////