Explorar el Código

* Change return value for function (success return (bool) true):

pipi_load, pipi_save, pipi_command, pipi_render_histogram, 
     pipi_get_image_histogram
 * Add pipi's php constants definitions


git-svn-id: file:///srv/caca.zoy.org/var/lib/svn/libpipi/trunk@3087 92316355-f0b4-4df1-b90c-862c8a59935f
remotes/tiles
nico hace 16 años
padre
commit
f4b2a4a738
Se han modificado 3 ficheros con 29 adiciones y 14 borrados
  1. +1
    -0
      pipi-php/examples/example1.php
  2. +4
    -4
      pipi-php/examples/pipi.php
  3. +24
    -10
      pipi-php/php_pipi.c

+ 1
- 0
pipi-php/examples/example1.php Ver fichero

@@ -1,5 +1,6 @@
<?
//print_r(pipi_get_command_list());
echo PIPI_COLOR_Y;

$img = pipi_load_stock("random:128x128");
$img = pipi_gaussian_blur($img, 10);


+ 4
- 4
pipi-php/examples/pipi.php Ver fichero

@@ -22,8 +22,8 @@ for ($argi = 1; $argi < $argc; $argi++) {
}
$cmd_argc = $list[$cmd_name];
if ($argi + $cmd_argc > $argc) {
die("too few arguments for $arg_name\n");
if ($argi + $cmd_argc + 1 > $argc) {
die("too few arguments for $cmd_name\n");
}

switch ($cmd_argc) {
@@ -36,13 +36,13 @@ for ($argi = 1; $argi < $argc; $argi++) {
default:
die();
}
if ($res != 0) {
if (!$res) {
die("command $cmd_name failed\n");
}
$argi += $cmd_argc;
}
else {
if (pipi_command($ctx, "load", $arg) != 0)
if (!pipi_command($ctx, "load", $arg))
die("could not load $arg\n");
}
}

+ 24
- 10
pipi-php/php_pipi.c Ver fichero

@@ -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_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);

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;
}

//----------SOMEMACROS---------------//
//----------SOME USEFULL MACROS---------------//

#define FETCH_STR(str) \
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);

#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) { \
RETURN_FALSE; \
} \
@@ -192,8 +207,7 @@ PHP_FUNCTION(pipi_create_context) {
}

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();

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);

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) {
@@ -262,7 +276,7 @@ PHP_FUNCTION(pipi_save) {
pipi_image_t *img;
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) {
@@ -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(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) {
@@ -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(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);
}



Cargando…
Cancelar
Guardar