com gtk/php-gtk: Override GdkDrawable::draw_rgb_image () and draw_rgb_32_image().: ext/gt k+/gdk.overrides

[email protected] (David Soria Parra) Thu, 30 Mar 2006 17:15:24 +0000
Newsgroups php.gtk.cvs
Message-ID <[email protected]>
Commit:    a54fa3f0bea14be4fb67153dcb5be085853bb8ed
Author:    Andrei Zmievski <[email protected]>         Thu, 30 Mar 2006 17:15:24 +0000
Parents:   c441793bb8dd51ea83a8e757e3faad6ff51d8eb6
Branches:  master

Link:       http://git.php.net/?p=gtk/php-gtk.git;a=commitdiff;h=a54fa3f0bea14be4fb67153dcb5be085853bb8ed

Log:
Override GdkDrawable::draw_rgb_image() and draw_rgb_32_image().

Changed paths:
  M  ext/gtk+/gdk.overrides


Diff:
a54fa3f0bea14be4fb67153dcb5be085853bb8ed
diff --git a/ext/gtk+/gdk.overrides b/ext/gtk+/gdk.overrides
index b9d9bed..c30dbef 100644
--- a/ext/gtk+/gdk.overrides
+++ b/ext/gtk+/gdk.overrides
@@ -41,6 +41,8 @@ ignore
     GdkColorInfoFlags
 %%
 ignore
+    gdk_draw_rgb_image_dithalign
+    gdk_draw_rgb_32_image_dithalign
     gdk_gc_new2
     gdk_pixbuf_new_from_inline
     gdk_string_extents
@@ -400,6 +402,76 @@ PHP_METHOD
     php_gtk_build_value(&return_value, "(ii)", width, height);
 }
 
+%%
+override gdk_draw_rgb_image
+PHP_METHOD
+{
+	zval *gc, *php_dith = NULL;
+	long x, y, width, height, rowstride = -1, xdith = 0, ydith = 0;
+	GdkRgbDither dith;
+	char *rgb_buf;
+    int rgb_buf_len;
+
+    NOT_STATIC_METHOD();
+
+	if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "OiiiiVs#|iii", &gc, gdkgc_ce, &x, &y, &width, &height, &php_dith, &rgb_buf, &rgb_buf_len, &rowstride, &xdith, &ydith))
+		return;
+
+	if (php_dith && phpg_gvalue_get_enum(GDK_TYPE_RGB_DITHER, php_dith, (gint *)&dith) == FAILURE) {
+		return;
+	}
+
+    if (width <= 0 || height <= 0) {
+        php_error(E_WARNING, "width and height must be greater than 0");
+        return;
+    }
+
+    if (rowstride == -1) {
+        rowstride = width * 3;
+    }
+    if (rgb_buf_len < rowstride * (height-1) + width * 3) {
+        php_error(E_WARNING, "RGB buffer is not large enough");
+        return;
+    }
+
+    gdk_draw_rgb_image_dithalign(GDK_DRAWABLE(PHPG_GOBJECT(this_ptr)), GDK_GC(PHPG_GOBJECT(gc)), (gint)x, (gint)y, (gint)width, (gint)height, dith, rgb_buf, (gint)rowstride, (gint)xdith, (gint)ydith);
+}
+
+%%
+override gdk_draw_rgb_32_image
+PHP_METHOD
+{
+	zval *gc, *php_dith = NULL;
+	long x, y, width, height, rowstride = -1, xdith = 0, ydith = 0;
+	GdkRgbDither dith;
+	char *rgb_buf;
+    int rgb_buf_len;
+
+    NOT_STATIC_METHOD();
+
+	if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "OiiiiVs#|iii", &gc, gdkgc_ce, &x, &y, &width, &height, &php_dith, &rgb_buf, &rgb_buf_len, &rowstride, &xdith, &ydith))
+		return;
+
+	if (php_dith && phpg_gvalue_get_enum(GDK_TYPE_RGB_DITHER, php_dith, (gint *)&dith) == FAILURE) {
+		return;
+	}
+
+    if (width <= 0 || height <= 0) {
+        php_error(E_WARNING, "width and height must be greater than 0");
+        return;
+    }
+
+    if (rowstride == -1) {
+        rowstride = width << 2;
+    }
+    if (rgb_buf_len < rowstride * (height-1) + (width << 2)) {
+        php_error(E_WARNING, "RGB buffer is not large enough");
+        return;
+    }
+
+    gdk_draw_rgb_32_image_dithalign(GDK_DRAWABLE(PHPG_GOBJECT(this_ptr)), GDK_GC(PHPG_GOBJECT(gc)), (gint)x, (gint)y, (gint)width, (gint)height, dith, rgb_buf, (gint)rowstride, (gint)xdith, (gint)ydith);
+}
+
 %% }}}
 
 %% {{{ GdkEvent