diff --git a/caca-php/examples/dithering.php b/caca-php/examples/dithering.php new file mode 100755 index 0000000..646655a --- /dev/null +++ b/caca-php/examples/dithering.php @@ -0,0 +1,15 @@ +#!/usr/bin/php5 +sx, img->sy); + + caca_canvas_t *canvas; + ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval1, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas); + caca_dither_t *dither; + ZEND_FETCH_RESOURCE(dither, caca_dither_t*, &_zval2, -1, PHP_CACA_DITHER_RES_NAME, le_caca_dither); + + gdImage *img = fetch_external_resource(_zval3, "gd"); + if (!img) { + RETURN_FALSE; + } + + printf("image size: %i x %i\n", img->sx, img->sy); + if (img->trueColor) { + printf("image is true color\n"); + RETURN_SUCCESS(caca_dither_bitmap(canvas, x, y, w, h, dither, (void *) *(img->tpixels))); } } diff --git a/caca-php/php_caca.h b/caca-php/php_caca.h index c65f120..626fd78 100644 --- a/caca-php/php_caca.h +++ b/caca-php/php_caca.h @@ -104,6 +104,7 @@ PHP_FUNCTION(caca_set_frame); PHP_FUNCTION(caca_set_frame_name); PHP_FUNCTION(caca_create_frame); PHP_FUNCTION(caca_free_frame); +PHP_FUNCTION(caca_create_dither); PHP_FUNCTION(caca_set_dither_palette); PHP_FUNCTION(caca_set_dither_brightness); PHP_FUNCTION(caca_get_dither_brightness);