X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestAllReadCompareDicom.cxx;h=56aecc31634df67bce56481e673b2aeb846c6f9e;hb=0c1b69c840b2ab0f42ef1cdbbc1897c44a5ed264;hp=e1dc9df5e4d1c79a864ebb57a381015e79df5867;hpb=651746cbfc1c7dfac951b4582a88a621813339af;p=gdcm.git diff --git a/Testing/TestAllReadCompareDicom.cxx b/Testing/TestAllReadCompareDicom.cxx index e1dc9df5..56aecc31 100644 --- a/Testing/TestAllReadCompareDicom.cxx +++ b/Testing/TestAllReadCompareDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: TestAllReadCompareDicom.cxx,v $ Language: C++ - Date: $Date: 2005/11/09 10:52:37 $ - Version: $Revision: 1.53 $ + Date: $Date: 2007/06/04 08:51:24 $ + Version: $Revision: 1.59 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -21,6 +21,7 @@ #include "gdcmGlobal.h" #include "gdcmTS.h" #include "gdcmDebug.h" +#include "gdcmUtil.h" #include @@ -137,7 +138,7 @@ TestFile::TestFile() Components = 0; Data = NULL; - SwapCode = 1234; + //SwapCode = 1234; } TestFile::~TestFile() @@ -167,7 +168,14 @@ void TestFile::Write(const std::string &filename) int TestFile::ComputeSwapCode(uint32_t tag) { +// FIXME : 100 % useless method ! +// "gdcm" was written on disc byte per byte. +// when you fread it, you'll get *always* "gdcm" +// whatever the processor indianess is ! + int swap = 0; + //std::cout << std::hex << "0x(" << tag << ")" << std::dec << std::endl; + for(int i=0;i<4;i++) { switch(tag&0x000000FF) @@ -189,6 +197,7 @@ int TestFile::ComputeSwapCode(uint32_t tag) } tag >>= 8; } + //std::cout << std::hex << "0x(" << tag << ")" << std::dec << tag << std::endl; return swap; } @@ -252,6 +261,7 @@ bool TestFile::ReadFileHeader(std::ifstream *fp) SwapCode = ComputeSwapCode(tag); if( SwapCode == 0 ) { + // We shall *never* come here! std::cout << "TestFile: Bad tag - Must be 'gdcm'" << std::endl; return(false); } @@ -259,7 +269,7 @@ bool TestFile::ReadFileHeader(std::ifstream *fp) SizeX = ReadInt32(fp); // Size X SizeY = ReadInt32(fp); // Size Y SizeZ = ReadInt32(fp); // Size Z - ScalarSize = ReadInt16(fp)/8; // bits per scalar + ScalarSize = ReadInt16(fp)/8; // bytes per scalar Components = ReadInt16(fp); // Number of components return(true); @@ -274,10 +284,18 @@ bool TestFile::ReadFileData(std::ifstream *fp) if( !Data ) return(false); - // Read data + // Read data Note : .tst images are *always* created + // on little endian processor ! fp->read((char *)Data,GetDataSize()); - - if (GetScalarSize() == 1 || GetSwapCode() == 1234) + + // Track BigEndian troubles + std::cout << " ScalarSize : " << GetScalarSize() + << " IsCurrentProcessorBigEndian:" + << gdcm::Util::IsCurrentProcessorBigEndian() + << std::endl; + + //if (GetScalarSize() == 1 || GetSwapCode() == 1234) + if (GetScalarSize() == 1 || !gdcm::Util::IsCurrentProcessorBigEndian() ) { return true; } @@ -285,11 +303,8 @@ bool TestFile::ReadFileData(std::ifstream *fp) // We *know* DataSize may be 1 or 2 ! uint16_t g; -// Track BigEndian troubles -std::cout << " calarSize : " << GetScalarSize() - << " SwapCode:" << GetSwapCode() - << std::endl; - + std::cout << " Let's swap Pixels" <