X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=common%2FclitkHisImageIO.cxx;h=702a1ba1606895f3811825f6f491c0c76bc60d01;hb=fac0ed982e49a7adde59d6e454b20bb846961bc7;hp=009d282428546ae2fdd18e29cbd4a41b8a7790f2;hpb=33b0605f7f0b0b8bb2a6d90c3fec771487b29744;p=clitk.git diff --git a/common/clitkHisImageIO.cxx b/common/clitkHisImageIO.cxx index 009d282..702a1ba 100755 --- a/common/clitkHisImageIO.cxx +++ b/common/clitkHisImageIO.cxx @@ -1,25 +1,23 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr -/*------------------------------------------------------------------------- - - Program: clitk - Language: C++ - - Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de - l'Image). All rights reserved. See Doc/License.txt or - http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. - This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notices for more information. - - -------------------------------------------------------------------------*/ + PURPOSE. See the copyright notices for more information. + It is distributed under dual licence + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ #ifndef CLITKHISIMAGEIO_CXX #define CLITKHISIMAGEIO_CXX - #define HEADER_INFO_SIZE 68 - /** ------------------------------------------------- * @file clitkHisImageIO.cxx @@ -31,6 +29,8 @@ * -------------------------------------------------*/ +// Based on a true story by the Nederlands Kanker Instituut (AVS_HEIMANN.CPP from the 20090608) + // std include #include @@ -81,7 +81,6 @@ void clitk::HisImageIO::ReadImageInformation() { SetDimensions(1, brx-ulx+1); if (nrframes>1) SetDimensions(2, nrframes); - file.close(); } //// //-------------------------------------------------------------------- @@ -97,7 +96,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 +115,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 +174,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(); } ////