public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                EmbeddedBitmapData bitmapInfo   = (EmbeddedBitmapData)value;
                MemoryStream       memoryStream = bitmapInfo.Stream;

                return(Convert.ToBase64String(memoryStream.ToArray()));
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
 /// <summary>
 /// In the designer Data is not set. To prevent exceptions when displaying in the Designer, add a dummy bitmap.
 /// </summary>
 private void EnsureStream()
 {
     if (_stream == null)
     {
         BitmapSource dummyBitmap = BitmapSource.Create(1, 1, 96.0, 96.0,
                                                        PixelFormats.Pbgra32, null, new byte[] { 0, 0, 0, 0 }, 4);
         PngBitmapEncoder encoder = new PngBitmapEncoder();
         encoder.Frames.Add(BitmapFrame.Create(dummyBitmap));
         MemoryStream stream = new MemoryStream();
         encoder.Save(stream);
         Data = new EmbeddedBitmapData(stream);
     }
 }