Pārlūkot izejas kodu

* Add a "caca_create_dither_gd" function that create the proper dither for a

given gd resource.
tags/v0.99.beta17
Nicolas Vion nico pirms 16 gadiem
vecāks
revīzija
e2fc23d7da
3 mainītis faili ar 22 papildinājumiem un 4 dzēšanām
  1. +6
    -4
      caca-php/examples/dithering.php
  2. +15
    -0
      caca-php/php_caca.c
  3. +1
    -0
      caca-php/php_caca.h

+ 6
- 4
caca-php/examples/dithering.php Parādīt failu

@@ -1,12 +1,14 @@
#!/usr/bin/php5
<?
$img = imagecreatefrompng(dirname(__FILE__)."/logo-caca.png");
$canvas = caca_create_canvas(0, 0);
$dither = caca_create_dither(32, 128, 128, 4 * 128, 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000);
$dither = caca_create_dither_gd($img);
if (!$dither)
die("Can not create dither. Maybe this image is not truecolor.\n");

$canvas = caca_create_canvas(0, 0);
$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_refresh_display($display);


+ 15
- 0
caca-php/php_caca.c Parādīt failu

@@ -88,6 +88,7 @@ static function_entry caca_functions[] = {
PHP_FE(caca_create_frame, NULL)
PHP_FE(caca_free_frame, 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_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);
}

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) {
}



+ 1
- 0
caca-php/php_caca.h Parādīt failu

@@ -105,6 +105,7 @@ PHP_FUNCTION(caca_set_frame_name);
PHP_FUNCTION(caca_create_frame);
PHP_FUNCTION(caca_free_frame);
PHP_FUNCTION(caca_create_dither);
PHP_FUNCTION(caca_create_dither_gd);
PHP_FUNCTION(caca_set_dither_palette);
PHP_FUNCTION(caca_set_dither_brightness);
PHP_FUNCTION(caca_get_dither_brightness);


Notiek ielāde…
Atcelt
Saglabāt