-
-
Notifications
You must be signed in to change notification settings - Fork 887
Closed
Labels
Description
Prerequisites
- I have written a descriptive issue title
- I have verified that I am running the latest version of ImageSharp
- I have verified if the problem exist in both
DEBUGandRELEASEmode - I have searched open and closed issues to ensure it has not already been reported
Description
System.AggregateException: 发生一个或多个错误。 ---> System.DivideByZeroException: 尝试除以零。
在 SixLabors.ImageSharp.Processing.Processors.Dithering.OrderedDither.Dither[TPixel](TPixel source, Int32 x, Int32 y, Int32 bitDepth, Single scale)
在 SixLabors.ImageSharp.Processing.Processors.Dithering.OrderedDither.QuantizeDitherRowOperation`2.Invoke(Int32 y)
在 SixLabors.ImageSharp.Advanced.ParallelRowIterator.RowOperationWrapper`1.Invoke(Int32 i)
在 System.Threading.Tasks.Parallel.<>c__DisplayClass17_0`1.<ForWorker>b__1()
在 System.Threading.Tasks.Task.InnerInvoke()
在 System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
在 System.Threading.Tasks.Task.<>c__DisplayClass176_0.<ExecuteSelfReplicating>b__0(Object <p0>)
--- 内部异常堆栈跟踪的结尾 ---
在 System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
在 System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
在 System.Threading.Tasks.Task.Wait()
在 System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
在 System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body)
在 SixLabors.ImageSharp.Advanced.ParallelRowIterator.IterateRows[T](Rectangle rectangle, ParallelExecutionSettings& parallelSettings, T& operation)
在 SixLabors.ImageSharp.Processing.Processors.Dithering.OrderedDither.ApplyQuantizationDither[TFrameQuantizer,TPixel](TFrameQuantizer& quantizer, ImageFrame`1 source, IndexedImageFrame`1 destination, Rectangle bounds)
在 SixLabors.ImageSharp.Processing.Processors.Quantization.QuantizerUtilities.SecondPass[TFrameQuantizer,TPixel](TFrameQuantizer& quantizer, ImageFrame`1 source, IndexedImageFrame`1 destination, Rectangle bounds)
在 SixLabors.ImageSharp.Processing.Processors.Quantization.QuantizerUtilities.QuantizeFrame[TFrameQuantizer,TPixel](TFrameQuantizer& quantizer, ImageFrame`1 source, Rectangle bounds)
在 SixLabors.ImageSharp.Processing.Processors.Quantization.OctreeQuantizer`1.QuantizeFrame(ImageFrame`1 source, Rectangle bounds)
在 SixLabors.ImageSharp.Formats.Gif.GifEncoderCore.Encode[TPixel](Image`1 image, Stream stream, CancellationToken cancellationToken)
在 SixLabors.ImageSharp.Formats.ImageEncoderUtilities.Encode[TPixel](IImageEncoderInternals encoder, Image`1 image, Stream stream)
在 SixLabors.ImageSharp.Formats.Gif.GifEncoder.Encode[TPixel](Image`1 image, Stream stream)
在 SixLabors.ImageSharp.Image.EncodeVisitor.Visit[TPixel](Image`1 image)
在 SixLabors.ImageSharp.Image`1.Accept(IImageVisitor visitor)
在 SixLabors.ImageSharp.Image.Save(Stream stream, IImageEncoder encoder)
在 SixLabors.ImageSharp.ImageExtensions.Save(Image source, String path, IImageEncoder encoder)
在 SixLabors.ImageSharp.ImageExtensions.SaveAsGif(Image source, String path)
在 WpfApp1.MainWindow.Button_Click(Object sender, RoutedEventArgs e) 位置 E:\lq\GifAdvanced\WpfApp1\MainWindow.xaml.cs:行号 76
在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
在 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
在 System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
在 System.Windows.Controls.Primitives.ButtonBase.OnClick()
在 System.Windows.Controls.Button.OnClick()
在 System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
在 System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
在 System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
在 System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
在 System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
在 System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
在 System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
在 System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
在 System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
在 System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
在 System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
在 System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
在 System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
在 System.Windows.Input.InputManager.ProcessStagingArea()
在 System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
在 System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
在 System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
在 System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
在 System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
在 MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
在 MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
在 System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
在 System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
在 System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
在 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
在 MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
在 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
在 System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
在 System.Windows.Application.RunDispatcher(Object ignore)
在 System.Windows.Application.RunInternal(Window window)
在 System.Windows.Application.Run(Window window)
在 System.Windows.Application.Run()
在 WpfApp1.App.Main()
Steps to Reproduce
System Configuration
- ImageSharp version:1.0.3
- Other ImageSharp packages and versions:
- Environment (Operating system, version and so on):window 10
- .NET Framework version: 4.7.2
- Additional information:
int w = 400;
int h = 400;
var gif = new Image<Rgba32>(w, h);
var gifMetadata = gif.Metadata.GetGifMetadata();
gifMetadata.RepeatCount = 0;
gif.Mutate(x => x.Fill(Color.Aqua));
gif.Frames[gif.Frames.Count - 1].Metadata.GetGifMetadata().FrameDelay = 100;
gif.Frames[gif.Frames.Count - 1].Metadata.GetGifMetadata().DisposalMethod = GifDisposalMethod.NotDispose;
Image<Rgba32> image = SixLabors.ImageSharp.Image.Load<Rgba32>(@"C:\Users\jxw\Desktop\630.png"); // create any way you like.
image.Mutate(x => x.Resize(new SixLabors.ImageSharp.Size(w, h)));
gif.Frames.AddFrame(image.Frames[0]);
gif.Frames[gif.Frames.Count-1].Metadata.GetGifMetadata().FrameDelay = 100;
gif.Frames[gif.Frames.Count - 1].Metadata.GetGifMetadata().DisposalMethod = GifDisposalMethod.NotDispose;
IBrush brush = Brushes.ForwardDiagonal(Color.Red, Color.Blue);
IPath yourPolygon = new Star(x: 100.0f, y: 100.0f, prongs: 5, innerRadii: 100.0f, outerRadii: 100.0f);
var img1 = image.Clone(x => x.Fill(brush, yourPolygon));
gif.Frames.AddFrame(img1.Frames[0]);
gif.Frames[gif.Frames.Count - 1].Metadata.GetGifMetadata().FrameDelay = 100;
gif.Frames[gif.Frames.Count - 1].Metadata.GetGifMetadata().DisposalMethod = GifDisposalMethod.NotDispose;
var oq = new SixLabors.ImageSharp.Processing.Processors.Quantization.OctreeQuantizer();
oq.Options.Dither = new SixLabors.ImageSharp.Processing.Processors.Dithering.OrderedDither();
GifEncoder gifEncoder = new GifEncoder
{
Quantizer = oq
};
gif.SaveAsGif(@"C:\Users\jxw\Desktop\630_1.gif");