Ignore:
Timestamp:
May 19, 2009, 2:46:34 PM (13 years ago)
Author:
Pascal Terjan
Message:

Import/export dirty rectangles

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/codec/export.c

    r3451 r3478  
    163163{
    164164    char *data, *cur;
    165     int f, n;
    166 
    167     /* 52 bytes for the header:
     165    int f, i, n;
     166
     167    /* at least 72 bytes for the header:
    168168     *  - 4 bytes for "\xCA\xCA" + "CV"
    169      *  - 16 bytes for the canvas header
    170      *  - 32 bytes for the frame info
     169     *  - 20 bytes for the canvas header
     170     *  - 16 bytes for each dirty rectangle info
     171     *  - 32 bytes for each frame info
    171172     * 8 bytes for each character cell */
    172     *bytes = 20 + (32 + 8 * cv->width * cv->height) * cv->framecount;
     173    *bytes = 24 + 16 * cv->ndirty + (32 + 8 * cv->width * cv->height) * cv->framecount;
    173174    cur = data = malloc(*bytes);
    174175
     
    177178
    178179    /* canvas_header */
    179     cur += sprintu32(cur, 16 + 32 * cv->framecount);
     180    cur += sprintu32(cur, 20 + 16 * cv->ndirty + 32 * cv->framecount);
    180181    cur += sprintu32(cur, cv->width * cv->height * 8 * cv->framecount);
    181     cur += sprintu16(cur, 0x0001);
     182    cur += sprintu16(cur, 0x0002);
     183    cur += sprintu32(cur, cv->ndirty);
    182184    cur += sprintu32(cur, cv->framecount);
    183185    cur += sprintu16(cur, 0x0000);
     186
     187    /* dirty rectangles info */
     188    for(i = 0; i < cv->ndirty; i++)
     189    {
     190        cur += sprintu32(cur, cv->dirty_xmin);
     191        cur += sprintu32(cur, cv->dirty_ymin);
     192        cur += sprintu32(cur, cv->dirty_xmax);
     193        cur += sprintu32(cur, cv->dirty_ymax);
     194    }
    184195
    185196    /* frame_info */
Note: See TracChangeset for help on using the changeset viewer.