Lvgl canvas draw image with palette does not draw

Description

I want to draw an image with a 1 bit palette (2 colors)

What MCU/Processor/Board and compiler are you using?

  • esp32s3 with st7789 296*240 spi lcd
  • online simulator

What LVGL version are you using?

  • v9.1
  • v9.0

What do you want to achieve?

I have a logo in a paletted format that I want to display on the screen

What have you tried so far?

code on the board and code in the simulator
I also tried changing the draw buffer color format to

  • lv.COLOR_FORMAT.NATIVE
  • lv.COLOR_FORMAT.NATIVE_WITH_ALPHA
  • lv.COLOR_FORMAT.I1

Code to reproduce

example to run in the online simulator
in my example the palette_data are all 1 bits, so I expect a red rectangle

# Initialize
import display_driver
import lvgl as lv
disp = lv.display_get_default()
disp.set_resolution(296,240)

scr = lv.screen_active()

buf = lv.draw_buf_create(scr.get_width(), scr.get_height(), lv.COLOR_FORMAT.RGB565, lv.STRIDE_AUTO)

canvas = lv.canvas(scr)
canvas.set_draw_buf(buf)
canvas.center()

layer = lv.layer_t()
canvas.init_layer(layer)

canvas.set_palette(0, lv.color32_make(0, 0, 255, 255))
canvas.set_palette(1, lv.color32_make(255, 0, 0, 255))

palette_data = b'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff'
print(len(palette_data))

square_side = 80

test_img = lv.image_dsc_t(
    dict(
        header=dict(cf=lv.COLOR_FORMAT.I1, w=square_side, h=square_side),
        data_size=len(palette_data),
        data=palette_data
        )
    )

imgd = lv.draw_image_dsc_t()
imgd.init()
imgd.src = test_img

coor = lv.area_t()
coor.x1 = 120 + 28 - int(square_side / 2)
coor.y1 = 120 - int(square_side / 2)
coor.x2 = coor.x1 + square_side
coor.y2 = coor.y1 + square_side

lv.draw_image(layer, imgd, coor)

canvas.finish_layer(layer)

Screenshot and/or video

REPL output from simulator

Running the SDL lvgl version
len(palette_data)=800

MicroPython v1.20.0-1052-gca138ed90-dirty on 2024-01-25; JS with Emscripten

screenshot from simulator
image