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().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.