Skip to content

context.BackgroundColor throws Object reference not set to an instance of an object. #1230

@themisir

Description

@themisir

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 DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

Description

Object reference not set to an instance of an object.

   at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)
   at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)
   at SixLabors.ImageSharp.GraphicOptionsDefaultsExtensions.GetGraphicsOptions(Configuration configuration)
   at SixLabors.ImageSharp.GraphicOptionsDefaultsExtensions.GetGraphicsOptions(IImageProcessingContext context)
   at SixLabors.ImageSharp.Processing.BackgroundColorExtensions.BackgroundColor(IImageProcessingContext source, Color color)
   at Dropmaker.Program.<RunOnce>b__12_0(IImageProcessingContext ctx) in C:\Users\misir\source\repos\Dropmarker\src\Program.cs:line 280
   at SixLabors.ImageSharp.Processing.ProcessingExtensions.ProcessingVisitor.Visit[TPixel](Image`1 image)
   at SixLabors.ImageSharp.Image`1.Accept(IImageVisitor visitor)
   at SixLabors.ImageSharp.Advanced.AdvancedImageExtensions.AcceptVisitor(Image source, IImageVisitor visitor)
   at SixLabors.ImageSharp.Processing.ProcessingExtensions.Mutate(Image source, Configuration configuration, Action`1 operation)
   at SixLabors.ImageSharp.Processing.ProcessingExtensions.Mutate(Image source, Action`1 operation)
   at Dropmaker.Program.RunOnce(State state) in C:\Users\misir\source\repos\Dropmarker\src\Program.cs:line 278

Steps to Reproduce

It happens sometimes when I compile & run this code.

var image = Image.Load("image.jpg");
image.Mutate(ctx =>
{
    ctx.BackgroundColor(Color.White);
});

System Configuration

  • ImageSharp version: [email protected]
  • Environment (Operating system, version and so on): Windows 10 x64
  • .NET Framework version: .NET Core 3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions