2 * $Id: rb_buffer.c 174 2005-01-19 21:31:04Z tilman $
4 * Copyright (C) 2004-2005 ruby-ecore team (see AUTHORS)
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 #include <Ecore_Evas.h>
26 #include "../ecore/rb_ecore.h"
27 #include "rb_ecore_evas_main.h"
28 #include "rb_ecore_evas.h"
30 static void c_free (RbEcoreEvas *ee)
32 c_ecore_evas_free (ee, true);
37 * Ecore::Evas::Buffer.new([w, h]) => buffer
39 * Creates an Ecore::Evas::Buffer object.
41 static VALUE c_new (int argc, VALUE *argv, VALUE klass)
44 RbEcoreEvas *ee = NULL;
47 self = Data_Make_Struct (klass, RbEcoreEvas,
48 c_ecore_evas_mark, c_free, ee);
50 rb_scan_args (argc, argv, "02", &w, &h);
53 Check_Type (w, T_FIXNUM);
58 Check_Type (h, T_FIXNUM);
65 ee->real = ecore_evas_buffer_new (iw, ih);
67 rb_obj_call_init (self, 0, NULL);
72 static VALUE c_pixels_get (VALUE self)
77 GET_OBJ (self, RbEcoreEvas, ee);
79 p = ecore_evas_buffer_pixels_get (ee->real);
81 return rb_str_new2 (""); /* FIXME raise an error instead? */
83 ecore_evas_geometry_get (ee->real, NULL, NULL, &w, &h);
85 return rb_str_new ((char *) p, h * w * 4);
88 void Init_Buffer (void)
90 VALUE c = rb_define_class_under (mEvas, "Buffer", cEcoreEvas);
92 rb_define_singleton_method (c, "new", c_new, -1);
93 rb_define_method (c, "pixels", c_pixels_get, 0);