1 /*=========================================================================
4 Module: $RCSfile: TestMakeIcon.cxx,v $
6 Date: $Date: 2005/02/11 12:14:26 $
7 Version: $Revision: 1.1 $
9 Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10 l'Image). All rights reserved. See Doc/License.txt or
11 http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
13 This software is distributed WITHOUT ANY WARRANTY; without even
14 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 PURPOSE. See the above copyright notices for more information.
17 =========================================================================*/
18 #include "gdcmDebug.h"
19 #include "gdcmGlobal.h"
20 #include "gdcmCommon.h"
22 #include "gdcmFileHelper.h"
23 #include "gdcmSeqEntry.h"
24 #include "gdcmSQItem.h"
25 #include "gdcmValEntry.h"
27 // 0088 0200 SQ 1 Icon Image Sequence
29 int TestMakeIcon (int , char )
32 //ard coded small image name
33 std::string input = "LIBIDO-8-ACR_NEMA-Lena_128_128.acr";
34 std::string output = "test.dcm";
43 std::cout << " Usage: " << argv[0]
44 << " input filename.dcm output Filename.dcm" << std::endl;
49 gdcm::File *f1 = new gdcm::File(input);
53 std::cout << " failed to open file" << std::endl;
56 gdcm::FileHelper *fh1 = new gdcm::FileHelper(f1);
57 uint8_t *pixels = fh1->GetImageData();
58 uint32_t lgth = fh1->GetImageDataSize();
60 gdcm::SeqEntry *icon = f1->InsertSeqEntry(0x0088, 0x0200);
61 gdcm::SQItem *sqi = new gdcm::SQItem(1);
62 icon->AddSQItem(sqi, 1);
64 // icone is just define like the image
65 // The purpose is NOT to imagine an icon,
66 // just check the stuff works
68 sqi->InsertValEntry( "MONOCHROME2", 0x0028,0x0004);
69 sqi->InsertValEntry( "128", 0x0028,0x0010);
70 sqi->InsertValEntry( "8", 0x0028,0x0100);
71 sqi->InsertValEntry( "8", 0x0028,0x0101);
72 sqi->InsertValEntry( "7", 0x0028,0x0102);
73 sqi->InsertValEntry( "0", 0x0028,0x0103);
74 sqi->InsertBinEntry( pixels, lgth, 0x7fe0,0x0010);
75 // just to see if it's stored a the right place
76 sqi->InsertValEntry( "128", 0x0028,0x0011);
78 fh1->WriteDcmExplVR(output);
82 f1 = new gdcm::File(output);
85 icon = f1->GetSeqEntry(0x0088, 0x0200);
86 sqi = icon->GetFirstSQItem();
88 if ( (sqi->GetValEntry(0x0028,0x0010))->GetValue() != "128" )
91 if ( (sqi->GetValEntry(0x0028,0x0011))->GetValue() != "128" )
94 if ( (sqi->GetValEntry(0x0028,0x0100))->GetValue() != "8" )
97 if ( (sqi->GetValEntry(0x0028,0x0101))->GetValue() != "8" )
100 if ( (sqi->GetValEntry(0x0028,0x0102))->GetValue() != "7" )
103 if ( (sqi->GetValEntry(0x0028,0x0103))->GetValue() != "0" )