I have a # of images that I\'m stitching together into a sprite sheet, how can I calculate the number of rows and columns to fit equally in an even rectangle (no blank space
Take a look into Integer Factorization
Maybe that is what you need.