mirror of
https://github.com/amitbet/vnc2video.git
synced 2025-08-11 17:31:50 +00:00
fixed fill filter in tight encoding
This commit is contained in:
parent
5c0f72a0cb
commit
fa9cdf83be
@ -69,6 +69,7 @@ const (
|
|||||||
EncClientRedirect EncodingType = -311
|
EncClientRedirect EncodingType = -311
|
||||||
EncFencePseudo EncodingType = -312
|
EncFencePseudo EncodingType = -312
|
||||||
EncContinuousUpdatesPseudo EncodingType = -313
|
EncContinuousUpdatesPseudo EncodingType = -313
|
||||||
|
EncExtendedClipboardPseudo EncodingType = -1063131698 //C0A1E5CE
|
||||||
)
|
)
|
||||||
|
|
||||||
var bPool = sync.Pool{
|
var bPool = sync.Pool{
|
||||||
|
@ -63,7 +63,7 @@ func (enc *TightEncoding) Write(c Conn, rect *Rectangle) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Read unmarshal color from conn
|
// Read unmarshal color from conn
|
||||||
func getTightColor(c io.Reader, pf *PixelFormat) (*color.RGBA64, error) {
|
func getTightColor(c io.Reader, pf *PixelFormat) (*color.RGBA, error) {
|
||||||
if pf.TrueColor == 0 {
|
if pf.TrueColor == 0 {
|
||||||
return nil, errors.New("support for non true color formats was not implemented")
|
return nil, errors.New("support for non true color formats was not implemented")
|
||||||
}
|
}
|
||||||
@ -76,11 +76,11 @@ func getTightColor(c io.Reader, pf *PixelFormat) (*color.RGBA64, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
rgb := color.RGBA64{
|
rgb := color.RGBA{
|
||||||
R: uint16(tbytes[0]),
|
R: uint8(tbytes[0]),
|
||||||
G: uint16(tbytes[1]),
|
G: uint8(tbytes[1]),
|
||||||
B: uint16(tbytes[2]),
|
B: uint8(tbytes[2]),
|
||||||
A: uint16(1),
|
A: uint8(1),
|
||||||
}
|
}
|
||||||
return &rgb, nil
|
return &rgb, nil
|
||||||
}
|
}
|
||||||
@ -106,10 +106,11 @@ func getTightColor(c io.Reader, pf *PixelFormat) (*color.RGBA64, error) {
|
|||||||
pixel = uint32(px)
|
pixel = uint32(px)
|
||||||
}
|
}
|
||||||
|
|
||||||
rgb := color.RGBA64{
|
rgb := color.RGBA{
|
||||||
R: uint16((pixel >> pf.RedShift) & uint32(pf.RedMax)),
|
R: uint8((pixel >> pf.RedShift) & uint32(pf.RedMax)),
|
||||||
G: uint16((pixel >> pf.GreenShift) & uint32(pf.GreenMax)),
|
G: uint8((pixel >> pf.GreenShift) & uint32(pf.GreenMax)),
|
||||||
B: uint16((pixel >> pf.BlueShift) & uint32(pf.BlueMax)),
|
B: uint8((pixel >> pf.BlueShift) & uint32(pf.BlueMax)),
|
||||||
|
A: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &rgb, nil
|
return &rgb, nil
|
||||||
@ -164,13 +165,6 @@ func (enc *TightEncoding) Read(c Conn, rect *Rectangle) error {
|
|||||||
enc.Image = image.NewRGBA(image.Rect(0, 0, int(c.Width()), int(c.Height())))
|
enc.Image = image.NewRGBA(image.Rect(0, 0, int(c.Width()), int(c.Height())))
|
||||||
}
|
}
|
||||||
|
|
||||||
//r.StartByteCollection()
|
|
||||||
|
|
||||||
//r.StartByteCollection()
|
|
||||||
// defer func() {
|
|
||||||
// t.bytes = r.EndByteCollection()
|
|
||||||
// }()
|
|
||||||
|
|
||||||
compctl, err := ReadUint8(c)
|
compctl, err := ReadUint8(c)
|
||||||
|
|
||||||
/////////////////
|
/////////////////
|
||||||
@ -200,28 +194,20 @@ func (enc *TightEncoding) Read(c Conn, rect *Rectangle) error {
|
|||||||
//logger.Debugf("afterSHL:%d", compType)
|
//logger.Debugf("afterSHL:%d", compType)
|
||||||
switch compType {
|
switch compType {
|
||||||
case TightCompressionFill:
|
case TightCompressionFill:
|
||||||
logger.Debugf("--TIGHT_FILL: reading fill size=%d,counter=%d", bytesPixel, counter)
|
logger.Infof("--TIGHT_FILL: reading fill size=%d,counter=%d", bytesPixel, counter)
|
||||||
//read color
|
//read color
|
||||||
pf := c.PixelFormat()
|
|
||||||
rectColor, err := getTightColor(c, &pf)
|
rectColor, err := getTightColor(c, &pixelFmt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Errorf("error in reading tight encoding: %v", err)
|
logger.Errorf("error in reading tight encoding: %v", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
c1 := color.RGBAModel.Convert(rectColor).(color.RGBA)
|
//c1 := color.RGBAModel.Convert(rectColor).(color.RGBA)
|
||||||
dst := (enc.Image).(*image.RGBA) // enc.Image.(*image.RGBA)
|
dst := (enc.Image).(*image.RGBA) // enc.Image.(*image.RGBA)
|
||||||
var x, y int
|
myRect := MakeRectFromVncRect(rect)
|
||||||
|
logger.Infof("--TIGHT_FILL: fill rect=%v,color=%v", myRect, rectColor)
|
||||||
for y = int(rect.Y); y < int(rect.Height+rect.Y); y++ {
|
FillRect(dst, &myRect, rectColor)
|
||||||
for x = int(rect.X); x < int(rect.Width+rect.X); x++ {
|
|
||||||
offset := dst.PixOffset(x, y)
|
|
||||||
dst.Pix[offset+0] = c1.R
|
|
||||||
dst.Pix[offset+1] = c1.G
|
|
||||||
dst.Pix[offset+2] = c1.B
|
|
||||||
dst.Pix[offset+3] = c1.A
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if bytesPixel != 3 {
|
if bytesPixel != 3 {
|
||||||
return fmt.Errorf("non tight bytesPerPixel format, should be 3 bytes")
|
return fmt.Errorf("non tight bytesPerPixel format, should be 3 bytes")
|
||||||
|
Loading…
Reference in New Issue
Block a user