The following question recently appeared in the WPF forum:
Is there posibility of resizing BitmapImage using WPF?
I do not want to resize an Image control. I want to resize image itself so when i convert it to bytes and stores it in database it has desired size.
In my response to that question, I included some sample code demonstrating how you might resize an image by leveraging the BitmapImage class to decode the image to the desired pixel width and height and then save the converted image back to a disk file or store it in a database.
I also mentioned that there are some additional imaging classes that can be leveraged for other common image manipulation tasks. After receiving a couple of inquiries about these other classes, I decided to expand my sample a little.
Here is a sample application that demonstrates how to use the CroppedImage and TransformedImage classes. It also includes the resize code from the earlier sample.
Note that I’ve written this sample as a simple .NET console application. (This should reinforce the idea that WPF is more than just a “presentation” framework.) You can pass the app commands like rotate left, rotate right, flip horizontally, flip vertically, and crop square.
Hope others find this useful.
Cheers,
Dr. WPF