mirror of
https://github.com/amitbet/vnc2video.git
synced 2025-09-25 12:23:00 +00:00
initial cursor support (just getting the image and location), not drawing correctly yet
This commit is contained in:
@@ -45,6 +45,7 @@ const (
|
||||
EncJPEGQualityLevelPseudo3 EncodingType = -30
|
||||
EncJPEGQualityLevelPseudo2 EncodingType = -31
|
||||
EncJPEGQualityLevelPseudo1 EncodingType = -32
|
||||
EncPointerPosPseudo EncodingType = -232
|
||||
EncCursorPseudo EncodingType = -239
|
||||
EncXCursorPseudo EncodingType = -240
|
||||
EncDesktopSizePseudo EncodingType = -223
|
||||
|
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/binary"
|
||||
"image/color"
|
||||
"image/draw"
|
||||
"vnc2video/logger"
|
||||
)
|
||||
|
||||
type CursorPseudoEncoding struct {
|
||||
@@ -27,6 +28,7 @@ func (enc *CursorPseudoEncoding) Reset() error {
|
||||
func (*CursorPseudoEncoding) Type() EncodingType { return EncCursorPseudo }
|
||||
|
||||
func (enc *CursorPseudoEncoding) Read(c Conn, rect *Rectangle) error {
|
||||
logger.Debugf("CursorPseudoEncoding.Read: got rect: %v", rect)
|
||||
//rgba := make([]byte, int(rect.Height)*int(rect.Width)*int(c.PixelFormat().BPP/8))
|
||||
numColors := int(rect.Height) * int(rect.Width)
|
||||
colors := make([]color.Color, numColors)
|
||||
@@ -53,7 +55,8 @@ func (enc *CursorPseudoEncoding) Read(c Conn, rect *Rectangle) error {
|
||||
for x := 0; x < int(rect.Width); x++ {
|
||||
offset := y*int(rect.Width) + x
|
||||
if bitmask[y*int(scanLine)+x/8]&(1<<uint(7-x%8)) > 0 {
|
||||
enc.Image.Set(x, y, colors[offset])
|
||||
enc.Image.Set(x+int(rect.X), y+int(rect.Y), colors[offset])
|
||||
//logger.Debugf("CursorPseudoEncoding.Read: setting pixel: (%d,%d) %v", x+int(rect.X), y+int(rect.Y), colors[offset])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -101,7 +101,7 @@ func (z *HextileEncoding) Read(r Conn, rect *Rectangle) error {
|
||||
//logger.Debugf("%v %v", rBounds, bgCol)
|
||||
}
|
||||
rBounds := image.Rectangle{Min: image.Point{int(tx), int(ty)}, Max: image.Point{int(tx) + int(tw), int(ty) + int(th)}}
|
||||
logger.Debugf("filling background rect: %v, col: %v", rBounds, bgCol)
|
||||
//logger.Debugf("filling background rect: %v, col: %v", rBounds, bgCol)
|
||||
FillRect(z.Image, &rBounds, bgCol)
|
||||
|
||||
if (subencoding & HextileForegroundSpecified) != 0 {
|
||||
|
38
encoding_pointer_pos.go
Normal file
38
encoding_pointer_pos.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package vnc2video
|
||||
|
||||
import (
|
||||
"image"
|
||||
"image/draw"
|
||||
"vnc2video/logger"
|
||||
)
|
||||
|
||||
type CursorPosPseudoEncoding struct {
|
||||
prevPosBackup draw.Image
|
||||
prevPositionRect image.Rectangle
|
||||
cursorImage draw.Image
|
||||
Image draw.Image
|
||||
}
|
||||
|
||||
func (*CursorPosPseudoEncoding) Supported(Conn) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (enc *CursorPosPseudoEncoding) SetTargetImage(img draw.Image) {
|
||||
enc.Image = img
|
||||
}
|
||||
|
||||
func (enc *CursorPosPseudoEncoding) Reset() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*CursorPosPseudoEncoding) Type() EncodingType { return EncPointerPosPseudo }
|
||||
|
||||
func (enc *CursorPosPseudoEncoding) Read(c Conn, rect *Rectangle) error {
|
||||
logger.Debugf("CursorPosPseudoEncoding: got cursot pos update: %v", rect)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (enc *CursorPosPseudoEncoding) Write(c Conn, rect *Rectangle) error {
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user