Reputation:
This is the continuation of
so now I have a BitmapImage coming from a stream. In short a BitmapImage I want to resize it to a desired size.
I have found tons of code on how to resize from an image on file system but none on how to resize from an already existing BitmapImage
Upvotes: 3
Views: 10767
Reputation: 128136
You may use a TransformedBitmap
with an appropriate ScaleTransform
:
BitmapImage sourceBitmap = ...
var targetBitmap = new TransformedBitmap(sourceBitmap, new ScaleTransform(0.5, 0.5));
The result is a TransformedBitmap, not a BitmapImage. However, this shouldn't matter, because in your application there should be no need to deal only with BitmapImages. It should be sufficient to do all image-related stuff with the base classes BitmapSource
or even ImageSource
, which is the type of the Source
property of the Image control.
Upvotes: 11