Documentation ¶
Overview ¶
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.
Index ¶
- func Decode(r io.Reader) (image.Image, error)
- func DecodeConfig(r io.Reader) (image.Config, error)
- func DecodeConfigAll(r io.Reader) ([]image.Config, error)
- func DecodeOne(r io.ReadSeeker, which int) (image.Image, error)
- func DecodeOnePic(r io.ReadSeeker, which int) (image.Image, error)
- func DecodeUpcoming(r io.Reader) (image.Image, error)
- func Encode(w io.Writer, m image.Image, o *Options) error
- type ColorKey
- type Header
- type Options
- type SpriteSet
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeConfig ¶
DecodeConfig returns the image.Config (width, height, colormodel) for the first image in either spriteset or picture file.
func DecodeConfigAll ¶ added in v0.0.6
DecodeConfigAll is not implemented, but would be useful for PICs.
It would return the dimensions of each of the images in the PIC file, or 32x32 for all images in the SPR file.
func DecodeOne ¶
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.
Example ¶
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 { panic(err.Error()) } defer f.Close() img, err := DecodeOne(f, 423) if err != nil { fmt.Printf("failed to decode spr: %s", err) return } pngf, err := os.Create(os.TempDir() + "/423.png") if err != nil { fmt.Printf("failed to open %q for write", os.TempDir()+"/423.png") return } png.Encode(pngf, img) f.Close() fmt.Printf("image: %dx%d\n", img.Bounds().Size().X, img.Bounds().Size().Y)
Output: image: 32x32
func DecodeOnePic ¶
DecodeOnePic behaves like DecodeOne, except it accepts .pic formatted files.
func DecodeUpcoming ¶
DecodeUpcoming decodes a single block of spr-format data. This is used in both pic and spr files.
Types ¶
type SpriteSet ¶
type SpriteSet struct { Header // contains filtered or unexported fields }
func DecodeAll ¶
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.