Sign in to follow this  
moc426

Border / Stroke Effect Updated 5/21/2007

Recommended Posts

This "effect" will draw a border around image or selection with your primary color. This is like the feature in photoshop were you can "stroke" a selection. It had option to stroke outside, middle or inside. This does inside only. Perhaps I can make changes to give those options. Other enhancement would be so it can work with circular and lasso selections, not sure how I can do that yet.

Simple process, has a size from 1-25 and an option to make it dashed.

After border is created, distort and blur effects can be used to make it look much more interesting, that is were you get creative.

DLL is here - Effect is under Render -> Border.

Here are some screenshots with descriptions of what I remembered being applied:

Normal

ss1_1.jpg

Dashed

ss2_1.jpg

Dashed border, Clouds on selection, Waves, Dents

ss4_1.jpg

Dashed border, Clouds on selection, Dents, Curves

ss5_1.jpg

Waves

ss6_1.jpg

Radial Blur

ss7_1.jpg

Edit: Update 5/21/2007

**********************************

Added 2 new modes, since the dashed wasn't really dashed.

- There is now line, broken (old dashed), dotted and dashed.

Increased width option from 0-25 to 0-200.

*new screenshot added below

**********************************

ipodcouponpreview.png

Edit. source code, codelab. Updated source added.

int Amount1=5; //[1,200]Thickness
int Amount2=0; //[0,3]Line      Broken      Dotted      Dashed

void Render(Surface dst, Surface src, Rectangle rect)
{
   // User Interface elements
   int GridSize = Amount1;
bool line = (Amount2 == 0);
   bool broken = (Amount2 == 1);
bool dotted = (Amount2 == 2);
bool dashed = (Amount2 == 3);
   // Other variables
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
   Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();
   ColorBgra CurrentPixel;
   ColorBgra PrimaryColor;
   ColorBgra SecondaryColor;

   // Get the current brush width
bool fill = false;

   // Grab the primary and secondary colors (swapping if specified in the UI)
   PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;
   SecondaryColor = (ColorBgra)EnvironmentParameters.SecondaryColor;


if ( ( dotted ) || ( dashed ) || ( broken ) )
{
	if ( GridSize == 1 )
	{
		GridSize = 2;
	}
}

int fillwidth = GridSize/2;
if ( ( broken ) || ( line ) )
{
	fillwidth = GridSize;
}
// Loop through all the pixels
for(int y = rect.Top; y < rect.Bottom; y++)
{
	for (int x = rect.Left; x < rect.Right; x++)
	{
		// Only work with a pixel if it is selected
		// (this handles convex & concave selections)
		if (selectionRegion.IsVisible(x, y))
		{
			// Get the source pixel
			CurrentPixel = src[x,y];
			fill = false;
			if ( ( x < selection.Left + fillwidth ) || ( x >= selection.Right - fillwidth ) )
			{
				if ( dashed )
				{
					fill = true;
					int div = rect.Top / GridSize;
					bool even = false;
					if ( div % 2 == 0 )
					{
							even = true;
						}

					if ( !even )
					{
							fill = false;
					}

				}
				else if ( ( broken ) || ( dotted ) )
				{
					fill = false;
					int pos = ( selection.Bottom - ( selection.Bottom - y )  ) % (GridSize-1);
					if ( ( pos == 0 ) || ( pos < GridSize/2 ) )
					{
						fill = true;
					}
				}
				else
				{
					fill = true;
				}
			}
			else if ( (  y <= selection.Top + fillwidth ) || ( y >= selection.Bottom - fillwidth ) )
			{
				if ( dashed )
				{
					fill = true;

					int div = (x - fillwidth) / GridSize;
					bool even = false;
					if ( div % 2 == 0 )
					{
							even = true;
						}

					if ( !even )
					{
							fill = false;
					}
				}
				else if ( ( broken ) || ( dotted ) )
				{
					fill = false;
					int pos = ( selection.Right - ( selection.Right - x )  ) % (GridSize-1);
					if ( ( pos == 0 ) || ( pos < GridSize/2 ) )
					{
						fill = true;
					}
				}
				else
				{
					fill = true;
				}
			}

			if ( fill )
			{
				CurrentPixel.R = (byte)PrimaryColor.R;
				CurrentPixel.G = (byte)PrimaryColor.G;
				CurrentPixel.B = (byte)PrimaryColor.B;
				CurrentPixel.A = (byte)PrimaryColor.A;
			}
			// Save the (modified?) pixel
			dst[x,y] = CurrentPixel;
		}
	}
}

}

Share this post


Link to post
Share on other sites

This will come to good use. Nice for simple image editing.

So can I use it for the Plugin Pack I'm working on (supposing I was to finish it)?

Share this post


Link to post
Share on other sites

Neat, as uH said this will indeed come in handy. Well done.

May I ask, what's your screen resolution?

Share this post


Link to post
Share on other sites
Neat, as uH said this will indeed come in handy. Well done.

May I ask, what's your screen resolution?

It looks like the same as mine-- 1280x1024 (I can tell by looking at the resolution of his picture).

@Akkarins_Spirit: Your sig is way to high.

Share this post


Link to post
Share on other sites

Correct 1280x1024, I want a wide screen monitor!

Neat, as uH said this will indeed come in handy. Well done.

May I ask, what's your screen resolution?

It looks like the same as mine-- 1280x1024 (I can tell by looking at the resolution of his picture).

@Akkarins_Spirit: Your sig is way to high.

Share this post


Link to post
Share on other sites

Finally! A border plug-in. Thanks so much Madjik! I've been waiting a long time for one of these. I did find a bug: If you try to add a border to a circle, it turns out as a square with the corners cut off.

Share this post


Link to post
Share on other sites
I did find a bug: If you try to add a border to a circle, it turns out as a square with the corners cut off.

Thus, his original post:

...Other enhancement would be so it can work with circular and lasso selections, not sure how I can do that yet...

:D

Share this post


Link to post
Share on other sites

As boltbait said, btw I am not Madjik.

Finally! A border plug-in. Thanks so much Madjik! I've been waiting a long time for one of these. I did find a bug: If you try to add a border to a circle, it turns out as a square with the corners cut off.

Share this post


Link to post
Share on other sites

Sorry didn't see your question. Sure you can use it.

This will come to good use. Nice for simple image editing.

So can I use it for the Plugin Pack I'm working on (supposing I was to finish it)?

Share this post


Link to post
Share on other sites

Is there any possible way we could use this effect to outline objects instead of the work itself? Not sure if you understand what I mean, if you don't, ask, and if you do, please help me out. It would be greatly appreciated. :)

Share this post


Link to post
Share on other sites
Finally! A border plug-in. Thanks so much Madjik! I've been waiting a long time for one of these. I did find a bug: If you try to add a border to a circle, it turns out as a square with the corners cut off.

I felt I had something to do with it!

Try this with codelab:

(only for square/rectangle selections/images)

int Amount1=2;	//[0,100]Distance from the edge
int Amount2=2;	//[0,100]Border width

void Render(Surface dst, Surface src, Rectangle rect)
{
   PdnRegion selectionRegion = EnvironmentParameters.GetSelection(src.Bounds);
   Rectangle selection = this.EnvironmentParameters.GetSelection(src.Bounds).GetBoundsInt();

   long MaxX = (long)(selection.Right - selection.Left);
   long MaxY = (long)(selection.Bottom - selection.Top);
   ColorBgra PrimaryColor = (ColorBgra)EnvironmentParameters.PrimaryColor;

   ColorBgra CurrentPixel;
   for(int y = rect.Top; y < rect.Bottom; y++)
   {
       for (int x = rect.Left; x < rect.Right; x++)
       {
           if (selectionRegion.IsVisible(x, y))
           {
               CurrentPixel = src[x,y];
               if ((x>=Amount1) && (x=Amount1)  && (y                if ((x>=MaxX - Amount1 - Amount2) && (x=Amount1)  && (y                if ((x>=Amount1) && (x=Amount1)  && (y                if ((x>=Amount1) && (x=MaxY - Amount1 - Amount2) && (y                dst[x,y] = CurrentPixel;
           }
       }
   }
}

Share this post


Link to post
Share on other sites

Not quite sure what you mean here, but if you mean I used your code as reference, I actually used boltbait's GridMaker for this one. If it makes any difference, I have referenced your code for a new plugin I am working on, as well as other code posted here by other members.

I think dragonpyro wants a border around a circular selection, pyrochild's shape thing plugin can do that -> http://paintdotnet.12.forumer.com/viewtopic.php?p=43191

Finally! A border plug-in. Thanks so much Madjik! I've been waiting a long time for one of these. I did find a bug: If you try to add a border to a circle, it turns out as a square with the corners cut off.

I felt I had something to do with it!

Try this with codelab:

(only for square/rectangle selections/images)

Share this post


Link to post
Share on other sites
Not quite sure what you mean here...

No pb! All code I could post here is for any forumer to use.

BTW I'm not saying you have used my code.

I think there is a missundertanding between our names by someone.

So as an answer I tried something to create a border (from scratch)...

Share this post


Link to post
Share on other sites

I'm sorry, but I'm new to all of this, and for some reason, this plugin is in a different format that the others I've downloaded from here, and for some reason my computer won't open the file..

EDIT: Oops.. Silly me :roll: It works now

Share this post


Link to post
Share on other sites

srry for renewing an old post but wen i try to move this dll to

my paint.net>effects... it doesnt work... wen i tried to do this tut: viewtopic.php?f=15&t=5505

i also needed the shape3d and when i did save as... for the dll into the file it didnt work either

but when i Dl'ed the zip file, and extracted it to that it worked fine.. so iono if this works but

can you make a zip file for this? for some reason my effects dont show it =[

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