本文整理汇总了C#中Writer.SetFileName方法的典型用法代码示例。如果您正苦于以下问题:C# Writer.SetFileName方法的具体用法?C# Writer.SetFileName怎么用?C# Writer.SetFileName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Writer
的用法示例。
在下文中一共展示了Writer.SetFileName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static int Main(string[] args)
{
gdcm.FileMetaInformation.SetSourceApplicationEntityTitle( "My Reformat App" );
// http://www.oid-info.com/get/1.3.6.1.4.17434
string THERALYS_ORG_ROOT = "1.3.6.1.4.17434";
gdcm.UIDGenerator.SetRoot( THERALYS_ORG_ROOT );
System.Console.WriteLine( "Root dir is now: " + gdcm.UIDGenerator.GetRoot() );
string filename = args[0];
string outfilename = args[1];
Reader reader = new Reader();
reader.SetFileName( filename );
if( !reader.Read() )
{
System.Console.WriteLine( "Could not read: " + filename );
return 1;
}
UIDGenerator uid = new UIDGenerator(); // helper for uid generation
FileDerivation fd = new FileDerivation();
// For the pupose of this execise we will pretend that this image is referencing
// two source image (we need to generate fake UID for that).
string ReferencedSOPClassUID = "1.2.840.10008.5.1.4.1.1.7"; // Secondary Capture
fd.AddReference( ReferencedSOPClassUID, uid.Generate() );
fd.AddReference( ReferencedSOPClassUID, uid.Generate() );
// Again for the purpose of the exercise we will pretend that the image is a
// multiplanar reformat (MPR):
// CID 7202 Source Image Purposes of Reference
// {"DCM",121322,"Source image for image processing operation"},
fd.SetPurposeOfReferenceCodeSequenceCodeValue( 121322 );
// CID 7203 Image Derivation
// { "DCM",113072,"Multiplanar reformatting" },
fd.SetDerivationCodeSequenceCodeValue( 113072 );
fd.SetFile( reader.GetFile() );
// If all Code Value are ok the filter will execute properly
if( !fd.Derive() )
{
return 1;
}
gdcm.FileMetaInformation fmi = reader.GetFile().GetHeader();
// The following three lines make sure to regenerate any value:
fmi.Remove( new gdcm.Tag(0x0002,0x0012) );
fmi.Remove( new gdcm.Tag(0x0002,0x0013) );
fmi.Remove( new gdcm.Tag(0x0002,0x0016) );
Writer writer = new Writer();
writer.SetFileName( outfilename );
writer.SetFile( fd.GetFile() );
if( !writer.Write() )
{
System.Console.WriteLine( "Could not write: " + outfilename );
return 1;
}
return 0;
}
示例2: Main
public static int Main(string[] args)
{
string directory = args[0];
string outfilename = args[1];
Directory d = new Directory();
uint nfiles = d.Load( directory, true );
if(nfiles == 0) return 1;
//System.Console.WriteLine( "Files:\n" + d.toString() );
// Implement fast path ?
// Scanner s = new Scanner();
string descriptor = "My_Descriptor";
FilenamesType filenames = d.GetFilenames();
gdcm.DICOMDIRGenerator gen = new DICOMDIRGenerator();
gen.SetFilenames( filenames );
gen.SetDescriptor( descriptor );
if( !gen.Generate() )
{
return 1;
}
gdcm.FileMetaInformation.SetSourceApplicationEntityTitle( "GenerateDICOMDIR" );
gdcm.Writer writer = new Writer();
writer.SetFile( gen.GetFile() );
writer.SetFileName( outfilename );
if( !writer.Write() )
{
return 1;
}
return 0;
}
示例3: Main
public static int Main(string[] args)
{
gdcm.Global global = gdcm.Global.GetInstance();
if( !global.LoadResourcesFiles() )
{
System.Console.WriteLine( "Could not LoadResourcesFiles" );
return 1;
}
string file1 = args[0];
string file2 = args[1];
Reader reader = new Reader();
reader.SetFileName( file1 );
bool ret = reader.Read();
if( !ret )
{
return 1;
}
string certpath = gdcm.Filename.Join(gdcm.Testing.GetSourceDirectory(), "/Testing/Source/Data/certificate.pem" );
gdcm.CryptographicMessageSyntax cms = new gdcm.CryptographicMessageSyntax();
if( !cms.ParseCertificateFile( certpath ) )
{
return 1;
}
//Anonymizer ano = new Anonymizer();
SmartPtrAno sano = Anonymizer.New();
Anonymizer ano = sano.__ref__();
//SimpleSubjectWatcher watcher = new SimpleSubjectWatcher(ano, "Anonymizer");
MyWatcher watcher = new MyWatcher(ano);
ano.SetFile( reader.GetFile() );
ano.SetCryptographicMessageSyntax( cms );
if( !ano.BasicApplicationLevelConfidentialityProfile() )
{
return 1;
}
Writer writer = new Writer();
writer.SetFileName( file2 );
writer.SetFile( ano.GetFile() );
ret = writer.Write();
if( !ret )
{
return 1;
}
return 0;
}
示例4: Main
public static int Main(string[] args)
{
System.Console.WriteLine("Hello World !");
//gdcm.Reader reader2;
string filename = args[0];
System.Console.WriteLine( "Reading: " + filename );
Reader reader = new Reader();
reader.SetFileName( filename );
bool ret = reader.Read();
if( !ret )
{
//throw new Exception("Could not read: " + filename );
return 1;
}
//std::cout << reader.GetFile()
Tag t = new Tag(0x10,0x10);
System.Console.WriteLine( "out:" + t.toString() );
System.Console.WriteLine( "out:" + reader.GetFile().GetDataSet().toString() );
Anonymizer ano = new Anonymizer();
ano.SetFile( reader.GetFile() );
ano.RemovePrivateTags();
ano.RemoveGroupLength();
ano.Replace( t, "GDCM^Csharp^Test^Hello^World" );
Writer writer = new Writer();
writer.SetFileName( "testcs.dcm" );
writer.SetFile( ano.GetFile() );
ret = writer.Write();
if( !ret )
{
//throw new Exception("Could not read: " + filename );
return 1;
}
return 0;
}
示例5: Main
public static int Main(string[] args)
{
string file1 = args[0];
string file2 = args[1];
Reader reader = new Reader();
reader.SetFileName( file1 );
bool ret = reader.Read();
if( !ret )
{
return 1;
}
Anonymizer ano = new Anonymizer();
ano.SetFile( reader.GetFile() );
ano.RemovePrivateTags();
ano.RemoveGroupLength();
Tag t = new Tag(0x10,0x10);
ano.Replace( t, "GDCM^Csharp^Test^Hello^World" );
UIDGenerator g = new UIDGenerator();
ano.Replace( new Tag(0x0008,0x0018), g.Generate() );
ano.Replace( new Tag(0x0020,0x000d), g.Generate() );
ano.Replace( new Tag(0x0020,0x000e), g.Generate() );
ano.Replace( new Tag(0x0020,0x0052), g.Generate() );
Writer writer = new Writer();
writer.SetFileName( file2 );
writer.SetFile( ano.GetFile() );
ret = writer.Write();
if( !ret )
{
return 1;
}
return 0;
}
示例6: ProcessOneFile
public static bool ProcessOneFile( gdcm.Anonymizer ano , string filename, string outfilename )
{
Reader reader = new Reader();
reader.SetFileName( filename );
bool ret = reader.Read();
if( !ret )
{
return false;
}
// Pass in the file:
ano.SetFile( reader.GetFile() );
// First step, let's protect all Patient information as per
// PS 3.15 / E.1 / Basic Application Level Confidentiality Profile
if( !ano.BasicApplicationLevelConfidentialityProfile() )
{
return false;
}
// Now let's pass in all Clinical Trial fields
// PS 3.3 - 2008 / C.7.1.3 Clinical Trial Subject Module
/*
Clinical Trial Sponsor Name (0012,0010) 1 The name of the clinical trial sponsor. See C.7.1.3.1.1.
Clinical Trial Protocol ID (0012,0020) 1 Identifier for the noted protocol. See C.7.1.3.1.2.
Clinical Trial Protocol Name (0012,0021) 2 The name of the clinical trial protocol. See C.7.1.3.1.3.
Clinical Trial Site ID (0012,0030) 2 The identifier of the site responsible for submitting clinical trial data. See C.7.1.3.1.4.
Clinical Trial Site Name (0012,0031) 2 Name of the site responsible for submitting clinical trial data. See C.7.1.3.1.5
Clinical Trial Subject ID (0012,0040) 1C The assigned identifier for the clinical trial subject. See C.7.1.3.1.6. Shall be present if Clinical Trial Subject Reading ID (0012,0042) is absent. May be present otherwise.
Clinical Trial Subject Reading ID (0012,0042) 1C Identifies the subject for blinded evaluations. Shall be present if Clinical Trial Subject ID (0012,0040) is absent. May be present otherwise. See C.7.1.3.1.7.
*/
ano.Replace( new gdcm.Tag(0x0012,0x0010), "MySponsorName");
ano.Replace( new gdcm.Tag(0x0012,0x0020), "MyProtocolID");
ano.Replace( new gdcm.Tag(0x0012,0x0021), "MyProtocolName");
ano.Replace( new gdcm.Tag(0x0012,0x0030), "MySiteId");
ano.Replace( new gdcm.Tag(0x0012,0x0031), "MySiteName");
ano.Replace( new gdcm.Tag(0x0012,0x0040), "MySponsorId");
ano.Replace( new gdcm.Tag(0x0012,0x0050), "MyTPId");
ano.Replace( new gdcm.Tag(0x0012,0x0051), "MyTPDescription");
// The following two are not required as they are guaranteed to be filled in by the
// Basic Application Level Confidentiality Profile. Only override if you understand what
// you are doing
//ano.Replace( new gdcm.Tag(0x0012,0x0062), "YES");
//ano.Replace( new gdcm.Tag(0x0012,0x0063), "My Super Duper Anonymization Overload");
// We might be generating a subdirectory. Let's make sure the subdir exist:
gdcm.Filename fn = new gdcm.Filename( outfilename );
string subdir = fn.GetPath();
if( !gdcm.PosixEmulation.MakeDirectory( subdir ) )
{
return false;
}
gdcm.FileMetaInformation fmi = ano.GetFile().GetHeader();
// The following three lines make sure to regenerate any value:
fmi.Remove( new gdcm.Tag(0x0002,0x0012) );
fmi.Remove( new gdcm.Tag(0x0002,0x0013) );
fmi.Remove( new gdcm.Tag(0x0002,0x0016) );
Writer writer = new Writer();
writer.SetFileName( outfilename );
writer.SetFile( ano.GetFile() );
ret = writer.Write();
if( !ret )
{
return false;
}
return true;
}