3 #include "gdcmHeader.h"
4 #include "gdcmDocument.h"
8 int main(int argc, char* argv[])
16 void* imageData, *imageData2;
17 int dataSize, dataSize2;
21 std::cerr << "Usage " << argv[0] << " image.dcm" << std::endl;
27 // --------------------- we read the input image
30 e1 = new gdcmHeader(toto, false, true);
31 if (!e1->IsReadable()) {
32 std::cerr << "Sorry, " << toto <<" not a Readable DICOM / ACR File"
37 f1 = new gdcmFile(e1);
38 imageData= f1->GetImageData();
39 dataSize = f1->GetImageDataSize();
41 // --------------------- we write it as an Explicit VR DICOM file
43 sprintf(zozo, "temp.XDCM" );
44 std::cout << "WriteDCM Explicit VR" << std::endl;
45 f1->WriteDcmExplVR(zozo);
47 // --------------------- we read the written image
49 e2 = new gdcmHeader(zozo, false, true);
50 if (!e2->IsReadable()) {
51 std::cerr << "Sorry, " << zozo << " not a Readable DICOM / ACR File"
55 f2 = new gdcmFile(e2);
56 imageData2= f2->GetImageData();
57 dataSize2 = f2->GetImageDataSize();
59 // --------------------- we compare the pixel areas
61 if (dataSize != dataSize2) {
62 std::cout << " ----------------------------------------- "
63 << "Bad shot! Lengthes are different : "
64 << dataSize << " # " << dataSize2
65 << " for file : " << toto << std::endl;
69 if (int res=memcmp(imageData,imageData2,dataSize) !=0) {
70 std::cout << " ----------------------------------------- "
71 << "Bad shot! Pixels are different : "
72 << " for file : " << toto << std::endl;
73 std::cout << "memcmp(imageData,imageData2,dataSize) = " << res << std::endl;
77 //If we reach here everythin is fine, return 0 then: