Hi,
I am trying to resize any image to 150x150 using the code below, but when I use it, the resulting image is the right size but is completely corrupted, it is just a series of horizontal lines through which you can just about make out the image. Please could someone have a look at this code and see where i've gone wrong?
Many thanks
Marc
I am trying to resize any image to 150x150 using the code below, but when I use it, the resulting image is the right size but is completely corrupted, it is just a series of horizontal lines through which you can just about make out the image. Please could someone have a look at this code and see where i've gone wrong?
Many thanks
Marc
VB.NET:
Dim Squarefile As Windows.Storage.StorageFile = Await StorageFile.GetFileFromPathAsync(txtSquareImage.Text)
Dim newfile = Await Squarefile.CopyAsync(ApplicationData.Current.LocalFolder, sb.ToString & Squarefile.FileType, NameCollisionOption.ReplaceExisting)
Dim sourceStream = Await newfile.OpenAsync(FileAccessMode.Read)
Dim decoder = Await BitmapDecoder.CreateAsync(sourceStream)
Dim pixelData = Await decoder.GetPixelDataAsync
Dim destinationStream = Await newfile.OpenAsync(FileAccessMode.ReadWrite)
Dim encoder = Await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, destinationStream)
encoder.SetPixelData(decoder.BitmapPixelFormat, decoder.BitmapAlphaMode, 150, 150, decoder.DpiX, decoder.DpiY, pixelData.DetachPixelData)
Await encoder.FlushAsync()