Jump to content
How to Install Plugins ×

Outline Selection


Aziz

Recommended Posts

First plugin, word.

Selection > Outline Selection

Size - The thickness of the border/outline

Outside <-> Inside - Right now, does nothing. Next version this will be removed, since I can't edit pixels outside the range, and I can't increase the size of the selection

Colour - Colour of the border/outline

It's quiet simple actually. The point was to allow me to make an outline outside/inside a highlighted selection. Much like Photoshop's Stroke command which I used to use quiet frequently. The effect simple puts a border of specified width and colour on the current layer.

Currently, this 'effect' only outlines on the inside of the selection, and only works for rectangular, singular selection (as in, not multiple boxes). The plan is to eventually be able to outline inside or outside the box, and if it's even possible, to outline on the canvas everything that is selected.

Right now it's not much more useful than the box tool, as it's just as easy to draw the selection as it is to draw the box. However, it does have some advantages:

- It's gaurenteed to be inside the selection.

- When there's nothing selected, it will outline the entire canvas. Since it works always inside the selection, this is great for adding a border to an image.

- Since it's based off of the selection, you can use the marquee tool to select a specific pixel size box, etc.

Let me know your comments. I can post source, if requested. It wasn't actually that complicated once I got realized what the heck was going on.

Edit: Of course I forgot to upload it.

Just a note, one person had the following error:

1 of 1

--------------

File: C:\Program Files\Paint.NET\Effects\OutlineSelection.dll

Effect Name: OutlineSelection.OutlineSelectionPlugin

Full error message: System.TypeLoadException: Method 'OnCreatePropertyCollection' in type 'OutlineSelection.OutlineSelectionPlugin' from assembly 'OutlineSelection, Version=1.0.3055.21360, Culture=neutral, PublicKeyToken=null' does not have an implementation.

I don't think this is because of my plugin, but if more people experience it, let me know, and I'll see if the .dll got corrupt. The actual code is pretty simple so I don't think there's a bug in it.

Copyright notice: This work is copyright me, Anthony Aziz. Feel free to use it or distribute it however you like, as long as you give credit back to me. The exception is that this plugin may not be sold in any way.

OutlineSelection.zip

Link to comment
Share on other sites

Looks good I s'pose. More than anything it seems like a plugin to grasp Paint.NET's Effects API so I hope you have learned something. This is better than anything I am currenty able to make :oops:

signature.png

Link to comment
Share on other sites

It doesn't work with irregular selections.

I hope that falls under "The above post contains sarcasm" :roll: :

Currently, this 'effect' only outlines on the inside of the selection, and only works for rectangular, singular selection (as in, not multiple boxes
Looks good I s'pose. More than anything it seems like a plugin to grasp Paint.NET's Effects API so I hope you have learned something. This is better than anything I am currenty able to make :oops:

It was my first plugin, and did help me grasp the Effects API. Though I only did it because I needed the effect :P I don't know about anyone else, but personally I'll be using this a lot.

Link to comment
Share on other sites

It doesn't work with irregular selections.

I hope that falls under "The above post contains sarcasm" :roll: :

Oops! I missed that.

Here is a version that does work on complex selections.

It is not based on your code... just your idea.

It is limited to single pixel width lines. Here is the source:

// Author: BoltBait
// Submenu: Selection
#region UICode
ColorBgra Amount1 = ColorBgra.FromBgr(0,0,255); // Outline Color
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
   ColorBgra CurrentPixel;
   for(int y = rect.Top; y     {
       for (int x = rect.Left; x         {
           CurrentPixel = src[x,y];
           if ( (x>0 && x0 && y            {
               if ((!selectionRegion.IsVisible(x-1, y) ||
                    !selectionRegion.IsVisible(x, y-1) ||
                    !selectionRegion.IsVisible(x+1, y) ||
                    !selectionRegion.IsVisible(x, y+1)
                  ))
               {
                   CurrentPixel=Amount1;
               }
           }
           else
           {
               CurrentPixel=Amount1;
           }
           dst[x,y] = CurrentPixel;
       }
   }
}

I will leave it up to you to add back in the line width... ;)

Link to comment
Share on other sites

Heh, sorry I guess I should've looked to see if someone else had done this. I guess mine does allow thicker borders at the expense of only doing rectagular selections. I read your post about finding the edge of an object based on looking at its neighbours. Though, at least in this situation, wouldn't it be better to look in 8 directions rather than 4? It's nice to know how to get the entire selected region and deal with it now, too. Thanks!

Link to comment
Share on other sites

Here is another version of the one I posted above. It includes outline width and works with complex selections:

BoltBaitOutlineSelection.zip

And, here is the source (ugly, I know):

// Author: BoltBait
// Submenu: Selection
#region UICode
int Amount1 = 2; // [1,10] Outline Width
ColorBgra Amount2 = ColorBgra.FromBgr(0,0,0); // Outline Color
#endregion

void Render(Surface dst, Surface src, Rectangle rect)
{
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
   ColorBgra CurrentPixel;
   int Width=Amount1*2;  
   int m,n;      
   for(int y = rect.Top; y     {
       for (int x = rect.Left; x         {
           CurrentPixel = src[x,y];
           for (int v=0; v            {
               m = y-(Width/2)+v;
               if (m                {
                   m=0;
                   CurrentPixel = Amount2;
               }
               if (m>=src.Height)
               {
                   m=src.Height;
                   CurrentPixel = Amount2;
               }                                                        
               for (int w=0; w                {
                   n = x-(Width/2)+w;
                   if (n                    {
                       n=0;
                       CurrentPixel = Amount2;
                   }                                                                            
                   if (n>=src.Width)
                   {
                       n=src.Width;
                       CurrentPixel = Amount2;
                   }                                                                    
                   if (!selectionRegion.IsVisible(n,m))
                       CurrentPixel = Amount2;
               }
           }                                                                
           dst[x,y] = CurrentPixel;
       }
   }
}

Anti-aliasing is an exercise left up to the reader. :P

Link to comment
Share on other sites

I believe that's why he showed the code to you but do be sure to give credit. After all, this is a open source community. Nice plugin by the way, I've already found it to be useful.

Link to comment
Share on other sites

Wow, taking me to school or what. Is it any problem if I use any of that in my code? I won't re-release it, as you already have, but more so for learning/using it myself.

I am giving this code to you.

I will not be publishing it on my own site or plugin pack in its current state (and probably never).

Any of the advanced coders can tell you that there are some obvious optimizations that should be made before it is ready for release.

Seriously, I only wrote this in order to teach you how to do it.

Link to comment
Share on other sites

i actually was looking for a plugin that did this a couple days ago to help clean up a few of my sketches i cant wait for it to be up and working at a decent speed :D

the artist formerly known as recon04

th_1210908099158.gif

Link to comment
Share on other sites

i was refering about boltbaits once u optimize it

i made the coin in my avi with ur plugin dll tho :D it made it real simple

the artist formerly known as recon04

th_1210908099158.gif

Link to comment
Share on other sites

  • 6 months later...
  • 6 years later...

I hate to effectively "bump" this thread, but what I see here is something I've been looking for for a long time, selection expansion/contraction.

You say that you have an "outside selection" option for the outline, but you don't know how to edit the selection to expand.

I thought about it this way, I don't know coding so I don't know how to translate this, but here goes.

Expanding a selection:
If a pixel is adjacent to a selected pixel, it then becomes a selected pixel.
Re-iterate this as many times as the user inputs.
New expanded selection is made.

Similarly, this works for contraction:
If a selected pixel is adjacent to a non-selected pixel, it then becomes an unselected pixel.
Re-iterate as needed.
New contracted selection is made.

I would like to take this on myself if nobody wanted to, but I have no idea where to read up on this kind of thing.

Edited by kaseykahnego9
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.

Guest
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...