Ignore:
Timestamp:
Oct 27, 2008, 8:35:48 PM (11 years ago)
Author:
nico
Message:
  • Add a "caca_create_dither_gd" function that create the proper dither for a given gd resource.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/caca-php/php_caca.c

    r3122 r3123  
    8989        PHP_FE(caca_free_frame, NULL)
    9090        PHP_FE(caca_create_dither, NULL)
     91        PHP_FE(caca_create_dither_gd, NULL)
    9192        PHP_FE(caca_set_dither_palette, NULL)
    9293        PHP_FE(caca_set_dither_brightness, NULL)
     
    964965}
    965966
     967PHP_FUNCTION(caca_create_dither_gd) {
     968        zval *_zval;
     969        if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &_zval) == FAILURE) {
     970                RETURN_FALSE;
     971        }
     972
     973        gdImage *img = fetch_external_resource(_zval, "gd");
     974        if (!img | !img->trueColor) {
     975                RETURN_FALSE;
     976        }
     977        caca_dither_t *dither = caca_create_dither(sizeof(int) * 8, img->sx, img->sy, img->sx * sizeof(int), 0x00ff0000, 0x0000ff00, 0x000000ff, 0x00000000);
     978        ZEND_REGISTER_RESOURCE(return_value, dither, le_caca_dither);
     979}
     980
    966981PHP_FUNCTION(caca_set_dither_palette) {
    967982}
Note: See TracChangeset for help on using the changeset viewer.