/* {{{ proto bool ImagickPixel::isSimilar(float fuzz) Returns true if the distance between two colors is less than the specified distance. */ static void s_is_pixelwand_similar(INTERNAL_FUNCTION_PARAMETERS, zend_bool use_quantum) { zval *param; double fuzz; php_imagickpixel_object *internp; MagickBooleanType status; PixelWand *color_wand; zend_bool allocated; /* Parse parameters given to function */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zd", ¶m, &fuzz) == FAILURE) { return; } internp = Z_IMAGICKPIXEL_P(getThis()); color_wand = php_imagick_zval_to_pixelwand (param, IMAGICKPIXEL_CLASS, &allocated TSRMLS_CC); if (!color_wand) return; status = IsPixelWandSimilar(internp->pixel_wand, color_wand, (use_quantum ? (QuantumRange * fuzz) : fuzz)); if (allocated) color_wand = DestroyPixelWand (color_wand); if (status == MagickFalse) { RETURN_FALSE; } RETURN_TRUE; }
/* {{{ proto bool ImagickPixel::isSimilar(float fuzz) Returns true if the distance between two colors is less than the specified distance. */ PHP_METHOD(imagickpixel, issimilar) { zval *param; double fuzz; php_imagickpixel_object *internp; MagickBooleanType status; PixelWand *color_wand; zend_bool allocated; /* Parse parameters given to function */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zd", ¶m, &fuzz) == FAILURE) { return; } internp = (php_imagickpixel_object *)zend_object_store_get_object(getThis() TSRMLS_CC); color_wand = php_imagick_zval_to_pixelwand (param, IMAGICKPIXEL_CLASS, &allocated TSRMLS_CC); if (!color_wand) return; status = IsPixelWandSimilar(internp->pixel_wand, color_wand, fuzz); if (allocated) color_wand = DestroyPixelWand (color_wand); if (status == MagickFalse) { RETURN_FALSE; } RETURN_TRUE; }