5 int main(int argc, char* argv[])
10 gdcm::Header* e1, *e2;
13 void* imageData, *imageData2;
14 int dataSize, dataSize2;
18 std::cerr << "Usage " << argv[0] << " image.dcm" << std::endl;
24 // --------------------- we read the input image
26 std::cout << argv[1] << std::endl;
28 e1 = new gdcm::Header( toto );
29 if (!e1->IsReadable()) {
30 std::cerr << "Sorry, " << toto <<" not a Readable DICOM / ACR File"
35 f1 = new gdcm::File(e1);
36 imageData= f1->GetImageData();
37 dataSize = f1->GetImageDataSize();
39 // --------------------- we write it as an Explicit VR DICOM file
41 sprintf(zozo, "temp.XDCM" );
42 std::cout << "WriteDCM Explicit VR" << std::endl;
43 f1->WriteDcmExplVR(zozo);
45 // --------------------- we read the written image
47 e2 = new gdcm::Header( zozo );
48 if (!e2->IsReadable()) {
49 std::cerr << "Sorry, " << zozo << " not a Readable DICOM / ACR File"
53 f2 = new gdcm::File(e2);
54 imageData2= f2->GetImageData();
55 dataSize2 = f2->GetImageDataSize();
57 // --------------------- we compare the pixel areas
59 if (dataSize != dataSize2) {
60 std::cout << " ----------------------------------------- "
61 << "Bad shot! Lengthes are different : "
62 << dataSize << " # " << dataSize2
63 << " for file : " << toto << std::endl;
67 if (int res=memcmp(imageData,imageData2,dataSize) !=0) {
68 std::cout << " ----------------------------------------- "
69 << "Bad shot! Pixels are different : "
70 << " for file : " << toto << std::endl;
71 std::cout << "memcmp(imageData,imageData2,dataSize) = " << res << std::endl;
75 //If we reach here everything is fine, return 0 then: