Skip to content

System.NullReferenceException when attempt to Mutate.Draw on a new created Image<L8> #1224

@sn4k3

Description

@sn4k3

Description

What i'm trying to do: Resize white pixels but keep original image Width & Height

Error: newImage=error CS0103: The name 'newImage' does not exist in the current context

image

void Resize() is called under a Task
this[layerIndex].Image; // Creates a new Image that loads compressed bytes in
Parallel Loop is executed once, every image instance are new objects created inside the loop (Not shared with other iterations)
Only line "newImage.Mutate(o => o.DrawImage(image, location, 1f));" can trigger the error, Resize operation always pass.

Collection is from 500 to 1000 images but i also tried with just one, same behaviour
This error don't always happens, if i keep redoing same operation sometimes it finish ok without error, others dont.

If i turn Parallel for into a normal for loop problem seens to never happen but of course way slower than using parallel which is what make me use Parallel instead.

System Configuration

  • ImageSharp version: 1.0.0-rc0002
  • Environment (Operating system, version and so on): Windows 10 v1909
  • .NET Framework version: .NET Standard 2.0 library, method called from .NET Framework 4.8 WinForm

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions