⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gd.c

📁 php-4.4.7学习linux时下载的源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
#else			RETURN_LONG(im->pixels[Z_LVAL_PP(x)][Z_LVAL_PP(y)]);#endif		} else {			php_error_docref(NULL TSRMLS_CC, E_NOTICE, "%ld,%ld is out of bounds", Z_LVAL_PP(x), Z_LVAL_PP(y));			RETURN_FALSE;		}#if HAVE_LIBGD20	}#endif}/* }}} *//* {{{ proto int imagecolorclosest(resource im, int red, int green, int blue)   Get the index of the closest color to the specified color */PHP_FUNCTION(imagecolorclosest){	zval **IM, **red, **green, **blue;	gdImagePtr im;	if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &IM, &red, &green, &blue) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);	convert_to_long_ex(red);	convert_to_long_ex(green);	convert_to_long_ex(blue);	RETURN_LONG(gdImageColorClosest(im, Z_LVAL_PP(red), Z_LVAL_PP(green), Z_LVAL_PP(blue)));}/* }}} */#if HAVE_COLORCLOSESTHWB/* {{{ proto int imagecolorclosesthwb(resource im, int red, int green, int blue)   Get the index of the color which has the hue, white and blackness nearest to the given color */PHP_FUNCTION(imagecolorclosesthwb){	zval **IM, **red, **green, **blue;	gdImagePtr im;	if (ZEND_NUM_ARGS() != 4 ||	zend_get_parameters_ex(4, &IM, &red, &green, &blue) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);	convert_to_long_ex(red);	convert_to_long_ex(green);	convert_to_long_ex(blue);	RETURN_LONG(gdImageColorClosestHWB(im, Z_LVAL_PP(red), Z_LVAL_PP(green), Z_LVAL_PP(blue)));}/* }}} */#endif/* {{{ proto bool imagecolordeallocate(resource im, int index)   De-allocate a color for an image */PHP_FUNCTION(imagecolordeallocate){	zval **IM, **index;	int col;	gdImagePtr im;	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &IM, &index) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);#if HAVE_LIBGD20	/* We can return right away for a truecolor image as deallocating colours is meaningless here */	if (gdImageTrueColor(im)) {		RETURN_TRUE;	}#endif	convert_to_long_ex(index);	col = Z_LVAL_PP(index);	if (col >= 0 && col < gdImageColorsTotal(im)) {		gdImageColorDeallocate(im, col);		RETURN_TRUE;	} else {		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Color index %d out of range",	col);		RETURN_FALSE;	}}/* }}} *//* {{{ proto int imagecolorresolve(resource im, int red, int green, int blue)   Get the index of the specified color or its closest possible alternative */PHP_FUNCTION(imagecolorresolve){	zval **IM, **red, **green, **blue;	gdImagePtr im;	if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &IM, &red, &green, &blue) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);	convert_to_long_ex(red);	convert_to_long_ex(green);	convert_to_long_ex(blue);	RETURN_LONG(gdImageColorResolve(im, Z_LVAL_PP(red), Z_LVAL_PP(green), Z_LVAL_PP(blue)));}/* }}} *//* {{{ proto int imagecolorexact(resource im, int red, int green, int blue)   Get the index of the specified color */PHP_FUNCTION(imagecolorexact){	zval **IM, **red, **green, **blue;	gdImagePtr im;	if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &IM, &red, &green, &blue) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);	convert_to_long_ex(red);	convert_to_long_ex(green);	convert_to_long_ex(blue);	RETURN_LONG(gdImageColorExact(im, Z_LVAL_PP(red), Z_LVAL_PP(green), Z_LVAL_PP(blue)));}/* }}} *//* {{{ proto void imagecolorset(resource im, int col, int red, int green, int blue)   Set the color for the specified palette index */PHP_FUNCTION(imagecolorset){	zval **IM, **color, **red, **green, **blue;	int col;	gdImagePtr im;	if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &IM, &color, &red, &green, &blue) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);	convert_to_long_ex(color);	convert_to_long_ex(red);	convert_to_long_ex(green);	convert_to_long_ex(blue);	col = Z_LVAL_PP(color);	if (col >= 0 && col < gdImageColorsTotal(im)) {		im->red[col]   = Z_LVAL_PP(red);		im->green[col] = Z_LVAL_PP(green);		im->blue[col]  = Z_LVAL_PP(blue);	} else {		RETURN_FALSE;	}}/* }}} *//* {{{ proto array imagecolorsforindex(resource im, int col)   Get the colors for an index */PHP_FUNCTION(imagecolorsforindex){	zval **IM, **index;	int col;	gdImagePtr im;	if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &IM, &index) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);	convert_to_long_ex(index);	col = Z_LVAL_PP(index);#if HAVE_LIBGD20	if ((col >= 0 && gdImageTrueColor(im)) || (!gdImageTrueColor(im) && col >= 0 && col < gdImageColorsTotal(im))) {		array_init(return_value);		add_assoc_long(return_value,"red",  gdImageRed(im,col));		add_assoc_long(return_value,"green", gdImageGreen(im,col));		add_assoc_long(return_value,"blue", gdImageBlue(im,col));		add_assoc_long(return_value,"alpha", gdImageAlpha(im,col));	}#else	if (col >= 0 && col < gdImageColorsTotal(im)) {		array_init(return_value);		add_assoc_long(return_value,"red",  im->red[col]);		add_assoc_long(return_value,"green", im->green[col]);		add_assoc_long(return_value,"blue", im->blue[col]);	}#endif	else {		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Color index %d out of range", col);		RETURN_FALSE;	}}/* }}} *//* {{{ proto bool imagegammacorrect(resource im, float inputgamma, float outputgamma)   Apply a gamma correction to a GD image */PHP_FUNCTION(imagegammacorrect){	zval **IM, **inputgamma, **outputgamma;	gdImagePtr im;	int i;	double input, output;	if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &IM, &inputgamma, &outputgamma) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	convert_to_double_ex(inputgamma);	convert_to_double_ex(outputgamma);	input = Z_DVAL_PP(inputgamma);	output = Z_DVAL_PP(outputgamma);	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);#if HAVE_LIBGD20	if (gdImageTrueColor(im))	{		int x, y, c;		for (y = 0; y < gdImageSY(im); y++)	{			for (x = 0; x < gdImageSX(im); x++)	{				c = gdImageGetPixel(im, x, y);				gdImageSetPixel(im, x, y,					gdTrueColor(						(int) ((pow((pow((gdTrueColorGetRed(c)   / 255.0), input)), 1.0 / output) * 255) + .5),						(int) ((pow((pow((gdTrueColorGetGreen(c) / 255.0), input)), 1.0 / output) * 255) + .5),						(int) ((pow((pow((gdTrueColorGetBlue(c)  / 255.0), input)), 1.0 / output) * 255) + .5)					)				);			}		}		RETURN_TRUE;	}#endif	for (i = 0; i < gdImageColorsTotal(im); i++) {		im->red[i]   = (int)((pow((pow((im->red[i]   / 255.0), input)), 1.0 / output) * 255) + .5);		im->green[i] = (int)((pow((pow((im->green[i] / 255.0), input)), 1.0 / output) * 255) + .5);		im->blue[i]  = (int)((pow((pow((im->blue[i]  / 255.0), input)), 1.0 / output) * 255) + .5);	}	RETURN_TRUE;}/* }}} *//* {{{ proto bool imagesetpixel(resource im, int x, int y, int col)   Set a single pixel */PHP_FUNCTION(imagesetpixel){	zval **IM, **x, **y, **col;	gdImagePtr im;	if (ZEND_NUM_ARGS() != 4 ||	zend_get_parameters_ex(4, &IM, &x, &y, &col) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);	convert_to_long_ex(x);	convert_to_long_ex(y);	convert_to_long_ex(col);	gdImageSetPixel(im, Z_LVAL_PP(x), Z_LVAL_PP(y), Z_LVAL_PP(col));	RETURN_TRUE;}/* }}} *//* {{{ proto bool imageline(resource im, int x1, int y1, int x2, int y2, int col)   Draw a line */PHP_FUNCTION(imageline){	zval **IM, **x1, **y1, **x2, **y2, **col;	gdImagePtr im;	if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &IM, &x1, &y1, &x2, &y2, &col) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);	convert_to_long_ex(x1);	convert_to_long_ex(y1);	convert_to_long_ex(x2);	convert_to_long_ex(y2);	convert_to_long_ex(col);#ifdef HAVE_GD_BUNDLED	if (im->antialias) {		gdImageAALine(im, Z_LVAL_PP(x1), Z_LVAL_PP(y1), Z_LVAL_PP(x2), Z_LVAL_PP(y2), Z_LVAL_PP(col));	} else#endif	{		gdImageLine(im, Z_LVAL_PP(x1), Z_LVAL_PP(y1), Z_LVAL_PP(x2), Z_LVAL_PP(y2), Z_LVAL_PP(col));	}	RETURN_TRUE;}/* }}} *//* {{{ proto bool imagedashedline(resource im, int x1, int y1, int x2, int y2, int col)   Draw a dashed line */PHP_FUNCTION(imagedashedline){	zval **IM, **x1, **y1, **x2, **y2, **col;	gdImagePtr im;	if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &IM, &x1, &y1, &x2, &y2, &col) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);	convert_to_long_ex(x1);	convert_to_long_ex(y1);	convert_to_long_ex(x2);	convert_to_long_ex(y2);	convert_to_long_ex(col);	gdImageDashedLine(im, Z_LVAL_PP(x1), Z_LVAL_PP(y1), Z_LVAL_PP(x2), Z_LVAL_PP(y2), Z_LVAL_PP(col));	RETURN_TRUE;}/* }}} *//* {{{ proto bool imagerectangle(resource im, int x1, int y1, int x2, int y2, int col)   Draw a rectangle */PHP_FUNCTION(imagerectangle){	zval **IM, **x1, **y1, **x2, **y2, **col;	gdImagePtr im;	if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &IM, &x1, &y1, &x2, &y2, &col) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);	convert_to_long_ex(x1);	convert_to_long_ex(y1);	convert_to_long_ex(x2);	convert_to_long_ex(y2);	convert_to_long_ex(col);	gdImageRectangle(im, Z_LVAL_PP(x1), Z_LVAL_PP(y1), Z_LVAL_PP(x2), Z_LVAL_PP(y2), Z_LVAL_PP(col));	RETURN_TRUE;}/* }}} *//* {{{ proto bool imagefilledrectangle(resource im, int x1, int y1, int x2, int y2, int col)   Draw a filled rectangle */PHP_FUNCTION(imagefilledrectangle){	zval **IM, **x1, **y1, **x2, **y2, **col;	gdImagePtr im;	if (ZEND_NUM_ARGS() != 6 ||	zend_get_parameters_ex(6, &IM, &x1, &y1, &x2, &y2, &col) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);	convert_to_long_ex(x1);	convert_to_long_ex(y1);	convert_to_long_ex(x2);	convert_to_long_ex(y2);	convert_to_long_ex(col);	gdImageFilledRectangle(im, Z_LVAL_PP(x1), Z_LVAL_PP(y1), Z_LVAL_PP(x2), Z_LVAL_PP(y2), Z_LVAL_PP(col));	RETURN_TRUE;}/* }}} *//* {{{ proto bool imagearc(resource im, int cx, int cy, int w, int h, int s, int e, int col)   Draw a partial ellipse */PHP_FUNCTION(imagearc){	zval **IM, **cx, **cy, **w, **h, **ST, **E, **col;	gdImagePtr im;	int e, st;	if (ZEND_NUM_ARGS() != 8 ||	zend_get_parameters_ex(8, &IM, &cx, &cy, &w, &h, &ST, &E, &col) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);	convert_to_long_ex(cx);	convert_to_long_ex(cy);	convert_to_long_ex(w);	convert_to_long_ex(h);	convert_to_long_ex(ST);	convert_to_long_ex(E);	convert_to_long_ex(col);	e = Z_LVAL_PP(E);	if (e < 0) {		e %= 360;	}	st = Z_LVAL_PP(ST);	if (st < 0) {		st %= 360;	}	gdImageArc(im, Z_LVAL_PP(cx), Z_LVAL_PP(cy), Z_LVAL_PP(w), Z_LVAL_PP(h), st, e, Z_LVAL_PP(col));	RETURN_TRUE;}/* }}} *//* {{{ proto bool imageellipse(resource im, int cx, int cy, int w, int h, int color)   Draw an ellipse */PHP_FUNCTION(imageellipse){	zval **IM, **cx, **cy, **w, **h, **color;	gdImagePtr im;	if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &IM, &cx, &cy, &w, &h, &color) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);	convert_to_long_ex(cx);	convert_to_long_ex(cy);	convert_to_long_ex(w);	convert_to_long_ex(h);	convert_to_long_ex(color);#ifdef HAVE_GD_IMAGEELLIPSE  /* this function is missing from GD 2.0.1 */	gdImageEllipse(im, Z_LVAL_PP(cx), Z_LVAL_PP(cy), Z_LVAL_PP(w), Z_LVAL_PP(h), Z_LVAL_PP(color));#else	gdImageArc(im, Z_LVAL_PP(cx), Z_LVAL_PP(cy), Z_LVAL_PP(w), Z_LVAL_PP(h), 0, 360, Z_LVAL_PP(color));#endif	RETURN_TRUE;}/* }}} *//* {{{ proto bool imagefilltoborder(resource im, int x, int y, int border, int col)   Flood fill to specific color */PHP_FUNCTION(imagefilltoborder){	zval **IM, **x, **y, **border, **col;	gdImagePtr im;	if (ZEND_NUM_ARGS() != 5 ||	zend_get_parameters_ex(5, &IM, &x, &y, &border, &col) == FAILURE) {		ZEND_WRONG_PARAM_COUNT();	}	ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", le_gd);	convert_to_long_ex(x);	convert_to_long_ex(y);	convert_to_long_ex(border);	convert_to_long_ex(col);	gdImageFillToBorder(im, Z_LVAL_PP(x), Z_LVAL_PP(y), Z_LVAL_PP(border), Z_LVAL_PP(col));	RETURN_TRUE;}/* }}} *//* {{{ proto bool imagefill(resource im, int x, int y, int col)   Flood fill */PHP_FUNCTION(imagefill){	zval **IM, **x, **y, **col;	gdImagePtr im;	if (ZEND_NUM_ARGS() != 4 ||	zend_get_par

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -