Sign in to follow this  
Followers 0
Aziz

Outline Selection

29 posts in this topic

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

0

Share this post


Link to post
Share on other sites

Of course! I've got a couple more in mind, too.

0

Share this post


Link to post
Share on other sites

It doesn't work with irregular selections.

0

Share this post


Link to post
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:

0

Share this post


Link to post
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.

0

Share this post


Link to post
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... ;)

0

Share this post


Link to post
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!

0

Share this post


Link to post
Share on other sites

I find that 4 directions is enough. I did a bunch of research around this issue when I was first woring on my Feather plugin. In fact, that is how my Feather plugin used to work. (It is much less complicated now.)

0

Share this post


Link to post
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

0

Share this post


Link to post
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.

0

Share this post


Link to post
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.

0

Share this post


Link to post
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.

0

Share this post


Link to post
Share on other sites

Right on, thanks. I'll look into that 'optimization' myself.

0

Share this post


Link to post
Share on other sites

seems handy *downloads*

0

Share this post


Link to post
Share on other sites

Yeah, while it's not complex or unique, it certainly is very handy.

0

Share this post


Link to post
Share on other sites
Yeah, while it's not complex or unique, it certainly is very handy.

yups :)

0

Share this post


Link to post
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

0

Share this post


Link to post
Share on other sites

Up and working at a decent speed? >_> It's slow? Or are you referring to BoltBait's additions? I should have some time today to put together a new version.

0

Share this post


Link to post
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

0

Share this post


Link to post
Share on other sites

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
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0