microsoft / microsoft-ui-xaml

Windows UI Library: the latest Windows 10 native controls and Fluent styles for your applications
MIT License
6.37k stars 680 forks source link

Support for CroppedBitmap #8452

Open Jdsle opened 1 year ago

Jdsle commented 1 year ago

CroppedBitmap has been missing since WPF, and cropping a bitmapsource, or any bitmap is somewhat complicated, so I think it'd be great to reimplement it into the SDK/WinUI 3

CroppedBitmap(BitmapSource, x, y, width, height);

(wasn't sure if this was more of a WinUI 3 or WASDK thing so I've posted it here)

castorix commented 1 year ago

There is this MS code which works with WinUI 3 (tested on Windows 10 22H2, Windows App SDK 1.1.0) : https://github.com/XamlBrewer/UWP-ImageCropper-/blob/master/XamlBrewer.Uwp.Controls/Helpers/CropBitmap.cs Just replace :

//using Windows.UI.Xaml.Media;
//using Windows.UI.Xaml.Media.Imaging;
using Microsoft.UI.Xaml.Media;
using Microsoft.UI.Xaml.Media.Imaging;