镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

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

Closed

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: SixLabors.ImageSharp@1.0.0-rc0002
  • Environment (Operating system, version and so on): Windows 10 x64
  • .NET Framework version: .NET Core 3.1

Activity

  1. changed the title [-]Object reference not set to an instance of an object.[/-] [+]context.BackgroundColor throws Object reference not set to an instance of an object.[/+] on Jun 15, 2020
  2. JimBobSquarePants commented on Jun 16, 2020

    @JimBobSquarePants
    Member

    It happens sometimes when I compile & run this code.

    What do you mean by this, Is the issue intermittent? What environmental factors trigger a difference in result.

    Are you running this in multiple threads?

  3. added a commit that references this issue on Jun 16, 2020
    e95c85a
  4. added this to the 1.0.0 milestone on Jun 16, 2020
  5. themisir commented on Jun 16, 2020

    @themisir
    Author

    What do you mean by this, Is the issue intermittent? What environmental factors trigger a difference in result.

    I really don't know what triggers the issue. Might be because of multithreaded process or something else. In case you're interested here's source code of the project: Program.cs:288. There might be some sort of low level issue which caused this code to throw an exception.

    at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)

    Are you running this in multiple threads?

    Yes. I did run this code in multiple threads to reduce time since I need to process thousands of images.

  6. JimBobSquarePants commented on Jun 16, 2020

    @JimBobSquarePants
    Member

    Yes. I did run this code in multiple threads to reduce time since I need to process thousands of images.

    Thanks @themisir that's correlates with my findings. If got a fix in motion. #1234

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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