vncproxy/encodings/enc-zrle.go
Yoan Blanc 11b1d45ce9
global: make the whole package go mod ready
Signed-off-by: Yoan Blanc <yoan.blanc@exoscale.ch>
2018-11-30 09:40:45 +01:00

39 lines
704 B
Go

package encodings
import (
"bytes"
"encoding/binary"
"io"
"github.com/amitbet/vncproxy/common"
)
type ZRLEEncoding struct {
bytes []byte
}
func (z *ZRLEEncoding) Type() int32 {
return 16
}
func (z *ZRLEEncoding) WriteTo(w io.Writer) (n int, err error) {
return w.Write(z.bytes)
}
func (z *ZRLEEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.IEncoding, error) {
bytes := &bytes.Buffer{}
len, err := r.ReadUint32()
if err != nil {
return nil, err
}
binary.Write(bytes, binary.BigEndian, len)
bts, err := r.ReadBytes(int(len))
if err != nil {
return nil, err
}
StoreBytes(bytes, bts)
z.bytes = bytes.Bytes()
return z, nil
}