given gd resource.tags/v0.99.beta17
@@ -1,12 +1,14 @@ | |||||
#!/usr/bin/php5 | #!/usr/bin/php5 | ||||
<? | <? | ||||
$img = imagecreatefrompng(dirname(__FILE__)."/logo-caca.png"); | $img = imagecreatefrompng(dirname(__FILE__)."/logo-caca.png"); | ||||
$canvas = caca_create_canvas(0, 0); | $dither = caca_create_dither_gd($img); | ||||
if (!$dither) | |||||
$dither = caca_create_dither(32, 128, 128, 4 * 128, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000); | die("Can not create dither. Maybe this image is not truecolor.\n"); | ||||
$canvas = caca_create_canvas(0, 0); | |||||
$display = caca_create_display($canvas); | $display = caca_create_display($canvas); | ||||
caca_set_display_time($display, 80000); | if (!$dither) | ||||
die("Can not create display.\n"); | |||||
caca_dither_bitmap_gd($canvas, 0, 0, caca_get_canvas_width($canvas), caca_get_canvas_height($canvas), $dither, $img); | caca_dither_bitmap_gd($canvas, 0, 0, caca_get_canvas_width($canvas), caca_get_canvas_height($canvas), $dither, $img); | ||||
caca_refresh_display($display); | caca_refresh_display($display); | ||||
@@ -88,6 +88,7 @@ static function_entry caca_functions[] = { | |||||
PHP_FE(caca_create_frame, NULL) | PHP_FE(caca_create_frame, NULL) | ||||
PHP_FE(caca_free_frame, NULL) | PHP_FE(caca_free_frame, NULL) | ||||
PHP_FE(caca_create_dither, NULL) | PHP_FE(caca_create_dither, NULL) | ||||
PHP_FE(caca_create_dither_gd, NULL) | |||||
PHP_FE(caca_set_dither_palette, NULL) | PHP_FE(caca_set_dither_palette, NULL) | ||||
PHP_FE(caca_set_dither_brightness, NULL) | PHP_FE(caca_set_dither_brightness, NULL) | ||||
PHP_FE(caca_get_dither_brightness, NULL) | PHP_FE(caca_get_dither_brightness, NULL) | ||||
@@ -963,6 +964,20 @@ PHP_FUNCTION(caca_create_dither) { | |||||
ZEND_REGISTER_RESOURCE(return_value, dither, le_caca_dither); | ZEND_REGISTER_RESOURCE(return_value, dither, le_caca_dither); | ||||
} | } | ||||
PHP_FUNCTION(caca_create_dither_gd) { | |||||
zval *_zval; | |||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &_zval) == FAILURE) { | |||||
RETURN_FALSE; | |||||
} | |||||
gdImage *img = fetch_external_resource(_zval, "gd"); | |||||
if (!img | !img->trueColor) { | |||||
RETURN_FALSE; | |||||
} | |||||
caca_dither_t *dither = caca_create_dither(sizeof(int) * 8, img->sx, img->sy, img->sx * sizeof(int), 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000); | |||||
ZEND_REGISTER_RESOURCE(return_value, dither, le_caca_dither); | |||||
} | |||||
PHP_FUNCTION(caca_set_dither_palette) { | PHP_FUNCTION(caca_set_dither_palette) { | ||||
} | } | ||||
@@ -105,6 +105,7 @@ PHP_FUNCTION(caca_set_frame_name); | |||||
PHP_FUNCTION(caca_create_frame); | PHP_FUNCTION(caca_create_frame); | ||||
PHP_FUNCTION(caca_free_frame); | PHP_FUNCTION(caca_free_frame); | ||||
PHP_FUNCTION(caca_create_dither); | PHP_FUNCTION(caca_create_dither); | ||||
PHP_FUNCTION(caca_create_dither_gd); | |||||
PHP_FUNCTION(caca_set_dither_palette); | PHP_FUNCTION(caca_set_dither_palette); | ||||
PHP_FUNCTION(caca_set_dither_brightness); | PHP_FUNCTION(caca_set_dither_brightness); | ||||
PHP_FUNCTION(caca_get_dither_brightness); | PHP_FUNCTION(caca_get_dither_brightness); | ||||