diff options
| -rw-r--r-- | filters/php_colormatrix.c | 70 |
1 files changed, 25 insertions, 45 deletions
diff --git a/filters/php_colormatrix.c b/filters/php_colormatrix.c index 1cd28b2..2f3ae83 100644 --- a/filters/php_colormatrix.c +++ b/filters/php_colormatrix.c @@ -264,42 +264,32 @@ static void _php_colormatrix_saturatemat(double mat[16], double sat) mat[15] = 1.0; } -static void _php_colormatrix_usermat(double mat[16], zval** data) +static void _php_colormatrix_usermat(double mat[16], zval* data) { HashTable* mat_ht; - HashPosition pos; + ulong num_index; + zend_string *str_index; + zval *value; - convert_to_array_ex(data); - - mat_ht=(*data)->value.ht; // FIXME: should really use HASH_OF macro. - // Filter API change needed to supply TSRMLS to filters - zend_hash_internal_pointer_reset_ex(mat_ht,&pos); - while (pos) - { - char *str_index; - ulong num_index; - int retval; - zval **value; + convert_to_array_ex(data); + mat_ht = HASH_OF(data); - retval=zend_hash_get_current_key_ex(mat_ht,&str_index,NULL,&num_index,0,&pos); - if (retval==HASH_KEY_IS_LONG) + ZEND_HASH_FOREACH_KEY_VAL(mat_ht, num_index, str_index, value) + { + if ((num_index>=0)&&(num_index<16)) { - if ((num_index>=0)&&(num_index<16)) - { - zend_hash_get_current_data_ex(mat_ht,(void**)&value,&pos); - convert_to_double_ex(value); - mat[num_index]=Z_DVAL_PP(value); - } + convert_to_double_ex(value); + mat[num_index]=Z_DVAL_P(value); } - - zend_hash_move_forward_ex(mat_ht,&pos); - } + } ZEND_HASH_FOREACH_END(); } static int _php_colormatrix_exec(Imlib_Image im, char* filter, HashTable* params) { - HashPosition pos; + ulong num_index; + zend_string *str_index; + zval *data; double mat[16]; int x=0,y=0,w,h,imgw,imgh; @@ -310,38 +300,28 @@ _php_colormatrix_exec(Imlib_Image im, char* filter, HashTable* params) w = imgw = imlib_image_get_width(); h = imgh = imlib_image_get_height(); - zend_hash_internal_pointer_reset_ex(params,&pos); - while (pos) + ZEND_HASH_FOREACH_KEY_VAL(params, num_index, str_index, data) { - char *str_index; - ulong num_index; - int retval; - - retval=zend_hash_get_current_key_ex(params,&str_index,NULL,&num_index,0,&pos); - if (retval==HASH_KEY_IS_STRING) + if (str_index) { - zval **data; - zend_hash_get_current_data_ex(params,(void**)&data,&pos); - - if (!strcmp(str_index,"x")) { convert_to_long_ex(data); x=Z_LVAL_PP(data); }; - if (!strcmp(str_index,"y")) { convert_to_long_ex(data); y=Z_LVAL_PP(data); }; - if (!strcmp(str_index,"w")) { convert_to_long_ex(data); w=Z_LVAL_PP(data); }; - if (!strcmp(str_index,"h")) { convert_to_long_ex(data); h=Z_LVAL_PP(data); }; + if (!strcmp(str_index->val,"x")) { convert_to_long_ex(data); x=Z_LVAL_P(data); }; + if (!strcmp(str_index->val,"y")) { convert_to_long_ex(data); y=Z_LVAL_P(data); }; + if (!strcmp(str_index->val,"w")) { convert_to_long_ex(data); w=Z_LVAL_P(data); }; + if (!strcmp(str_index->val,"h")) { convert_to_long_ex(data); h=Z_LVAL_P(data); }; if (!strcmp(filter,"cm_user")) { - if (!strcmp(str_index,"matrix")) _php_colormatrix_usermat(mat,data); + if (!strcmp(str_index->val,"matrix")) _php_colormatrix_usermat(mat,data); } if (!strcmp(filter,"cm_saturation")) { - if (!strcmp(str_index,"sat")) { convert_to_double_ex(data); _php_colormatrix_saturatemat(mat,Z_DVAL_PP(data)); }; + if (!strcmp(str_index->val,"sat")) { convert_to_double_ex(data); _php_colormatrix_saturatemat(mat,Z_DVAL_P(data)); }; } if (!strcmp(filter,"cm_huerot")) { - if (!strcmp(str_index,"angle")) { convert_to_double_ex(data); _php_colormatrix_huerotatemat(mat,Z_DVAL_PP(data)); }; + if (!strcmp(str_index->val,"angle")) { convert_to_double_ex(data); _php_colormatrix_huerotatemat(mat,Z_DVAL_P(data)); }; } } - zend_hash_move_forward_ex(params,&pos); - } + } ZEND_HASH_FOREACH_END(); if (x<0) x=0; if (y<0) y=0; |
