func Decode(r io.Reader) (outImage image.Image, err error) {
	var data bytes.Buffer

	if _, err = data.ReadFrom(r); err != nil {
		return
	}

	b := data.Bytes()

	if len(b) < 100 {
		err = ErrFormat
		return
	}

	nameLen := bytes.IndexByte(b, 0)
	if nameLen < 0 || nameLen > 32 {
		nameLen = 32
	}
	name := string(b[:nameLen])

	w := int(LittleEndian.Uint32(b[32:]))
	h := int(LittleEndian.Uint32(b[36:]))
	flags := SurfFlags(LittleEndian.Uint32(b[88:]))
	contents := Contents(LittleEndian.Uint32(b[92:]))
	value := LittleEndian.Uint32(b[96:])

	nextLen := bytes.IndexByte(b[56:], 0)
	if nextLen < 0 || nextLen > 32 {
		nextLen = 32
	}
	nextName := string(b[56 : 56+nextLen])

	b = b[100:]

	if w*h > len(b) {
		err = ErrFormat
	} else {
		rect := image.Rect(0, 0, w, h)
		outImage = &WAL{
			&image.Paletted{
				Pix:     b,
				Stride:  w,
				Rect:    rect,
				Palette: Palette,
			},
			name,
			nextName,
			flags,
			contents,
			value,
		}
	}

	return
}
// Decode decodes a WAL image.
Decode decodes a WAL image.
// Decode decodes a WAL image .
func Decode(r io.Reader) (outImage image.Image, err error) {
	var data bytes.Buffer
	if _, err = data.ReadFrom(r); err != nil {
		return
	}
	b := data.Bytes()
	if len(b) < 100 {
		err = ErrFormat
		return
	}
	nameLen := bytes.IndexByte(b, 0)
	if nameLen < 0 || nameLen > 32 {
		nameLen = 32
	}
	name := string(b[:nameLen])
	w := int(LittleEndian.Uint32(b[32:]))
	h := int(LittleEndian.Uint32(b[36:]))
	flags := SurfFlags(LittleEndian.Uint32(b[88:]))
	contents := Contents(LittleEndian.Uint32(b[92:]))
	value := LittleEndian.Uint32(b[96:])
	nextLen := bytes.IndexByte(b[56:], 0)
	if nextLen < 0 || nextLen > 32 {
		nextLen = 32
	}
	nextName := string(b[56 : 56+nextLen])
	b = b[100:]
	if w*h > len(b) {
		err = ErrFormat
	} else {
		rect := image.Rect(0, 0, w, h)
		outImage = &WAL{
			&image.Paletted{
				Pix:     b,
				Stride:  w,
				Rect:    rect,
				Palette: Palette,
			},
			name,
			nextName,
			flags,
			contents,
			value,
		}
	}
	return
}
func Decode ( r io . Reader ) ( outImage image . Image , err error ) { var data bytes . Buffer if _ , err = data . ReadFrom ( r ) ; err != nil { return } b := data . Bytes ( ) if len ( b ) < 100 { err = ErrFormat return } nameLen := bytes . IndexByte ( b , 0 ) if nameLen < 0 || nameLen > 32 { nameLen = 32 } name := string ( b [ : nameLen ] ) w := int ( LittleEndian . Uint32 ( b [ 32 : ] ) ) h := int ( LittleEndian . Uint32 ( b [ 36 : ] ) ) flags := SurfFlags ( LittleEndian . Uint32 ( b [ 88 : ] ) ) contents := Contents ( LittleEndian . Uint32 ( b [ 92 : ] ) ) value := LittleEndian . Uint32 ( b [ 96 : ] ) nextLen := bytes . IndexByte ( b [ 56 : ] , 0 ) if nextLen < 0 || nextLen > 32 { nextLen = 32 } nextName := string ( b [ 56 : 56 + nextLen ] ) b = b [ 100 : ] if w * h > len ( b ) { err = ErrFormat } else { rect := image . Rect ( 0 , 0 , w , h ) outImage = & WAL { & image . Paletted { Pix : b , Stride : w , Rect : rect , Palette : Palette , } , name , nextName , flags , contents , value , } } return }
Decode decodes a WAL image.
Decode decodes a WAL image .