Skip to content

Commit

Permalink
Merge pull request #203 from microsoft/zt/183-image-scaling-freezes
Browse files Browse the repository at this point in the history
#183: Run image scaling in a task to unblock UI
  • Loading branch information
nmetulev authored Feb 13, 2025
2 parents 68d2e74 + 6c80038 commit 9850f89
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion AIDevGallery/Samples/WCRAPIs/IncreaseFidelity.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,15 @@ private async void ScaleImage()
{
ScaledPanel.Visibility = Visibility.Collapsed;
Loader.Visibility = Visibility.Visible;

var newWidth = (int)(_originalImage.PixelWidth * ScaleSlider.Value);
var newHeight = (int)(_originalImage.PixelHeight * ScaleSlider.Value);
var bitmap = _imageScaler.ScaleSoftwareBitmap(_originalImage, newWidth, newHeight);

var bitmap = await Task.Run(() =>
{
return _imageScaler.ScaleSoftwareBitmap(_originalImage, newWidth, newHeight);
});

Loader.Visibility = Visibility.Collapsed;
ScaledPanel.Visibility = Visibility.Visible;
await SetImageSource(ScaledImage, bitmap, ScaledDimensionsTxt);
Expand Down

0 comments on commit 9850f89

Please sign in to comment.