public static BitmapFrame ToBitmapFrame(this DefineBitsLosslessTag tag)
{
if (tag == null) return null;
BitmapFrame frame;
try
{
using (var stream = new MemoryStream())
{
tag.GetBitmap().Save(stream, ImageFormat.Png);
frame = BitmapFrame.Create(stream,
BitmapCreateOptions.IgnoreColorProfile, BitmapCacheOption.OnLoad);
}
}
catch (NotSupportedException)
{
return null;
}
return frame;
}