Thanks for the help but I already know that. I am talking about how to get the sprite or tile to have the right frame you want so they can be for the top, sides, bottom, and corners like in the picture.
I am not sure how I can get the game to know which is what to make it choose the right frame for the right place like if the sprite or tile needed to be top, side, bottom, or corner frame.
EDIT: To clarify, it is a randomly generated dungeon so I need something that would be able to change the frames to the right ones where they are needed.