- if( gdcm::Debug::GetDebugFlag() )
- std::cout << "About to built empty file" << std::endl;
-
- gdcm::File *fileToBuild = gdcm::File::New();
-
- if( gdcm::Debug::GetDebugFlag() )
- std::cout << "Finish to built empty file" << std::endl;
-
- std::ostringstream str;
- str.str("");
- str << nx;
- fileToBuild->InsertEntryString(str.str(),0x0028,0x0011); // Columns
- str.str("");
- str << ny;
- fileToBuild->InsertEntryString(str.str(),0x0028,0x0010); // Rows
-
- fileToBuild->InsertEntryString("8",0x0028,0x0100); // Bits Allocated
- fileToBuild->InsertEntryString("8",0x0028,0x0101); // Bits Stored
- fileToBuild->InsertEntryString("7",0x0028,0x0102); // High Bit
- fileToBuild->InsertEntryString("0",0x0028,0x0103); // Pixel Representation
- fileToBuild->InsertEntryString("1",0x0028,0x0002); // Samples per Pixel
-
- fileToBuild->InsertEntryString("MONOCHROME2 ",0x0028,0x0004);
- // Other mandatory fields will be set automatically,
- // just before Write(), by FileHelper::CheckMandatoryElements()
-
- if( gdcm::Debug::GetDebugFlag() )
- std::cout << "-------------About to built FileHelper" << std::endl;
-
- gdcm::FileHelper *fh = gdcm::FileHelper::New(fileToBuild);
-
- if( gdcm::Debug::GetDebugFlag() )
- std::cout << "-------------Finish to built FileHelper" << std::endl;
-
- fh->SetImageData(overlayPixelImage,nx*ny);
- fh->SetWriteTypeToDcmExplVR();
-
- str.str("");
- str<<"gdcmOverlay" << ".dcm";
- // Write the current 'overlay' file
-
- if( !fh->Write(str.str()) )
- {
- std::cout << "Failed\n"
- << "File in unwrittable\n";
- fh->Delete();
- if (fileToBuild)
- fileToBuild->Delete();
- delete overlayPixelImage;
-
- return 0;
- }
- else
- {
- std::cout << "File written successfully" << std::endl;
- }
-
- if (f)
- fh->Delete();
- if (fileToBuild)
- fileToBuild->Delete();
- f->Delete();
- delete overlayPixelImage;
-