Changeset 3119
- Timestamp:
- Oct 27, 2008, 5:23:05 PM (14 years ago)
- Location:
- libcaca/trunk/caca-php
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
libcaca/trunk/caca-php/config.m4
r3089 r3119 6 6 PHP_ADD_LIBRARY(caca,, CACA_SHARED_LIBADD) 7 7 ], [ 8 AC_MSG_ERROR(libcaca required !)8 AC_MSG_ERROR(libcaca development files required !) 9 9 ]) 10 11 AC_CHECK_LIB(gd, gdImageSetPixel, [ 12 PHP_ADD_LIBRARY(gd,, CACA_SHARED_LIBADD) 13 ], [ 14 AC_MSG_ERROR(gd development files required !) 15 ]) 16 10 17 PHP_NEW_EXTENSION(caca, php_caca.c, $ext_shared,,) 11 18 PHP_SUBST(CACA_SHARED_LIBADD) -
libcaca/trunk/caca-php/php_caca.c
r3117 r3119 17 17 #include "php.h" 18 18 #include "php_caca.h" 19 #include <gd.h> 19 20 20 21 static function_entry caca_functions[] = { … … 106 107 PHP_FE(caca_get_dither_algorithm_list, NULL) 107 108 PHP_FE(caca_get_dither_algorithm, NULL) 108 PHP_FE(caca_dither_bitmap , NULL)109 PHP_FE(caca_dither_bitmap_gd, NULL) 109 110 PHP_FE(caca_get_font_list, NULL) 110 111 PHP_FE(caca_get_font_width, NULL) … … 342 343 RETURN_BOOL((i) == 0); 343 344 345 //------- Function that allows to fetch external php resources such as gd resouces 346 347 void *fetch_external_resource(zval *_zval, char const *type_name) { 348 int resource_id = _zval->value.lval; 349 int resource_type; 350 void *result = zend_list_find(resource_id, &resource_type); 351 char *resource_type_name = zend_rsrc_list_get_rsrc_type(resource_id); 352 return (strcmp(resource_type_name, type_name) == 0) ? result : NULL; 353 } 354 344 355 //------- PHP Binding's specific functions ----------// 345 356 … … 1125 1136 } 1126 1137 1127 PHP_FUNCTION(caca_dither_bitmap) { 1128 zval *_zval1, *_zval2; 1129 int x, y, w, h = 0; 1130 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllllr", &_zval1, &x, &y, &w, &h, &_zval2) == FAILURE) { 1131 RETURN_FALSE; 1132 } 1133 caca_canvas_t *canvas; 1134 ZEND_FETCH_RESOURCE(canvas, caca_canvas_t*, &_zval1, -1, PHP_CACA_CANVAS_RES_NAME, le_caca_canvas); 1135 caca_dither_t *dither; 1136 ZEND_FETCH_RESOURCE(dither, caca_dither_t*, &_zval2, -1, PHP_CACA_DITHER_RES_NAME, le_caca_dither); 1137 /* RETURN_SUCCESS(caca_dither_bitmap(canvas, x, y, x, h, dither, pixels); //TODO: Use gd ressouces for pixels? 1138 */ 1138 PHP_FUNCTION(caca_dither_bitmap_gd) { 1139 zval *_zval; 1140 if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &_zval) == FAILURE) { 1141 RETURN_FALSE; 1142 } 1143 gdImage *img = fetch_external_resource(_zval, "gd"); 1144 if (img) { 1145 printf("image size: %i x %i\n", img->sx, img->sy); 1146 } 1139 1147 } 1140 1148 -
libcaca/trunk/caca-php/php_caca.h
r3112 r3119 124 124 PHP_FUNCTION(caca_get_dither_algorithm_list); 125 125 PHP_FUNCTION(caca_get_dither_algorithm); 126 PHP_FUNCTION(caca_dither_bitmap );126 PHP_FUNCTION(caca_dither_bitmap_gd); 127 127 PHP_FUNCTION(caca_get_font_list); 128 128 PHP_FUNCTION(caca_get_font_width);
Note: See TracChangeset
for help on using the changeset viewer.