i'm read a image from PhotoChooserTask and have a stream of a photo. I have to reduce the size of image
i write this code
WriteableBitmap writeableBitmap = new WriteableBitmap(400, 400);
writeableBitmap.LoadJpeg(stream);
using (var isoFile = IsolatedStorageFile.GetUserStoreForApplication())
{
if (isoFile.FileExists("Myfile.jpg")) isoFile.DeleteFile("Myfile.jpg");
using (var filestream = isoFile.CreateFile("Myfile.jpg"))
{
writeableBitmap.SaveJpeg(filestream, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight, 0, 100);
}
}
this code not keep aspect ration of image.
how to make?
First load the source image to writeableBitmap (without resizing).
Then get the source width (PixelWidth) and full height (PixelHeight). Dividing PixelWidth with PixelHeight will give you the ratio. You can use this value when resizing.
So:
Then when saving just do