X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Testing%2FTestAllReadCompareDicom.cxx;h=1e911cfe043d332cd6b00f0adac7ff4631e0bc58;hb=f8be63ebb26fa8fc3381c4ac129138fabf229412;hp=05069a76b7ecdb70a935f5eed6ddc95bb589af99;hpb=8341008e6e7cf155a053b5fe469b182bf7eed52a;p=gdcm.git diff --git a/Testing/TestAllReadCompareDicom.cxx b/Testing/TestAllReadCompareDicom.cxx index 05069a76..1e911cfe 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/08 09:13:22 $ - Version: $Revision: 1.52 $ + Date: $Date: 2005/11/15 11:43:22 $ + Version: $Revision: 1.55 $ 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 if, you'll get *allways* "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) @@ -259,7 +267,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); @@ -276,8 +284,14 @@ bool TestFile::ReadFileData(std::ifstream *fp) // Read data fp->read((char *)Data,GetDataSize()); - - if (GetScalarSize() == 1 || GetSwapCode() == 1234) + + // Track BigEndian troubles + std::cout << " ScalarSize : " << GetScalarSize() + << " SwapCode:" << GetSwapCode() + << std::endl; + + //if (GetScalarSize() == 1 || GetSwapCode() == 1234) + if (GetScalarSize() == 1 || !gdcm::Util::IsCurrentProcessorBigEndian() ) { return true; } @@ -285,11 +299,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" <