# Quick sprite contouring solutions?

I want to be able to quickly outline sprites(mainly with black, but other colours too) without doing it manually, as pictured. What would be a good program/solution to do so?

Edit: I don't want it to happen at runtime, I just want to have the second version and I can scrap the first.

• Sounds like a lot of processing for something that could be done very easily when creating the sprites for no additional processing. – Shroeder Nov 6 '14 at 15:35
• What do you mean, "very easily"? I need some sort of automated process. – Alex Mitan Nov 8 '14 at 15:44

it's trivial, you can do it yourself. Assuming your sprites have alpha value 0 in unused areas, you can do the following (in pseudocode):

pixels_out = pixels
for y in pixels.height()
for x in pixels.width()
if pixels(x,y).alpha == 0,
neighbour_in_sprite = false
for y2 in [-1,0,1]
for x2 in [-1,0,1]
if pixels(x+x2,y+y2).alpha > 0
neighbour_in_sprite = true
break
if neighbour_in_sprite
break
if neighbour_in_sprite
pixels_out(x,y).color = [0,0,0]
pixels_out(x,y).alpha = 255


It's pretty much, for every unused pixel in the 8-neighbourhood of a used pixel, mark it as silhouette and set the black colour and normal alpha .