Ignore:
Timestamp:
May 21, 2009, 10:55:21 PM (11 years ago)
Author:
Sam Hocevar
Message:

Add caca_export_area_to_memory() to export only a selected part of the
current canvas. This is useful to export dirty rectangles. Accordingly,
add caca_import_area_from_memory() and caca_import_area_from_file().

Location:
libcaca/trunk/examples
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/examples/blit.c

    r2821 r3495  
    11/*
    22 *  blit          libcaca blit test program
    3  *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    5959    sprite = caca_create_canvas(0, 0);
    6060    caca_set_color_ansi(sprite, CACA_LIGHTRED, CACA_BLACK);
    61     caca_import_memory(sprite, pig, strlen(pig), "text");
     61    caca_import_canvas_from_memory(sprite, pig, strlen(pig), "text");
    6262    caca_set_canvas_handle(sprite, caca_get_canvas_width(sprite) / 2,
    6363                                    caca_get_canvas_height(sprite) / 2);
  • libcaca/trunk/examples/export.c

    r2821 r3495  
    11/*
    22 *  export        libcaca export test program
    3  *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    7777    {
    7878        cv = caca_create_canvas(0, 0);
    79         if(caca_import_file(cv, file, "") < 0)
     79        if(caca_import_canvas_from_file(cv, file, "") < 0)
    8080        {
    8181            fprintf(stderr, "%s: `%s' has unknown format\n", argv[0], file);
     
    149149    }
    150150
    151     buffer = caca_export_memory(cv, format, &len);
     151    buffer = caca_export_canvas_to_memory(cv, format, &len);
    152152    fwrite(buffer, len, 1, stdout);
    153153    free(buffer);
  • libcaca/trunk/examples/figfont.c

    r2821 r3495  
    11/*
    22 *  figfont       libcaca FIGfont test program
    3  *  Copyright (c) 2007 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2007-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    4848    }
    4949
    50     buffer = caca_export_memory(cv, "utf8", &len);
     50    buffer = caca_export_canvas_to_memory(cv, "utf8", &len);
    5151    fwrite(buffer, len, 1, stdout);
    5252    free(buffer);
  • libcaca/trunk/examples/font2tga.c

    r2821 r3495  
    11/*
    22 *  font2tga      libcaca font test program
    3  *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    7575    caca_free_font(f);
    7676
    77     buffer = caca_export_memory(cv, "tga", &len);
     77    buffer = caca_export_canvas_to_memory(cv, "tga", &len);
    7878    fwrite(buffer, len, 1, stdout);
    7979    free(buffer);
  • libcaca/trunk/examples/import.c

    r2821 r3495  
    4141    }
    4242
    43     if(caca_import_file(cv, argv[1], argc >= 3 ? argv[2] : "") < 0)
     43    if(caca_import_canvas_from_file(cv, argv[1], argc >= 3 ? argv[2] : "") < 0)
    4444    {
    4545        fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
  • libcaca/trunk/examples/spritedit.c

    r2821 r3495  
    11/*
    22 *  spritedit     sprite editor for libcaca
    3  *  Copyright (c) 2003 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2003-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    6262    {
    6363        caca_set_frame(sprite, i);
    64         caca_import_memory(sprite, guy[i], strlen(guy[i]), "utf8");
     64        caca_import_canvas_from_memory(sprite, guy[i], strlen(guy[i]), "utf8");
    6565    }
    6666
    6767    /* Export our sprite in a memory buffer. We could save this to
    6868     * disk afterwards. */
    69     buffer = caca_export_memory(sprite, "caca", &len);
     69    buffer = caca_export_canvas_to_memory(sprite, "caca", &len);
    7070
    7171    /* Free our sprite and reload it from the memory buffer. We could
     
    7373    caca_free_canvas(sprite);
    7474    sprite = caca_create_canvas(0, 0);
    75     caca_import_memory(sprite, buffer, len, "caca");
     75    caca_import_canvas_from_memory(sprite, buffer, len, "caca");
    7676    free(buffer);
    7777
     
    8181        caca_set_frame(sprite, i);
    8282        printf("Frame #%i\n", i);
    83         buffer = caca_export_memory(sprite, "utf8", &len);
     83        buffer = caca_export_canvas_to_memory(sprite, "utf8", &len);
    8484        fwrite(buffer, len, 1, stdout);
    8585        free(buffer);
  • libcaca/trunk/examples/swallow.c

    r2821 r3495  
    11/*
    22 *  swallow       swallow another libcaca application
    3  *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    8888        for(i = 0; i < 4; i++)
    8989        {
    90             bytes[i] = caca_import_memory(app, buf[i], total[i], "caca");
     90            bytes[i] = caca_import_canvas_from_memory(app, buf[i],
     91                                                      total[i], "caca");
    9192
    9293            if(bytes[i] > 0)
  • libcaca/trunk/examples/text.c

    r2821 r3495  
    11/*
    22 *  text          canvas text import/export
    3  *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    4242
    4343    pig = caca_create_canvas(0, 0);
    44     caca_import_memory(pig, STRING, strlen(STRING), "text");
     44    caca_import_canvas_from_memory(pig, STRING, strlen(STRING), "text");
    4545
    4646    cv = caca_create_canvas(caca_get_canvas_width(pig) * 2,
     
    7777    }
    7878
    79     buffer = caca_export_memory(cv, "utf8", &len);
     79    buffer = caca_export_canvas_to_memory(cv, "utf8", &len);
    8080    fwrite(buffer, len, 1, stdout);
    8181    free(buffer);
    8282
    8383    caca_rotate_left(cv);
    84     buffer = caca_export_memory(cv, "utf8", &len);
     84    buffer = caca_export_canvas_to_memory(cv, "utf8", &len);
    8585    fwrite(buffer, len, 1, stdout);
    8686    free(buffer);
  • libcaca/trunk/examples/transform.c

    r2821 r3495  
    11/*
    22 *  unicode       libcaca Unicode rendering test program
    3  *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    6060
    6161    caca_set_color_ansi(sprite, CACA_LIGHTMAGENTA, CACA_BLACK);
    62     caca_import_memory(sprite, pig, strlen(pig), "text");
     62    caca_import_canvas_from_memory(sprite, pig, strlen(pig), "text");
    6363    caca_blit(image, 55, 0, sprite, NULL);
    6464
    6565    caca_set_color_ansi(sprite, CACA_LIGHTGREEN, CACA_BLACK);
    66     caca_import_memory(sprite, duck, strlen(duck), "text");
     66    caca_import_canvas_from_memory(sprite, duck, strlen(duck), "text");
    6767    caca_blit(image, 30, 1, sprite, NULL);
    6868
Note: See TracChangeset for help on using the changeset viewer.