Skip to content

NullReferenceException is thrown when trying to reuse an ImageBrush<T> #881

Description

@antonfirsov

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

A NullReferenceException is thrown when trying to reuse an ImageBrush<T>. Looks like the source image is being disposed during the first Fill(...) call.

Steps to Reproduce

using (var src = new Image<Rgba32>(5, 5))
{
    var brush = new ImageBrush<Rgba32>(src);
    using (var dest = new Image<Rgba32>(10, 10))
    {
        dest.Mutate(c => c.Fill(brush, new Rectangle(0, 0, 10, 10)));
        dest.Mutate(c => c.Fill(brush, new Rectangle(0, 0, 10, 10)));
    }
}

System Configuration

  • ImageSharp version: current main
  • Other ImageSharp packages and versions: n.a.
  • Environment (Operating system, version and so on): Any
  • .NET Framework version: Any
  • Additional information: -

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions