pub fn analyze_spritesheet(
img: &DynamicImage,
gap_threshold: Option<u32>,
) -> SpritesheetInfo
Expand description
Analyze a spritesheet image and return its grid information.
§Arguments
img
- A reference to a DynamicImage representing the spritesheet.gap_threshold
- Optional threshold for gaps between sprites. Defaults to 40.
§Returns
A SpritesheetInfo
struct containing the frame dimensions, grid (columns/rows), and valid frame count.
§Details
This function assumes:
- If the image width is evenly divisible by its height, the sprites are square frames.
- Otherwise, it uses the pixel at
(0, 0)
as the margin/padding color to detect boundaries. - A cell is counted as a valid frame if any pixel inside it is not equal to the margin color.