Jump to content

Can a plugin alter the "selection" object itself? (as in "Grow/Shrink Selection")

Recommended Posts

I'm new here: I often read forums, but usually avoid posting (I feel it's bad form to do a disappearing act when my interests change, which they frequently do). However, after perusing the available plugins (especially the ones that offer a peek at the code), various forum discussions, as well as some of the object definitions in the PaintDotNet.Effects dll over the past few days I'm no closer to figuring out the answer on my own, so it seems I have to bug other people with it.


Yes, I'm aware of the "plugins may not modify canvas outside the selected region" rule, and I'm also aware that it's (possibly?) no longer in force (as several officially published plugins do that), though if that's been made official, I've failed to find where. I've seen some discussions on moving/rotating selections, but couldn't really tell from the context whether the point was to move/rotate the constituent pixels or the region itself. It appears no one has tried to create a Grow/Shrink Selection plugin, or even suggested that would be useful functionality to have - or, at least, my every attempt to find this topic came up empty.


I suppose I should explain why I want one so much. A few years ago I made extensive use of Paint.Net to edit a large number of photos of a jewelry collection I created - and seeing as I really suck at photography, the editing was meant to make up for this shortfall and make the images look less sad (and closer to what the jewelry looks like "in person"). I gave up eventually - it was more work than I could handle: after a few months of concerted effort, the results were better, but still not good enough, plus all the clicking gave me tennis elbow, and a serious ergonomic hardware upgrade wasn't in the budget. In retrospect, having a simple way to increase/decrease the size of a selection (say, obtained with the Magic Wand tool) by 1-5 pixels, rather than having to employ various tricks (involving blurring mask layers, outlining selections, etc) to achieve the same end would have made a huge productivity difference.


While this particular use case is no longer relevant to me, I assume it may still be relevant to someone attempting a large volume of photo-editing with limited resources. It's possible I'll be needing it again in the future as well. I've noticed that it's now possible to outline the "outside" of a selection, and a plugin already exists for that, so that does offer more of a shortcut, in case the answer to my question is "NO" (i.e. the selected region is a private object owned by the application and plugins may not update it.)


At the moment, the main relevance of creating a plugin to me personally is just as a training exercise. I'm not new to programming, but I haven't touched .Net or C# for a little over a decade, and they've both changed A LOT since then. I'm also (mostly) a graphics newb (coding them, not using them) - my only experience being limited to a few p5js generative art sketches. Since I learn best by doing, and made-up exercises, lacking real-world stakes/constraints, just don't cut it, I've had to think of a real use-case, and I'm afraid creating some plugins for Paint.Net was all I could come up with. The grow/shrink selection functionality, however, is only a convenient first target, because it bugged me once upon a time not to have had it; if it turns out to be off limits, I'll figure out something else that might be of use.


All comments/suggestions are welcome and appreciated.


Edited by AnneYusual
Link to comment
Share on other sites

Plugins can now officially write outside the selection, though I believe that's limited to the two new-fangled varieties, not the "classic" plugin we know and love. Fortunately, one of the new style of plugins can do the things the old-style plugins can do. So far though, unless I somehow missed it, plugins still can't change the selection. You can write a modified selection to the clipboard, then load it with Paste Selection, but obviously that's a bit awkward and inflexible.



  • You're a Smart Cookie! 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...