From 941d5dc33f764cc2f1a4091be1746de8c0b25ec2 Mon Sep 17 00:00:00 2001 From: Simon Rit Date: Fri, 27 Apr 2012 13:09:34 +0200 Subject: [PATCH] Extended Gate Ascii output to any pixel type --- common/clitkGateAsciiImageIO.cxx | 47 +++++++++++++++++++++++++++++--- common/clitkGateAsciiImageIO.h | 1 - 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/common/clitkGateAsciiImageIO.cxx b/common/clitkGateAsciiImageIO.cxx index 589c30c..99520ee 100644 --- a/common/clitkGateAsciiImageIO.cxx +++ b/common/clitkGateAsciiImageIO.cxx @@ -252,9 +252,49 @@ void clitk::GateAsciiImageIO::Write(const void* abstract_buffer) stream << "# nbVal = " << nb_value << endl; stream << "######################" << endl; - const double* buffer = static_cast(abstract_buffer); - for (unsigned long kk=0; kkGetComponentType()==itk::ImageIOBase::UCHAR) { + const unsigned char* buffer = static_cast(abstract_buffer); + for (unsigned long kk=0; kkGetComponentType()==itk::ImageIOBase::CHAR) { + const char* buffer = static_cast(abstract_buffer); + for (unsigned long kk=0; kkGetComponentType()==itk::ImageIOBase::USHORT) { + const unsigned short* buffer = static_cast(abstract_buffer); + for (unsigned long kk=0; kkGetComponentType()==itk::ImageIOBase::SHORT) { + const short* buffer = static_cast(abstract_buffer); + for (unsigned long kk=0; kkGetComponentType()==itk::ImageIOBase::UINT) { + const unsigned int* buffer = static_cast(abstract_buffer); + for (unsigned long kk=0; kkGetComponentType()==itk::ImageIOBase::INT) { + const int* buffer = static_cast(abstract_buffer); + for (unsigned long kk=0; kkGetComponentType()==itk::ImageIOBase::ULONG) { + const unsigned long* buffer = static_cast(abstract_buffer); + for (unsigned long kk=0; kkGetComponentType()==itk::ImageIOBase::LONG) { + const long* buffer = static_cast(abstract_buffer); + for (unsigned long kk=0; kkGetComponentType()==itk::ImageIOBase::FLOAT) { + const float* buffer = static_cast(abstract_buffer); + for (unsigned long kk=0; kkGetComponentType()==itk::ImageIOBase::DOUBLE) { + const double* buffer = static_cast(abstract_buffer); + for (unsigned long kk=0; kkGetComponentTypeAsString(this->GetComponentType())); + return; } FILE* handle = fopen(m_FileName.c_str(),"w"); @@ -264,6 +304,5 @@ void clitk::GateAsciiImageIO::Write(const void* abstract_buffer) } fwrite(stream.str().c_str(),1,stream.str().size(),handle); - fclose(handle); } diff --git a/common/clitkGateAsciiImageIO.h b/common/clitkGateAsciiImageIO.h index 7d174f8..7d134de 100644 --- a/common/clitkGateAsciiImageIO.h +++ b/common/clitkGateAsciiImageIO.h @@ -42,7 +42,6 @@ public: typedef GateAsciiImageIO Self; typedef itk::ImageIOBase Superclass; typedef itk::SmartPointer Pointer; - typedef signed short int PixelType; struct GateAsciiHeader { double matrix_size[3]; -- 2.47.1