/* {{{ proto GmagickPixel GmagickPixel::setColorValue(int color, float value )
	Sets the normalized color of the GmagickPixel.
*/
PHP_METHOD(gmagickpixel, setcolorvalue)
{
	php_gmagickpixel_object *internp;
	zend_long color;
	double color_value;

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

	internp = Z_GMAGICKPIXEL_OBJ_P(getThis());

	switch (color) {

		case GMAGICK_COLOR_BLACK:
			PixelSetBlack(internp->pixel_wand, color_value);
		break;

		case GMAGICK_COLOR_BLUE:
			PixelSetBlue(internp->pixel_wand, color_value);
		break;

		case GMAGICK_COLOR_CYAN:
			PixelSetCyan(internp->pixel_wand, color_value);
		break;

		case GMAGICK_COLOR_GREEN:
			PixelSetGreen(internp->pixel_wand, color_value);
		break;

		case GMAGICK_COLOR_RED:
			PixelSetRed(internp->pixel_wand, color_value);
		break;

		case GMAGICK_COLOR_YELLOW:
			PixelSetYellow(internp->pixel_wand, color_value);
		break;

		case GMAGICK_COLOR_MAGENTA:
			PixelSetMagenta(internp->pixel_wand, color_value);
		break;

		case GMAGICK_COLOR_OPACITY:
			PixelSetOpacity(internp->pixel_wand, color_value);
		break;

		default:
			GMAGICK_THROW_GMAGICKPIXEL_EXCEPTION(internp->pixel_wand, "Unknown color type");
		break;
		
	}
	GMAGICK_CHAIN_METHOD;
}
Beispiel #2
0
/* {{{ proto float ImagickPixel::setColorValue(int color, float value )
	Sets the normalized color of the ImagickPixel.
*/
PHP_METHOD(imagickpixel, setcolorvalue)
{
    php_imagick_color_t color_enum;
    php_imagickpixel_object *internp;
    im_long color;
    double color_value;

    /* Parse parameters given to function */
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ld", &color, &color_value) == 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:
        PixelSetBlack(internp->pixel_wand, color_value);
        break;

    case PHP_IMAGICK_COLOR_BLUE:
        PixelSetBlue(internp->pixel_wand, color_value);
        break;

    case PHP_IMAGICK_COLOR_CYAN:
        PixelSetCyan(internp->pixel_wand, color_value);
        break;

    case PHP_IMAGICK_COLOR_GREEN:
        PixelSetGreen(internp->pixel_wand, color_value);
        break;

    case PHP_IMAGICK_COLOR_RED:
        PixelSetRed(internp->pixel_wand, color_value);
        break;

    case PHP_IMAGICK_COLOR_YELLOW:
        PixelSetYellow(internp->pixel_wand, color_value);
        break;

    case PHP_IMAGICK_COLOR_MAGENTA:
        PixelSetMagenta(internp->pixel_wand, color_value);
        break;

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

    case PHP_IMAGICK_COLOR_ALPHA:
        PixelSetAlpha(internp->pixel_wand, color_value);
        break;

#if MagickLibVersion > 0x628
    case PHP_IMAGICK_COLOR_FUZZ:
        PixelSetFuzz(internp->pixel_wand, color_value);
        break;
#endif

    default:
        php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Unknown color type" TSRMLS_CC);
        return;
        break;
    }
    RETVAL_TRUE;
}
Beispiel #3
0
/* {{{ proto float ImagickPixel::setColorValue(int color, float value )
	Sets the normalized color of the ImagickPixel.
*/
PHP_METHOD(imagickpixel, setcolorvalue)
{
	php_imagickpixel_object *internp;
	long color;
	double color_value;

	/* Parse parameters given to function */
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ld", &color, &color_value) == FAILURE) {
		return;
	}
	
	internp = (php_imagickpixel_object *)zend_object_store_get_object(getThis() TSRMLS_CC);

	switch (color) {

		case IMAGICKCOLORBLACK:
			PixelSetBlack(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLORBLUE:
			PixelSetBlue(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLORCYAN:
			PixelSetCyan(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLORGREEN:
			PixelSetGreen(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLORRED:
			PixelSetRed(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLORYELLOW:
			PixelSetYellow(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLORMAGENTA:
			PixelSetMagenta(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLOROPACITY:
			PixelSetOpacity(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLORALPHA:
			PixelSetAlpha(internp->pixel_wand, color_value);
		break;

#if MagickLibVersion > 0x628
		case IMAGICKCOLORFUZZ:
			PixelSetFuzz(internp->pixel_wand, color_value);
		break;
#endif

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