private static XamlShapes.Shape CreateSymbolFromSvg(int bitmapId, double opacity, SymbolCache symbolCache) { var image = ((XamlMedia.DrawingImage)symbolCache.GetOrCreate(bitmapId)); //.ToImageBrush(); double width = 0; double height = 0; if (image != null) { // note: It probably makes more sense to use PixelWidth here: width = image.Width; height = image.Height; } var path = new XamlShapes.Path { Data = new XamlMedia.RectangleGeometry { Rect = new Rect(-width * 0.5, -height * 0.5, width, height) }, Fill = new XamlMedia.DrawingBrush { Drawing = image.Drawing }, Opacity = opacity, Width = width, Height = height, }; return(path); }
private static XamlShapes.Shape CreateSymbolFromBitmap(int bitmapId, double opacity, SymbolCache symbolCache) { var imageBrush = symbolCache.GetOrCreate(bitmapId).ToImageBrush(); // note: It probably makes more sense to use PixelWidth 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); }
private static BitmapImage GetOrCreateBitmapImage(Styles.Brush brush, SymbolCache symbolCache = null) { return(symbolCache != null ? (BitmapImage)symbolCache.GetOrCreate(brush.BitmapId): ((System.IO.Stream)BitmapRegistry.Instance.Get(brush.BitmapId)).ToBitmapImage()); }
private static BitmapImage GetOrCreateBitmapImage(Styles.Brush brush, SymbolCache symbolCache = null) { return(symbolCache != null? symbolCache.GetOrCreate(brush.BitmapId) : BitmapRegistry.Instance.Get(brush.BitmapId).ToBitmapImage()); }