/* {{{ proto float GmagickPixel::getColorValue(int color ) Gets the normalized color of the GmagickPixel. */ PHP_METHOD(gmagickpixel, getcolorvalue) { php_gmagickpixel_object *internp; zend_long color; double color_value = 0; /* Parse parameters given to function */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color) == FAILURE) { return; } internp = Z_GMAGICKPIXEL_OBJ_P(getThis()); switch (color) { case GMAGICK_COLOR_BLACK: color_value = PixelGetBlack(internp->pixel_wand); break; case GMAGICK_COLOR_BLUE: color_value = PixelGetBlue(internp->pixel_wand); break; case GMAGICK_COLOR_CYAN: color_value = PixelGetCyan(internp->pixel_wand); break; case GMAGICK_COLOR_GREEN: color_value = PixelGetGreen(internp->pixel_wand); break; case GMAGICK_COLOR_RED: color_value = PixelGetRed(internp->pixel_wand); break; case GMAGICK_COLOR_YELLOW: color_value = PixelGetYellow(internp->pixel_wand); break; case GMAGICK_COLOR_MAGENTA: color_value = PixelGetMagenta(internp->pixel_wand); break; case GMAGICK_COLOR_OPACITY: color_value = PixelGetOpacity(internp->pixel_wand); break; default: GMAGICK_THROW_GMAGICKPIXEL_EXCEPTION(internp->pixel_wand, "Unknown color type"); break; } RETVAL_DOUBLE(color_value); }
/* {{{ proto float ImagickPixel::getColorValue(int color) Gets the normalized value of a color in the ImagickPixel. */ PHP_METHOD(imagickpixel, getcolorvalue) { php_imagick_color_t color_enum; php_imagickpixel_object *internp; im_long color; double color_value = 0; /* Parse parameters given to function */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color) == FAILURE) { return; } internp = Z_IMAGICKPIXEL_P(getThis()); if (color <= PHP_IMAGICK_COLOR_MIN || color >= PHP_IMAGICK_COLOR_MAX) { php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Unknown color type" TSRMLS_CC); return; } color_enum = color; switch (color_enum) { case PHP_IMAGICK_COLOR_BLACK: color_value = PixelGetBlack(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_BLUE: color_value = PixelGetBlue(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_CYAN: color_value = PixelGetCyan(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_GREEN: color_value = PixelGetGreen(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_RED: color_value = PixelGetRed(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_YELLOW: color_value = PixelGetYellow(internp->pixel_wand); break; case PHP_IMAGICK_COLOR_MAGENTA: color_value = PixelGetMagenta(internp->pixel_wand); break; #if MagickLibVersion < 0x700 case PHP_IMAGICK_COLOR_OPACITY: color_value = PixelGetOpacity(internp->pixel_wand); break; #endif case PHP_IMAGICK_COLOR_ALPHA: color_value = PixelGetAlpha(internp->pixel_wand); break; #if MagickLibVersion > 0x628 case PHP_IMAGICK_COLOR_FUZZ: color_value = PixelGetFuzz(internp->pixel_wand); break; #endif default: php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Unknown color type" TSRMLS_CC); return; break; } RETVAL_DOUBLE(color_value); }
/* {{{ proto float ImagickPixel::getColorValue(int color) Gets the normalized color of the ImagickPixel. */ PHP_METHOD(imagickpixel, getcolorvalue) { php_imagickpixel_object *internp; long color; double color_value = 0; /* Parse parameters given to function */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color) == FAILURE) { return; } internp = (php_imagickpixel_object *)zend_object_store_get_object(getThis() TSRMLS_CC); switch (color) { case IMAGICKCOLORBLACK: color_value = PixelGetBlack(internp->pixel_wand); break; case IMAGICKCOLORBLUE: color_value = PixelGetBlue(internp->pixel_wand); break; case IMAGICKCOLORCYAN: color_value = PixelGetCyan(internp->pixel_wand); break; case IMAGICKCOLORGREEN: color_value = PixelGetGreen(internp->pixel_wand); break; case IMAGICKCOLORRED: color_value = PixelGetRed(internp->pixel_wand); break; case IMAGICKCOLORYELLOW: color_value = PixelGetYellow(internp->pixel_wand); break; case IMAGICKCOLORMAGENTA: color_value = PixelGetMagenta(internp->pixel_wand); break; case IMAGICKCOLOROPACITY: color_value = PixelGetOpacity(internp->pixel_wand); break; case IMAGICKCOLORALPHA: color_value = PixelGetAlpha(internp->pixel_wand); break; #if MagickLibVersion > 0x628 case IMAGICKCOLORFUZZ: color_value = PixelGetFuzz(internp->pixel_wand); break; #endif default: php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Unknown color type" TSRMLS_CC); return; break; } RETVAL_DOUBLE(color_value); }