Description
Image spiflash decoder and rendering with transformations
What MCU/Processor/Board and compiler are you using?
STM32F411 + spiflash
What do you want to achieve?
The decoder I wrote seems working with images as designed but I have problem when some transformation are involved during rendering.
For example, I have an arrow 4 pixels width and 144 pixels height rotating by animation.
In its original position it is showed, but when it starts to rotate it disappears.
I think my problems are in my get_area decoder function because I don’t really understand how rendering works.
In lv_draw_images.c, I put my focus on the function img_decode_and_draw, follow the snippet of the main else branch of it.
/*Draw in smaller pieces*/
else {
lv_area_t relative_full_area_to_decode = *clipped_img_area;
lv_area_move(&relative_full_area_to_decode, -img_area->x1, -img_area->y1);
lv_area_t tmp;
if(relative_decoded_area == NULL) relative_decoded_area = &tmp;
relative_decoded_area->x1 = LV_COORD_MIN;
relative_decoded_area->y1 = LV_COORD_MIN;
relative_decoded_area->x2 = LV_COORD_MIN;
relative_decoded_area->y2 = LV_COORD_MIN;
lv_result_t res = LV_RESULT_OK;
while(res == LV_RESULT_OK) {
res = lv_image_decoder_get_area(decoder_dsc, &relative_full_area_to_decode, relative_decoded_area);
lv_area_t absolute_decoded_area = *relative_decoded_area;
lv_area_move(&absolute_decoded_area, img_area->x1, img_area->y1);
if(res == LV_RESULT_OK) {
/*Limit draw area to the current decoded area and draw the image*/
lv_area_t clipped_img_area_sub;
if(lv_area_intersect(&clipped_img_area_sub, clipped_img_area, &absolute_decoded_area)) {
draw_core_cb(t, draw_dsc, decoder_dsc, &sup,
&absolute_decoded_area, &clipped_img_area_sub);
}
}
}
My decoder get_area function gets the image from spiflash line by line(due to memory limitations).
At the first call it allocates the line buffer by relative_full_area_to_decode x1,x2,cf and uses it in the iteration until it reads all lines needed.
When the rotation comes, the code at the beginning of the snippet
lv_area_move(&relative_full_area_to_decode, -img_area->x1, -img_area->y1);
puts negative value in relative_full_area_to_decode->x1 and I don’t understand what it means.
Does anyone explain me the really meaning relative_full_area_to_decode informations?
Does the decoder spiflash “line by line” work when rotation or any other transformations are on?
Thanks for any tips you’ll give me.
Best regards.