lvgl / lv_demos

Examples, tutorials and applications for the LVGL embedded GUI library
https://lvgl.io
492 stars 366 forks source link

Declaring 4 times bigger Canvas Buffer #92

Closed Player-1-TR closed 3 years ago

Player-1-TR commented 3 years ago

Am I missing something I'm not sure. When I look up the canvas examples Canvas's buffer is always 4 times bigger than the actual pixel buffer. For example https://github.com/lvgl/lv_examples/blob/master/src/lv_ex_widgets/lv_ex_canvas/lv_ex_canvas_2.c

line 16: static lv_color_t cbuf[LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT)];

For a RGBA8888 format: LV_CANVAS_BUF_SIZE_TRUE_COLOR(CANVAS_WIDTH, CANVAS_HEIGHT) means this; LV_IMG_BUF_SIZE_TRUE_COLOR(w, h) ((LV_COLOR_SIZE / 8) * w * h) then w=200 h=150; ((32 / 8) * w * h) = 120 000 array elements lv_color_t 4 bytes; 4 * 120 000 = 480 000 bytes!

Raw data should be RGBA8888 x 150 x 200 = 120 000 bytes?

Is it a issue or not?

embeddedt commented 3 years ago

I'm pretty sure you're correct; I think this buffer should be declared with uint8_t not lv_color_t.

kisvegabor commented 3 years ago

That correct, it really gives the result in bytes. I've just fixed the example.

Thank you for the report.