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

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

Closed

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

Activity

  1. antonfirsov commented on Jun 10, 2020

    @antonfirsov
    Member

    @sn4k3 how is the compilation error CS0103 related to the rest of the issue?

    Any chance you can create a self-contained console app repro? A lot may depend on image sizes, position of x,y and other contextual factors.

  2. sn4k3 commented on Jun 10, 2020

    @sn4k3
    Author

    Repo here: https://github.com/sn4k3/PrusaSL1Viewer
    How to reproduce: Execute Main app -> Menu -> Open -> sl1 file from zip. Go to Menu -> Mutators -> Resize -> Pick any value diferent from 100 -> Click ok -> Error happen here
    Note the error doesn't always trigger but most of the times will

    Void Resize(): https://github.com/sn4k3/PrusaSL1Viewer/blob/master/PrusaSL1Reader/FileFormat.cs#L636
    Called at: https://github.com/sn4k3/PrusaSL1Viewer/blob/master/PrusaSL1Viewer/FrmMain.cs#L1893

    input_file.zip

  3. JimBobSquarePants commented on Jun 16, 2020

    @JimBobSquarePants
    Member

    I think this might be related to #1230 @sn4k3 if you can provide a stack trace that would be really useful.

  4. sn4k3 commented on Jun 16, 2020

    @sn4k3
    Author

    System.NullReferenceException
    HResult=0x80004003
    Message=A referência de objecto não foi definida como uma instância de um objecto.
    Source=mscorlib
    StackTrace:
    at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
    at SixLabors.ImageSharp.GraphicOptionsDefaultsExtensions.GetGraphicsOptions(Configuration configuration)
    at SixLabors.ImageSharp.GraphicOptionsDefaultsExtensions.GetGraphicsOptions(IImageProcessingContext context)
    at SixLabors.ImageSharp.Processing.DrawImageExtensions.DrawImage(IImageProcessingContext source, Image image, Point location, Single opacity)
    at UVtools.Parser.FileFormat.<>c__DisplayClass124_1.b__2(IImageProcessingContext o) in D:\Tiago\Dropbox\Programming\C#\UVtools\UVtools.Parser\FileFormat.cs:line 687

  5. JimBobSquarePants commented on Jun 16, 2020

    @JimBobSquarePants
    Member

    @sn4k3 Perfect. Yep, definitely the same issue. I've got #1234 waiting for review to fix this.

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions