public static Size GetImageSourceSize(this WImageSource source) { if (source is null) { return(Size.Zero); } else if (source is BitmapSource bitmap) { return(new Size { Width = bitmap.PixelWidth, Height = bitmap.PixelHeight }); } // WINUI //else if (source is CanvasImageSource canvas) //{ // return new Size // { // Width = canvas.Size.Width, // Height = canvas.Size.Height // }; //} throw new InvalidCastException($"\"{source.GetType().FullName}\" is not supported."); }
public static Graphics.Size GetImageSourceSize(this WImageSource source) { if (source is null) { return(Graphics.Size.Zero); } else if (source is BitmapSource bitmap) { return(new Graphics.Size { Width = bitmap.PixelWidth, Height = bitmap.PixelHeight }); } else if (source is CanvasImageSource canvas) { return(new Graphics.Size { Width = canvas.Size.Width, Height = canvas.Size.Height }); } throw new InvalidCastException($"\"{source.GetType().FullName}\" is not supported."); }
void UpdateThumbStyle() { if (_thumb == null) { return; } WImageSource imageSource = ThumbImageSource; if (imageSource != null) { _thumb.Style = ImageThumbStyle; _thumb.Tag = imageSource; } else { _thumb.Style = _originalThumbStyle; _thumb.Tag = null; } }
void IImageVisualElementRenderer.SetImage(Microsoft.UI.Xaml.Media.ImageSource image) { _image.Source = image; }