예제 #1
0
/* {{{ proto ImagickPixel ImagickPixel::__construct([string color] )
   The ImagickPixel constructor
*/
PHP_METHOD(imagickpixel, __construct)
{
    php_imagickpixel_object *internp;
    char *color_name = NULL;
    IM_LEN_TYPE color_name_len = 0;

    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &color_name, &color_name_len) == FAILURE) {
        return;
    }

    internp = Z_IMAGICKPIXEL_P(getThis());
    internp->pixel_wand = NewPixelWand();

    if (!internp->pixel_wand) {
        php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Failed to allocate PixelWand structure" TSRMLS_CC);
        return;
    }

    /* If color was given as parameter, set it here.*/
    if (color_name && color_name_len) {
        if (PixelSetColor(internp->pixel_wand, color_name) == MagickFalse) {
            php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Unable to construct ImagickPixel" TSRMLS_CC);
            return;
        }
    }
}
예제 #2
0
/* {{{ proto ImagickPixel ImagickPixel::clone(void)
        Clones the ImagickPixel
*/
PHP_METHOD(imagickpixel, clone)
{
    php_imagickpixel_object *internp;
    php_imagickpixel_object *intern_return;
    PixelWand *pixel_wand;

    if (zend_parse_parameters_none() == FAILURE) {
        return;
    }

    IMAGICK_METHOD_DEPRECATED("ImagickPixel", "clone");

    internp = Z_IMAGICKPIXEL_P(getThis());

    pixel_wand = php_imagick_clone_pixelwand (internp->pixel_wand);
    if (!pixel_wand) {
        php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Failed to allocate" TSRMLS_CC);
        return;
    }

    object_init_ex(return_value, php_imagickpixel_sc_entry);
    intern_return = Z_IMAGICKPIXEL_P(return_value);

    php_imagick_replace_pixelwand(intern_return, pixel_wand);
    return;
}
예제 #3
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);
}
예제 #4
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
}
예제 #5
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;
}
예제 #6
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;
}