Beispiel #1
0
        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);
            }

            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);
        }
Beispiel #2
0
        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);
            }

#if NETFX_CORE
            var width  = ((BitmapImage)imageBrush.ImageSource).PixelWidth;
            var height = ((BitmapImage)imageBrush.ImageSource).PixelHeight;
#else
// note: It probably makes more sense to use PixelWith here:
            var width  = imageBrush.ImageSource.Width;
            var height = imageBrush.ImageSource.Height;
#endif

            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);
        }
Beispiel #3
0
 private static ImageBrush CreateImageBrush(Styles.Brush brush, BrushCache brushCache = null)
 {
     return(brushCache != null?brushCache.GetImageBrush(brush.BitmapId, CreateImageBrush) : CreateImageBrush(BitmapRegistry.Instance.Get(brush.BitmapId)));
 }