private static XamlShapes.Shape CreateSymbolFromBitmap(int bmpId, double opacity, BrushCache brushCache = null)
{
XamlMedia.ImageBrush imageBrush;
if (brushCache == null)
{
var data = BitmapRegistry.Instance.Get(bmpId);
var bitmapImage = data.CreateBitmapImage();
imageBrush = new XamlMedia.ImageBrush {ImageSource = bitmapImage};
}
else
{
imageBrush = brushCache.GetImageBrush(bmpId);
}
// note: It probably makes more sense to use PixelWith here:
var width = imageBrush.ImageSource.Width;
var height = imageBrush.ImageSource.Height;
var path = new XamlShapes.Path
{
Data = new XamlMedia.RectangleGeometry
{
Rect = new Rect(-width*0.5, -height*0.5, width, height)
},
Fill = imageBrush,
Opacity = opacity
};
return path;
}