What it is
SpriteFinder is a tool that I started developing because I have a lot of spritesheets without any predefined lists of individual sprites’ location and size. Previously I had used Paint to locate the position of and figure out the size of the sprites, which was very time consuming and not that fun.
How to use it
You start by loading a spritesheet, then going into the settings window and choosing the size of the sprites in the spritesheet. If they have varying sizes, you choose “Unknown size” and the algorithm will figure out the sprite sizes for you – though that function only works if there’s at least a 1px space between sprites in the spritesheet.
Next up, you choose how the generated sprite string should look. All that’s left to do at this point is to click “Find Sprites”, and the tool will start figuring out where the sprites are.
Now left click a sprite to add the sprite to the list of sprites, or right click and then left click to merge two sprites (mainly used if there are sprites that have spaces between them).
How it works
The first functioning version simply split the entire spritesheet into 16×16 squares, today I finished work on an algorithm to find sprites no matter the size (it is basically a simpler version of A*). The algorithm currently only works if the sprites have at least 1 px of space between them.
At first, I had a List (Position is a struct containing only X and Y coordinates) of pixels that were part of sprites. The program worked, but checking if a list of well over 30k items contains a specific item.. is very CPU intensive.
Changing the collection that contained all the positions of all the found pixels inside all the found sprites from a List to a HashSet improved the algorithm’s speed by a lot more than > 10x.
Before the change, the tool would, after about 2 seconds, stop responding and not update the UI even though Application.DoEvents() was used. It also took long enough to finish that I felt compelled to change it.
After the change, the entire process actually looks smooth and does the job much faster.
Even spritesheets with individual sprites that contain over 30k pixels work without crashing the program (for reference, 64×64 sprites contain about 4k pixels).