icat: Dont try to further compress PNG images when using stream based transmission

This commit is contained in:
Kovid Goyal 2023-02-01 11:44:15 +05:30
parent a73f09cf89
commit 5eaa935ede
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 8 additions and 11 deletions

View File

@ -332,7 +332,7 @@ sequence of escape codes to the terminal emulator::
Note that only the first escape code needs to have the full set of control Note that only the first escape code needs to have the full set of control
codes such as width, height, format, etc. Subsequent chunks **must** have only codes such as width, height, format, etc. Subsequent chunks **must** have only
the ``m`` and optionally ``q`` keys. When sending animation frame data, subsequent the ``m`` and optionally ``q`` keys. When sending animation frame data, subsequent
chunks must also specify the ``a=f`` key. The client **must** finish sending chunks **must** also specify the ``a=f`` key. The client **must** finish sending
all chunks for a single image before sending any other graphics related escape all chunks for a single image before sending any other graphics related escape
codes. Note that the cursor position used to display the image **must** be the codes. Note that the cursor position used to display the image **must** be the
position when the final chunk is received. Finally, terminals must not display position when the final chunk is received. Finally, terminals must not display

View File

@ -544,14 +544,14 @@ func (self *GraphicsCommand) WriteWithPayloadTo(o io.StringWriter, payload []byt
return self.serialize_to(o, base64.StdEncoding.EncodeToString(payload)) return self.serialize_to(o, base64.StdEncoding.EncodeToString(payload))
} }
gc := *self gc := *self
if self.Format() != GRT_format_png {
compressed := compress_with_zlib(payload) compressed := compress_with_zlib(payload)
if len(compressed) < len(payload) { if len(compressed) < len(payload) {
gc.SetCompression(GRT_compression_zlib) gc.SetCompression(GRT_compression_zlib)
gc.SetDataSize(uint64(len(payload)))
payload = compressed payload = compressed
} }
}
data := base64.StdEncoding.EncodeToString(payload) data := base64.StdEncoding.EncodeToString(payload)
is_first := true
for len(data) > 0 && err == nil { for len(data) > 0 && err == nil {
chunk := data chunk := data
if len(data) > 4096 { if len(data) > 4096 {
@ -569,10 +569,7 @@ func (self *GraphicsCommand) WriteWithPayloadTo(o io.StringWriter, payload []byt
if err != nil { if err != nil {
return err return err
} }
if !is_first { gc = GraphicsCommand{q: self.q, a: self.a}
gc = GraphicsCommand{}
}
is_first = false
} }
return return
} }