Program: gdcm
Module: $RCSfile: TestWriteSimple.cxx,v $
Language: C++
- Date: $Date: 2005/01/08 15:03:58 $
- Version: $Revision: 1.10 $
+ Date: $Date: 2005/01/24 16:44:54 $
+ Version: $Revision: 1.14 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
* The image content is a horizontal grayscale from
*
*/
-#include "gdcmHeader.h"
#include "gdcmFile.h"
+#include "gdcmFileHelper.h"
#include <iostream>
+#include <sstream>
typedef struct
{
// Step 1 : Create the header of the image
std::cout << " 1...";
- gdcm::Header *header = new gdcm::Header();
+ gdcm::File *header = new gdcm::File();
std::ostringstream str;
// Set the image size
str.str("");
str << img.sizeX;
- header->ReplaceOrCreate(str.str(),0x0028,0x0011); // Columns
+ header->Insert(str.str(),0x0028,0x0011); // Columns
str.str("");
str << img.sizeY;
- header->ReplaceOrCreate(str.str(),0x0028,0x0010); // Rows
+ header->Insert(str.str(),0x0028,0x0010); // Rows
if(img.sizeZ>1)
{
str.str("");
str << img.sizeZ;
- header->ReplaceOrCreate(str.str(),0x0028,0x0008); // Number of Frames
+ header->Insert(str.str(),0x0028,0x0008); // Number of Frames
}
// Set the pixel type
str.str("");
str << img.componentSize;
- header->ReplaceOrCreate(str.str(),0x0028,0x0100); // Bits Allocated
+ header->Insert(str.str(),0x0028,0x0100); // Bits Allocated
str.str("");
str << img.componentUse;
- header->ReplaceOrCreate(str.str(),0x0028,0x0101); // Bits Stored
+ header->Insert(str.str(),0x0028,0x0101); // Bits Stored
str.str("");
str << img.componentSize - 1;
- header->ReplaceOrCreate(str.str(),0x0028,0x0102); // High Bit
+ header->Insert(str.str(),0x0028,0x0102); // High Bit
// Set the pixel representation
str.str("");
str << img.sign;
- header->ReplaceOrCreate(str.str(),0x0028,0x0103); // Pixel Representation
+ header->Insert(str.str(),0x0028,0x0103); // Pixel Representation
// Set the samples per pixel
str.str("");
str << img.components;
- header->ReplaceOrCreate(str.str(),0x0028,0x0002); // Samples per Pixel
+ header->Insert(str.str(),0x0028,0x0002); // Samples per Pixel
if( !header->IsReadable() )
{
// Step 3 : Create the file of the image
std::cout << "3...";
- gdcm::File *file = new gdcm::File(header);
+ gdcm::FileHelper *file = new gdcm::FileHelper(header);
file->SetImageData(imageData,size);
// Step 4 : Set the writting mode and write the image
// Step 5 : Read the written image
std::cout << "5...";
- gdcm::File* reread = new gdcm::File( fileName );
- if( !reread->GetHeader()->IsReadable() )
+ gdcm::FileHelper* reread = new gdcm::FileHelper( fileName );
+ if( !reread->GetFile()->IsReadable() )
{
std::cerr << "Failed" << std::endl
<< "Test::TestReadWriteReadCompare: Could not reread image "
uint8_t* imageDataWritten = reread->GetImageData();
// Test the image size
- if (header->GetXSize() != reread->GetHeader()->GetXSize() ||
- header->GetYSize() != reread->GetHeader()->GetYSize() ||
- header->GetZSize() != reread->GetHeader()->GetZSize())
+ if (header->GetXSize() != reread->GetFile()->GetXSize() ||
+ header->GetYSize() != reread->GetFile()->GetYSize() ||
+ header->GetZSize() != reread->GetFile()->GetZSize())
{
std::cout << "Failed" << std::endl
<< " X Size differs: "
<< "X: " << header->GetXSize() << " # "
- << reread->GetHeader()->GetXSize() << " | "
+ << reread->GetFile()->GetXSize() << " | "
<< "Y: " << header->GetYSize() << " # "
- << reread->GetHeader()->GetYSize() << " | "
+ << reread->GetFile()->GetYSize() << " | "
<< "Z: " << header->GetZSize() << " # "
- << reread->GetHeader()->GetZSize() << std::endl;
+ << reread->GetFile()->GetZSize() << std::endl;
delete header;
delete file;
delete reread;