Program: gdcm
Module: $RCSfile: TestWriteSimple.cxx,v $
Language: C++
- Date: $Date: 2005/03/09 09:45:33 $
- Version: $Revision: 1.28 $
+ Date: $Date: 2005/06/03 10:15:19 $
+ Version: $Revision: 1.30 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
fileToBuild->InsertValEntry(str.str(),0x0028,0x0101); // Bits Stored
str.str("");
- str << img.componentSize - 1;
+ str << ( img.componentSize - 1 );
fileToBuild->InsertValEntry(str.str(),0x0028,0x0102); // High Bit
// Set the pixel representation
str << img.components;
fileToBuild->InsertValEntry(str.str(),0x0028,0x0002); // Samples per Pixel
- if( !fileToBuild->IsReadable() )
- {
- std::cout << "Failed\n"
- << " Prepared image isn't readable\n";
- delete fileToBuild;
- return 1;
- }
// Step 2 : Create the output image
std::cout << "2...";
{
for(int c=0;c<img.components;c++)
{
- *tmp = j%256;
+ *tmp = (unsigned char)(j%256);
if( img.componentSize>8 )
{
- *(tmp+1) = j/256;
+ *(tmp+1) = (unsigned char)(j/256);
}
tmp += img.componentSize/8;
}
// Step 3 : Create the file of the image
std::cout << "3...";
- gdcm::FileHelper *file = new gdcm::FileHelper(fileToBuild);
- file->SetImageData(imageData,size);
+ gdcm::FileHelper *fileH = new gdcm::FileHelper(fileToBuild);
+ fileH->SetImageData(imageData,size);
// Step 4 : Set the writting mode and write the image
std::cout << "4...";
- file->SetWriteModeToRaw();
+ fileH->SetWriteModeToRaw();
switch (img.writeMode)
{
case 'a' : // Write an ACR file
- file->SetWriteTypeToAcr();
+ fileH->SetWriteTypeToAcr();
break;
case 'e' : // Write a DICOM Explicit VR file
- file->SetWriteTypeToDcmExplVR();
+ fileH->SetWriteTypeToDcmExplVR();
break;
case 'i' : // Write a DICOM Implicit VR file
- file->SetWriteTypeToDcmImplVR();
+ fileH->SetWriteTypeToDcmImplVR();
break;
default :
std::cout << "Failed\n"
<< " Write mode '"<<img.writeMode<<"' is undefined\n";
- delete file;
+ delete fileH;
delete fileToBuild;
delete[] imageData;
return 1;
}
- if( !file->Write(fileName.str()) )
+ if( !fileH->Write(fileName.str()) )
{
std::cout << "Failed\n"
- << "File in unwrittable\n";
+ << " File in unwrittable\n";
- delete file;
+ delete fileH;
delete fileToBuild;
delete[] imageData;
return 1;
std::cerr << "Failed" << std::endl
<< "Could not read written image : " << fileName << std::endl;
delete fileToBuild;
- delete file;
+ delete fileH;
delete reread;
delete[] imageData;
return 1;
uint8_t *imageDataWritten = reread->GetImageData();
// Test the image write mode
- if (reread->GetFile()->GetFileType() != file->GetWriteType())
+ if (reread->GetFile()->GetFileType() != fileH->GetWriteType())
{
std::cout << "Failed" << std::endl
<< " File type differ: "
- << file->GetWriteType() << " # "
+ << fileH->GetWriteType() << " # "
<< reread->GetFile()->GetFileType() << std::endl;
delete fileToBuild;
- delete file;
+ delete fileH;
delete reread;
delete[] imageData;
<< "Z: " << fileToBuild->GetZSize() << " # "
<< reread->GetFile()->GetZSize() << std::endl;
delete fileToBuild;
- delete file;
+ delete fileH;
delete reread;
delete[] imageData;
<< " Pixel areas lengths differ: "
<< size << " # " << dataSizeWritten << std::endl;
delete fileToBuild;
- delete file;
+ delete fileH;
delete reread;
delete[] imageData;
std::cout << "Failed" << std::endl
<< " Pixel differ (as expanded in memory)." << std::endl;
delete fileToBuild;
- delete file;
+ delete fileH;
delete reread;
delete[] imageData;
std::cout << "OK" << std::endl;
delete fileToBuild;
- delete file;
+ delete fileH;
delete reread;
delete[] imageData;
return 1;
}
- //gdcm::Debug::DebugOn();
+ gdcm::Debug::DebugOn();
int ret=0;
int i=0;