From 2ac2c17929a01a870bfddf61c3923ab1147ec3b0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 9 Oct 2025 09:35:06 +0530 Subject: [PATCH] Fix transmission by file --- kittens/choose_files/graphics.go | 6 ++---- tools/utils/images/loading.go | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kittens/choose_files/graphics.go b/kittens/choose_files/graphics.go index 9bdc1181c..917e3a79f 100644 --- a/kittens/choose_files/graphics.go +++ b/kittens/choose_files/graphics.go @@ -179,9 +179,7 @@ func (self *GraphicsHandler) transmit(lp *loop.Loop, img *images.ImageData, m *i gc := self.new_graphics_command() gc.SetImageId(self.image_transmitted) gc.SetDataWidth(uint64(frame.Width)).SetDataHeight(uint64(frame.Height)) - if frame.Is_opaque { - gc.SetFormat(graphics.GRT_format_rgb) - } + gc.SetFormat(utils.IfElse(frame.Is_opaque, graphics.GRT_format_rgb, graphics.GRT_format_rgba)) switch frame_num { case 0: gc.SetAction(graphics.GRT_action_transmit) @@ -285,7 +283,7 @@ func (self *GraphicsHandler) RenderImagePreview(h *Handler, p *ImagePreview, x, } } if files_supported { - self.transmit(h.lp, img, img_metadata, p.cached_data) + self.transmit(h.lp, img, img_metadata, cached_data) } else { if img == nil { if img, err = load_image(cached_data); err != nil { diff --git a/tools/utils/images/loading.go b/tools/utils/images/loading.go index e6290ad7f..86bceceb6 100644 --- a/tools/utils/images/loading.go +++ b/tools/utils/images/loading.go @@ -62,6 +62,10 @@ type SerializableImageFrame struct { Size int } +func (s SerializableImageFrame) NeededSize() int { + return utils.IfElse(s.Is_opaque, 3, 4) * s.Width * s.Height +} + func (s *ImageFrame) Serialize() SerializableImageFrame { return SerializableImageFrame{ Width: s.Width, Height: s.Height, Left: s.Left, Top: s.Top,