Я пытаюсь масштабировать существующий образ до 50% его размера с помощью WinRT. Копирует изображение в локальную папку, но не меняет его размер;
var openPicker = new Windows.Storage.Pickers.FileOpenPicker();
openPicker.viewMode = Windows.Storage.Pickers.PickerViewMode.thumbnail;
openPicker.suggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.picturesLibrary;
openPicker.fileTypeFilter.replaceAll([".png", ".jpg", ".jpeg"]);
openPicker.pickSingleFileAsync().then(function (file) {
file.copyAsync(Windows.Storage.ApplicationData.current.localFolder, file.name)
.then(function (file) {
return file.openAsync(Windows.Storage.FileAccessMode.readWrite);
})
.then(function (stream) {
return Windows.Graphics.Imaging.BitmapDecoder.createAsync(stream);
})
.then(function (decoder) {
fileStream = new Windows.Storage.Streams.InMemoryRandomAccessStream();
return Windows.Graphics.Imaging.BitmapEncoder.createForTranscodingAsync(fileStream, decoder);
})
.then(function (encoder) {
encoder.bitmapTransform.scaledWidth = 50;
encoder.bitmapTransform.scaledHeight = 50;
return encoder.flushAsync();
})
.then(function () {
fileStream.close();
})
.done(function () {
// use image in the program
});
});