alexo Posted June 4, 2018 Posted June 4, 2018 A problem that iy have with this plugin is that it immediately starts working when I change the settings, even if I am not done changing them, and then I have to wait a long time for it to finish only to update the settings again. It would be better to have an "apply" button. Quote
Rick Brewster Posted June 4, 2018 Posted June 4, 2018 Perhaps the algorithm affords a "draft quality" setting? (I'm not familiar with the algorithm though...) Similar to how some of the other effects have a Quality slider. Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
null54 Posted June 5, 2018 Author Posted June 5, 2018 9 hours ago, alexo said: A problem that iy have with this plugin is that it immediately starts working when I change the settings, even if I am not done changing them, and then I have to wait a long time for it to finish only to update the settings again. The effect renders automatically because that is the expected behavior for all Paint.NET effects that do not show their own drawing surface. If I were to add an apply button it would be controlled by a checkbox that disables the automatic rendering. 6 hours ago, Rick Brewster said: Perhaps the algorithm affords a "draft quality" setting? I could try to adjust the number of refinement passes and random points the algorithm will try when searching for matches. Currently the algorithm uses 6 refinement passes and will try up to 500 random points if it does not find a match in the 16 neighboring points. Unfortunately this algorithm only supports sequential processing of the image data, so it cannot use Paint.NET's multi-threaded rendering. 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
BoltBait Posted June 5, 2018 Posted June 5, 2018 2 hours ago, null54 said: Unfortunately this algorithm only supports sequential processing of the image data, so it cannot use Paint.NET's multi-threaded rendering. Sprinkle these throughout the algorithm? if (IsCancelRequested) return; Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
null54 Posted June 5, 2018 Author Posted June 5, 2018 52 minutes ago, BoltBait said: Sprinkle these throughout the algorithm? That is what the plugin does when it is run as a repeat effect (in OnSetRenderInfo). Because Paint.NET does not allow Effect plugins to report their own progress, the effect dialog uses a BackgroundWorker for rendering to allow its progress bar to be updated. Currently the effect dialog does not tell the BackgroundWorker to abort and restart when the settings change, it only aborts the BackgroundWorker when the user cancels the dialog. 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
alexo Posted June 5, 2018 Posted June 5, 2018 18 hours ago, null54 said: The effect renders automatically because that is the expected behavior for all Paint.NET effects that do not show their own drawing surface. If I were to add an apply button it would be controlled by a checkbox that disables the automatic rendering. The problem is that if I want to move the slider from the default 50 to say 12, the process starts as soon as I start moving the slider, before it reaches the mark. Then I have to wait for it to finish (can take 20 second's or so), then try to trigger it again, which is problem when the slider is already in the correct position, so I end up running it twice more. It is an unnecessary inconvenience. Quote
BoltBait Posted June 5, 2018 Posted June 5, 2018 16 hours ago, null54 said: That is what the plugin does when it is run as a repeat effect (in OnSetRenderInfo). Because Paint.NET does not allow Effect plugins to report their own progress, the effect dialog uses a BackgroundWorker for rendering to allow its progress bar to be updated. Currently the effect dialog does not tell the BackgroundWorker to abort and restart when the settings change, it only aborts the BackgroundWorker when the user cancels the dialog. Try this instead... https://forums.getpaint.net/topic/112378-plugin-development-nuggets-of-wisdom-i-learned/?do=findComment&comment=542006 Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
null54 Posted June 5, 2018 Author Posted June 5, 2018 2 hours ago, BoltBait said: Try this instead... Rendering in OnSetRenderInfo would break the progress reporting for the plugin. 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
BoltBait Posted June 5, 2018 Posted June 5, 2018 Well, I'm out of ideas on how to make your UI more responsive. 1 Quote Download: BoltBait's Plugin Pack | CodeLab | and a Free Computer Dominos Game
Rick Brewster Posted June 5, 2018 Posted June 5, 2018 You should be able to give the BackgroundWorker access to your Effect.IsCancelRequested. And then just stop what you're doing -- either return or `throw OperationCanceledException` (and catch it in an appropriate place). 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
null54 Posted June 6, 2018 Author Posted June 6, 2018 3 hours ago, Rick Brewster said: You should be able to give the BackgroundWorker access to your Effect.IsCancelRequested. And then just stop what you're doing -- either return or `throw OperationCanceledException` (and catch it in an appropriate place). The IsCancelRequested property would not help as I render to a temporary surface, and only call FinishTokenUpdate when the BackgroundWorker completes. 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 June 6, 2018 Posted June 6, 2018 That sounds like the wrong way to architect this then. Rendering should happen in response to OnRender(). Even rendering in OnSetRenderInfo() isn't the right way to do things anymore now that IsCancelRequested exists. 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
null54 Posted June 6, 2018 Author Posted June 6, 2018 1 hour ago, Rick Brewster said: Even rendering in OnSetRenderInfo() isn't the right way to do things anymore now that IsCancelRequested exists. Unfortunately not all algorithms are compatible with the chunked rendering used by OnRender. The algorithm used by this plugin performs multi-pass rendering on the selected area. After some experimentation I determined that rendering in OnSetRenderInfo and adding an event to the effect class that allows the config dialog to receive the rendering progress appears to be the best approach to fixing the UI responsiveness. This allows Paint.NET to handle the restarting the effect when the token changes while still allowing the dialog to display the rendering progress. 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
null54 Posted June 8, 2018 Author Posted June 8, 2018 Improved the UI responsiveness when changing settings, file version updated to 1.3.0.0. 3 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
MJW Posted June 9, 2018 Posted June 9, 2018 On 6/6/2018 at 8:26 AM, Rick Brewster said: That sounds like the wrong way to architect this then. Rendering should happen in response to OnRender(). Even rendering in OnSetRenderInfo() isn't the right way to do things anymore now that IsCancelRequested exists. IsCancelRequested currently works in OnSetRnderInfo, and at least originally was intended to be pollable from within OnSetRenderInfo: On 12/28/2009 at 11:54 PM, Rick Brewster said: .NET threads will correspond to Win32 threads. The abstraction between "managed thread ID" and "native thread ID" mapping does exist, but it only matters if you are doing custom .NET hosting, e.g. SQL Server. Also, .NET is not a virtual machine or environment, so you are doing yourself a disservice by thinking that way. As a corollary, in Paint.NET you can be sure that a managed thread will not be "migrated" among native threads, or processes. Fibers are never used anywhere. And you're right that Paint.NET has a lot of "ambitious ambiguity" in the contract. However, at this point (5 years later) it's safe to say: 1) OnSetRenderInfo() will always be called first, and always by itself. 2) OnRender() will be called next. The first ROI is always executed by itself. After that, parallelism ensues. Also, the token that is given to the effect is a Clone() of the one from the effect config dialog. From there, each thread used for OnRender() has its own Clone() of the token. So, there is some "bracketing" that takes place. You can be assured that calls to OnSetRenderInfo() and OnRender() will never overlap when drawn on a timeline. Also, in v3.5.2 I am adding an IsCancelRequested property that you can poll from within OnSetRenderInfo() or OnRender(). The guarantee at that point is that when IsCancelRequested flips to true that any "in-flight" OnRender() calls will be discarded. In a future version, I plan to redo the effect system to provide more control over execution and progress reporting type stuff. Basically you'll be given an object to report progress through, and a simple ReadPixels() / WritePixels() interface. From there, additional classes will be provided which will take care of chunking of ROIs, parallelism, etc. But at that point those things will be optional -- great for multipass effects, and also great for effects where a different ROI "chunking" strategy is preferred. I certainly hope it will always work in OnSetRenderInfo. As null54 points out, there are many very useful algorithms that require the entire canvas be processed at once, not in randomly-ordered pieces. Quote
Rick Brewster Posted June 9, 2018 Posted June 9, 2018 I don't remember if IsCancelRequested works during OnSetRenderInfo. If it does, then everything's fine. Otherwise you won't be able to cancel out of your rendering until the first OnRender() call, which will be too late to maintain a good user experience. 1 Quote The Paint.NET Blog: https://blog.getpaint.net/ Donations are always appreciated! https://www.getpaint.net/donate.html
MJW Posted June 9, 2018 Posted June 9, 2018 IsCancelRequested works in OnSetRenderInfo. I tested it to make sure processing in OnSetRenderInfo is aborted when a control is changed. Perhaps I should say it worked as of Nov. 2016, since that's when I ran the test. 1 1 Quote
alexo Posted July 10, 2018 Posted July 10, 2018 Getting errors when using lasso selected regions: File: C:\Program Files\paint.net\Effects\ContentAwareFill.dll Name: ContentAwareFill.ContentAwareFillEffect Version: 1.3.0.0 Author: null54 Copyright: Copyright © 2018 Nicholas Hayes (aka null54) Website: https://forums.getpaint.net/index.php?showtopic=112730 Full error message: PaintDotNet.WorkerThreadException: Worker thread threw an exception ---> System.NullReferenceException: Object reference not set to an instance of an object. at ContentAwareFill.ContentAwareFillEffect.OnConfigDialogProgress(Int32 value) at ContentAwareFill.Resynthesizer.Synthesize(Int32 pass, Func`1 abortCallback) at ContentAwareFill.Resynthesizer.ContentAwareFill(Func`1 abortCallback) at ContentAwareFill.ContentAwareFillEffect.OnSetRenderInfo(EffectConfigToken parameters, RenderArgs dstArgs, RenderArgs srcArgs) at PaintDotNet.Effects.BackgroundEffectRenderer.ThreadFunction() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 225 --- End of inner exception stack trace --- at PaintDotNet.Effects.BackgroundEffectRenderer.DrainExceptions() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 418 at PaintDotNet.Effects.BackgroundEffectRenderer.Abort() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 374 at PaintDotNet.Effects.BackgroundEffectRenderer.Start() in D:\src\pdn\src\PaintDotNet\Effects\BackgroundEffectRenderer.cs:line 320 at PaintDotNet.Menus.EffectMenuBase.<>c__DisplayClass42_5.<RunEffectImpl>b__5() in D:\src\pdn\src\PaintDotNet\Menus\EffectMenuBase.cs:line 1032 Quote
null54 Posted July 10, 2018 Author Posted July 10, 2018 2 hours ago, alexo said: Getting errors when using lasso selected regions: That should be fixed in 1.3.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
Mallaboro Posted September 10, 2018 Posted September 10, 2018 That is really quite phenomenal. So many applications ? Quote
xod Posted October 3, 2018 Posted October 3, 2018 Amazing plugin. Brilliant! Thank you very much @null54. How could I miss such a good plugin? Quote
ReMake Posted October 3, 2018 Posted October 3, 2018 I noticed some bug. Click on the image or on the effect UI when you have this message and then click Cancel button. As a result, we have endless canceling. 1 Quote
null54 Posted October 4, 2018 Author Posted October 4, 2018 17 hours ago, ReMake said: I noticed some bug. Click on the image or on the effect UI when you have this message and then click Cancel button. Fixed in 1.3.2. 21 hours ago, xod said: How could I miss such a good plugin? With the large number of plugins available on this forum it does not surprise me that some may be overlooked, and this is more of a niche plugin than something like Feather or Clipwarp. I do not envy @Ego Eram Reputo's job keeping the plugin index up to date. ? 1 2 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
Gorey Posted January 3, 2019 Posted January 3, 2019 This is a fantastic plugin. Quick question, is there a way to add a shortcut in the GUI for this plugin so you do not need to go to Effects > Selection each time? Thank you. Quote
Ego Eram Reputo Posted January 3, 2019 Posted January 3, 2019 No. The PDN interface cannot be modified in that way. You could bookmark the plugin in the Plugin Browser https://forums.getpaint.net/topic/110458-the-plugin-browser-v1302-sept-28-2018/ Quote ebook: Mastering Paint.NET | resources: Plugin Index | Stereogram Tut | proud supporter of Codelab plugins: EER's Plugin Pack | Planetoid | StickMan | WhichSymbol+ | Dr Scott's Markup Renderer | CSV Filetype | dwarf horde plugins: Plugin Browser | ShapeMaker
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.