X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FexImageLighten.cxx;h=ba11866493649c960068416adc12ab50fc48e8db;hb=d37154e4495e1e1c18c44f6cae6ef2ff8a2891cf;hp=5797d82d242e50f53bb27102ace339179ee423d4;hpb=dfa6db1c22f6b67eceb10c1ef94a91a643e36dd2;p=gdcm.git diff --git a/Example/exImageLighten.cxx b/Example/exImageLighten.cxx index 5797d82d..ba118664 100644 --- a/Example/exImageLighten.cxx +++ b/Example/exImageLighten.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exImageLighten.cxx,v $ Language: C++ - Date: $Date: 2005/07/06 15:49:31 $ - Version: $Revision: 1.2 $ + Date: $Date: 2007/05/23 14:18:05 $ + Version: $Revision: 1.10 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -19,16 +19,13 @@ #include "gdcmFile.h" #include "gdcmFileHelper.h" #include "gdcmDocument.h" -#include "gdcmValEntry.h" -#include "gdcmBinEntry.h" +#include "gdcmDataEntry.h" #include "gdcmSeqEntry.h" #include // for exit int main(int argc, char *argv[]) -{ - gdcm::File *f1; - +{ std::cout << "-----------------------------------------------" << std::endl; std::cout << "Removes from a full gdcm-readable Dicom image" << std::endl; std::cout << " all the 'Shadow groups' and the 'Sequence' entries" @@ -58,11 +55,16 @@ int main(int argc, char *argv[]) std::cout << argv[1] << std::endl; - f1 = new gdcm::File( fileName ); - if (!f1->IsReadable()) { + GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New(); + f->SetLoadMode( GDCM_NAME_SPACE::LD_ALL); + f->SetFileName( fileName ); + bool res = f->Load(); + + if (!res) { std::cerr << "Sorry, " << fileName <<" not a gdcm-readable " << "DICOM / ACR File" <Delete(); return 0; } std::cout << " ... is readable " << std::endl; @@ -75,53 +77,47 @@ int main(int argc, char *argv[]) // Pixel Reading must be done here, to be sure // to load the Palettes Color (if any) - // First, create a gdcm::FileHelper - gdcm::FileHelper *fh1 = new gdcm::FileHelper(f1); + // First, create a GDCM_NAME_SPACE::FileHelper + GDCM_NAME_SPACE::FileHelper *fh = GDCM_NAME_SPACE::FileHelper::New(f); // Load the pixels, DO NOT transform LUT (if any) into RGB Pixels - uint8_t *imageDataRaw = fh1->GetImageDataRaw(); + uint8_t *imageDataRaw = fh->GetImageDataRaw(); // Get the image data size - size_t dataRawSize = fh1->GetImageDataRawSize(); + size_t dataRawSize = fh->GetImageDataRawSize(); // ============================================================ -// Create a new gdcm::Filehelper, to hold new image. +// Create a new GDCM_NAME_SPACE::Filehelper, to hold new image. // ============================================================ - gdcm::FileHelper *copy = new gdcm::FileHelper( output ); + GDCM_NAME_SPACE::FileHelper *copy = GDCM_NAME_SPACE::FileHelper::New( ); + copy->SetFileName( output ); + copy->Load(); // ============================================================ // Selective copy of the entries (including Pixel Element). // ============================================================ - gdcm::DocEntry *d = f1->GetFirstEntry(); - - d = f1->GetFirstEntry(); + GDCM_NAME_SPACE::DocEntry *d = f->GetFirstEntry(); while(d) { // We skip SeqEntries, since user cannot do much with them - if ( !(dynamic_cast(d)) + if ( !(dynamic_cast(d)) // We skip Shadow Groups, since nobody knows what they mean && !( d->GetGroup()%2 ) ) { - if ( gdcm::BinEntry *b = dynamic_cast(d) ) + if ( GDCM_NAME_SPACE::DataEntry *de = dynamic_cast(d) ) { - copy->GetFile()->InsertBinEntry( b->GetBinArea(),b->GetLength(), - b->GetGroup(),b->GetElement(), - b->GetVR() ); - } - else if ( gdcm::ValEntry *v = dynamic_cast(d) ) - { - copy->GetFile()->InsertValEntry( v->GetValue(), - v->GetGroup(),v->GetElement(), - v->GetVR() ); + copy->GetFile()->InsertEntryBinArea( de->GetBinArea(),de->GetLength(), + de->GetGroup(),de->GetElement(), + de->GetVR() ); } else { - // We skip gdcm::SeqEntries + // We skip GDCM_NAME_SPACE::SeqEntries } } - d = f1->GetNextEntry(); + d = f->GetNextEntry(); } // User wants to keep the Palette Color -if any- @@ -133,9 +129,10 @@ int main(int argc, char *argv[]) std::cout << std::endl << "------------------------------------------------------------" << std::endl; - delete f1; - delete fh1; - delete copy; + + f->Delete(); + fh->Delete(); + copy->Delete(); exit (0); }