Changeset 3495 for libcaca/trunk


Ignore:
Timestamp:
May 21, 2009, 10:55:21 PM (10 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
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca/caca.h

    r3494 r3495  
    426426 *
    427427 *  @{ */
    428 __extern ssize_t caca_import_memory(caca_canvas_t *, void const *,
    429                                      size_t, char const *);
    430 __extern ssize_t caca_import_file(caca_canvas_t *, char const *,
    431                                    char const *);
     428__extern ssize_t caca_import_canvas_from_memory(caca_canvas_t *, void const *,
     429                                                size_t, char const *);
     430__extern ssize_t caca_import_canvas_from_file(caca_canvas_t *, char const *,
     431                                              char const *);
     432__extern ssize_t caca_import_area_from_memory(caca_canvas_t *, int, int,
     433                                              void const *, size_t,
     434                                              char const *);
     435__extern ssize_t caca_import_area_from_file(caca_canvas_t *, int, int,
     436                                            char const *, char const *);
    432437__extern char const * const * caca_get_import_list(void);
    433 __extern void *caca_export_memory(caca_canvas_t const *, char const *,
    434                                    size_t *);
     438__extern void *caca_export_canvas_to_memory(caca_canvas_t const *,
     439                                            char const *, size_t *);
     440__extern void *caca_export_area_to_memory(caca_canvas_t const *, int, int,
     441                                          int, int, char const *, size_t *);
    435442__extern char const * const * caca_get_export_list(void);
    436443/*  @} */
     
    523530__extern caca_canvas_t * cucul_import_canvas(cucul_buffer_t *,
    524531                                              char const *) CACA_DEPRECATED;
     532__extern ssize_t caca_import_memory(caca_canvas_t *, void const *, size_t,
     533                                    char const *) CACA_DEPRECATED;
     534__extern ssize_t caca_import_file(caca_canvas_t *, char const *,
     535                                  char const *) CACA_DEPRECATED;
     536__extern void *caca_export_memory(caca_canvas_t const *, char const *,
     537                                  size_t *) CACA_DEPRECATED;
    525538__extern int cucul_rotate(caca_canvas_t *) CACA_DEPRECATED;
    526539__extern int cucul_set_dither_invert(caca_dither_t *, int) CACA_DEPRECATED;
  • libcaca/trunk/caca/caca0.c

    r2858 r3495  
    11/*
    22 *  libcaca       Colour ASCII-Art library
    3  *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2002-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    216216
    217217    cv = caca_create_canvas(0, 0);;
    218     if(caca_import_file(cv, file, "") < 0)
     218    if(caca_import_canvas_from_file(cv, file, "") < 0)
    219219    {
    220220        caca_free_canvas(cv);
  • libcaca/trunk/caca/codec/export.c

    r3492 r3495  
    8181 *  \return A pointer to the exported memory area, or NULL in case of error.
    8282 */
    83 void *caca_export_memory(caca_canvas_t const *cv, char const *format,
    84                           size_t *bytes)
     83void *caca_export_canvas_to_memory(caca_canvas_t const *cv, char const *format,
     84                                   size_t *bytes)
    8585{
    8686    if(!strcasecmp("caca", format))
     
    119119    seterrno(EINVAL);
    120120    return NULL;
     121}
     122
     123/** \brief Export a canvas portion into a foreign format.
     124 *
     125 *  This function exports a portion of a \e libcaca canvas into various
     126 *  formats. For more information, see caca_export_canvas_to_memory().
     127 *
     128 *  If an error occurs, NULL is returned and \b errno is set accordingly:
     129 *  - \c EINVAL Unsupported format requested or invalid coordinates.
     130 *  - \c ENOMEM Not enough memory to allocate output buffer.
     131 *
     132 *  \param cv A libcaca canvas
     133 *  \param x The leftmost coordinate of the area to export.
     134 *  \param y The topmost coordinate of the area to export.
     135 *  \param w The width of the area to export.
     136 *  \param h The height of the area to export.
     137 *  \param format A string describing the requested output format.
     138 *  \param bytes A pointer to a size_t where the number of allocated bytes
     139 *         will be written.
     140 *  \return A pointer to the exported memory area, or NULL in case of error.
     141 */
     142void *caca_export_area_to_memory(caca_canvas_t const *cv, int x, int y, int w,
     143                                 int h, char const *format, size_t *bytes)
     144{
     145    caca_canvas_t *tmp;
     146    void *ret;
     147
     148    if(w < 0 || h < 0 || x < 0 || y < 0
     149        || x + w >= cv->width || y + h >= cv->height)
     150    {
     151        seterrno(EINVAL);
     152        return NULL;
     153    }
     154
     155    /* TODO: we need to spare the blit here by exporting the area we want. */
     156    tmp = caca_create_canvas(w, h);
     157    caca_blit(tmp, -x, -y, cv, NULL);
     158
     159    ret = caca_export_canvas_to_memory(tmp, format, bytes);
     160
     161    caca_free_canvas(tmp);
     162
     163    return ret;
    121164}
    122165
     
    938981
    939982void *cucul_export_memory(cucul_canvas_t const *, char const *,
    940                           size_t *) CACA_ALIAS(caca_export_memory);
     983                          size_t *) CACA_ALIAS(caca_export_canvas_to_memory);
     984void *caca_export_memory(caca_canvas_t const *, char const *,
     985                         size_t *) CACA_ALIAS(caca_export_canvas_to_memory);
    941986char const * const * cucul_get_export_list(void)
    942987         CACA_ALIAS(caca_get_export_list);
  • libcaca/trunk/caca/codec/import.c

    r3492 r3495  
    7272 *  or -1 if an error occurred.
    7373 */
    74 ssize_t caca_import_memory(caca_canvas_t *cv, void const *data,
    75                             size_t len, char const *format)
     74ssize_t caca_import_canvas_from_memory(caca_canvas_t *cv, void const *data,
     75                                       size_t len, char const *format)
    7676{
    7777    if(!strcasecmp("caca", format))
     
    137137 *  or -1 if an error occurred.
    138138 */
    139 ssize_t caca_import_file(caca_canvas_t *cv, char const *filename,
    140                           char const *format)
     139ssize_t caca_import_canvas_from_file(caca_canvas_t *cv, char const *filename,
     140                                     char const *format)
    141141{
    142142#if defined __KERNEL__
     
    168168    caca_file_close(f);
    169169
    170     ret = caca_import_memory(cv, data, size, format);
     170    ret = caca_import_canvas_from_memory(cv, data, size, format);
    171171    free(data);
    172172
    173173    return ret;
    174174#endif
     175}
     176
     177/** \brief Import a memory buffer into a canvas area
     178 *
     179 *  Import a memory buffer into the given libcaca canvas's current
     180 *  frame, at the specified position. For more information, see
     181 *  caca_import_canvas_from_memory().
     182 *
     183 *  If an error occurs, -1 is returned and \b errno is set accordingly:
     184 *  - \c EINVAL Unsupported format requested or invalid coordinates.
     185 *  - \c ENOMEM Not enough memory to allocate canvas.
     186 *
     187 *  \param cv A libcaca canvas in which to import the file.
     188 *  \param x The leftmost coordinate of the area to import to.
     189 *  \param y The topmost coordinate of the area to import to.
     190 *  \param data A memory area containing the data to be loaded into the canvas.
     191 *  \param len The size in bytes of the memory area.
     192 *  \param format A string describing the input format.
     193 *  \return The number of bytes read, or 0 if there was not enough data,
     194 *  or -1 if an error occurred.
     195 */
     196ssize_t caca_import_area_from_memory(caca_canvas_t *cv, int x, int y,
     197                                     void const *data, size_t len,
     198                                     char const *format)
     199{
     200    caca_canvas_t *tmp;
     201    ssize_t ret;
     202
     203    tmp = caca_create_canvas(0, 0);
     204    ret = caca_import_canvas_from_memory(tmp, data, len, format);
     205
     206    if(ret > 0)
     207        caca_blit(cv, x, y, tmp, NULL);
     208
     209    caca_free_canvas(tmp);
     210
     211    return ret;
     212}
     213
     214/** \brief Import a file into a canvas area
     215 *
     216 *  Import a file into the given libcaca canvas's current frame, at the
     217 *  specified position. For more information, see
     218 *  caca_import_canvas_from_file().
     219 *
     220 *  If an error occurs, -1 is returned and \b errno is set accordingly:
     221 *  - \c ENOSYS File access is not implemented on this system.
     222 *  - \c ENOMEM Not enough memory to allocate canvas.
     223 *  - \c EINVAL Unsupported format requested or invalid coordinates.
     224 *  caca_import_file() may also fail and set \b errno for any of the
     225 *  errors specified for the routine fopen().
     226 *
     227 *  \param cv A libcaca canvas in which to import the file.
     228 *  \param x The leftmost coordinate of the area to import to.
     229 *  \param y The topmost coordinate of the area to import to.
     230 *  \param filename The name of the file to load.
     231 *  \param format A string describing the input format.
     232 *  \return The number of bytes read, or 0 if there was not enough data,
     233 *  or -1 if an error occurred.
     234 */
     235ssize_t caca_import_area_from_file(caca_canvas_t *cv, int x, int y,
     236                                   char const *filename, char const *format)
     237{
     238    caca_canvas_t *tmp;
     239    ssize_t ret;
     240
     241    tmp = caca_create_canvas(0, 0);
     242    ret = caca_import_canvas_from_file(tmp, filename, format);
     243
     244    if(ret > 0)
     245        caca_blit(cv, x, y, tmp, NULL);
     246
     247    caca_free_canvas(tmp);
     248
     249    return ret;
    175250}
    176251
     
    330405ssize_t cucul_import_file(cucul_canvas_t *, char const *,
    331406                          char const *) CACA_ALIAS(caca_import_file);
     407ssize_t caca_import_memory(caca_canvas_t *, void const *, size_t, char const *)
     408                                  CACA_ALIAS(caca_import_canvas_from_memory);
     409ssize_t caca_import_file(caca_canvas_t *, char const *, char const *)
     410                                  CACA_ALIAS(caca_import_canvas_from_file);
    332411char const * const * cucul_get_import_list(void)
    333412         CACA_ALIAS(caca_get_import_list);
  • libcaca/trunk/caca/driver/raw.c

    r2962 r3495  
    11/*
    22 *  libcaca       Colour ASCII-Art library
    3  *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2002-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    7171    size_t len;
    7272
    73     buffer = caca_export_memory(dp->cv, "caca", &len);
     73    buffer = caca_export_canvas_to_memory(dp->cv, "caca", &len);
    7474    if(!buffer)
    7575        return;
  • libcaca/trunk/caca/figfont.c

    r3484 r3495  
    11/*
    22 *  libcaca       Colour ASCII-Art library
    3  *  Copyright (c) 2006-2007 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2002-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    449449    /* Import buffer into canvas */
    450450    ff->fontcv = caca_create_canvas(0, 0);
    451     caca_import_memory(ff->fontcv, data, i, "utf8");
     451    caca_import_canvas_from_memory(ff->fontcv, data, i, "utf8");
    452452    free(data);
    453453
  • libcaca/trunk/caca/legacy.c

    r2821 r3495  
    11/*
    22 *  libcaca       Colour ASCII-Art library
    3  *  Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2002-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    9999{
    100100    caca_canvas_t *cv = caca_create_canvas(0, 0);
    101     int ret = caca_import_memory(cv, (unsigned char const *)buf->data,
    102                                   buf->size, format);
     101    int ret = caca_import_canvas_from_memory(cv,
     102                                             (unsigned char const *)buf->data,
     103                                             buf->size, format);
    103104    if(ret < 0)
    104105    {
     
    125126    }
    126127
    127     ex->data = caca_export_memory(cv, format, &ex->size);
     128    ex->data = caca_export_canvas_to_memory(cv, format, &ex->size);
    128129    if(!ex->data)
    129130    {
  • libcaca/trunk/cxx/caca++.cpp

    r2822 r3495  
    292292}
    293293
    294 long int Canvas::importMemory(void const *buf, size_t len, char const *fmt)
    295 {
    296     return caca_import_memory(cv, buf, len, fmt);
    297 }
    298 
    299 long int Canvas::importFile(char const *file, char const *fmt)
    300 {
    301     return caca_import_file(cv, file, fmt);
     294long int Canvas::importFromMemory(void const *buf, size_t len, char const *fmt)
     295{
     296    return caca_import_canvas_from_memory(cv, buf, len, fmt);
     297}
     298
     299long int Canvas::importFromFile(char const *file, char const *fmt)
     300{
     301    return caca_import_canvas_from_file(cv, file, fmt);
    302302}
    303303
     
    307307}
    308308
    309 void *Canvas::exportMemory(char const *fmt, size_t *len)
    310 {
    311     return caca_export_memory(cv, fmt, len);
     309void *Canvas::exportToMemory(char const *fmt, size_t *len)
     310{
     311    return caca_export_canvas_to_memory(cv, fmt, len);
    312312}
    313313
  • libcaca/trunk/cxx/caca++.h

    r2822 r3495  
    138138
    139139    char const * const * getImportList(void);
    140     long int importMemory(void const *, size_t, char const *);
    141     long int importFile(char const *, char const *);
     140    long int importFromMemory(void const *, size_t, char const *);
     141    long int importFromFile(char const *, char const *);
    142142    char const * const * getExportList(void);
    143     void *exportMemory(char const *, size_t *);
     143    void *exportToMemory(char const *, size_t *);
    144144
    145145    static int Rand(int, int);
  • libcaca/trunk/cxx/cxxtest.cpp

    r2824 r3495  
    6565        pig = new Canvas();
    6666        pig->setColorANSI(CACA_LIGHTMAGENTA, CACA_TRANSPARENT);
    67         pig->importMemory(pigstring, strlen(pigstring), "text");
     67        pig->importFromMemory(pigstring, strlen(pigstring), "text");
    6868    }
    6969    catch(int e) {
  • 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
  • libcaca/trunk/ruby/caca-canvas.c

    r2829 r3495  
    2222static VALUE x (VALUE self)                             \
    2323{                                                       \
    24     if( caca_##x (_SELF) <0)                           \
     24    if( caca_##x (_SELF) <0)                            \
    2525        rb_raise(rb_eRuntimeError, strerror(errno));    \
    2626                                                        \
     
    3131static VALUE get_##x (VALUE self)                       \
    3232{                                                       \
    33     return INT2NUM(caca_get_##x (_SELF));              \
     33    return INT2NUM(caca_get_##x (_SELF));               \
    3434}
    3535
     
    4141static VALUE canvas_alloc(VALUE klass)
    4242{
    43     VALUE obj;   
     43    VALUE obj;
    4444    obj = Data_Wrap_Struct(klass, NULL, canvas_free, NULL);
    4545    return obj;
     
    535535}
    536536
    537 static VALUE import_memory(VALUE self, VALUE data, VALUE format)
     537static VALUE import_from_memory(VALUE self, VALUE data, VALUE format)
    538538{
    539539    long int bytes;
    540     bytes = caca_import_memory (_SELF, StringValuePtr(data), RSTRING(StringValue(data))->len, StringValuePtr(format));
     540    bytes = caca_import_canvas_from_memory (_SELF, StringValuePtr(data), RSTRING(StringValue(data))->len, StringValuePtr(format));
    541541    if(bytes <= 0)
    542542        rb_raise(rb_eRuntimeError, strerror(errno));
     
    545545}
    546546
    547 static VALUE import_file(VALUE self, VALUE filename, VALUE format)
     547static VALUE import_from_file(VALUE self, VALUE filename, VALUE format)
    548548{
    549549    long int bytes;
    550     bytes = caca_import_file (_SELF, StringValuePtr(filename), StringValuePtr(format));
     550    bytes = caca_import_canvas_from_file (_SELF, StringValuePtr(filename), StringValuePtr(format));
    551551    if(bytes <= 0)
    552552        rb_raise(rb_eRuntimeError, strerror(errno));
     
    555555}
    556556
    557 static VALUE export_memory(VALUE self, VALUE format)
     557static VALUE export_to_memory(VALUE self, VALUE format)
    558558{
    559559    size_t bytes;
    560560    void *result;
    561561    VALUE ret;
    562     result = caca_export_memory (_SELF, StringValuePtr(format), &bytes);
     562    result = caca_export_canvas_to_memory (_SELF, StringValuePtr(format), &bytes);
    563563    ret = rb_str_new(result, bytes);
    564564    free(result);
     
    644644
    645645    rb_define_method(cCanvas, "render", render_canvas, 4);
    646     rb_define_method(cCanvas, "import_memory", import_memory, 2);
    647     rb_define_method(cCanvas, "import_file", import_file, 2);
    648     rb_define_method(cCanvas, "export_memory", export_memory, 1);
     646    rb_define_method(cCanvas, "import_from_memory", import_from_memory, 2);
     647    rb_define_method(cCanvas, "import_from_file", import_from_file, 2);
     648    rb_define_method(cCanvas, "export_to_memory", export_to_memory, 1);
    649649    rb_define_singleton_method(cCanvas, "export_list", export_list, 0);
    650650    rb_define_singleton_method(cCanvas, "import_list", import_list, 0);
    651    
    652 }
    653 
     651}
     652
  • libcaca/trunk/src/cacadraw.c

    r2821 r3495  
    11/*
    22 *  event         event lister for libcaca
    3  *  Copyright (c) 2004 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2004-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    5656        {
    5757            image = caca_create_canvas(0, 0);
    58             if(caca_import_file(image, argv[file], "ansi") < 0)
     58            if(caca_import_canvas_from_file(image, argv[file], "ansi") < 0)
    5959            {
    6060                fprintf(stderr, "%s: invalid file `%s'.\n", argv[0], argv[1]);
  • libcaca/trunk/src/cacaplay.c

    r3474 r3495  
    11/*
    22 *  cacaplay      caca file player
    3  *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
    44 *                All Rights Reserved
    55 *
     
    9090        }
    9191
    92         bytes = caca_import_memory(app, buf, total, "caca");
     92        bytes = caca_import_canvas_from_memory(app, buf, total, "caca");
    9393
    9494        if(bytes > 0)
  • libcaca/trunk/src/cacaserver.c

    r3412 r3495  
    22 *  cacaserver    Colour ASCII-Art library
    33 *  Copyright (c) 2006 Jean-Yves Lamoureux <jylam@lnxscene.org>
    4  *                2006 Sam Hocevar <sam@zoy.org>
     4 *                2006-2009 Sam Hocevar <sam@hocevar.net>
    55 *                All Rights Reserved
    66 *
     
    214214        }
    215215
    216         while(caca_import_memory(server->canvas, server->input,
    217                                   server->read, "caca") < 0)
     216        while(caca_import_canvas_from_memory(server->canvas, server->input,
     217                                             server->read, "caca") < 0)
    218218        {
    219219            memmove(server->input, server->input + 1, server->read - 1);
     
    225225            ssize_t needed, wanted;
    226226
    227             needed = caca_import_memory(server->canvas, server->input,
    228                                          server->read, "caca");
     227            needed = caca_import_canvas_from_memory(server->canvas,
     228                                                    server->input,
     229                                                    server->read, "caca");
    229230            if(needed < 0)
    230231                goto restart;
     
    253254        /* Get ANSI representation of the image and skip the end-of buffer
    254255         * linefeed ("\r\n", 2 byte) */
    255         server->buffer = caca_export_memory(server->canvas, "utf8cr",
    256                                              &server->buflen);
     256        server->buffer = caca_export_canvas_to_memory(server->canvas, "utf8cr",
     257                                                      &server->buflen);
    257258        server->buflen -= 2;
    258259
  • libcaca/trunk/src/img2txt.c

    r2833 r3495  
    11/*
    22 *  img2txt       image to text converter
    3  *  Copyright (c) 2006 Sam Hocevar <sam@zoy.org>
     3 *  Copyright (c) 2006-2009 Sam Hocevar <sam@hocevar.net>
    44 *                2007 Jean-Yves Lamoureux <jylam@lnxscene.org>
    55 *                All Rights Reserved
     
    8282    printf(
    8383    "img2txt Copyright 2006-2007 Sam Hocevar and Jean-Yves Lamoureux\n"
    84     "Internet: <sam@zoy.org> <jylam@lnxscene.org> Version: %s, date: %s\n"
     84    "Internet: <sam@hocevar.net> <jylam@lnxscene.org> Version: %s, date: %s\n"
    8585    "\n"
    8686    "img2txt, along with its documentation, may be freely copied and distributed.\n"
     
    225225    unload_image(i);
    226226
    227     export = caca_export_memory(cv, format?format:"ansi", &len);
     227    export = caca_export_canvas_to_memory(cv, format?format:"ansi", &len);
    228228    if(!export)
    229229    {
Note: See TracChangeset for help on using the changeset viewer.