--- /dev/null
+/*
+ * $Id: rb_buffer.c 174 2005-01-19 21:31:04Z tilman $
+ *
+ * Copyright (C) 2004-2005 ruby-ecore team (see AUTHORS)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <ruby.h>
+
+#include <Ecore.h>
+#include <Ecore_Evas.h>
+
+#include "../ecore/rb_ecore.h"
+#include "rb_ecore_evas_main.h"
+#include "rb_ecore_evas.h"
+
+static void c_free (RbEcoreEvas *ee)
+{
+ c_ecore_evas_free (ee, true);
+}
+
+/*
+ * call-seq:
+ * Ecore::Evas::Buffer.new([w, h]) => buffer
+ *
+ * Creates an Ecore::Evas::Buffer object.
+ */
+static VALUE c_new (int argc, VALUE *argv, VALUE klass)
+{
+ VALUE self, w, h;
+ RbEcoreEvas *ee = NULL;
+ int iw = 0, ih = 0;
+
+ self = Data_Make_Struct (klass, RbEcoreEvas,
+ c_ecore_evas_mark, c_free, ee);
+
+ rb_scan_args (argc, argv, "02", &w, &h);
+
+ if (!NIL_P (w)) {
+ Check_Type (w, T_FIXNUM);
+ iw = FIX2INT (w);
+ }
+
+ if (!NIL_P (h)) {
+ Check_Type (h, T_FIXNUM);
+ ih = FIX2INT (h);
+ }
+
+ ecore_init ();
+ ecore_evas_init ();
+
+ ee->real = ecore_evas_buffer_new (iw, ih);
+
+ rb_obj_call_init (self, 0, NULL);
+
+ return self;
+}
+
+static VALUE c_pixels_get (VALUE self)
+{
+ const int *p;
+ int w = 0, h = 0;
+
+ GET_OBJ (self, RbEcoreEvas, ee);
+
+ p = ecore_evas_buffer_pixels_get (ee->real);
+ if (!p)
+ return rb_str_new2 (""); /* FIXME raise an error instead? */
+
+ ecore_evas_geometry_get (ee->real, NULL, NULL, &w, &h);
+
+ return rb_str_new ((char *) p, h * w * 4);
+}
+
+void Init_Buffer (void)
+{
+ VALUE c = rb_define_class_under (mEvas, "Buffer", cEcoreEvas);
+
+ rb_define_singleton_method (c, "new", c_new, -1);
+ rb_define_method (c, "pixels", c_pixels_get, 0);
+}
--- /dev/null
+/*
+ * $Id: rb_buffer.h 174 2005-01-19 21:31:04Z tilman $
+ *
+ * Copyright (C) 2004-2005 ruby-ecore team (see AUTHORS)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef __RB_BUFFER_H
+#define __RB_BUFFER_H
+
+void Init_Buffer (void);
+
+#endif