2 * Copyright (C) 2004-2005 ruby-ecore team (see AUTHORS)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <Ecore_Evas.h>
24 #include "../ecore/rb_ecore.h"
25 #include "rb_ecore_evas_main.h"
26 #include "rb_ecore_evas.h"
28 static void c_free (RbEcoreEvas *ee)
30 c_ecore_evas_free (ee, true);
33 static VALUE c_alloc (VALUE klass)
35 RbEcoreEvas *ee = NULL;
40 return Data_Make_Struct (klass, RbEcoreEvas,
41 c_ecore_evas_mark, c_free, ee);
46 * Ecore::Evas::Buffer.new([w, h]) => buffer
48 * Creates an Ecore::Evas::Buffer object.
50 static VALUE c_init (int argc, VALUE *argv, VALUE self)
55 GET_OBJ (self, RbEcoreEvas, ee);
57 rb_scan_args (argc, argv, "02", &w, &h);
60 Check_Type (w, T_FIXNUM);
65 Check_Type (h, T_FIXNUM);
69 ee->real = ecore_evas_buffer_new (iw, ih);
71 rb_call_super (argc, argv);
76 static VALUE c_pixels_get (VALUE self)
81 GET_OBJ (self, RbEcoreEvas, ee);
83 p = ecore_evas_buffer_pixels_get (ee->real);
85 return rb_str_new2 (""); /* FIXME raise an error instead? */
87 ecore_evas_geometry_get (ee->real, NULL, NULL, &w, &h);
89 return rb_str_new ((char *) p, h * w * 4);
92 void Init_Buffer (void)
94 VALUE c = rb_define_class_under (mEvas, "Buffer", cEcoreEvas);
96 rb_define_alloc_func (c, c_alloc);
97 rb_define_method (c, "initialize", c_init, -1);
98 rb_define_method (c, "pixels", c_pixels_get, 0);