Convert StorageFile to a BitmapImage in Universal Windows Apps

We have already seen how to convert a WritableBitmap to a StorageFile in Universal Windows apps. A StorageFile can be converted to a BitmapImage using the following function. public class ImageUtils { public static async Task<BitmapImage> StorageFileToBitmapImage(StorageFile savedStorageFile) { using (IRandomAccessStream fileStream = await savedStorageFile.OpenAsync(Windows.Storage.FileAccessMode.Read)) { BitmapImage bitmapImage = new BitmapImage(); bitmapImage.DecodePixelHeight = 100; bitmapImage.DecodePixelWidth […]

Read More

Converting WritableBitmap to StorageFile in Universal Windows Apps

WriteableBitmap is quite useful when an app requires image processing. It provides a BitmapSource, that can be written and manipulated. Ultimately that bitmap source is supplied to an image control of a Windows Store app. We are going to save the WritableBitmap to a StorageFile in our app. For image encoding WinRT offers the BitmapEncoder […]

Read More

How to Fix IpOverUsbSvc error while registering Windows Phone device

Sometimes while registering your Windows Phone device for development you might get a IpOverUsbSvc error. Here’s how to register your device for development. http://windowsapptutorials.com/windows-phone/general/developer-unlock-your-windows-phone-8-device/ A simple fix that seems to work most of the times is to restart the service. Here’s how to do it. Step 1: Open Powershell in Admin mode Go to start […]

Read More

Convert Storage File to Byte Array in Universal Windows apps

This async function converts a storage file to a byte array. public static async Task<byte[]> GetBytesAsync(StorageFile file) { byte[] fileBytes = null; if (file == null) return null; using (var stream = await file.OpenReadAsync()) { fileBytes = new byte[stream.Size]; using (var reader = new DataReader(stream)) { await reader.LoadAsync((uint)stream.Size); reader.ReadBytes(fileBytes); } } return fileBytes; } It […]

Read More