Private Async Function UpdateImageSource() As Task
sb = btmp.ToSoftwareBitmap()
sbs = New SoftwareBitmapSource()
Await sbs.SetBitmapAsync(sb)
img.Source = sbs
img.Width = btmp.PixelWidth
img.Height = btmp.PixelHeight
End Function
Private Async Function ApplyTransform(t As BaseTransform) As Task
Dim bm = btmp.Transform(t)
btmp.Dispose()
btmp = bm
Await UpdateImageSource()
End Function
Private Async Sub btnCrop_Click(sender As Object, e As RoutedEventArgs)
Dim cropRect As New ImageRect(150, 100, 300, 250)
Await ApplyTransform(New Clipper() With {.ImageRect = cropRect})
End Sub