修改原始图像质量的传输方式

This commit is contained in:
lwch
2021-11-02 17:44:10 +08:00
parent c6f4ed4572
commit 650ceda05e
2 changed files with 11 additions and 0 deletions
+1
View File
@@ -101,6 +101,7 @@ func (v *VNC) localRead(ctx context.Context, local *websocket.Conn, remote *pool
case "mouse":
v.mouseEvent(remote, data)
case "keyboard":
v.keyboardEvent(remote, data)
case "cad":
}
}
+10
View File
@@ -165,6 +165,11 @@ func (link *Link) sendAll(img *image.RGBA) {
}
rect := image.Rect(x, y, x+width, y+height)
next := img.SubImage(rect)
if link.quality == 100 {
link.remote.SendVNCImage(link.target, link.targetIdx, link.id,
screen, rect, network.VncImage_raw, next.(*image.RGBA).Pix)
continue
}
buf.Reset()
err := jpeg.Encode(&buf, next, &jpeg.Options{Quality: int(link.quality)})
if err == nil {
@@ -184,6 +189,11 @@ func (link *Link) sendDiff(img *image.RGBA) {
var buf bytes.Buffer
for _, block := range blocks {
next := img.SubImage(block)
if link.quality == 100 {
link.remote.SendVNCImage(link.target, link.targetIdx, link.id,
screen, block, network.VncImage_raw, next.(*image.RGBA).Pix)
continue
}
buf.Reset()
err := jpeg.Encode(&buf, next, &jpeg.Options{Quality: int(link.quality)})
if err == nil {