mirror of
https://github.com/php/php-gtk-src.git
synced 2026-03-26 10:12:19 +01:00
- Small fixes to gdk-pixbuf test script.
- gdk-pixbuf 2.0 has a fill function. Implemented a manual emulation of it for now. - Made interpolation parameter for GdkPixbuf::scale_simple() optional. - Realized that the code to set tile/stipple/clip_mask of GdkGC was broken and only accepted GdkWindow's instead of GdkPixmap/GdkBitmap.
This commit is contained in:
@@ -22,7 +22,7 @@ $font = gdk::font_load("-*-helvetica-bold-r-*-*-*-120-*-*-*-*-*-*");
|
||||
$extents = $font->extents($image_file);
|
||||
|
||||
$area = &new GtkDrawingArea();
|
||||
$area->size($pixbuf->get_width() - 2, $pixbuf->get_height() - 2);
|
||||
$area->size($pixbuf->get_width(), $pixbuf->get_height());
|
||||
$area->connect('expose_event', 'expose_event', $pixbuf, $font, $extents, basename($image_file));
|
||||
$frame = &new GtkFrame();
|
||||
$frame->add($area);
|
||||
@@ -40,8 +40,7 @@ function expose_event($area, $event, $pixbuf, $font, $extents, $image_file)
|
||||
$event->area->x, $event->area->y,
|
||||
$event->area->x, $event->area->y,
|
||||
$event->area->width, $event->area->height,
|
||||
GDK_RGB_DITHER_NORMAL,
|
||||
$event->area->x, $event->area->y);
|
||||
GDK_RGB_DITHER_NORMAL, 0, 0);
|
||||
|
||||
if ($event->area->x < $extents[2] + 3 &&
|
||||
$event->area->y < $extents[3] + $extents[4] + 3) {
|
||||
|
||||
@@ -308,7 +308,7 @@
|
||||
(return-type GdkPixbuf*)
|
||||
(parameter (type-and-name int dest_width))
|
||||
(parameter (type-and-name int dest_height))
|
||||
(parameter (type-and-name GdkInterpType interp_type))
|
||||
(parameter (type-and-name GdkInterpType interp_type) (default GDK_INTERP_BILINEAR))
|
||||
)
|
||||
|
||||
(method composite_color_simple
|
||||
|
||||
@@ -49,3 +49,46 @@ PHP_FUNCTION(gdk_pixbuf_render_pixmap_and_mask)
|
||||
*return_value = *php_gtk_build_value("(NN)", php_gdk_pixmap_new(pixmap),
|
||||
php_gdk_bitmap_new(mask));
|
||||
}
|
||||
%%
|
||||
override gdk_pixbuf_fill fill GdkPixbuf
|
||||
PHP_FUNCTION(gdk_pixbuf_fill)
|
||||
{
|
||||
unsigned int color;
|
||||
int x, y, width, height, rowstride, n_chan;
|
||||
guchar *pixels;
|
||||
gboolean alpha;
|
||||
GdkPixbuf *pixbuf;
|
||||
guchar *p, *row;
|
||||
|
||||
NOT_STATIC_METHOD();
|
||||
|
||||
if (!php_gtk_parse_args(ZEND_NUM_ARGS(), "i", &color))
|
||||
return;
|
||||
|
||||
pixbuf = PHP_GDK_PIXBUF_GET(this_ptr);
|
||||
width = gdk_pixbuf_get_width(pixbuf);
|
||||
height = gdk_pixbuf_get_height(pixbuf);
|
||||
pixels = gdk_pixbuf_get_pixels(pixbuf);
|
||||
rowstride = gdk_pixbuf_get_rowstride(pixbuf);
|
||||
n_chan = gdk_pixbuf_get_n_channels(pixbuf);
|
||||
alpha = gdk_pixbuf_get_has_alpha(pixbuf);
|
||||
|
||||
row = pixels;
|
||||
for (y = 0; y < height; y++, row += rowstride) {
|
||||
p = row;
|
||||
if (alpha) {
|
||||
for (x = 0; x < width; x++, p += n_chan) {
|
||||
p[0] = color >> 24;
|
||||
p[1] = color >> 16;
|
||||
p[2] = color >> 8;
|
||||
p[3] = color;
|
||||
}
|
||||
} else {
|
||||
for (x = 0; x < width; x++, p += n_chan) {
|
||||
p[0] = color >> 16;
|
||||
p[1] = color >> 8;
|
||||
p[2] = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ extern int le_gdk_pixbuf;
|
||||
extern php_gtk_ext_entry gdkpixbuf_ext_entry;
|
||||
#define gdkpixbuf_ext_ptr &gdkpixbuf_ext_entry
|
||||
|
||||
void php_gdkpixbuf_register_constants(int module_number TSRMLS_DC);
|
||||
void php_gdkpixbuf_register_classes();
|
||||
void php_gdk_pixbuf_register_constants(int module_number TSRMLS_DC);
|
||||
void php_gdk_pixbuf_register_classes();
|
||||
zval *php_gdk_pixbuf_new(GdkPixbuf *pixbuf);
|
||||
|
||||
#define PHP_GDK_PIXBUF_GET(w) PHP_GTK_GET_GENERIC(w, GdkPixbuf*, le_gdk_pixbuf)
|
||||
|
||||
@@ -1615,15 +1615,22 @@ static int gdk_gc_set_property(zval *object, zend_llist_element **element, zval
|
||||
gdk_gc_set_font(gc, PHP_GDK_FONT_GET(value));
|
||||
else
|
||||
type_mismatch = 1;
|
||||
} else if (php_gtk_check_class(value, gdk_window_ce) || Z_TYPE_P(value) == IS_NULL) {
|
||||
GdkWindow *w = (Z_TYPE_P(value) == IS_NULL) ? NULL : PHP_GDK_WINDOW_GET(value);
|
||||
|
||||
} else if (php_gtk_check_class(value, gdk_pixmap_ce) || php_gtk_check_class(value, gdk_bitmap_ce) || Z_TYPE_P(value) == IS_NULL) {
|
||||
GdkDrawable *d = NULL;
|
||||
|
||||
if (Z_TYPE_P(value) != IS_NULL) {
|
||||
if (php_gtk_check_class(value, gdk_pixmap_ce))
|
||||
d = PHP_GDK_PIXMAP_GET(value);
|
||||
else
|
||||
d = PHP_GDK_BITMAP_GET(value);
|
||||
}
|
||||
|
||||
if (!strcmp(prop_name, "tile"))
|
||||
gdk_gc_set_tile(gc, w);
|
||||
gdk_gc_set_tile(gc, d);
|
||||
else if (!strcmp(prop_name, "stipple"))
|
||||
gdk_gc_set_stipple(gc, w);
|
||||
gdk_gc_set_stipple(gc, d);
|
||||
else if (!strcmp(prop_name, "clip_mask"))
|
||||
gdk_gc_set_clip_mask(gc, w);
|
||||
gdk_gc_set_clip_mask(gc, d);
|
||||
else
|
||||
type_mismatch = 1;
|
||||
} else
|
||||
|
||||
Reference in New Issue
Block a user