Beispiel #1
0
 public void Given_An_Ip_Then_Return_An_Other_Ip()
 {
     Assert.AreNotEqual("10.0.0.1", Anonymizer.ReplaceIps("10.0.0.1"));
     Assert.AreNotEqual("10.0.0.10", Anonymizer.ReplaceIps("10.0.0.10"));
     Assert.AreNotEqual("192.168.0.1", Anonymizer.ReplaceIps("192.168.0.1"));
     Assert.AreNotEqual("192.168.20.1", Anonymizer.ReplaceIps("192.168.20.1"));
 }
Beispiel #2
0
 internal ImageManager(string userImagePath)
 {
     Logger.Debug($"Helios will load user images from {Anonymizer.Anonymize(userImagePath)}");
     _documentImagePath = userImagePath;
     _documentImageUri  = new Uri(userImagePath);
     _xamlFirewall      = new XamlFirewall();
 }
Beispiel #3
0
        private static ImageSource LoadXamlResource(Uri imageUri, int?width, int?height)
        {
            Logger.Debug("XAML being loaded as vector drawing from trusted resource {URI}", Anonymizer.Anonymize(imageUri));
            StreamResourceInfo streamResourceInfo = Application.GetResourceStream(imageUri);

            if (streamResourceInfo == null)
            {
                // these are supposed to be in our assembly, so log as error
                Logger.Error("could not resolve XAML image at {URI}", Anonymizer.Anonymize(imageUri));
                return(null);
            }
            Stream xamlStream = streamResourceInfo.Stream;

            if (xamlStream == null)
            {
                // these are supposed to be in our assembly, so log as error
                Logger.Error("XAML image not found at {URI}", Anonymizer.Anonymize(imageUri));
                return(null);
            }
            using (xamlStream)
            {
                Canvas canvas = (Canvas)XamlReader.Load(xamlStream);
                return(RenderXaml(canvas, width, height));
            }
        }
Beispiel #4
0
        private void toolStripButtonDeleteTag_Click(object sender, EventArgs e)
        {
            AnonymizeScript selectedScript = listViewAnonymizeScripts.GetSelectedScript();

            if (selectedScript == null)
            {
                return;
            }

            Anonymizer currentAnonymizer = selectedScript.Anonymizer;

            if (currentAnonymizer == null)
            {
                return;
            }

            List <DicomTagNode> nodes = (from n in treeGridViewTags.Rows.Cast <DataGridViewRow>()
                                         where n.Selected
                                         select n as DicomTagNode).ToList();

            foreach (DicomTagNode node in nodes)
            {
                // treeGridViewTags.Nodes.Remove(node);
                treeGridViewTags.Rows.Remove(node);
                currentAnonymizer.DeleteMacro(node.DicomTag.Code);
            }

            if (nodes.Count > 0)
            {
                SetDirty();
            }
        }
Beispiel #5
0
 public void Given_An_Text_With_An_Url_Then_Replace_Only_The_Url()
 {
     Assert.AreNotEqual("This is a url http://ky-programming.de/ test", Anonymizer.ReplaceUrls("This is a url http://ky-programming.de/ test"));
     Assert.AreNotEqual("This is a url https://ky-programming.de/ test", Anonymizer.ReplaceUrls("This is a url https://ky-programming.de/ test"));
     Assert.AreNotEqual("This is a url https://sub.ky-programming.de test", Anonymizer.ReplaceUrls("This is a url https://sub.ky-programming.de test"));
     Assert.AreNotEqual("This is a url https://ky-programming.de:80/sub test", Anonymizer.ReplaceUrls("This is a url https://ky-programming.de:80/sub test"));
 }
Beispiel #6
0
 public void SetAnonymizer(PropertyInfo property, Anonymizer anonymizer)
 {
     lock (_propertyAnonymizer)
     {
         _propertyAnonymizer[property] = anonymizer;
     }
 }
Beispiel #7
0
        private DicomTagNode AddAnonymizationTag(AnonymizeScript selectedScript, long tag, string name, string macro)
        {
            DicomTag     dicomTag = DicomTagTable.Instance.Find(tag);
            DicomTagNode node     = new DicomTagNode();

            node.CreateCells(treeGridViewTags);
            node.SetValues(string.Format("({0:X4},{1:X4})", tag.GetGroup(), tag.GetElement()), name, macro);
            treeGridViewTags.Rows.Add(node);

            // treeGridViewTags.Rows.Add(node);
            node.DicomTag = dicomTag;
            // node.Image = Resources.Tag_16x16;

            //if (dicomTag != null && dicomTag.VR == DicomVRType.SQ)
            //   node.Image = Resources.Tags_16x16;
            Anonymizer selectedAnonymizer = null;

            if (selectedScript != null)
            {
                selectedAnonymizer = selectedScript.Anonymizer;
            }
            if (selectedAnonymizer != null)
            {
                selectedAnonymizer[tag] = macro;
                node.Tag = selectedAnonymizer.FindTag(tag);
                return(node);
            }
            return(null);
        }
Beispiel #8
0
        /// <summary>
        /// Converts the specified values.
        /// </summary>
        /// <param name="values">The values.</param>
        /// <param name="targetType">Type of the target.</param>
        /// <param name="parameter">The parameter.</param>
        /// <param name="culture">The culture.</param>
        /// <returns>The anonymized text.</returns>
        public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values == null || values.Length != 2)
            {
                return(null);
            }

            string text      = values[0] as string;
            var    anonymize = values[1] is Anonymize ? (Anonymize)values[1] : Anonymize.DoNotAnonymize;

            if (text == null)
            {
                text = ObjectToStringConverter.ToDisplayString(values[0]);
            }

            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            if (anonymize == Anonymize.DoNotAnonymize)
            {
                return(text);
            }

            return(Anonymizer.WordsToX(text));
        }
Beispiel #9
0
 static ExportExtensions()
 {
     _Codecs     = new RasterCodecs();
     _Anonymizer = new Anonymizer();
     _Anonymizer.ApplicationDescription  = "HTML5 Medical Viewer";
     _Anonymizer.BeforeTagAnonymization += new EventHandler <BeforeTagAnonymizationEventArgs>(_Anonymizer_BeforeTagAnonymization);
 }
Beispiel #10
0
        public void ShouldAnonymizePNGFile()
        {
            string filePathToRead  = @"../../../Data/Plan.png";
            string filePathToWrite = @"../../../Data/PlanAnonymized.png";

            Anonymizer.Anonymize(filePathToRead, filePathToWrite);
        }
        public void ShowCaseTest()
        {
            Assert.IsTrue(em.IsValid());
            BO4E.StaticLogger.Logger = new Microsoft.Extensions.Logging.Debug.DebugLogger("Testlogger", (log, level) => { return(true); });
            // Image there is a service provider to analyse the verbrauchs data but he shouldn't know about the location data.
            // Yet it should still be possible to map the results back to my original data. So hashing seems like a good approach.
            var config = new AnonymizerConfiguration();

            config.SetOption(BO4E.meta.DataCategory.POD, AnonymizerApproach.HASH);
            byte[] salt = new Byte[100];
            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();

            rng.GetBytes(salt);
            config.hashingSalt = Convert.ToBase64String(salt); // Some random but not necessarily secret salt;
            Energiemenge anonymizedEm;

            using (Anonymizer anon = new Anonymizer(config))
            {
                anonymizedEm = anon.ApplyOperations <Energiemenge>(em);
            }
            Debug.WriteLine($"No one knowing only {anonymizedEm.LokationsId} actually means {em.LokationsId}");
            Assert.AreNotEqual(em.LokationsId, anonymizedEm.LokationsId);
            Debug.WriteLine($"But it won't cause any problems in satellite systems because the data is still there (!=null) and the business object is still valid.");
            Assert.IsNotNull(anonymizedEm.LokationsId);
            Assert.IsTrue(anonymizedEm.IsValid());
        }
Beispiel #12
0
        public Anonymizable(string propertyDisplayName, Type[] availableAnonymizerTypes, int defaultAnonymizerIndex)
        {
            if (defaultAnonymizerIndex < -1 || defaultAnonymizerIndex >= availableAnonymizerTypes.Length)
            {
                throw new SensusException("Attempted to set default anonymizer for property \"" + propertyDisplayName + "\" outside the bounds of available types:  " + defaultAnonymizerIndex + ".");
            }

            _propertyDisplayName = propertyDisplayName;

            // instantiate available anonymizers
            _availableAnonymizers = new List <Anonymizer>();
            foreach (Type availableAnonymizerType in availableAnonymizerTypes)
            {
                Anonymizer availableAnonymizer = Activator.CreateInstance(availableAnonymizerType) as Anonymizer;

                if (availableAnonymizer == null)
                {
                    throw new SensusException("Attempted to create an anonymizer from a type that does not derive from Anonymizer.");
                }

                _availableAnonymizers.Add(availableAnonymizer);
            }

            // set default anonymizer if requested
            if (defaultAnonymizerIndex >= 0)
            {
                _defaultAnonymizer = _availableAnonymizers[defaultAnonymizerIndex];
            }
        }
        static void Main(string[] args)
        {
            // Create ByteScout.DocumentAnonymizer.Anonymizer object instance.
            Anonymizer anonymizer = new Anonymizer();

            // Load document.
            anonymizer.LoadDocument(@".\invoice.pdf");

            // Setup anonymization:
            anonymizer.AnonymizeCompanyNames = true;
            anonymizer.AnonymizePhoneNumbers = true;
            anonymizer.AnonymizePersons      = true;
            anonymizer.AnonymizePersonalIDs  = true;
            anonymizer.AnonymizeAddresses    = true;
            anonymizer.AnonymizeEmails       = true;

            // Set anonymization type.
            anonymizer.AnonymizationType = AnonymizationType.Randomizing; // or AnonymizationType.DummyValues

            // Perform anonymization.
            anonymizer.Anonymize();

            // Save anonymized document.
            anonymizer.SaveDocument(@".\result.pdf");

            // Cleanup.
            anonymizer.Dispose();
        }
        public LogDeviceDetails(LogSeverity severity, string logMessage, string additionalInfo = "")
        {
            Severity    = severity;
            Description = Anonymizer.RedactText(logMessage);

            DateTime reportedUtcDateTime = SystemTime.Now().ToUniversalTime();
            DateTime lastNTPDateTime     = LocalPreferencesHelper.LastNTPUtcDateTime;

            ReportedTime = reportedUtcDateTime == null ||
                           (lastNTPDateTime - reportedUtcDateTime).Duration().Days >= 365 * 2
                ? LocalPreferencesHelper.LastNTPUtcDateTime
                : reportedUtcDateTime;

            ApiVersion = Conf.APIVersion;

            string addInfoPostfix = ServiceLocator.Current.GetInstance <IApiDataHelper>().GetBackGroundServicVersionLogString();

            AdditionalInfo = Anonymizer.RedactText(additionalInfo) + addInfoPostfix;

#if UNIT_TEST
            BuildNumber     = "23";
            BuildVersion    = "1.1";
            DeviceOSVersion = "13.4";
#else
            BuildNumber     = AppInfo.BuildString;
            BuildVersion    = AppInfo.VersionString;
            DeviceOSVersion = DeviceInfo.VersionString;
#endif
        }
Beispiel #15
0
 private void AnonymizeButton_Click(object sender, EventArgs e)
 {
     if (SaveFileDialog.ShowDialog() == DialogResult.OK)
     {
         Anonymizer.Anonymize(FilepathTextBox.Text, SaveFileDialog.FileName);
     }
 }
Beispiel #16
0
        private void InitializeMacroCombo(AnonymizeScript selectedScript)
        {
            DataGridViewComboBoxColumn column = (DataGridViewComboBoxColumn)treeGridViewTags.Columns[TAGS_VALUE_COLUMN];

            column.Items.Clear();
            if (selectedScript == null)
            {
                return;
            }

            column.DisplayStyle = DataGridViewComboBoxDisplayStyle.DropDownButton;
            Anonymizer selectedAnonymizer = selectedScript.Anonymizer;

            if (selectedAnonymizer != null)
            {
                foreach (string key in selectedAnonymizer.MacroProcessor.Macros.Keys)
                {
                    column.Items.Add(string.Format("${{{0}}}", key));
                }

                column.Items.Add("${random_string(5)}");
                column.Items.Add("${add_days(7)}");
                column.Items.Add("${add_days(5)}");
                column.Items.Add("${random_time(05:00:00)}");
                column.Items.Add("${replace}");
            }
        }
Beispiel #17
0
        public void TestCaginMeLos()
        {
            BO4E.StaticLogger.Logger = new Microsoft.Extensions.Logging.Debug.DebugLogger("Testlogger", (log, level) => { return(true); });
            var result = new Dictionary <string, string>()
            {
                { "DE0004096816110000000000000022591", null },
                { "DE0004946353300000000000001652988", null },
                { "DE00746663128OF000000000000010156", null },
                { "DE0004946307100000000000001312595", null },
            };
            var conf = new AnonymizerConfiguration();

            conf.SetOption(DataCategory.POD, AnonymizerApproach.HASH);

            using (Anonymizer anonymizer = new Anonymizer(conf))
            {
                foreach (var plaintextMeLoId in result.Keys.ToList())
                {
                    Messlokation melo = new Messlokation()
                    {
                        MesslokationsId = plaintextMeLoId
                    };
                    var hashedMelo = anonymizer.ApplyOperations <Messlokation>(melo);
                    result[plaintextMeLoId] = hashedMelo.MesslokationsId;
                }
            }
            var resultJson = JsonConvert.SerializeObject(result);
        }
Beispiel #18
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }

            try
            {
                _TagItems        = new Dictionary <long, int>();
                Messager.Caption = "C# DICOM Anonymizer Demo";
                Text             = Messager.Caption + " - Untitled";
                _Anonymizer      = new Anonymizer(true);
                _Anonymizer.ApplicationDescription = Messager.Caption;
                _Anonymizer.Progress += new EventHandler <ProgressEventArgs>(_Anonymizer_Progress);
                RegisterEvents();
                SizeColumns();
                InitializeMacroCombo();
                LoadMacros(_Anonymizer.TagMacros);
                _Modified = false;
                new RowNumberDataGridViewDecorator(treeGridViewTags);
                new SelectionDecorator(treeGridViewDifference);
                //new DifferenceDecorator(treeGridViewDifference);
                toolStripProgressBar.Size = new Size(Width / 4, toolStripProgressBar.Size.Height);
            }
            catch { }
            Application.Idle += new EventHandler(Application_Idle);
            _ActiveDataSet    = new DicomDataSet();
            LoadDefault();
        }
Beispiel #19
0
 public AnonymizeScript(string friendlyName, AnonymizeScript previousScript)
 {
     Anonymizer   = new Anonymizer(false);
     FriendlyName = friendlyName;
     foreach (TagMacro tagMacro in previousScript.Anonymizer.TagMacros)
     {
         Anonymizer.TagMacros.Add(tagMacro);
     }
 }
Beispiel #20
0
    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.CryptoFactory fact             = gdcm.CryptoFactory.GetFactoryInstance();
        gdcm.CryptographicMessageSyntax cms = fact.CreateCMSProvider();
        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);
    }
Beispiel #21
0
        public void Should_Not_Shift_Observation_EffectiveDate_Null()
        {
            var pepper = Guid.NewGuid();
            var obs = new ObservationDatasetRecord { Salt = Guid.NewGuid() };
            var anon = new Anonymizer<ObservationDatasetRecord>(pepper);

            anon.Anonymize(obs);

            Assert.Null(obs.EffectiveDate);
        }
Beispiel #22
0
 public LogApiDetails(ApiResponse apiResponse)
 {
     Api          = "/" + apiResponse.Endpoint;
     ApiErrorCode = apiResponse.StatusCode > 0
         ? (int?)apiResponse.StatusCode
         : null;
     ApiErrorMessage = (new int?[] { 200, 201 }).Contains(ApiErrorCode)
         ? null
         : Anonymizer.RedactText(apiResponse.ResponseText);
 }
Beispiel #23
0
        public void Should_Mask_Encounter_PersonId_And_EncounterId()
        {
            var pepper = Guid.NewGuid();
            var enc = new EncounterDatasetRecord { Salt = Guid.NewGuid(), PersonId = "abc123", EncounterId = "def456" };
            var anon = new Anonymizer<EncounterDatasetRecord>(pepper);

            anon.Anonymize(enc);

            Assert.NotEqual("abc123", enc.PersonId);
            Assert.NotEqual("def456", enc.EncounterId);
        }
Beispiel #24
0
        public void Should_Mask_Observation_PersonId_And_EncounterId()
        {
            var pepper = Guid.NewGuid();
            var obs = new ObservationDatasetRecord { Salt = Guid.NewGuid(), PersonId = "abc123", EncounterId = "def456" };
            var anon = new Anonymizer<ObservationDatasetRecord>(pepper);

            anon.Anonymize(obs);

            Assert.NotEqual("abc123", obs.PersonId);
            Assert.NotEqual("def456", obs.EncounterId);
        }
Beispiel #25
0
        public void Should_Not_Shift_Encounter_AdmitDate_And_DischargeDate_Null()
        {
            var pepper = Guid.NewGuid();
            var enc = new EncounterDatasetRecord { Salt = Guid.NewGuid() };
            var anon = new Anonymizer<EncounterDatasetRecord>(pepper);

            anon.Anonymize(enc);

            Assert.Null(enc.AdmitDate);
            Assert.Null(enc.DischargeDate);
        }
Beispiel #26
0
        public void Should_Shift_Observation_EffectiveDate_NotNull()
        {
            var pepper = Guid.NewGuid();
            var obs = new ObservationDatasetRecord { Salt = Guid.NewGuid(), EffectiveDate = new DateTime(2018, 12, 14, 10, 33, 00) };
            var anon = new Anonymizer<ObservationDatasetRecord>(pepper);

            anon.Anonymize(obs);

            Assert.NotNull(obs.EffectiveDate);
            Assert.NotEqual(new DateTime(2018, 12, 14, 10, 33, 00), obs.EffectiveDate);
            Assert.Equal(33, obs.EffectiveDate.Value.Minute);
        }
Beispiel #27
0
        private void EnablePlugin()
        {
            if (anonymizer != null)
            {
                return;
            }

            // Anonymize all active players
            anonymizer = new Anonymizer(BasePlayer.activePlayerList, () => config.RandomNameConfiguration.GenerateRandomName());

            Subscribe("OnUserConnected");
            Subscribe("OnUserDisconnected");
        }
Beispiel #28
0
 Func <EncounterDatasetRecord, Encounter> GetConverter(bool anonymize)
 {
     if (anonymize)
     {
         var anon = new Anonymizer <EncounterDatasetRecord>(Pepper);
         return((rec) =>
         {
             anon.Anonymize(rec);
             return rec.ToEncounter();
         });
     }
     return((rec) => rec.ToEncounter());
 }
Beispiel #29
0
 Func <ConditionDatasetRecord, Condition> GetConverter(bool anonymize)
 {
     if (anonymize)
     {
         var anon = new Anonymizer <ConditionDatasetRecord>(Pepper);
         return((rec) =>
         {
             anon.Anonymize(rec);
             return rec.ToCondition();
         });
     }
     return((rec) => rec.ToCondition());
 }
Beispiel #30
0
 Func <ProcedureDatasetRecord, Procedure> GetConverter(bool anonymize)
 {
     if (anonymize)
     {
         var anon = new Anonymizer <ProcedureDatasetRecord>(Pepper);
         return((rec) =>
         {
             anon.Anonymize(rec);
             return rec.ToProcedure();
         });
     }
     return((rec) => rec.ToProcedure());
 }
  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;
    }
Beispiel #32
0
    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;
    }
Beispiel #33
0
  public static int Main(string[] args)
    {
    string file1 = args[0];
    Mpeg2VideoInfo info = new Mpeg2VideoInfo(file1);
    System.Console.WriteLine( info.StartTime );
    System.Console.WriteLine( info.EndTime );
    System.Console.WriteLine( info.Duration );
    System.Console.WriteLine( info.AspectRatio );
    System.Console.WriteLine( info.FrameRate );
    System.Console.WriteLine( info.PictureWidth );
    System.Console.WriteLine( info.PictureHeight );

    ImageReader r = new ImageReader();
    //Image image = new Image();
    Image image = r.GetImage();
    image.SetNumberOfDimensions( 3 );
    DataElement pixeldata = new DataElement( new gdcm.Tag(0x7fe0,0x0010) );

    System.IO.FileStream infile =
      new System.IO.FileStream(file1, System.IO.FileMode.Open, System.IO.FileAccess.Read);
    uint fsize = gdcm.PosixEmulation.FileSize(file1);

    byte[] jstream  = new byte[fsize];
    infile.Read(jstream, 0 , jstream.Length);

    SmartPtrFrag sq = SequenceOfFragments.New();
    Fragment frag = new Fragment();
    frag.SetByteValue( jstream, new gdcm.VL( (uint)jstream.Length) );
    sq.AddFragment( frag );
    pixeldata.SetValue( sq.__ref__() );

    // insert:
    image.SetDataElement( pixeldata );

    PhotometricInterpretation pi = new PhotometricInterpretation( PhotometricInterpretation.PIType.YBR_PARTIAL_420 );
    image.SetPhotometricInterpretation( pi );
    // FIXME hardcoded:
    PixelFormat pixeltype = new PixelFormat(3,8,8,7);
    image.SetPixelFormat( pixeltype );

    // FIXME hardcoded:
    TransferSyntax ts = new TransferSyntax( TransferSyntax.TSType.MPEG2MainProfile);
    image.SetTransferSyntax( ts );

    image.SetDimension(0, (uint)info.PictureWidth);
    image.SetDimension(1, (uint)info.PictureHeight);
    image.SetDimension(2, 721);

    ImageWriter writer = new ImageWriter();
    gdcm.File file = writer.GetFile();
    file.GetHeader().SetDataSetTransferSyntax( ts );
    Anonymizer anon = new Anonymizer();
    anon.SetFile( file );

    MediaStorage ms = new MediaStorage( MediaStorage.MSType.VideoEndoscopicImageStorage);

    UIDGenerator gen = new UIDGenerator();
    anon.Replace( new Tag(0x0008,0x16), ms.GetString() );
    anon.Replace( new Tag(0x0018,0x40), "25" );
    anon.Replace( new Tag(0x0018,0x1063), "40.000000" );
    anon.Replace( new Tag(0x0028,0x34), "4\\3" );
    anon.Replace( new Tag(0x0028,0x2110), "01" );

    writer.SetImage( image );
    writer.SetFileName( "dummy.dcm" );
    if( !writer.Write() )
      {
      System.Console.WriteLine( "Could not write" );
      return 1;
      }

    return 0;
    }