null54 Posted January 17 Author Posted January 17 1 hour ago, Rick Brewster said: That appears to be the same crash reported in the post above yours by @user.by It is, and I know what is causing it. For some reason ILLink is removing System.IDisposable from the trimmed runtime, despite the fact that I set the option in the project file that should make it ignore the main executable and any assemblies that are not marked as compatible with trimming. The main executable uses IDisposable in a few places, so I have no idea why ILLink thinks it can be removed. It was working when I built 2.0.6, but it obviously no longer does. Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait
Rick Brewster Posted January 18 Posted January 18 That might be something that folks on the C# Discord Server can help figure out. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
null54 Posted January 18 Author Posted January 18 Release version 2.0.8, which fixes a crash when running 32-bit filters. 1 1 Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait
user.by Posted January 18 Posted January 18 1 hour ago, null54 said: Release version 2.0.8, which fixes a crash when running 32-bit filters. First time thank you for your works, I just say as information, i have some plugin problems. I am using Curve plugin (http://www.mehdiplugins.com/english/curves.htm) It's work v2.0.2 and earlier versions but dont work 2.0.3 and later versions. Like this first pic v2.0.8 - second pic 2.0.2 Quote
null54 Posted January 18 Author Posted January 18 11 hours ago, user.by said: It's work v2.0.2 and earlier versions but dont work 2.0.3 and later versions. Like this Version 2.0.3 had a lot of changes to the image storage and rendering code, I converted it all from GDI+ to WIC/Direct2D. As a workaround you can delete the 64-bit version of that filter, the 32-bit version is working correctly. I am not sure what is going on with the 64-bit version, it looks like a possible bug in the pixel copying or resizing code. 1 Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait
user.by Posted January 19 Posted January 19 9 hours ago, null54 said: Version 2.0.3 had a lot of changes to the image storage and rendering code, I converted it all from GDI+ to WIC/Direct2D. As a workaround you can delete the 64-bit version of that filter, the 32-bit version is working correctly. I am not sure what is going on with the 64-bit version, it looks like a possible bug in the pixel copying or resizing code. Thank you for concern, you know better, but when i change PSFilterPdn.dll all versions are working. Quote
null54 Posted January 19 Author Posted January 19 It looks like Paint.NET is padding the stride of the WIC bitmaps depending on the dimensions. This does not occur when using WIC directly. I still don't know how this is causing the code to produce a corrupt image. the loops should handle different stride values when copying the data. 1 Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait
Rick Brewster Posted January 19 Posted January 19 10 hours ago, null54 said: It looks like Paint.NET is padding the stride of the WIC bitmaps depending on the dimensions. This does not occur when using WIC directly. I still don't know how this is causing the code to produce a corrupt image. the loops should handle different stride values when copying the data. It depends on circumstances. Bitmap allocations are pooled/recycled, and I also try to pool/recycle Direct2D device contexts along with the bitmaps they were wrapped around (via IDirect2DFactory.CreateBitmapRenderTarget(), which has special/private performance advantages vs. other paths). In order to reuse these bitmaps and their DCs better, I do some trickery with the strides to reduce the need to recreate device contexts (which aren't cheap, so this improves perf by quite a good amount). See BitmapUtil.GetOptimalStrideChecked() for more. Is the "corrupt" bitmap being drawn by the 8BF plugin? It may not be doing the right thing when it comes to stride -- a lot of code out there incorrectly assumes that stride==width*sizeof(pixel), which almost always works ... Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
null54 Posted January 20 Author Posted January 20 8 hours ago, Rick Brewster said: Is the "corrupt" bitmap being drawn by the 8BF plugin? Not directly, PSFilterPdn is feeding it bad data when the image uses those stride tricks. But I have no idea where the underlying bug is located, everything I have checked looks correct. The data copy loops I am using would be similar to: using (IBitmapLock<ColorBgra32> bitmapLock = scaledSurface!.Lock(bounds, BitmapLockMode.Read)) { for (int y = 0; y < bounds.Height; y++) { uint* src = (uint*)((byte*)bitmapLock.Buffer + (nuint)((nint)y * bitmapLock.BufferStride)); byte* dst = (byte*)dstScan0 + ((y + padding.top) * destStride) + padding.left; ImageRow.Load(src, bitmapLock.BufferStride, dst, destStride, bounds.Width, channelIndex, numberOfPlanes); } } The source BufferStride is equal to whatever PDN sets it to, and the destination buffer stride is equal to width x numberOfPlanes. Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait
Rick Brewster Posted January 20 Posted January 20 3 hours ago, null54 said: byte* dst = (byte*)dstScan0 + ((y + padding.top) * destStride) + padding.left; padding.left is not being multiplied by the bytes-per-pixel? Also there are methods in PaintDotNet.Imaging.BitmapUtil that will make your life much easier for calculations like these, like GetRowPointer and GetPointPointer Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
null54 Posted January 20 Author Posted January 20 7 hours ago, Rick Brewster said: padding.left is not being multiplied by the bytes-per-pixel? That was a bug, but unfortunately not the cause of this issue. Padding is a Photoshop API feature that its filters can use to virtually extend the canvas by the requested number of pixels, it was presumably intended to make writing convolution filters easier. Instead of adjusting the algorithm to handle the image edges a filter developer could have the host extend the canvas by replicating those pixels for n rows/columns. Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait
Rick Brewster Posted January 20 Posted January 20 Hmm. If you've got a link to the code in question, I can take a look and see if I can figure something out Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
null54 Posted January 20 Author Posted January 20 4 minutes ago, Rick Brewster said: Hmm. If you've got a link to the code in question, I can take a look and see if I can figure something out Copy to 8bf filter loop: https://github.com/0xC0000054/PSFilterPdn/blob/4066ed29118dfff69994361d38bc0a0a45cdcf7e/src/PSApi/LoadPsFilter.cs#L1788 ImageRow load method: https://github.com/0xC0000054/PSFilterPdn/blob/4066ed29118dfff69994361d38bc0a0a45cdcf7e/src/PSApi/ImageRow.cs#L41 Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait
Rick Brewster Posted January 20 Posted January 20 I can't seem to figure it out from looking at the code 🤔 But from looking at the screenshots, my guess is there's (at least) a bug with how the per-row output pointer is being calculated. Notice how it has a transparent chunk at the bottom. This could happen if the destination stride was not taken into account, and if that stride was a bit larger than the width*bytesPerPixel. It looks like maybe about 10% wasn't filled in? So maybe the output is ~900px wide, but the buffer is ~1024px wide (with 3600 byte stride). I can't really discern a specific pattern in the output pixels -- it's obviously not just the left portion of the image, which sometimes happens if bytesPerPixel is incorrectly applied (e.g. only filling or utilizing the left 25%, or something like that) Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
Rick Brewster Posted January 21 Posted January 21 @null54 you can do some additional debugging by making your own implementation of IBitmap[Source]. Derive from BitmapSourceBase<TPixel> and then also implement IBitmap<TPixel>. In your implementation you can use whatever allocator you want, e.g. NativeMemory, so you can employ whatever stride you need to help you narrow down where the problem is. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
null54 Posted January 21 Author Posted January 21 21 minutes ago, Rick Brewster said: Derive from BitmapSourceBase<TPixel> and then also implement IBitmap<TPixel>. In your implementation you can use whatever allocator you want, e.g. NativeMemory, so you can employ whatever stride you need to help you narrow down where the problem is. Could that also be used as a workaround for this issue? So that instead of calling PDN's IImagingFactory.CreateBitmap, I have my own IBitmap<TPixel> class that ensures the bitmap has the correct stride. Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait
Rick Brewster Posted January 22 Posted January 22 I could also look into adding that in an extra overload, like factory.CreateBitmap(..., CreateBitmapOptions.RequireContiguousAllocation) There isn't yet a non-internal implementation of IBitmap[Source] that I know of, so I'm not yet ready to endorse and support it. It's not that I'm disallowing it, there's just a few weird corner cases in the component model and I need to make sure the potential sharp edges are rounded off. For the moment, let's just see if it helps narrow down what the problem is. Then we can figure out if 5.0.13 should have that extra overload. And/or we make sure that implementing IBitmap[Source] via BitmapSourceBase<TPixel> is both possible (which it is right now) and fully supported (i.o.w. I won't regret it later for some reason I can't foresee right now). Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
Rick Brewster Posted January 22 Posted January 22 In other words I prefer you to not need to implement IBitmap yourself. Having a flag for controlling this behavior does sound reasonable. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
user.by Posted May 20 Posted May 20 Submits for your information Otherwise i tried 2.0.2.0 vs 2.0.8.0 versions with Paint.Net 5.1 and result is same. First pic 2.0.2.0 perfect working and Second pic not working 2.0.8.0 Quote
null54 Posted May 20 Author Posted May 20 4 hours ago, user.by said: First pic 2.0.2.0 perfect working and Second pic not working 2.0.8.0 It is the same issue as the other filter you reported. The 32-bit version works fine. Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait
Rick Brewster Posted May 21 Posted May 21 2 hours ago, null54 said: It is the same issue as the other filter you reported. The 32-bit version works fine. Is this the issue with stride? Is that solveable now (in 5.1) with BitmapAllocationOptions.Contiguous? Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
null54 Posted May 21 Author Posted May 21 1 hour ago, Rick Brewster said: Is this the issue with stride? Yes. 1 hour ago, Rick Brewster said: Is that solveable now (in 5.1) with BitmapAllocationOptions.Contiguous? It should be, but I haven't tested it yet. Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait
jennXjenn Posted October 4 Posted October 4 On 12/15/2010 at 6:44 PM, null54 said: This plug-in hosts Adobe® Photoshop®-compatible filter plug-ins under Paint.NET. Many 3rd-party filters should run although some may have issues. For instructions on installing 8bf filters see Installing 8bf filters. This plugin is compatible with Paint.NET 5.0.12+. Download PSFilterPdn.zip To install place the PSFilterPdn folder in your Effects folder which is usually located in one the following locations depending on the Paint.NET version you have installed. Classic: C:\Program Files\Paint.NET\Effects Microsoft Store: Documents\paint.net App Files\Effects Portable: <Paint.NET folder>\Effects Effects->8bf Filter... Source Code https://github.com/0xC0000054/PSFilterPdn I am aware this thread is "old"... but..I'm just learning and I have found Paint.net is more my speed. However, I am a bit confused...I know I just have to copy and paste the pdn.dll files to the effects folder ... but... what do I do with the pdb and the shim.exe? Quote
null54 Posted October 4 Author Posted October 4 22 minutes ago, jennXjenn said: what do I do with the pdb and the shim.exe? The whole unzippped PSFilterPdn folder should be placed in the Effects folder. Quote Plugin Pack | PSFilterPdn | Content Aware Fill | G'MIC | Paint Shop Pro Filetype | RAW Filetype | WebP Filetype The small increase in performance you get coding in C++ over C# is hardly enough to offset the headache of coding in the C++ language. ~BoltBait
Otto04 Posted October 15 Posted October 15 (edited) I use this for a while, mainly with the old google NIK Collection. Suddenly, half of these filters are broken for me. I have no idea what changed on my PC, paint.net is the same version, the filters, too. But any filter about colors go "blue" when opening: paint.net is version 5.0.13. It is not related to paint.net but the filters act the same with Affinity Photo 2. My only idea is a recent Microsoft or AMD graphics driver update, i am running an RX 6800 with Adrenaline 24.9.1 Rolling back to the 2023 Pro Edition driver fixed this. This has to be something with one of the latest Adrenaline drivers. Edited November 18 by Otto04 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.