Jump to content

null54

Moderator
  • Posts

    1,965
  • Joined

  • Last visited

  • Days Won

    90

Posts posted by null54

  1. @user.by I filed an issue about this in the .NET Runtime repository on GitHub: https://github.com/dotnet/runtime/issues/81342

    I also found a workaround that allows the filter to run: Patch the filter(s) with FilterMeister FM Patcher utility.

     

    Ideally there would be a way to disable the termination on heap corruption for the PSFilterShim process. But if that is not possible I am considering trying to detect if the filter is one of these older FilterMeister-based filters and providing an error message that links to the FM Patcher utility.

    • Like 1
  2. 7 hours ago, user.by said:

    Likewise with working 1.0.8.2 and 4.3.12 but i am using 5.0.1 and says need 2.0 and above, therefore i asked.

     

    Version 1.0.8.2 works on Paint.NET 5.0.1, but it does not support the 5.0 specific features.

    I plan to file an issue in the dotnet runtime repository.

  3. On 1/23/2023 at 1:02 PM, user.by said:

    Some psd plugings is freezing with 5.0i i'm using latest 2.0 psd filter version

     

    The Paint.NET UI freeze has been fixed in version 2.0.1. That filter still crashes with a heap corruption error, but PSFilterPdn will now show an error message when it does.

     

    Release version 2.0.1.

    This release requires Paint.NET 5.0.

     

    Changes:

    • Fixed an issue where a 32-bit filter crashing the PSFilterShim process would make Paint.NET unresponsive.
    • Show an error message if a 32-bit filter crashes the PSFilterShim process.
    • Fixed the Effects folders searching when PSFilterPdn is installed in a sub-folder.

    Technical details about the freezing issue (if anyone is interested):

     

    PSFilterPdn 2.0.0 and earlier would make Paint.NET the parent window of the 32-bit filter dialog, even though it was running in a separate 32-bit process.

    This appears to have caused the OS to think that Paint.NET is covered by an invisible modal dialog if the PSFilterShim process crashed.

    Raymond Chen has a blog post on cross-process window ownership: https://devblogs.microsoft.com/oldnewthing/20130412-00/?p=4683.

     

    To fix this I changed PSFilterShim to show its own window that the 32-bit filters use as their parent window.

    See this GitHub commit: https://github.com/0xC0000054/PSFilterPdn/commit/ef6e2c3f464b6bd1e9ad152be27269642253c82b

    • Like 4
    • Upvote 1
  4. @Rick Brewster I got your FillRectange code sample working, but Direct2D ignores the second FilllRectangle call that I am trying to use to mask out the selection.

     

    IBitmap<ColorAlpha8> sourceMask = this.imagingFactory.CreateBitmap<ColorAlpha8>(this.environment.Document.Size);
    IDirect2DFactory d2dFactory = this.serviceProvider.GetService<IDirect2DFactory>();
    
    RectInt32 maskBounds = RectInt32.Empty;
    
    using (PaintDotNet.Direct2D1.IDeviceContext deviceContext = d2dFactory.CreateBitmapDeviceContext(this.sourceMask))
    {
        using (ISolidColorBrush selectedRegionBrush = deviceContext.CreateSolidColorBrush(Colors.White))
        using (ISolidColorBrush unselectedRegionBrush = deviceContext.CreateSolidColorBrush(Colors.TransparentBlack))
        using (deviceContext.UseBeginDraw())
        {
            IReadOnlyList<RectInt32> selectionRects = this.environment.Selection.RenderScans;
            RectInt32 surfaceBounds = this.sourceMask.Bounds();
    
            deviceContext.Clear(Colors.TransparentBlack);
            foreach (RectInt32 rect in selectionRects)
            {
                RectInt32 expandedRect = RectInt32.Inflate(rect, this.sampleSize, this.sampleSize);
                RectInt32 selectedArea = RectInt32.Intersect(expandedRect, surfaceBounds);
    
                deviceContext.FillRectangle(selectedArea, selectedRegionBrush);
                // Exclude the pixels in the original selection.
                // Direct2D ignores this command.
                deviceContext.FillRectangle(rect, unselectedRegionBrush);
    
                maskBounds = RectInt32.Union(maskBounds, selectedArea);
            }
        }
    }

     

    The alternative approach I have been considering is drawing the mask outline using 4 rectangles, but I would like to avoid that if possible.

  5. 1 hour ago, Rick Brewster said:

    You're using this for a mask bitmap?

     

    Yes, but my mask bitmap is custom MaskSurface type a not a WIC Bitmap. This avoid having to lock and unlock the bitmap when using it.

     

    One issue that I see with your proposed code is that the original selection rectangle is not excluded, but that could be solved with a second FillRectangle call.

    Does FillRectangle already handle clipping the rectangle to the image bounds?

     

    I also need the bounds of the expanded region, but I can get that from the scan rectangles.

  6. 26 minutes ago, Conan said:

    was the process something like this?

     

    Yes, the post-build step used the Header Pack Script for CFF Explorer to remove the debug section. The script is also posted at the bottom of the following NTCore blog post, with some more detail about what it does: https://www.ntcore.com/files/richsign.htm

     

    26 minutes ago, Conan said:

    what was the fix?

     

     Stop using that script. 😀

  7. 21 minutes ago, Conan said:

    Just out of curiosity, what was the issue with the plugin's managed DLLs issue, signtool saying signed yet explorer and Get-AuthenticodeSignature saying not signed?

     

    It was related to a post-build script I was using that removed the debug information section from the DLL headers.

    No idea why it was causing that behavior, perhaps a checksum or something with the managed code sections was not being correctly updated when it rebuilt the headers after removing that data.

    • Thanks 1
  8. I am trying to convert my Content Aware Fill plugin to a BitmapEffect.

     

    The effect creates a new PdnRegion representing the area outside of the selection that the plugin uses for sampling, this region is then converted to a mask bitmap.

     

    private PdnRegion CreateSampleRegion()
    {
        if (this.sampleSize < 0)
        {
            throw new ArgumentOutOfRangeException(nameof(this.sampleSize), "The sample size cannot be negative.");
        }
    
        Rectangle[] expandedScans = this.selection.GetRegionScansInt();
    
        for (int i = 0; i < expandedScans.Length; i++)
        {
            // Expand each scan rectangle by the specified number of pixels.
            expandedScans[i].Inflate(this.sampleSize, this.sampleSize);
        }
    
        PdnRegion sampleRegion;
    
        using (PdnGraphicsPath path = new())
        {
            path.FillMode = System.Drawing.Drawing2D.FillMode.Winding;
            path.AddRectangles(expandedScans);
    
            sampleRegion = new PdnRegion(path);
        }
    
        // Clip the expanded region to the surface bounds and exclude the original selection.
        // Excluding the original selection prevents sampling from the area that is to be replaced.
        sampleRegion.Intersect(this.sourceBounds);
        sampleRegion.Exclude(this.selection);
    
        return sampleRegion;
    }

     

    What would the equivalent IGeometry code be?

    ID2D1GeometrySink does not have an AddRectangle method, so I assume that the rectangles would have to be converted to lines.

  9. 2 hours ago, TrevorOutlaw said:

    would it be possible for your PS ABR script to be integrated into Smudge?

     

    Possibly, I would have to investigate it more.

    From a quick look at the Smudge plugin code on GitHub, the brush loading code would need a fairly extensive rewrite to handle formats other than PNG.

    • Like 1
×
×
  • Create New...