arakiken / mlterm

Other
147 stars 13 forks source link

Sixel graphics are not drawn on xlib 1bpp and --with-imagelib=no #93

Closed tsutsui closed 1 month ago

tsutsui commented 3 months ago

It looks xlib mlterm calls ui_imagelib_load_file() to draw sixel graphics data: https://github.com/arakiken/mlterm/blob/f0d1c4237a38caa124675b74d90eac9ac54919ad/uitoolkit/xlib/ui_imagelib.c#L1714-L1729

but load_sixel() doesn't work on depth<8 so load_file() is called later: https://github.com/arakiken/mlterm/blob/f0d1c4237a38caa124675b74d90eac9ac54919ad/uitoolkit/xlib/ui_imagelib.c#L431

load_file() calls exec_mlimgloader() with pixbuf arg, but the function in tool/mlimgloader/none.c doesn't support pixbuf so mlimgloader exits with an error.

arakiken commented 1 month ago

Thanks. Does this fix improve it? https://github.com/arakiken/mlterm/commit/63bb60ee8b115bdca3e775dfce612e29a1e7ecfa

tsutsui commented 1 month ago

I'll try it (on vax), but maybe one more depth check should be removed?

diff --git a/uitoolkit/xlib/ui_imagelib.c b/uitoolkit/xlib/ui_imagelib.c
index 13a4d5e8..9e53cff2 100644
--- a/uitoolkit/xlib/ui_imagelib.c
+++ b/uitoolkit/xlib/ui_imagelib.c
@@ -428,7 +428,7 @@ static int load_sixel(ui_display_t *disp, char *path, Pixmap *pixmap,
   GC mask_gc;
   int num_cells;

-  if (disp->depth < 8 || !(data = in = load_sixel_from_file(path, &w, &h, transparent))) {
+  if (!(data = in = load_sixel_from_file(path, &w, &h, transparent))) {
     return 0;
   }
arakiken commented 1 month ago

Thanks. https://github.com/arakiken/mlterm/commit/a4baddc173046ac0e1eaed0f1912fbb2578d769a

tsutsui commented 1 month ago

Confirmed fix with pkgsrc mlterm 3.9.3 + https://github.com/arakiken/mlterm/commit/63bb60ee8b115bdca3e775dfce612e29a1e7ecfa + https://github.com/arakiken/mlterm/commit/a4baddc173046ac0e1eaed0f1912fbb2578d769a

Thanks, mlterm-xlib-1bpp-sixel-1 mlterm-xlib-1bpp-sixel-2