Program: gdcm
Module: $RCSfile: TestAllReadCompareDicom.cxx,v $
Language: C++
- Date: $Date: 2005/11/03 14:07:12 $
- Version: $Revision: 1.51 $
+ Date: $Date: 2005/11/28 16:29:13 $
+ Version: $Revision: 1.58 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
#include "gdcmGlobal.h"
#include "gdcmTS.h"
#include "gdcmDebug.h"
+#include "gdcmUtil.h"
#include <iostream>
Components = 0;
Data = NULL;
- SwapCode = 1234;
+ //SwapCode = 1234;
}
TestFile::~TestFile()
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)
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);
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;
}
// We *know* the .tst files are written in 'Little Endian' format.
// We *know* DataSize may be 1 or 2 !
- uint16_t g;
+ uint16_t g;
+
+ std::cout << " Let's swap Pixels" <<std::endl;
+
for (unsigned int i=0; i<GetDataSize()/2; i++)
{
g = ((uint16_t *)Data)[i];
g = ( g << 8 | g >> 8 );
((uint16_t *)Data)[i] = g;
}
-
-
-
return(true);
}
WriteInt8(fp,'d'); // Bitmap tag - must be 'd'
WriteInt8(fp,'c'); // Bitmap tag - must be 'c'
WriteInt8(fp,'m'); // Bitmap tag - must be 'm'
+
+ // FIXME : Think of writting an int32, better !
+ // (('g' << 8 + 'd') << 8 + 'c') + 'm'
+ // if you want to use it to check the endianess.
+ // (and upload again *all* the .tst files ...)
WriteInt32(fp,SizeX); // Size X
WriteInt32(fp,SizeY); // Size Y
WriteInt32(fp,SizeZ); // Size Z
int TestAllReadCompareDicom(int argc, char *argv[])
{
+// Temporarily added, to track BigEndian troubles
+gdcm::Debug::WarningOn();
+
if (argc == 4)
gdcm::Debug::DebugOn();
return 1;
}
+//if (gdcmDataImages[i] == "D_CLUNIE_CT2_RLE.dcm")
+// gdcm::Debug::DebugOn(); // track pb on BigEndian Proc
+//else
+ gdcm::Debug::DebugOff();
+
////// Step 1 (see above description):
std::string filename = GDCM_DATA_ROOT;
filename += "/";