X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FReWrite.cxx;h=43241c1f2a76dd8e16b14131f7c4eabd9fd2a1f7;hb=5632bd68b349f72ddae6d5676193d9b03d50adb2;hp=ee5583c2c20b50db81a5e32680ed0370810da2b8;hpb=94d13393e488310ea378c26380566596ef208bfd;p=gdcm.git diff --git a/Example/ReWrite.cxx b/Example/ReWrite.cxx index ee5583c2..43241c1f 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/06/07 11:12:10 $ - Version: $Revision: 1.1 $ + Date: $Date: 2005/06/17 12:37:20 $ + Version: $Revision: 1.7 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -27,15 +27,16 @@ int main(int argc, char *argv[]) { START_USAGE(usage) " \n ReWrite :\n", - " Re write a full gdcm-readable Dicom image", - " (usefull when the file header is not very straight).", - " ", - " usage: ReWrite filein=inputFileName fileout=anonymizedFileName ", - " [mode=write mode] [noshadow] [noseq][debug] ", - " mode = a (ACR), x (Explicit VR Dicom), r (RAW : only pixels)", + " Re write a full gdcm-readable Dicom image ", + " (usefull when the file header is not very straight). ", + "", + " usage: ReWrite filein=inputFileName fileout=anonymizedFileName ", + " [mode=write mode] [noshadow] [noseq][debug] ", + " mode = a (ACR), x (Explicit VR Dicom), r (RAW : only pixels) ", " noshadow : user doesn't want to load Private groups (odd number)", - " noseq : user doesn't want to load Sequences ", - " debug : user wants to run the program in 'debug mode' ", + " noseq : user doesn't want to load Sequences ", + " rgb : user wants to tranform LUT (if any) to RGB pixels ", + " debug : user wants to run the program in 'debug mode' ", FINISH_USAGE // ----- Initialize Arguments Manager ------ @@ -61,7 +62,7 @@ int main(int argc, char *argv[]) return 0; } - char *mode = am->ArgMgrGetString("filein","X"); + char *mode = am->ArgMgrGetString("mode",(char *)"X"); int loadMode; if ( am->ArgMgrDefined("noshadow") && am->ArgMgrDefined("noseq") ) @@ -73,10 +74,12 @@ int main(int argc, char *argv[]) else loadMode = 0; + bool rgb = ( 0 != am->ArgMgrDefined("RGB") ); + if (am->ArgMgrDefined("debug")) gdcm::Debug::DebugOn(); - // if unused Param we give up + // if unused Params we give up if ( am->ArgMgrPrintUnusedLabels() ) { am->ArgMgrUsage(usage); @@ -86,8 +89,7 @@ int main(int argc, char *argv[]) delete am; // we don't need Argument Manager any longer - void *imageData; - int dataSize; + // ----------- End Arguments Manager --------- gdcm::File *e1 = new gdcm::File(); e1->SetLoadMode(loadMode); @@ -96,22 +98,37 @@ int main(int argc, char *argv[]) if ( !res ) { delete e1; - delete am; return 0; } + if (!e1->IsReadable()) { std::cerr << "Sorry, not a Readable DICOM / ACR File" <GetImageDataSize(); + imageData = f1->GetImageData(); // somewhat important... can't remember + f1->SetWriteModeToRGB(); + } + else + { + dataSize = f1->GetImageDataRawSize(); + imageData = f1->GetImageDataRaw();// somewhat important... can't remember + f1->SetWriteModeToRaw(); + } -// --- - - dataSize = f1->GetImageDataSize(); + if ( imageData == 0 ) // to avoid warning + { + std::cout << "Was unable to read pixels " << std::endl; + } std::cout <GetTransferSyntaxName(); std::cout << " TransferSyntaxName= [" << transferSyntaxName << "]" << std::endl; - - imageData= f1->GetImageData(); switch (mode[0]) { case 'A' : + case 'a' : // Writting an ACR file // from a full gdcm readable File @@ -149,7 +165,7 @@ int main(int argc, char *argv[]) break; case 'D' : // Not documented in the 'usage', because the method is known to be bugged. - + case 'd' : // Writting a DICOM Implicit VR file // from a full gdcm readable File @@ -158,6 +174,7 @@ int main(int argc, char *argv[]) break; case 'X' : + case 'x' : // writting a DICOM Explicit VR // from a full gdcm readable File @@ -166,6 +183,7 @@ int main(int argc, char *argv[]) break; case 'R' : + case 'r' : // Writting a Raw File, std::cout << "WriteRaw" << std::endl; @@ -175,7 +193,6 @@ int main(int argc, char *argv[]) } delete e1; delete f1; - delete am; return 0; }