X-Git-Url: http://git.code-monkey.de/?p=ruby-evas.git;a=blobdiff_plain;f=src%2Frb_image.c;h=6efca2853fc81471bc6befeb49532e0b4c241bd4;hp=8e7f5ed797f96d404087d2fb16e0cd21e5ecc567;hb=c3202d026f3800676461ee407f2a5e46dc20e2f2;hpb=ff457c57c3ac469622c2fcd6bf9e66a55c1df678 diff --git a/src/rb_image.c b/src/rb_image.c index 8e7f5ed..6efca28 100644 --- a/src/rb_image.c +++ b/src/rb_image.c @@ -1,6 +1,4 @@ /* - * $Id: rb_image.c 354 2006-02-10 18:14:08Z tilman $ - * * Copyright (C) 2004 Tilman Sauerbeck (tilman at code-monkey de) * * This library is free software; you can redistribute it and/or @@ -84,12 +82,8 @@ static VALUE c_set_file (int argc, VALUE *argv, VALUE self) rb_scan_args (argc, argv, "11", &file, &key); - Check_Type (file, T_STRING); - - if (!NIL_P (key)) { - Check_Type (key, T_STRING); + if (!NIL_P (key)) k = StringValuePtr (key); - } evas_object_image_file_set (e->real, StringValuePtr (file), k); @@ -255,6 +249,46 @@ static VALUE c_reload (VALUE self) return Qnil; } +static VALUE c_data_get (int argc, VALUE *argv, VALUE self) +{ + VALUE read_write = Qfalse; + void *data; + int w = 0, h = 0; + + GET_OBJ (self, RbEvasObject, e); + + rb_scan_args (argc, argv, "01", &read_write); + + if (NIL_P (read_write)) + read_write = Qfalse; + + data = evas_object_image_data_get (e->real, read_write == Qtrue); + evas_object_image_size_get (e->real, &w, &h); + + return rb_str_new (data, h * w * 4); +} + +static VALUE c_data_set (VALUE self, VALUE data) +{ + GET_OBJ (self, RbEvasObject, e); + + evas_object_image_data_set (e->real, StringValuePtr (data)); + + return Qnil; +} + +static VALUE c_data_update_add (VALUE self, VALUE x, VALUE y, + VALUE w, VALUE h) +{ + GET_OBJ (self, RbEvasObject, e); + + evas_object_image_data_update_add (e->real, + FIX2INT (x), FIX2INT (y), + FIX2INT (w), FIX2INT (h)); + + return Qnil; +} + void Init_Image (void) { VALUE c = rb_define_class_under (mEvas, "Image", cEvasObject); @@ -271,4 +305,7 @@ void Init_Image (void) rb_define_method (c, "get_border", c_get_border, 0); rb_define_method (c, "set_border", c_set_border, 4); rb_define_method (c, "reload", c_reload, 0); + rb_define_method (c, "data", c_data_get, -1); + rb_define_method (c, "data=", c_data_set, 1); + rb_define_method (c, "data_update_add", c_data_update_add, 4); }