X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FReWrite.cxx;h=9cdab8e3fafdbe770b8ca490bdb3a57c189c40be;hb=be9028b872c05c24a826b6fdf0ee688a877d47ee;hp=131c687fb9f2cae212ec36f57710a8c81448fed9;hpb=f746c4740d107bba67f517bc59544b5b1f1844ed;p=gdcm.git diff --git a/Example/ReWrite.cxx b/Example/ReWrite.cxx index 131c687f..9cdab8e3 100644 --- a/Example/ReWrite.cxx +++ b/Example/ReWrite.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: ReWrite.cxx,v $ Language: C++ - Date: $Date: 2005/10/17 10:29:32 $ - Version: $Revision: 1.12 $ + Date: $Date: 2005/11/07 09:53:53 $ + Version: $Revision: 1.16 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -96,24 +96,24 @@ int main(int argc, char *argv[]) // ----------- End Arguments Manager --------- - gdcm::File *f = new gdcm::File(); + gdcm::File *f = gdcm::File::New(); f->SetLoadMode( loadMode ); f->SetFileName( fileName ); bool res = f->Load(); if ( !res ) { - delete f; + f->Delete(); return 0; } if (!f->IsReadable()) { std::cerr << "Sorry, not a Readable DICOM / ACR File" <Delete(); return 0; } - gdcm::FileHelper *fh = new gdcm::FileHelper(f); + gdcm::FileHelper *fh = gdcm::FileHelper::New(f); void *imageData; int dataSize; @@ -150,7 +150,7 @@ int main(int argc, char *argv[]) << " SampleserPixel=" << sPP << " PlanarConfiguration=" << planarConfig << " PhotometricInterpretation=" - << f->GetEntryValue(0x0028,0x0004) + << f->GetEntryString(0x0028,0x0004) << std::endl; int numberOfScalarComponents=f->GetNumberOfScalarComponents(); @@ -160,73 +160,75 @@ int main(int argc, char *argv[]) std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl; + // Since we just ReWrite the image, we know no modification + // was performed on the pixels. + // We don't want this image appears as a 'Secondary Captured image' + fh->SetKeepMediaStorageSOPClassUID(true); + switch (mode[0]) { - case 'A' : - case 'a' : - // Writting an ACR file - // from a full gdcm readable File - - std::cout << "WriteACR" << std::endl; - fh->WriteAcr(outputFileName); - break; - - case 'D' : // Not documented in the 'usage', because the method - case 'd' : // is known to be bugged. - // Writting a DICOM Implicit VR file - // from a full gdcm readable File - - std::cout << "WriteDCM Implicit VR" << std::endl; - fh->WriteDcmImplVR(outputFileName); - break; - - case 'X' : - case 'x' : - // writting a DICOM Explicit VR - // from a full gdcm readable File - - std::cout << "WriteDCM Explicit VR" << std::endl; - fh->WriteDcmExplVR(outputFileName); - break; - - case 'R' : - case 'r' : - // Writting a Raw File, - - std::cout << "WriteRaw" << std::endl; - fh->WriteRawData(outputFileName); - break; + case 'A' : + case 'a' : + // Writting an ACR file + // from a full gdcm readable File + std::cout << "WriteACR" << std::endl; + fh->WriteAcr(outputFileName); + break; + + case 'D' : // Not documented in the 'usage', because the method + case 'd' : // is known to be bugged. + // Writting a DICOM Implicit VR file + // from a full gdcm readable File + std::cout << "WriteDCM Implicit VR" << std::endl; + fh->WriteDcmImplVR(outputFileName); + break; + + case 'X' : + case 'x' : + // writting a DICOM Explicit VR + // from a full gdcm readable File + std::cout << "WriteDCM Explicit VR" << std::endl; + // fh->WriteDcmExplVR(outputFileName); + // Try this one : + fh->SetWriteTypeToDcmExplVR(); + fh->Write(outputFileName); + break; + + case 'R' : + case 'r' : + // Writting a Raw File, + std::cout << "WriteRaw" << std::endl; + fh->WriteRawData(outputFileName); + break; // Just for fun : - // Write a 'Videon inverse' version of the file/ + // Write a 'Video inverse' version of the file. // *Not* described, on purpose, in the USAGE - - case 'V' : - case 'v' : - - if ( fh->GetFile()->GetBitsAllocated() == 8) - { - std::cout << "videoinv for 8 bits" << std::endl; - for (int i=0; iWriteDcmExplVR(outputFileName); - break; - + case 'V' : + case 'v' : + if ( fh->GetFile()->GetBitsAllocated() == 8) + { + std::cout << "videoinv for 8 bits" << std::endl; + for (int i=0; iWriteDcmExplVR(outputFileName); + break; } - delete f; - delete fh; + + f->Delete(); + fh->Delete(); return 0; }