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."); }
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."); }