I am working on a WinRT application that will do some image processing, and one of the things I want to do is convert jpg or png to gif. I have something like that. For some of my test jpgs, it works by others, it is a scrambled image that outputs the result. Just wondering if there is something that I have not seen. That's what i still have
public async static void ConvertToGif(IRandomAccessStream stream) { var decoder = await BitmapDecoder.CreateAsync(stream); var pixels = await decoder.GetPixelDataAsync(); var file = await KnownFolders.PicturesLibrary.CreateFileAsync("test.gif", CreationCollisionOption.ReplaceExisting); var outStream = await file.OpenAsync(FileAccessMode.ReadWrite); var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.GifEncoderId, outStream); encoder.SetPixelData(decoder.BitmapPixelFormat, BitmapAlphaMode.Ignore, decoder.PixelWidth, decoder.PixelHeight, decoder.DpiX, decoder.DpiY, pixels.DetachPixelData()); await encoder.FlushAsync(); outStream.Dispose(); }
Smaller jpgs seem to work, but larger ones go beyond. Is there any other way to achieve this?
source share