1
0
mirror of https://github.com/amitbet/vncproxy.git synced 2025-05-05 14:16:20 +00:00
vncproxy/encodings/enc-raw.go
amit bezalel 007e748c61 added RfbReaderHelper which wraps the connection reader and allows to add listeners like the recorder or proxy
added fbs recorder, and tested it against vine vnc server 5.0.1 and rfbplayer 1.4 —> works! (there is still some problem with tight VNC server)
2017-06-17 11:02:06 +03:00

59 lines
1.7 KiB
Go

package encodings
import (
"vncproxy/common"
)
// RawEncoding is raw pixel data sent by the server.
//
// See RFC 6143 Section 7.7.1
type RawEncoding struct {
//Colors []Color
}
func (*RawEncoding) Type() int32 {
return 0
}
func (*RawEncoding) Read(pixelFmt *common.PixelFormat, rect *common.Rectangle, r *common.RfbReadHelper) (common.Encoding, error) {
//conn := &DataSource{conn: conn.c, PixelFormat: conn.PixelFormat}
//conn := common.RfbReadHelper{Reader:r}
bytesPerPixel := int(pixelFmt.BPP / 8)
//pixelBytes := make([]uint8, bytesPerPixel)
// var byteOrder binary.ByteOrder = binary.LittleEndian
// if conn.PixelFormat.BigEndian {
// byteOrder = binary.BigEndian
// }
//colors := make([]vnc.Color, int(rect.Height)*int(rect.Width))
for y := uint16(0); y < rect.Height; y++ {
for x := uint16(0); x < rect.Width; x++ {
if _, err := r.ReadBytes(bytesPerPixel); err != nil {
return nil, err
}
// var rawPixel uint32
// if conn.PixelFormat.BPP == 8 {
// rawPixel = uint32(pixelBytes[0])
// } else if conn.PixelFormat.BPP == 16 {
// rawPixel = uint32(byteOrder.Uint16(pixelBytes))
// } else if conn.PixelFormat.BPP == 32 {
// rawPixel = byteOrder.Uint32(pixelBytes)
// }
// color := &colors[int(y)*int(rect.Width)+int(x)]
// if conn.PixelFormat.TrueColor {
// color.R = uint16((rawPixel >> conn.PixelFormat.RedShift) & uint32(conn.PixelFormat.RedMax))
// color.G = uint16((rawPixel >> conn.PixelFormat.GreenShift) & uint32(conn.PixelFormat.GreenMax))
// color.B = uint16((rawPixel >> conn.PixelFormat.BlueShift) & uint32(conn.PixelFormat.BlueMax))
// } else {
// *color = conn.ColorMap[rawPixel]
// }
}
}
return &RawEncoding{}, nil
}