Version: v0.0.5 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2022 License: GPL-2.0 Imports: 8 Imported by: 0



Package spr implements a reader for individual sprites in a Tibia.spr files.

A higher level implementation needs to be used together with the dataset information on a thing's graphics layout and sprites in order to actually construct a full recognizable image.

Since .pic format also uses the same encoder, it can be used as a basis for a .pic decoder.




This section is empty.


This section is empty.


func Decode

func Decode(r io.Reader) (image.Image, error)

func DecodeConfig

func DecodeConfig(r io.Reader) (image.Config, error)

func DecodeOne

func DecodeOne(r io.ReadSeeker, which int) (image.Image, error)

DecodeOne accepts an io.ReadSeeker positioned at the beginning of a spr-formatted file (a sprite set file), finds the image with passed index, and returns the requested image as an image.Image.


ExampleDecodeOne decodes a single spr, encodes it into a png, and prints out the image size.

var err error
f, err := paths.Open("Tibia.spr")
if err != nil {
defer f.Close()

img, err := DecodeOne(f, 423)
if err != nil {
	fmt.Printf("failed to decode spr: %s", err)
pngf, err := os.Create(os.TempDir() + "/423.png")
if err != nil {
	fmt.Printf("failed to open %q for write", os.TempDir()+"/423.png")
png.Encode(pngf, img)

fmt.Printf("image: %dx%d\n", img.Bounds().Size().X, img.Bounds().Size().Y)

image: 32x32

func DecodeOnePic

func DecodeOnePic(r io.ReadSeeker, which int) (image.Image, error)

DecodeOnePic behaves like DecodeOne, except it accepts .pic formatted files.

func DecodeUpcoming

func DecodeUpcoming(r io.Reader) (image.Image, error)

DecodeUpcoming decodes a single block of spr-format data. This is used in both pic and spr files.

func Encode

func Encode(w io.Writer, m image.Image, o *Options) error


type ColorKey

type ColorKey struct{ ColorKeyR, ColorKeyG, ColorKeyB uint8 }
type Header struct {
	Signature   uint32
	SpriteCount uint16

type Options

type Options struct{}

type SpriteSet

type SpriteSet struct {
	// contains filtered or unexported fields

func DecodeAll

func DecodeAll(r io.Reader) (*SpriteSet, error)

DecodeAll decodes all images in the passed reader, and returns a sprite set.

It is currently implemented as an in-memory buffer which can be queried to return a particular sprite.

func (*SpriteSet) EncodeAll

func (s *SpriteSet) EncodeAll(w io.Writer) error

EncodeAll encodes all images in the sprite set and writes them to the passed writer.

It is currently not implemented.

func (*SpriteSet) Image

func (s *SpriteSet) Image(idx int) image.Image

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL