Samsung / rlottie

A platform independent standalone library that plays Lottie Animation.
Other
1.19k stars 228 forks source link

CAPI render image test doesn't work #41

Closed hermet closed 5 years ago

hermet commented 5 years ago

/TEST Rlottie/

include "unistd.h"

include "stdlib.h"

include "stdio.h"

include "rlottie_capi.h"

int main () { double duration; size_t i, k, frame, frame_number, width = 64U, height = 64U, bytes_per_line = width sizeof(uint32_t); uint32_t p_render; uint32_t* buffer;

Lottie_Animation* animation = lottie_animation_from_file("example/resource/abstract_circle.json");

if (animation == NULL)
{
    perror("Lottie animation is NULL.\n");
    return 1;
}

lottie_animation_get_size(animation, &width, &height);

if ((width > 1024) || (height > 1024))
{
    perror("Returned size too large\n");
    return 1;
}

buffer       = (uint32_t*)calloc(bytes_per_line * height, sizeof(uint32_t));
duration     = lottie_animation_get_duration(animation);
frame_number = lottie_animation_get_totalframe(animation);
frame        = lottie_animation_get_frame_at_pos(animation, 1);

if (frame_number == 0U)
{
    perror("Lottie resource have no animation.\n");
    return 1;
}

printf ("Sufrace Buffer = %p\n", buffer);
printf ("Running test app... animation ptr (%p) duration [%lf] frame [%lu]\n", animation, duration, frame);

for (i = 0; i < frame_number; i++)
{
    lottie_animation_render_async(animation, i, &buffer[0], width, height, bytes_per_line);
    p_render = lottie_animation_render_flush(animation);

    if (p_render != buffer)
    {
        perror ("Render flash mismatch output\n");
    }

    for (k = 0U; k < bytes_per_line * height; k++)
    {
        if (buffer[k] != 0U)
        {
            printf("Buffer Delta found at idx %lu.\n", k);
            break;
        }
    }
}

printf ("\n");
return 0;

}

hermet commented 5 years ago

catched the problem point,