Skip to content

[regression/8.0.0] Clipping not working on WindowsΒ #18430

@davidbritch

Description

@davidbritch

Description

I just updated my GraphicsViewDemos project to .NET 8 and used PlatformImage.FromStream to load images on all platforms. Very nice!

In doing so I discovered a crash on Windows when you try and clip an image. It's this issue again. When you try to run clipping code you get an unhandled exception on Windows, with the message: "After calling CanvasDrawingSession.CreateLayer, you must close the resulting CanvasActiveLayer before ending the CanvasDrawingSession"

Capture

Both of the following code blocks cause the exception:

            IImage image;
            var assembly = GetType().GetTypeInfo().Assembly;
            using (var stream = assembly.GetManifestResourceStream("GraphicsViewDemos.Resources.Images.dotnet_bot.png"))
            {
                image = PlatformImage.FromStream(stream);
            }

            if (image != null)
            {
                PathF path = new PathF();
                path.AppendCircle(100, 90, 80);
                canvas.ClipPath(path);  // Must be called before DrawImage
                canvas.DrawImage(image, 10, 10, image.Width, image.Height);
            }
            IImage image;
            var assembly = GetType().GetTypeInfo().Assembly;
            using (var stream = assembly.GetManifestResourceStream("GraphicsViewDemos.Resources.Images.dotnet_bot.png"))
            {
                image = PlatformImage.FromStream(stream);
            }

            if (image != null)
            {
                canvas.SubtractFromClip(60, 60, 90, 90);
                canvas.DrawImage(image, 10, 10, image.Width, image.Height);
            }

Steps to Reproduce

  1. Run the attached sample on Windows.

Link to public reproduction project repository

https://github.com/davidbritch/dotnet-maui-issues/tree/main/GraphicsViewClipping

Version with bug

8.0.0-rc.2.9373

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-controls-imageImage controli/great-reporterThis issue is opened by an author who is known to open high-quality issuespartner/syncfusionIssues / PR's with Syncfusion collaborationplatform/windowspotential-regressionThis issue described a possible regression on a currently supported version., verification pendings/triagedIssue has been revieweds/verifiedVerified / Reproducible Issue ready for Engineering Triaget/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions