/// <summary>
        /// Called when the source stream is available.
        /// </summary>
        /// <param name="stream"></param>
        protected override void OnStreamAvailable(Stream stream)
        {
            try {
                EmfConverter converter = new EmfConverter();
                converter.TreatWarningAsError = false;

                string xaml = converter.ToXaml(stream);
#if SILVERLIGHT
                this.result = (FrameworkElement)XamlReader.Load(xaml);
#else
                MemoryStream ss = new MemoryStream();
                StreamWriter writer = new StreamWriter(ss);
                writer.Write(xaml);
                writer.Flush();
                ss.Position = 0;
               
                this.result = (FrameworkElement)XamlReader.Load(ss);
                
                writer.Close();
                ss.Close();
#endif

                if (this.owner != null) {
                    this.owner.SetResult(this.result);
                }
            }
            catch (Exception e) {
                OnImageFailed(e);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="Pen"/> class.
 /// </summary>
 /// <param name="parameters">The parameters.</param>
 public Pen(byte[] parameters)
 {
     this.Style = EmfConverter.ReadInt16(parameters, 0);
     this.Width = EmfConverter.ReadInt16(parameters, 2);
     this.Color = EmfConverter.ReadColor(parameters, 4);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Brush"/> class.
 /// </summary>
 /// <param name="parameters">The parameters.</param>
 public Brush(byte[] parameters)
 {
     this.Style = EmfConverter.ReadInt16(parameters, 0);
     this.Color = EmfConverter.ReadColor(parameters, 2);
     this.Hatch = EmfConverter.ReadInt16(parameters, 6);
 }