From 89ff8ac9e383071f75e750ca3866c67d14a28792 Mon Sep 17 00:00:00 2001 From: betzalel Date: Mon, 12 Jun 2017 18:56:50 +0300 Subject: [PATCH] added coRRE --- vnc/enc-rre.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/vnc/enc-rre.go b/vnc/enc-rre.go index 344f3c5..2b58811 100644 --- a/vnc/enc-rre.go +++ b/vnc/enc-rre.go @@ -25,3 +25,45 @@ func (z *RREEncoding) Read(conn *ClientConn, rect *Rectangle, r io.Reader) (Enco } return z, nil } + +type CoRREEncoding struct { + Colors []Color +} + +func (z *CoRREEncoding) Type() int32 { + return 4 +} + +func (z *CoRREEncoding) Read(conn *ClientConn, rect *Rectangle, r io.Reader) (Encoding, error) { + + bytesPerPixel := int(conn.PixelFormat.BPP / 8) + numOfSubrectangles, _ := conn.readUint32() + + //read whole rect background color + conn.readBytes(bytesPerPixel) + + //read all individual rects (color=BPP + x=16b + y=16b + w=16b + h=16b) + _, err := conn.readBytes(int(numOfSubrectangles) * (bytesPerPixel + 4)) + + if err != nil { + return nil, err + } + return z, nil + + //int nSubrects = rfb.readU32(); + + //byte[] bg_buf = new byte[bytesPerPixel]; + //rfb.readFully(bytesPerPixel); + //Color pixel; + // if (bytesPixel == 1) { + // pixel = colors[bg_buf[0] & 0xFF]; + // } else { + // pixel = new Color(bg_buf[2] & 0xFF, bg_buf[1] & 0xFF, bg_buf[0] & 0xFF); + // } + // memGraphics.setColor(pixel); + // memGraphics.fillRect(x, y, w, h); + + // byte[] buf = new byte[nSubrects * (bytesPixel + 4)]; + // rfb.readFully(buf); + +}