我的GifRenderer类有问题。 在Windows Phone 8应用程序中,我的范围是从存储在app的独立存储中的png图像列表开始生成动画gif,然后保存并共享它。 当我在我的代码中调用GifRenderer.RenderAsync方法时,我有一个ArgumentException,Value不在预期范围内,正如您在下面的VB代码中看到的那样。 我在哪里做错了?
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