Bitmap border/stroke alogirthm?
The Euclidean Distance Transform can produce dilations and erosions with suitable parameters and filtering.

The algorithm that Photoshop uses, and the one that is best suited for stroking, is to calculate the Euclidean Distance Transform in integers and without taking the square root (i.e. calculate distance squared). This can be made extremely fast using the technique from Meijster.

To get anti-aliasing, just use the fractional part of the number after taking the square root.

For example:

if (distanceSquared &lt; radius * radius)
{
  (fill solid pixel)
}
else
{
   distance = sqrt (distanceSquared);

   if (distance &lt; radius + 1)
   {
     alpha = 1 - (distance - radius);

     (blend pixel at alpha)
   }
}


This techinque is used in my open source library:

https://github.com/vinniefalco/LayerEffects.git