X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FAnonymize.cxx;h=639856430c963ff5e4a65b2f7358b25f7f40c873;hb=1b20e56c29494e7d1bef31d3ade5de833347c228;hp=16983535180204d0a58e446c8abe02a7f1a360bd;hpb=f3cc252fad08c3e8dbc395f2ca7cabf47bf95302;p=gdcm.git diff --git a/Example/Anonymize.cxx b/Example/Anonymize.cxx index 16983535..63985643 100644 --- a/Example/Anonymize.cxx +++ b/Example/Anonymize.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: Anonymize.cxx,v $ Language: C++ - Date: $Date: 2005/08/30 15:13:05 $ - Version: $Revision: 1.5 $ + Date: $Date: 2005/11/07 09:53:53 $ + 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 @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) gdcm::File *f; - f = new gdcm::File( ); + f = gdcm::File::New( ); f->SetLoadMode( gdcm::LD_ALL ); f->SetFileName( fileName ); int res = f->Load(); @@ -85,7 +85,7 @@ int main(int argc, char *argv[]) { std::cerr << "Sorry, " << fileName <<" not a gdcm-readable " << "DICOM / ACR File" <Delete(); return 0; } std::cout << " ... is readable " << std::endl; @@ -95,9 +95,10 @@ int main(int argc, char *argv[]) // ============================================================ // We need a gdcm::FileHelper, since we want to load the pixels - gdcm::FileHelper *fh = new gdcm::FileHelper(f); + gdcm::FileHelper *fh = gdcm::FileHelper::New(f); - // (unit8_t DOESN'T mean it's mandatory for the image to be a 8 bits one) + // unit8_t DOESN'T mean it's mandatory for the image to be a 8 bits one ! + // Feel free to cast if you know it's not. uint8_t *imageData = fh->GetImageData(); @@ -106,8 +107,8 @@ int main(int argc, char *argv[]) std::cerr << "Sorry, Pixels of" << fileName <<" are not " << " gdcm-readable." << std::endl << "Use exAnonymizeNoLoad" << std::endl; - delete f; - delete fh; + f->Delete(); + fh->Delete(); return 0; } @@ -125,7 +126,7 @@ int main(int argc, char *argv[]) // Telephone f->AddAnonymizeElement(0x0010, 0x2154, "3615" ); - // Aware user will add more fields to anonymize here + // Aware user will add here more fields to anonymize here // The gdcm::File is modified in memory @@ -134,7 +135,12 @@ int main(int argc, char *argv[]) // ============================================================ // Write a new file // ============================================================ - + + // Since we just Anonymized the file, we know no modification + // was performed on the pixels. + // We don't want this image appears as a 'Secondary Captured image' + fh->SetKeepMediaStorageSOPClassUID(true); + fh->WriteDcmExplVR(outputFileName); std::cout <<"End Anonymize" << std::cout; @@ -143,8 +149,8 @@ int main(int argc, char *argv[]) // ============================================================ f->ClearAnonymizeList(); - delete f; - delete fh; + f->Delete(); + fh->Delete(); return 0; }