1

I have a problem with GifRenderer class. In an Windows Phone 8 app, my scope is generate an animated gif starting from a list of png images stored in isolated storage of app and then save it and share it. When in my code I call GifRenderer.RenderAsync method, I have an ArgumentException, Value does not fall within the expected range, as you can see in following VB code. Where am I doing wrong?

Dim images = New List(Of IImageProvider)
Dim image As Picture

Try
    For Each fileName In fileNames
        images.Add(New StorageFileImageSource(Await StorageFile.GetFileFromPathAsync(IO.Path.Combine(ApplicationData.Current.LocalFolder.Path, fileName))))
    Next

    Dim info = Await images(0).GetInfoAsync()
    Using renderer = New GifRenderer()
        renderer.Size = info.ImageSize
        renderer.Sources = images
        renderer.Duration = 1000
        Dim gifBuffer = Await renderer.RenderAsync()
        Dim stream = gifBuffer.AsStream()

        Using library = New MediaLibrary()
            Dim filename = String.Format("{0}+{1}.gif", IO.Path.GetFileNameWithoutExtension(fileNames(0)), fileNames.Count)
            image = library.SavePicture(IO.Path.GetFileName(filename), stream)
        End Using
    End Using

    Dim task = New ShareMediaTask()
    task.FilePath = image.GetPath()
    task.Show()
Catch ex As Exception
    Debug.WriteLine(ex)
    'renderer.RenderAsync() ->
    'System.ArgumentException: Value does not fall within the expected range.
    ' at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
    ' at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
    ' at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
    ' at WP8.App.VB$StateMachine_0_ShareAnimation.MoveNext()
End Try
David Božjak
  • 16,887
  • 18
  • 67
  • 98
Mr Wolf
  • 80
  • 7
  • Same question seems to be asked here: http://developer.nokia.com/community/discussion/showthread.php/246704-GifRenderer-ArgumentException-Value-does-not-fall-within-the-expected-range?p=937935 – David Božjak Apr 25 '14 at 08:30
  • If you enable native debugging for your app, do you then see a better error message in the output window? Because what you see is just the generic text of the exception type. The SDK emits more than that. – CÅdahl May 26 '14 at 05:44
  • The link to the nokia dev site in the comment above is now broken unfortunately. Did you ever find out what was out of range? – user1725145 Nov 22 '15 at 10:25

0 Answers0