Пример #1
0
/* {{{ proto int ImagickPixel::getColorValueQuantum(int color)
	Gets the quantum color of the ImagickPixel
*/
PHP_METHOD(imagickpixel, getcolorvaluequantum)
{
	php_imagickpixel_object *internp;
	long color, color_value;

	/* 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 = PixelGetBlackQuantum(internp->pixel_wand);
		break;

		case IMAGICKCOLORBLUE:
			color_value = PixelGetBlueQuantum(internp->pixel_wand);
		break;

		case IMAGICKCOLORCYAN:
			color_value = PixelGetCyanQuantum(internp->pixel_wand);
		break;

		case IMAGICKCOLORGREEN:
			color_value = PixelGetGreenQuantum(internp->pixel_wand);
		break;

		case IMAGICKCOLORRED:
			color_value = PixelGetRedQuantum(internp->pixel_wand);
		break;

		case IMAGICKCOLORYELLOW:
			color_value = PixelGetYellowQuantum(internp->pixel_wand);
		break;

		case IMAGICKCOLORMAGENTA:
			color_value = PixelGetMagentaQuantum(internp->pixel_wand);
		break;

		case IMAGICKCOLOROPACITY:
			color_value = PixelGetOpacityQuantum(internp->pixel_wand);
		break;

		case IMAGICKCOLORALPHA:
			color_value = PixelGetAlphaQuantum(internp->pixel_wand);
		break;

		default:
			php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Unknown color type" TSRMLS_CC);
			return;
		break;
	}
	RETVAL_LONG(color_value);
}
Пример #2
0
/* {{{ proto float GmagickPixel::getColorValueQuantum(int color )
	Gets the quantum color of the GmagickPixel.
*/
PHP_METHOD(gmagickpixel, getcolorvaluequantum)
{
	php_gmagickpixel_object *internp;
	zend_long color_quantum;
	Quantum color_value_quantum = 0;

	/* Parse parameters given to function */
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color_quantum) == FAILURE) {
		return;
	}

	internp = Z_GMAGICKPIXEL_OBJ_P(getThis());

	switch (color_quantum) {

		case GMAGICK_COLOR_BLACK:
			color_value_quantum = PixelGetBlackQuantum(internp->pixel_wand);
			break;

		case GMAGICK_COLOR_BLUE:
			color_value_quantum = PixelGetBlueQuantum(internp->pixel_wand);
			break;

		case GMAGICK_COLOR_CYAN:
			color_value_quantum = PixelGetCyanQuantum(internp->pixel_wand);
			break;

		case GMAGICK_COLOR_GREEN:
			color_value_quantum = PixelGetGreenQuantum(internp->pixel_wand);
			break;

		case GMAGICK_COLOR_RED:
			color_value_quantum = PixelGetRedQuantum(internp->pixel_wand);
			break;

		case GMAGICK_COLOR_YELLOW:
			color_value_quantum = PixelGetYellowQuantum(internp->pixel_wand);
			break;

		case GMAGICK_COLOR_MAGENTA:
			color_value_quantum = PixelGetMagentaQuantum(internp->pixel_wand);
			break;

		case GMAGICK_COLOR_OPACITY:
			color_value_quantum = PixelGetOpacityQuantum(internp->pixel_wand);
			break;

		default:
			zend_throw_exception_ex(php_gmagickpixel_exception_class_entry, 2 TSRMLS_CC, "Unknown color type: %d", color_quantum);
			RETURN_NULL();
	}
	RETVAL_LONG(color_value_quantum);
}
Пример #3
0
/* {{{ proto Quantum ImagickPixel::getColorValueQuantum(int color)
	Gets the quantum value of a color in the ImagickPixel. Quantum is a float if ImageMagick was compiled with HDRI
	otherwise an integer.
*/
PHP_METHOD(imagickpixel, getcolorvaluequantum)
{
    php_imagickpixel_object *internp;
    im_long color;
    Quantum color_value;

    /* Parse parameters given to function */
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &color) == FAILURE) {
        return;
    }

    internp = Z_IMAGICKPIXEL_P(getThis());

    switch (color) {

    case PHP_IMAGICK_COLOR_BLACK:
        color_value = PixelGetBlackQuantum(internp->pixel_wand);
        break;

    case PHP_IMAGICK_COLOR_BLUE:
        color_value = PixelGetBlueQuantum(internp->pixel_wand);
        break;

    case PHP_IMAGICK_COLOR_CYAN:
        color_value = PixelGetCyanQuantum(internp->pixel_wand);
        break;

    case PHP_IMAGICK_COLOR_GREEN:
        color_value = PixelGetGreenQuantum(internp->pixel_wand);
        break;

    case PHP_IMAGICK_COLOR_RED:
        color_value = PixelGetRedQuantum(internp->pixel_wand);
        break;

    case PHP_IMAGICK_COLOR_YELLOW:
        color_value = PixelGetYellowQuantum(internp->pixel_wand);
        break;

    case PHP_IMAGICK_COLOR_MAGENTA:
        color_value = PixelGetMagentaQuantum(internp->pixel_wand);
        break;

#if MagickLibVersion < 0x700
    case PHP_IMAGICK_COLOR_OPACITY:
        color_value = PixelGetOpacityQuantum(internp->pixel_wand);
        break;
#endif

    case PHP_IMAGICK_COLOR_ALPHA:
        color_value = PixelGetAlphaQuantum(internp->pixel_wand);
        break;

    default:
        php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Unknown color type" TSRMLS_CC);
        return;
        break;
    }

#if MAGICKCORE_HDRI_ENABLE
    RETVAL_DOUBLE(color_value);
#else
    RETVAL_LONG(color_value);
#endif
}