X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FTestWriteSimple.cxx;h=2e60574c6cec38ae54161575ad270b42be047f8a;hb=e30e614e7f63b52306d85040068e2205a9e6327a;hp=0c03379cdca49e303c9f935e82eb8683490ace17;hpb=1d69b92978803204089d270599133917d944c651;p=gdcm.git diff --git a/Example/TestWriteSimple.cxx b/Example/TestWriteSimple.cxx index 0c03379c..2e60574c 100644 --- a/Example/TestWriteSimple.cxx +++ b/Example/TestWriteSimple.cxx @@ -1,4 +1,22 @@ -#include "gdcm.h" +/*========================================================================= + + Program: gdcm + Module: $RCSfile: TestWriteSimple.cxx,v $ + Language: C++ + Date: $Date: 2005/01/21 11:40:53 $ + Version: $Revision: 1.9 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ +#include "gdcmFile.h" +#include "gdcmFileHelper.h" int main(int argc, char* argv[]) { @@ -6,31 +24,30 @@ int main(int argc, char* argv[]) if (argc < 3) { std::cerr << "Usage :" << std::endl << argv[0] << - " InputHeader OutputDicom" << std::endl; + " InputFile OutputDicom" << std::endl; return 0; } std::string header = argv[1]; const char *output = argv[2]; - gdcm::Header *f1 = new gdcm::Header( header ); - gdcm::File *f2 = new gdcm::File( f1 ); + gdcm::File *f1 = new gdcm::File( header ); + gdcm::FileHelper *f2 = new gdcm::FileHelper( f1 ); // If the following call is important, then the API sucks. Why is it // required to allocate PixelData when we are not using it !? - void* PixelData = f2->GetImageData(); //EXTREMELY IMPORTANT + uint8_t* PixelData = f2->GetImageData(); //EXTREMELY IMPORTANT //Otherwise ReadPixel == -1 -> the dicom writing fails completely int dataSize = f2->GetImageDataSize(); // unsigned char cast is necessary to be able to delete the buffer // since deleting a void* is not allowed in c++ - uint8_t* imageData = (uint8_t*)f2->GetImageData(); + uint8_t *imageData = (uint8_t *)f2->GetImageData(); - f2->SetImageData( imageData, dataSize); + f2->SetImageData( imageData, dataSize ); f2->WriteDcmExplVR( output ); - delete[] imageData; delete f1; delete f2; //delete PixelData; //Does GetImageData return the same pointer ?