Changeset 2147 for libcaca/trunk


Ignore:
Timestamp:
Dec 20, 2007, 4:26:12 PM (12 years ago)
Author:
Sam Hocevar
Message:
  • Fix canvas export for the caca format. We now export all frames.
  • Fix the sprite import/export example.
Location:
libcaca/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/cucul/export.c

    r2102 r2147  
    163163static void *export_caca(cucul_canvas_t const *cv, unsigned long int *bytes)
    164164{
    165     uint32_t *attrs = cv->attrs;
    166     uint32_t *chars = cv->chars;
    167165    char *data, *cur;
    168     unsigned int n;
     166    unsigned int f, n;
    169167
    170168    /* 52 bytes for the header:
     
    173171     *  - 32 bytes for the frame info
    174172     * 8 bytes for each character cell */
    175     *bytes = 52 + 8 * cv->width * cv->height;
     173    *bytes = 20 + (32 + 8 * cv->width * cv->height) * cv->framecount;
    176174    cur = data = malloc(*bytes);
    177175
     
    180178
    181179    /* canvas_header */
    182     cur += sprintu32(cur, 16 + 32 * 1);
    183     cur += sprintu32(cur, cv->width * cv->height * 8);
     180    cur += sprintu32(cur, 16 + 32 * cv->framecount);
     181    cur += sprintu32(cur, cv->width * cv->height * 8 * cv->framecount);
    184182    cur += sprintu16(cur, 0x0001);
    185     cur += sprintu32(cur, 1);
     183    cur += sprintu32(cur, cv->framecount);
    186184    cur += sprintu16(cur, 0x0000);
    187185
    188186    /* frame_info */
    189     cur += sprintu32(cur, cv->width);
    190     cur += sprintu32(cur, cv->height);
    191     cur += sprintu32(cur, 0);
    192     cur += sprintu32(cur, cv->curattr);
    193     cur += sprintu32(cur, cv->frames[0].x);
    194     cur += sprintu32(cur, cv->frames[0].y);
    195     cur += sprintu32(cur, cv->frames[0].handlex);
    196     cur += sprintu32(cur, cv->frames[0].handley);
     187    for(f = 0; f < cv->framecount; f++)
     188    {
     189        cur += sprintu32(cur, cv->width);
     190        cur += sprintu32(cur, cv->height);
     191        cur += sprintu32(cur, 0);
     192        cur += sprintu32(cur, cv->curattr);
     193        cur += sprintu32(cur, cv->frames[f].x);
     194        cur += sprintu32(cur, cv->frames[f].y);
     195        cur += sprintu32(cur, cv->frames[f].handlex);
     196        cur += sprintu32(cur, cv->frames[f].handley);
     197    }
    197198
    198199    /* canvas_data */
    199     for(n = cv->height * cv->width; n--; )
    200     {
    201         cur += sprintu32(cur, *chars++);
    202         cur += sprintu32(cur, *attrs++);
     200    for(f = 0; f < cv->framecount; f++)
     201    {
     202        uint32_t *attrs = cv->frames[f].attrs;
     203        uint32_t *chars = cv->frames[f].chars;
     204
     205        for(n = cv->height * cv->width; n--; )
     206        {
     207            cur += sprintu32(cur, *chars++);
     208            cur += sprintu32(cur, *attrs++);
     209        }
    203210    }
    204211
  • libcaca/trunk/examples/spritedit.c

    r2146 r2147  
    6464    {
    6565        cucul_set_frame(sprite, i);
    66         cucul_import_memory(sprite, guy[i], strlen(guy[i]), "text");
     66        cucul_import_memory(sprite, guy[i], strlen(guy[i]), "utf8");
    6767    }
    6868
Note: See TracChangeset for help on using the changeset viewer.