← back to roto on ba3a.dev

AseCodec

object AseCodec

Reads and writes AseSprites as Aseprite .ase files, readable by Aseprite and LibreSprite.

Only indexed-colour sprites are supported. The same sprite always encodes to the same bytes, and reading what was written gives back an equal sprite. Reading also accepts the files those editors save after an artist has worked on them; anything outside the AseSprite subset fails with an AseFormatException that names the feature.

Functions

Link copied to clipboard

Reads a sprite from input, which is read to its end but not closed.

fun read(path: Path): AseSprite

Reads the sprite saved at path.

Link copied to clipboard
fun write(sprite: AseSprite, output: OutputStream)

Writes sprite to output, which is not closed.

fun write(sprite: AseSprite, path: Path)

Writes sprite to path through AtomicFile, so a crash never leaves a half-written file.