Here is a solution from a similar question that I answered last month:
Private Sub SaveJpgImage(source As BitmapImage, photoLocation As String)
SaveImage(source, photoLocation, New JpegBitmapEncoder())
End Sub
Private Sub SavePngImage(source As BitmapImage, photoLocation As String)
SaveImage(source, photoLocation, New PngBitmapEncoder())
End Sub
Private Sub SaveImage(source As BitmapImage, photoLocation As String, encoder As BitmapEncoder)
encoder.Frames.Add(BitmapFrame.Create(source))
Using filestream = New FileStream(photoLocation, FileMode.Create)
encoder.Save(filestream)
End Using
End Sub
And to use:
SaveJpgImage(myImage, ".\cropped.jpg")
Where
myImage
is of type
BitmapImage
.