|
@@ -142,10 +142,26 @@ PHP_MINIT_FUNCTION(pipi) { |
|
|
le_pipi_image = zend_register_list_destructors_ex(php_pipi_image_dtor, NULL, PHP_PIPI_IMAGE_RES_NAME, module_number); |
|
|
le_pipi_image = zend_register_list_destructors_ex(php_pipi_image_dtor, NULL, PHP_PIPI_IMAGE_RES_NAME, module_number); |
|
|
le_pipi_context = zend_register_list_destructors_ex(php_pipi_context_dtor, NULL, PHP_PIPI_CONTEXT_RES_NAME, module_number); |
|
|
le_pipi_context = zend_register_list_destructors_ex(php_pipi_context_dtor, NULL, PHP_PIPI_CONTEXT_RES_NAME, module_number); |
|
|
le_pipi_histogram = zend_register_list_destructors_ex(php_pipi_histogram_dtor, NULL, PHP_PIPI_HISTOGRAM_RES_NAME, module_number); |
|
|
le_pipi_histogram = zend_register_list_destructors_ex(php_pipi_histogram_dtor, NULL, PHP_PIPI_HISTOGRAM_RES_NAME, module_number); |
|
|
|
|
|
|
|
|
|
|
|
REGISTER_LONG_CONSTANT("PIPI_SCAN_RASTER", PIPI_SCAN_RASTER, CONST_CS | CONST_PERSISTENT); |
|
|
|
|
|
REGISTER_LONG_CONSTANT("PIPI_SCAN_SERPENTINE", PIPI_SCAN_SERPENTINE, CONST_CS | CONST_PERSISTENT); |
|
|
|
|
|
REGISTER_LONG_CONSTANT("PIPI_PIXELS_UNINITIALISED", PIPI_PIXELS_UNINITIALISED, CONST_CS | CONST_PERSISTENT); |
|
|
|
|
|
REGISTER_LONG_CONSTANT("PIPI_PIXELS_RGBA_C", PIPI_PIXELS_RGBA_C, CONST_CS | CONST_PERSISTENT); |
|
|
|
|
|
REGISTER_LONG_CONSTANT("PIPI_PIXELS_BGR_C", PIPI_PIXELS_BGR_C, CONST_CS | CONST_PERSISTENT); |
|
|
|
|
|
REGISTER_LONG_CONSTANT("PIPI_PIXELS_RGBA_F", PIPI_PIXELS_RGBA_F, CONST_CS | CONST_PERSISTENT); |
|
|
|
|
|
REGISTER_LONG_CONSTANT("PIPI_PIXELS_Y_F", PIPI_PIXELS_Y_F, CONST_CS | CONST_PERSISTENT); |
|
|
|
|
|
REGISTER_LONG_CONSTANT("PIPI_PIXELS_MASK_C", PIPI_PIXELS_MASK_C, CONST_CS | CONST_PERSISTENT); |
|
|
|
|
|
REGISTER_LONG_CONSTANT("PIPI_PIXELS_MAX", PIPI_PIXELS_MAX, CONST_CS | CONST_PERSISTENT); |
|
|
|
|
|
REGISTER_LONG_CONSTANT("PIPI_COLOR_R", PIPI_COLOR_R, CONST_CS | CONST_PERSISTENT); |
|
|
|
|
|
REGISTER_LONG_CONSTANT("PIPI_COLOR_G", PIPI_COLOR_G, CONST_CS | CONST_PERSISTENT); |
|
|
|
|
|
REGISTER_LONG_CONSTANT("PIPI_COLOR_B", PIPI_COLOR_B, CONST_CS | CONST_PERSISTENT); |
|
|
|
|
|
REGISTER_LONG_CONSTANT("PIPI_COLOR_A", PIPI_COLOR_A, CONST_CS | CONST_PERSISTENT); |
|
|
|
|
|
REGISTER_LONG_CONSTANT("PIPI_COLOR_Y", PIPI_COLOR_Y, CONST_CS | CONST_PERSISTENT); |
|
|
|
|
|
|
|
|
return SUCCESS; |
|
|
return SUCCESS; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//----------SOMEMACROS---------------// |
|
|
|
|
|
|
|
|
//----------SOME USEFULL MACROS---------------// |
|
|
|
|
|
|
|
|
#define FETCH_STR(str) \ |
|
|
#define FETCH_STR(str) \ |
|
|
int __len; \ |
|
|
int __len; \ |
|
@@ -166,8 +182,7 @@ PHP_MINIT_FUNCTION(pipi) { |
|
|
ZEND_FETCH_RESOURCE(img, pipi_image_t*, &_zval, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image); |
|
|
ZEND_FETCH_RESOURCE(img, pipi_image_t*, &_zval, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image); |
|
|
|
|
|
|
|
|
#define FETCH_IMG_IMG(img1, img2) \ |
|
|
#define FETCH_IMG_IMG(img1, img2) \ |
|
|
zval *_zval1; \ |
|
|
|
|
|
zval *_zval2; \ |
|
|
|
|
|
|
|
|
zval *_zval1, *_zval2; \ |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &_zval1, &_zval2) == FAILURE) { \ |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &_zval1, &_zval2) == FAILURE) { \ |
|
|
RETURN_FALSE; \ |
|
|
RETURN_FALSE; \ |
|
|
} \ |
|
|
} \ |
|
@@ -192,8 +207,7 @@ PHP_FUNCTION(pipi_create_context) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
PHP_FUNCTION(pipi_get_command_list) { |
|
|
PHP_FUNCTION(pipi_get_command_list) { |
|
|
pipi_command_t const *list; |
|
|
|
|
|
pipi_command_t const *cmd; |
|
|
|
|
|
|
|
|
pipi_command_t const *list, *cmd; |
|
|
list = pipi_get_command_list(); |
|
|
list = pipi_get_command_list(); |
|
|
|
|
|
|
|
|
array_init(return_value); |
|
|
array_init(return_value); |
|
@@ -213,9 +227,9 @@ PHP_FUNCTION(pipi_command) { |
|
|
ZEND_FETCH_RESOURCE(ctxt, pipi_context_t*, &res, -1, PHP_PIPI_CONTEXT_RES_NAME, le_pipi_context); |
|
|
ZEND_FETCH_RESOURCE(ctxt, pipi_context_t*, &res, -1, PHP_PIPI_CONTEXT_RES_NAME, le_pipi_context); |
|
|
|
|
|
|
|
|
if (arg2_len != 0) { |
|
|
if (arg2_len != 0) { |
|
|
RETURN_LONG(pipi_command(ctxt, arg1, arg2)); |
|
|
|
|
|
|
|
|
RETURN_BOOL(pipi_command(ctxt, arg1, arg2) == 0); |
|
|
} |
|
|
} |
|
|
RETURN_LONG(pipi_command(ctxt, arg1)); |
|
|
|
|
|
|
|
|
RETURN_BOOL(pipi_command(ctxt, arg1) == 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
PHP_FUNCTION(pipi_load) { |
|
|
PHP_FUNCTION(pipi_load) { |
|
@@ -262,7 +276,7 @@ PHP_FUNCTION(pipi_save) { |
|
|
pipi_image_t *img; |
|
|
pipi_image_t *img; |
|
|
ZEND_FETCH_RESOURCE(img, pipi_image_t*, &res, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image); |
|
|
ZEND_FETCH_RESOURCE(img, pipi_image_t*, &res, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image); |
|
|
|
|
|
|
|
|
RETURN_LONG(pipi_save(img, str)); |
|
|
|
|
|
|
|
|
RETURN_BOOL(pipi_save(img, str) == 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
PHP_FUNCTION(pipi_set_gamma) { |
|
|
PHP_FUNCTION(pipi_set_gamma) { |
|
@@ -761,7 +775,7 @@ PHP_FUNCTION(pipi_get_image_histogram) { |
|
|
ZEND_FETCH_RESOURCE(image, pipi_image_t*, &_zval_img, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image); |
|
|
ZEND_FETCH_RESOURCE(image, pipi_image_t*, &_zval_img, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image); |
|
|
ZEND_FETCH_RESOURCE(histogram, pipi_histogram_t*, &_zval_hst, -1, PHP_PIPI_HISTOGRAM_RES_NAME, le_pipi_histogram); |
|
|
ZEND_FETCH_RESOURCE(histogram, pipi_histogram_t*, &_zval_hst, -1, PHP_PIPI_HISTOGRAM_RES_NAME, le_pipi_histogram); |
|
|
|
|
|
|
|
|
RETURN_LONG(pipi_get_image_histogram(image, histogram, flags)); |
|
|
|
|
|
|
|
|
RETURN_BOOL(pipi_get_image_histogram(image, histogram, flags) == 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
PHP_FUNCTION(pipi_render_histogram) { |
|
|
PHP_FUNCTION(pipi_render_histogram) { |
|
@@ -775,7 +789,7 @@ PHP_FUNCTION(pipi_render_histogram) { |
|
|
ZEND_FETCH_RESOURCE(image, pipi_image_t*, &_zval_img, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image); |
|
|
ZEND_FETCH_RESOURCE(image, pipi_image_t*, &_zval_img, -1, PHP_PIPI_IMAGE_RES_NAME, le_pipi_image); |
|
|
ZEND_FETCH_RESOURCE(histogram, pipi_histogram_t*, &_zval_hst, -1, PHP_PIPI_HISTOGRAM_RES_NAME, le_pipi_histogram); |
|
|
ZEND_FETCH_RESOURCE(histogram, pipi_histogram_t*, &_zval_hst, -1, PHP_PIPI_HISTOGRAM_RES_NAME, le_pipi_histogram); |
|
|
|
|
|
|
|
|
RETURN_LONG(pipi_render_histogram(image, histogram, flags)); |
|
|
|
|
|
|
|
|
RETURN_BOOL(pipi_render_histogram(image, histogram, flags) == 0); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|