PHP_FE(imagecopymerge, NULL)
PHP_FE(imagecopyresized, NULL)
PHP_FE(imagecreate, NULL)
- PHP_FE(imagecreatefromstring, NULL)
+ PHP_FE(imagecreatefromstring, NULL)
PHP_FE(imagecreatefrompng, NULL)
PHP_FE(imagepng, NULL)
PHP_FE(imagecreatefromgif, NULL)
ZEND_GET_MODULE(gd)
#endif
+
static void php_free_gd_image(zend_rsrc_list_entry *rsrc)
{
gdImageDestroy((gdImagePtr)rsrc->ptr);
}
+
static void php_free_gd_font(zend_rsrc_list_entry *rsrc)
{
gdFontPtr fp = (gdFontPtr)rsrc->ptr;
}
-
PHP_MINIT_FUNCTION(gd)
{
GDLS_FETCH();
/* {{{ proto int imageloadfont(string filename)
Load a new font */
-PHP_FUNCTION(imageloadfont) {
+PHP_FUNCTION(imageloadfont)
+{
zval **file;
int hdr_size = sizeof(gdFont) - sizeof(char *);
int ind, body_size, n=0, b;
int issock=0, socketd=0;
GDLS_FETCH();
-
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &file) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(file);
#ifdef PHP_WIN32
- fp = V_FOPEN((*file)->value.str.val, "rb");
+ fp = V_FOPEN(Z_STRVAL_PP(file), "rb");
#else
- fp = php_fopen_wrapper((*file)->value.str.val, "r", IGNORE_PATH|IGNORE_URL_WIN, &issock, &socketd, NULL);
+ fp = php_fopen_wrapper(Z_STRVAL_PP(file), "r", IGNORE_PATH|IGNORE_URL_WIN, &issock, &socketd, NULL);
#endif
if (fp == NULL) {
php_error(E_WARNING, "ImageFontLoad: unable to open file");
convert_to_long_ex(x_size);
convert_to_long_ex(y_size);
- im = gdImageCreate((*x_size)->value.lval, (*y_size)->value.lval);
+ im = gdImageCreate(Z_LVAL_PP(x_size), Z_LVAL_PP(y_size));
ZEND_REGISTER_RESOURCE(return_value, im, GDG(le_gd));
}
gdImagePtr im;
gdIOCtx *io_ctx;
- io_ctx = gdNewDynamicCtx ((*data)->value.str.len,
- (*data)->value.str.val);
+ io_ctx = gdNewDynamicCtx (Z_STRLEN_PP(data),Z_STRVAL_PP(data));
if(!io_ctx) {
return NULL;
GDLS_FETCH();
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &data) == FAILURE)
+ {
WRONG_PARAM_COUNT;
-
- convert_to_string_ex (data);
- memcpy(sig, (*data)->value.str.val, 8);
+ }
+
+ convert_to_string_ex(data);
+ memcpy(sig, Z_STRVAL_PP(data), 8);
imtype = _php_image_type (sig);
}
/* }}} */
-static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, gdImagePtr (*func_p)(), gdImagePtr (*ioctx_func_p)()) {
+static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, gdImagePtr (*func_p)(), gdImagePtr (*ioctx_func_p)())
+{
zval **file;
gdImagePtr im;
char *fn=NULL;
int issock=0, socketd=0;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &file) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &file) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
+
convert_to_string_ex(file);
- fn = (*file)->value.str.val;
+
+ fn = Z_STRVAL_PP(file);
+
#ifdef PHP_WIN32
- fp = V_FOPEN(Z_STRVAL_PP(file), "rb");
+ fp = V_FOPEN(fn, "rb");
#else
- fp = php_fopen_wrapper(Z_STRVAL_PP(file), "r", IGNORE_PATH|IGNORE_URL_WIN, &issock, &socketd, NULL);
+ fp = php_fopen_wrapper(fn, "r", IGNORE_PATH|IGNORE_URL_WIN, &issock, &socketd, NULL);
#endif
if (!fp && !socketd) {
php_strip_url_passwd(fn);
}
/* }}} */
-static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, void (*func_p)()) {
+static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, void (*func_p)())
+{
zval **imgind, **file, **quality;
gdImagePtr im;
char *fn = NULL;
FILE *fp;
- int argc;
+ int argc = ZEND_NUM_ARGS();
int output = 1, q = -1;
GDLS_FETCH();
- argc = ZEND_NUM_ARGS();
- if (argc < 1 || argc > 3 || zend_get_parameters_ex(argc, &imgind, &file, &quality) == FAILURE) {
+ if (argc < 1 || argc > 3 || zend_get_parameters_ex(argc, &imgind, &file, &quality) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
+
ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", GDG(le_gd));
if (argc > 1) {
Destroy an image */
PHP_FUNCTION(imagedestroy)
{
- zval **imgind;
+ zval **IM;
gdImagePtr im;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &imgind) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &IM) == FAILURE) {
WRONG_PARAM_COUNT;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", GDG(le_gd));
+ ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
- zend_list_delete((*imgind)->value.lval);
+ zend_list_delete(Z_LVAL_PP(IM));
RETURN_TRUE;
}
Allocate a color for an image */
PHP_FUNCTION(imagecolorallocate)
{
- zval **imgind, **red, **green, **blue;
- int col;
- int r, g, b;
+ zval **IM, **red, **green, **blue;
gdImagePtr im;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &imgind, &red,
- &green, &blue) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &IM, &red, &green, &blue) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", GDG(le_gd));
+ ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
convert_to_long_ex(red);
convert_to_long_ex(green);
convert_to_long_ex(blue);
- r = (*red)->value.lval;
- g = (*green)->value.lval;
- b = (*blue)->value.lval;
-
- col = gdImageColorAllocate(im, r, g, b);
- RETURN_LONG(col);
+ RETURN_LONG(gdImageColorAllocate(im, Z_LVAL_PP(red), Z_LVAL_PP(green), Z_LVAL_PP(blue)));
}
/* }}} */
#if HAVE_LIBGD15
zval **dstim, **srcim;
gdImagePtr dst, src;
+ GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 2 ||
- zend_get_parameters_ex(2, &dstim, &srcim) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &dstim, &srcim) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
Get the index of the color of a pixel */
PHP_FUNCTION(imagecolorat)
{
- zval **imgind, **x, **y;
+ zval **IM, **x, **y;
gdImagePtr im;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &imgind, &x, &y) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &IM, &x, &y) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", GDG(le_gd));
+ ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
+
convert_to_long_ex(x);
convert_to_long_ex(y);
- if (gdImageBoundsSafe(im, (*x)->value.lval, (*y)->value.lval)) {
+ if (gdImageBoundsSafe(im, Z_LVAL_PP(x), Z_LVAL_PP(y))) {
#if HAVE_LIBGD13
- RETURN_LONG(im->pixels[(*y)->value.lval][(*x)->value.lval]);
+ RETURN_LONG(im->pixels[Z_LVAL_PP(y)][Z_LVAL_PP(x)]);
#else
- RETURN_LONG(im->pixels[(*x)->value.lval][(*y)->value.lval]);
+ RETURN_LONG(im->pixels[Z_LVAL_PP(x)][Z_LVAL_PP(y)]);
#endif
}
else {
Get the index of the closest color to the specified color */
PHP_FUNCTION(imagecolorclosest)
{
- zval **imgind, **red, **green, **blue;
- int col;
- int r, g, b;
+ zval **IM, **red, **green, **blue;
gdImagePtr im;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &imgind, &red,
- &green, &blue) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &IM, &red, &green, &blue) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", GDG(le_gd));
+ ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
convert_to_long_ex(red);
convert_to_long_ex(green);
convert_to_long_ex(blue);
- r = (*red)->value.lval;
- g = (*green)->value.lval;
- b = (*blue)->value.lval;
-
- col = gdImageColorClosest(im, r, g, b);
- RETURN_LONG(col);
+ RETURN_LONG(gdImageColorClosest(im, Z_LVAL_PP(red), Z_LVAL_PP(green), Z_LVAL_PP(blue)));
}
/* }}} */
PHP_FUNCTION(imagecolorclosesthwb)
{
#if HAVE_COLORCLOSESTHWB
- zval **imgind, **r, **g, **b;
- int col;
+ zval **IM, **red, **green, **blue;
gdImagePtr im;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 4 ||
- zend_get_parameters_ex(4, &imgind, &r, &g, &b) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &IM, &red, &green, &blue) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", GDG(le_gd));
+ ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
- convert_to_long_ex(r);
- convert_to_long_ex(g);
- convert_to_long_ex(b);
+ convert_to_long_ex(red);
+ convert_to_long_ex(green);
+ convert_to_long_ex(blue);
- col = gdImageColorClosestHWB(im, Z_LVAL_PP(r), Z_LVAL_PP(g), Z_LVAL_PP(b));
- RETURN_LONG(col);
+ RETURN_LONG(gdImageColorClosestHWB(im, Z_LVAL_PP(red), Z_LVAL_PP(green), Z_LVAL_PP(blue)));
#else
php_error(E_WARNING, "ImageColorClosestHWB functionality was added in GD 1.8");
RETURN_FALSE;
De-allocate a color for an image */
PHP_FUNCTION(imagecolordeallocate)
{
- zval **imgind, **index;
+ zval **IM, **index;
int col;
gdImagePtr im;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &imgind, &index) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &IM, &index) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", GDG(le_gd));
+ ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
convert_to_long_ex(index);
- col = (*index)->value.lval;
+ col = Z_LVAL_PP(index);
if (col >= 0 && col < gdImageColorsTotal(im)) {
gdImageColorDeallocate(im, col);
RETURN_TRUE;
- }
- else {
+ } else {
php_error(E_WARNING, "Color index out of range");
RETURN_FALSE;
}
Get the index of the specified color or its closest possible alternative */
PHP_FUNCTION(imagecolorresolve)
{
- zval **imgind, **red, **green, **blue;
- int col;
- int r, g, b;
+ zval **IM, **red, **green, **blue;
gdImagePtr im;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &imgind, &red,
- &green, &blue) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &IM, &red, &green, &blue) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", GDG(le_gd));
+ ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
convert_to_long_ex(red);
convert_to_long_ex(green);
convert_to_long_ex(blue);
- r = (*red)->value.lval;
- g = (*green)->value.lval;
- b = (*blue)->value.lval;
-
- col = gdImageColorResolve(im, r, g, b);
- RETURN_LONG(col);
+ RETURN_LONG(gdImageColorResolve(im, Z_LVAL_PP(red), Z_LVAL_PP(green), Z_LVAL_PP(blue)));
}
/* }}} */
Get the index of the specified color */
PHP_FUNCTION(imagecolorexact)
{
- zval **imgind, **red, **green, **blue;
- int col;
- int r, g, b;
+ zval **IM, **red, **green, **blue;
gdImagePtr im;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &imgind, &red,
- &green, &blue) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &IM, &red, &green, &blue) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", GDG(le_gd));
+ ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
convert_to_long_ex(red);
convert_to_long_ex(green);
convert_to_long_ex(blue);
- r = (*red)->value.lval;
- g = (*green)->value.lval;
- b = (*blue)->value.lval;
-
- col = gdImageColorExact(im, r, g, b);
- RETURN_LONG(col);
+ RETURN_LONG(gdImageColorExact(im, Z_LVAL_PP(red), Z_LVAL_PP(green), Z_LVAL_PP(blue)));
}
/* }}} */
Set the color for the specified palette index */
PHP_FUNCTION(imagecolorset)
{
- zval **imgind, **color, **red, **green, **blue;
+ zval **IM, **color, **red, **green, **blue;
int col;
- int r, g, b;
gdImagePtr im;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &imgind, &color, &red, &green, &blue) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &IM, &color, &red, &green, &blue) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", GDG(le_gd));
+ ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
convert_to_long_ex(color);
convert_to_long_ex(red);
convert_to_long_ex(green);
convert_to_long_ex(blue);
- col = (*color)->value.lval;
- r = (*red)->value.lval;
- g = (*green)->value.lval;
- b = (*blue)->value.lval;
+ col = Z_LVAL_PP(color);
if (col >= 0 && col < gdImageColorsTotal(im)) {
- im->red[col] = r;
- im->green[col] = g;
- im->blue[col] = b;
- }
- else {
+ im->red[col] = Z_LVAL_PP(red);
+ im->green[col] = Z_LVAL_PP(green);
+ im->blue[col] = Z_LVAL_PP(blue);
+ } else {
RETURN_FALSE;
}
}
Get the colors for an index */
PHP_FUNCTION(imagecolorsforindex)
{
- zval **imgind, **index;
+ zval **IM, **index;
int col;
gdImagePtr im;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &imgind, &index) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &IM, &index) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", GDG(le_gd));
+ ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
convert_to_long_ex(index);
- col = (*index)->value.lval;
+ col = Z_LVAL_PP(index);
if (col >= 0 && col < gdImageColorsTotal(im)) {
if (array_init(return_value) == FAILURE) {
RETURN_FALSE;
}
- add_assoc_long(return_value,"red",im->red[col]);
+ 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]);
- }
- else {
+ add_assoc_long(return_value,"blue", im->blue[col]);
+ } else {
php_error(E_WARNING, "Color index out of range");
RETURN_FALSE;
}
zval **IM, **inputgamma, **outputgamma;
gdImagePtr im;
int i;
+ double input, output;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 3 ||
- zend_get_parameters_ex(3, &IM, &inputgamma, &outputgamma) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &IM, &inputgamma, &outputgamma) == FAILURE)
+ {
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", GDG(le_gd));
for (i = 0; i < gdImageColorsTotal(im); i++) {
- im->red[i] = (int)((pow((pow((im->red[i] / 255.0),(*inputgamma)->value.dval)), 1.0 / (*outputgamma)->value.dval) * 255)+.5);
- im->green[i] = (int)((pow((pow((im->green[i] / 255.0),(*inputgamma)->value.dval)), 1.0 / (*outputgamma)->value.dval) * 255)+.5);
- im->blue[i] = (int)((pow((pow((im->blue[i] / 255.0),(*inputgamma)->value.dval)), 1.0 / (*outputgamma)->value.dval) * 255)+.5);
+ 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;
Set a single pixel */
PHP_FUNCTION(imagesetpixel)
{
- zval **imgind, **xarg, **yarg, **colarg;
+ zval **IM, **x, **y, **col;
gdImagePtr im;
- int col, y, x;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 4 ||
- zend_get_parameters_ex(4, &imgind, &xarg, &yarg, &colarg) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &IM, &x, &y, &col) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
- ZEND_FETCH_RESOURCE(im, gdImagePtr, imgind, -1, "Image", GDG(le_gd));
-
- convert_to_long_ex(xarg);
- convert_to_long_ex(yarg);
- convert_to_long_ex(colarg);
+ ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
- col = (*colarg)->value.lval;
- y = (*yarg)->value.lval;
- x = (*xarg)->value.lval;
+ convert_to_long_ex(x);
+ convert_to_long_ex(y);
+ convert_to_long_ex(col);
- gdImageSetPixel(im,x,y,col);
+ gdImageSetPixel(im,Z_LVAL_PP(x),Z_LVAL_PP(y),Z_LVAL_PP(col));
RETURN_TRUE;
}
Draw a line */
PHP_FUNCTION(imageline)
{
- zval **IM, **COL, **X1, **Y1, **X2, **Y2;
+ zval **IM, **x1, **y1, **x2, **y2, **col;
gdImagePtr im;
- int col, y2, x2, y1, x1;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 6 ||
- zend_get_parameters_ex(6, &IM, &X1, &Y1, &X2, &Y2, &COL) == FAILURE)
+ if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &IM, &x1, &y1, &x2, &y2, &col) == FAILURE)
{
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(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);
-
- x1 = (*X1)->value.lval;
- y1 = (*Y1)->value.lval;
- x2 = (*X2)->value.lval;
- y2 = (*Y2)->value.lval;
- col = (*COL)->value.lval;
+ 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);
- gdImageLine(im,x1,y1,x2,y2,col);
+ gdImageLine(im,Z_LVAL_PP(x1),Z_LVAL_PP(y1),Z_LVAL_PP(x2),Z_LVAL_PP(y2),Z_LVAL_PP(col));
RETURN_TRUE;
}
/* }}} */
Draw a dashed line */
PHP_FUNCTION(imagedashedline)
{
- zval **IM, **COL, **X1, **Y1, **X2, **Y2;
+ zval **IM, **x1, **y1, **x2, **y2, **col;
gdImagePtr im;
- int col, y2, x2, y1, x1;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &IM, &X1, &Y1, &X2, &Y2, &COL) == FAILURE)
+ if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &IM, &x1, &y1, &x2, &y2, &col) == FAILURE)
{
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(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);
+ 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);
- x1 = (*X1)->value.lval;
- y1 = (*Y1)->value.lval;
- x2 = (*X2)->value.lval;
- y2 = (*Y2)->value.lval;
- col = (*COL)->value.lval;
-
- gdImageDashedLine(im,x1,y1,x2,y2,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;
}
/* }}} */
Draw a rectangle */
PHP_FUNCTION(imagerectangle)
{
- zval **IM, **COL, **X1, **Y1, **X2, **Y2;
+ zval **IM, **x1, **y1, **x2, **y2, **col;
gdImagePtr im;
- int col, y2, x2, y1, x1;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 6 ||
- zend_get_parameters_ex(6, &IM, &X1, &Y1, &X2, &Y2, &COL) == FAILURE)
+ if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &IM, &x1, &y1, &x2, &y2, &col) == FAILURE)
{
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
- convert_to_long_ex(IM);
- 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);
-
- x1 = (*X1)->value.lval;
- y1 = (*Y1)->value.lval;
- x2 = (*X2)->value.lval;
- y2 = (*Y2)->value.lval;
- col = (*COL)->value.lval;
+ 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,x1,y1,x2,y2,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;
}
/* }}} */
Draw a filled rectangle */
PHP_FUNCTION(imagefilledrectangle)
{
- zval **IM, **COL, **X1, **Y1, **X2, **Y2;
+ zval **IM, **x1, **y1, **x2, **y2, **col;
gdImagePtr im;
- int col, y2, x2, y1, x1;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 6 ||
- zend_get_parameters_ex(6, &IM, &X1, &Y1, &X2, &Y2, &COL) == FAILURE)
+ if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &IM, &x1, &y1, &x2, &y2, &col) == FAILURE)
{
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(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);
-
- x1 = (*X1)->value.lval;
- y1 = (*Y1)->value.lval;
- x2 = (*X2)->value.lval;
- y2 = (*Y2)->value.lval;
- col = (*COL)->value.lval;
+ 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,x1,y1,x2,y2,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;
}
/* }}} */
Draw a partial ellipse */
PHP_FUNCTION(imagearc)
{
- zval **COL, **E, **ST, **H, **W, **CY, **CX, **IM;
+ zval **IM, **cx, **cy, **w, **h, **ST, **E, **col;
gdImagePtr im;
- int col, e, st, h, w, cy, cx;
+ int e,st;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 8 ||
- zend_get_parameters_ex(8, &IM, &CX, &CY, &W, &H, &ST, &E, &COL) == FAILURE)
+ if (ZEND_NUM_ARGS() != 8 || zend_get_parameters_ex(8, &IM, &cx, &cy, &w, &h, &ST, &E, &col) == FAILURE)
{
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(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(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);
+ convert_to_long_ex(col);
- col = (*COL)->value.lval;
- e = (*E)->value.lval;
- st = (*ST)->value.lval;
- h = (*H)->value.lval;
- w = (*W)->value.lval;
- cy = (*CY)->value.lval;
- cx = (*CX)->value.lval;
+ e = Z_LVAL_PP(E);
+ st = Z_LVAL_PP(ST);
- if (e < 0) {
- e %= 360;
- }
- if (st < 0) {
- st %= 360;
- }
+ if (e < 0) e %= 360;
+ if (st < 0) st %= 360;
- gdImageArc(im,cx,cy,w,h,st,e,col);
+ 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;
}
/* }}} */
Flood fill to specific color */
PHP_FUNCTION(imagefilltoborder)
{
- zval **IM, **X, **Y, **BORDER, **COL;
+ zval **IM, **x, **y, **border, **col;
gdImagePtr im;
- int col, border, y, x;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 5 ||
- zend_get_parameters_ex(5, &IM, &X, &Y, &BORDER, &COL) == FAILURE)
+ if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &IM, &x, &y, &border, &col) == FAILURE)
{
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
- convert_to_long_ex(X);
- convert_to_long_ex(Y);
- convert_to_long_ex(BORDER);
- convert_to_long_ex(COL);
-
- col = (*COL)->value.lval;
- border = (*BORDER)->value.lval;
- y = (*Y)->value.lval;
- x = (*X)->value.lval;
+ convert_to_long_ex(x);
+ convert_to_long_ex(y);
+ convert_to_long_ex(border);
+ convert_to_long_ex(col);
- gdImageFillToBorder(im,x,y,border,col);
+ gdImageFillToBorder(im,Z_LVAL_PP(x),Z_LVAL_PP(y),Z_LVAL_PP(border),Z_LVAL_PP(col));
RETURN_TRUE;
}
/* }}} */
Flood fill */
PHP_FUNCTION(imagefill)
{
- zval **IM, **X, **Y, **COL;
+ zval **IM, **x, **y, **col;
gdImagePtr im;
- int col, y, x;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 4 ||
- zend_get_parameters_ex(4, &IM, &X, &Y, &COL) == FAILURE)
+ if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &IM, &x, &y, &col) == FAILURE)
{
WRONG_PARAM_COUNT;
}
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
- convert_to_long_ex(X);
- convert_to_long_ex(Y);
- convert_to_long_ex(COL);
-
- col = (*COL)->value.lval;
- y = (*Y)->value.lval;
- x = (*X)->value.lval;
+ convert_to_long_ex(x);
+ convert_to_long_ex(y);
+ convert_to_long_ex(col);
- gdImageFill(im,x,y,col);
+ gdImageFill(im,Z_LVAL_PP(x),Z_LVAL_PP(y),Z_LVAL_PP(col));
RETURN_TRUE;
}
/* }}} */
gdImagePtr im;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &IM) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &IM) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
+
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
RETURN_LONG(gdImageColorsTotal(im));
{
zval **IM, **COL;
gdImagePtr im;
- int col;
GDLS_FETCH();
switch(ZEND_NUM_ARGS()) {
if (ZEND_NUM_ARGS() > 1) {
gdImageColorTransparent(im, Z_LVAL_PP(COL));
}
- col = gdImageGetTransparent(im);
- RETURN_LONG(col);
+
+ RETURN_LONG(gdImageGetTransparent(im));
}
/* }}} */
Enable or disable interlace */
PHP_FUNCTION(imageinterlace)
{
- zval **IM, **INT = NULL;
+ zval **IM, **INT;
gdImagePtr im;
- int interlace;
GDLS_FETCH();
switch(ZEND_NUM_ARGS()) {
ZEND_FETCH_RESOURCE(im, gdImagePtr, IM, -1, "Image", GDG(le_gd));
- if ((*INT) != NULL) {
- interlace = (*INT)->value.lval;
- gdImageInterlace(im,interlace);
+ if (ZEND_NUM_ARGS() > 1) {
+ gdImageInterlace(im,Z_LVAL_PP(INT));
}
- interlace = gdImageGetInterlaced(im);
- RETURN_LONG(interlace);
+
+ RETURN_LONG(gdImageGetInterlaced(im));
}
/* }}} */
int npoints, col, nelem, i;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 4 ||
- zend_get_parameters_ex(4, &IM, &POINTS, &NPOINTS, &COL) == FAILURE)
+ if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &IM, &POINTS, &NPOINTS, &COL) == FAILURE)
{
WRONG_PARAM_COUNT;
}
convert_to_long_ex(NPOINTS);
convert_to_long_ex(COL);
- npoints = (*NPOINTS)->value.lval;
- col = (*COL)->value.lval;
+ npoints = Z_LVAL_PP(NPOINTS);
+ col = Z_LVAL_PP(COL);
if ((*POINTS)->type != IS_ARRAY) {
php_error(E_WARNING, "2nd argument to imagepolygon not an array");
RETURN_FALSE;
}
-/*
- ** we shouldn't need this check, should we? **
-
- if (!ParameterPassedByReference(ht, 2)) {
- php_error(E_WARNING, "2nd argument to imagepolygon not passed by reference");
- RETURN_FALSE;
- }
-*/
-
nelem = zend_hash_num_elements((*POINTS)->value.ht);
if (nelem < 6) {
- php_error(E_WARNING,
- "you must have at least 3 points in your array");
+ php_error(E_WARNING, "you must have at least 3 points in your array");
RETURN_FALSE;
}
if (nelem < npoints * 2) {
- php_error(E_WARNING,
- "trying to use %d points in array with only %d points",
- npoints, nelem/2);
+ php_error(E_WARNING, "trying to use %d points in array with only %d points", npoints, nelem/2);
RETURN_FALSE;
}
if (zend_hash_index_find((*POINTS)->value.ht, (i * 2), (void **) &var) == SUCCESS) {
SEPARATE_ZVAL((var));
convert_to_long(*var);
- points[i].x = (*var)->value.lval;
+ points[i].x = Z_LVAL_PP(var);
}
if (zend_hash_index_find((*POINTS)->value.ht, (i * 2) + 1, (void **) &var) == SUCCESS) {
SEPARATE_ZVAL(var);
convert_to_long(*var);
- points[i].y = (*var)->value.lval;
+ points[i].y = Z_LVAL_PP(var);
}
}
if (filled) {
gdImageFilledPolygon(im, points, npoints, col);
- }
- else {
+ } else {
gdImagePolygon(im, points, npoints, col);
}
efree(points);
-
RETURN_TRUE;
}
*/
static void php_imagefontsize(INTERNAL_FUNCTION_PARAMETERS, int arg)
{
- pval *SIZE;
+ zval **SIZE;
gdFontPtr font;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters(ht, 1, &SIZE) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &SIZE) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
- convert_to_long(SIZE);
- font = php_find_gd_font(SIZE->value.lval);
+
+ convert_to_long_ex(SIZE);
+
+ font = php_find_gd_font(Z_LVAL_PP(SIZE));
RETURN_LONG(arg ? font->h : font->w);
}
* arg = 2 ImageString
* arg = 3 ImageStringUp
*/
-static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode) {
+static void php_imagechar(INTERNAL_FUNCTION_PARAMETERS, int mode)
+{
zval **IM, **SIZE, **X, **Y, **C, **COL;
gdImagePtr im;
int ch = 0, col, x, y, size, i, l = 0;
gdFontPtr font;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 6 ||
- zend_get_parameters_ex(6, &IM, &SIZE, &X, &Y, &C, &COL) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &IM, &SIZE, &X, &Y, &C, &COL) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(C);
convert_to_long_ex(COL);
- col = (*COL)->value.lval;
+ col = Z_LVAL_PP(COL);
if (mode < 2) {
- ch = (int)((unsigned char)*((*C)->value.str.val));
+ ch = (int)((unsigned char)*(Z_STRVAL_PP(C)));
} else {
- str = (unsigned char *) estrndup((*C)->value.str.val, (*C)->value.str.len);
+ str = (unsigned char *) estrndup(Z_STRVAL_PP(C), Z_STRLEN_PP(C));
l = strlen(str);
}
- y = (*Y)->value.lval;
- x = (*X)->value.lval;
- size = (*SIZE)->value.lval;
+ y = Z_LVAL_PP(Y);
+ x = Z_LVAL_PP(X);
+ size = Z_LVAL_PP(SIZE);
font = php_find_gd_font(size);
/* {{{ proto int imagechar(int im, int font, int x, int y, string c, int col)
Draw a character */
-PHP_FUNCTION(imagechar) {
+PHP_FUNCTION(imagechar)
+{
php_imagechar(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */
/* {{{ proto int imagecharup(int im, int font, int x, int y, string c, int col)
Draw a character rotated 90 degrees counter-clockwise */
-PHP_FUNCTION(imagecharup) {
+PHP_FUNCTION(imagecharup)
+{
php_imagechar(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
}
/* }}} */
/* {{{ proto int imagestring(int im, int font, int x, int y, string str, int col)
Draw a string horizontally */
-PHP_FUNCTION(imagestring) {
+PHP_FUNCTION(imagestring)
+{
php_imagechar(INTERNAL_FUNCTION_PARAM_PASSTHRU, 2);
}
/* }}} */
/* {{{ proto int imagestringup(int im, int font, int x, int y, string str, int col)
Draw a string vertically - rotated 90 degrees counter-clockwise */
-PHP_FUNCTION(imagestringup) {
+PHP_FUNCTION(imagestringup)
+{
php_imagechar(INTERNAL_FUNCTION_PARAM_PASSTHRU, 3);
}
/* }}} */
PHP_FUNCTION(imagecopy)
{
zval **SIM, **DIM, **SX, **SY, **SW, **SH, **DX, **DY;
- gdImagePtr im_dst;
- gdImagePtr im_src;
+ gdImagePtr im_dst, im_src;
int srcH, srcW, srcY, srcX, dstY, dstX;
GDLS_FETCH();
- if (ZEND_NUM_ARGS() != 8 ||
- zend_get_parameters_ex(8, &DIM, &SIM, &DX, &DY, &SX, &SY, &SW, &SH)
- == FAILURE) {
+ if (ZEND_NUM_ARGS() != 8 ||
+ zend_get_parameters_ex(8, &DIM, &SIM, &DX, &DY, &SX, &SY, &SW, &SH) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(DX);
convert_to_long_ex(DY);
- srcX = (*SX)->value.lval;
- srcY = (*SY)->value.lval;
- srcH = (*SH)->value.lval;
- srcW = (*SW)->value.lval;
- dstX = (*DX)->value.lval;
- dstY = (*DY)->value.lval;
+ srcX = Z_LVAL_PP(SX);
+ srcY = Z_LVAL_PP(SY);
+ srcH = Z_LVAL_PP(SH);
+ srcW = Z_LVAL_PP(SW);
+ dstX = Z_LVAL_PP(DX);
+ dstY = Z_LVAL_PP(DY);
gdImageCopy(im_dst, im_src, dstX, dstY, srcX, srcY, srcW, srcH);
RETURN_TRUE;
{
#if HAVE_LIBGD15
zval **SIM, **DIM, **SX, **SY, **SW, **SH, **DX, **DY, **PCT;
- gdImagePtr im_dst;
- gdImagePtr im_src;
+ gdImagePtr im_dst, im_src;
int srcH, srcW, srcY, srcX, dstY, dstX, pct;
GDLS_FETCH();
if (ZEND_NUM_ARGS() != 9 ||
- zend_get_parameters_ex(9, &DIM, &SIM, &DX, &DY, &SX, &SY, &SW, &SH, &PCT) == FAILURE) {
+ zend_get_parameters_ex(9, &DIM, &SIM, &DX, &DY, &SX, &SY, &SW, &SH, &PCT) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
PHP_FUNCTION(imagecopyresized)
{
zval **SIM, **DIM, **SX, **SY, **SW, **SH, **DX, **DY, **DW, **DH;
- gdImagePtr im_dst;
- gdImagePtr im_src;
+ gdImagePtr im_dst, im_src;
int srcH, srcW, dstH, dstW, srcY, srcX, dstY, dstX;
GDLS_FETCH();
if (ZEND_NUM_ARGS() != 10 ||
- zend_get_parameters_ex(10, &DIM, &SIM, &DX, &DY, &SX, &SY, &DW, &DH,
- &SW, &SH) == FAILURE) {
+ zend_get_parameters_ex(10, &DIM, &SIM, &DX, &DY, &SX, &SY, &DW, &DH, &SW, &SH) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
convert_to_long_ex(DW);
convert_to_long_ex(DH);
- srcX = (*SX)->value.lval;
- srcY = (*SY)->value.lval;
- srcH = (*SH)->value.lval;
- srcW = (*SW)->value.lval;
- dstX = (*DX)->value.lval;
- dstY = (*DY)->value.lval;
- dstH = (*DH)->value.lval;
- dstW = (*DW)->value.lval;
-
- gdImageCopyResized(im_dst, im_src, dstX, dstY, srcX, srcY, dstW, dstH,
- srcW, srcH);
+ srcX = Z_LVAL_PP(SX);
+ srcY = Z_LVAL_PP(SY);
+ srcH = Z_LVAL_PP(SH);
+ srcW = Z_LVAL_PP(SW);
+ dstX = Z_LVAL_PP(DX);
+ dstY = Z_LVAL_PP(DY);
+ dstH = Z_LVAL_PP(DH);
+ dstW = Z_LVAL_PP(DW);
+
+ gdImageCopyResized(im_dst, im_src, dstX, dstY, srcX, srcY, dstW, dstH, srcW, srcH);
RETURN_TRUE;
}
/* }}} */
{
zval **IM, **PTSIZE, **ANGLE, **X, **Y, **C, **FONTNAME, **COL;
gdImagePtr im=NULL;
- int col, x, y, l=0, i;
- int brect[8];
+ int col, x, y, l=0, i, brect[8];
double ptsize, angle;
unsigned char *str = NULL, *fontname = NULL;
char *error;
convert_to_double_ex(ANGLE);
convert_to_string_ex(FONTNAME);
convert_to_string_ex(C);
+
if (mode == TTFTEXT_BBOX) {
- im = NULL;
+ im = NULL;
col = x = y = -1;
} else {
convert_to_long_ex(X);
convert_to_long_ex(Y);
convert_to_long_ex(COL);
- col = (*COL)->value.lval;
- y = (*Y)->value.lval;
- x = (*X)->value.lval;
+ col = Z_LVAL_PP(COL);
+ y = Z_LVAL_PP(Y);
+ x = Z_LVAL_PP(X);
}
- ptsize = (*PTSIZE)->value.dval;
- angle = (*ANGLE)->value.dval * (M_PI/180); /* convert to radians */
+ ptsize = Z_DVAL_PP(PTSIZE);
+ angle = Z_DVAL_PP(ANGLE) * (M_PI/180); /* convert to radians */
- str = (unsigned char *) (*C)->value.str.val;
+ str = (unsigned char *) Z_STRVAL_PP(C);
l = strlen(str);
- fontname = (unsigned char *) (*FONTNAME)->value.str.val;
+ fontname = (unsigned char *) Z_STRVAL_PP(FONTNAME);
#ifdef USE_GD_IMGSTRTTF
error = gdImageStringTTF(im, brect, col, fontname, ptsize, angle, x, y, str);
php_error(E_WARNING, "%s", error);
RETURN_FALSE;
}
-
if (array_init(return_value) == FAILURE) {
RETURN_FALSE;
{
#if HAVE_LIBT1
zval **file;
- int f_ind;
- int *font;
+ int f_ind, *font;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &file) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &file) == FAILURE)
+ {
WRONG_PARAM_COUNT;
}
convert_to_string_ex(file);
- f_ind = T1_AddFont((*file)->value.str.val);
+ f_ind = T1_AddFont(Z_STRVAL_PP(file));
if (f_ind < 0) {
switch (f_ind) {
PHP_FUNCTION(imagepscopyfont)
{
#if HAVE_LIBT1
- pval *fnt;
+ zval **fnt;
int l_ind, type;
gd_ps_font *nf_ind, *of_ind;
- if (ZEND_NUM_ARGS() != 1 || zend_get_parameters(ht, 1, &fnt) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &fnt) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_long(fnt);
+ convert_to_long_ex(fnt);
- of_ind = zend_list_find(fnt->value.lval, &type);
+ of_ind = zend_list_find(Z_LVAL_PP(fnt), &type);
if (type != GDG(le_ps_font)) {
- php_error(E_WARNING, "%d is not a Type 1 font index", fnt->value.lval);
+ php_error(E_WARNING, "%d is not a Type 1 font index", Z_LVAL_PP(fnt));
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", GDG(le_ps_font));
- zend_list_delete((*fnt)->value.lval);
+ zend_list_delete(Z_LVAL_PP(fnt));
RETURN_TRUE;
#else
php_error(E_WARNING, "ImagePsFreeFont: No T1lib support in this PHP build");
ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", GDG(le_ps_font));
- if ((enc_vector = T1_LoadEncoding((*enc)->value.str.val)) == NULL) {
- php_error(E_WARNING, "Couldn't load encoding vector from %s", (*enc)->value.str.val);
+ if ((enc_vector = T1_LoadEncoding(Z_STRVAL_PP(enc))) == NULL) {
+ php_error(E_WARNING, "Couldn't load encoding vector from %s", Z_STRVAL_PP(enc));
RETURN_FALSE;
}
ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", GDG(le_ps_font));
- if (T1_ExtendFont(*f_ind, (*ext)->value.dval) != 0) RETURN_FALSE;
+ if (T1_ExtendFont(*f_ind, Z_DVAL_PP(ext)) != 0) RETURN_FALSE;
RETURN_TRUE;
#else
ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", GDG(le_ps_font));
- if (T1_SlantFont(*f_ind, (*slt)->value.dval) != 0) RETURN_FALSE;
+ if (T1_SlantFont(*f_ind, Z_DVAL_PP(slt)) != 0) RETURN_FALSE;
RETURN_TRUE;
#else
php_error(E_WARNING, "ImagePsSlantFont: No T1lib support in this PHP build");
int space;
int *f_ind;
int h_lines, v_lines, c_ind;
- int rd, gr, bl, fg_rd, fg_gr, fg_bl, bg_rd, bg_gr, bg_bl;
+ int rd, gr, bl, fg_rd, fg_gr, fg_bl, bg_rd, bg_gr, bg_bl,_fg,_bg;
int aa[16], aa_steps;
int width, amount_kern, add_width;
double angle, extend;
GLYPH *str_img;
T1_OUTLINE *char_path, *str_path;
T1_TMATRIX *transform = NULL;
-
+ char *_str;
+
switch(ZEND_NUM_ARGS()) {
case 8:
if (zend_get_parameters_ex(8, &img, &str, &fnt, &sz, &fg, &bg, &px, &py) == FAILURE) {
RETURN_FALSE;
}
- convert_to_string_ex(str);
- convert_to_long_ex(sz);
- convert_to_long_ex(fg);
- convert_to_long_ex(bg);
- convert_to_long_ex(px);
- convert_to_long_ex(py);
- x = (*px)->value.lval;
- y = (*py)->value.lval;
space = 0;
aa_steps = 4;
width = 0;
if (zend_get_parameters_ex(12, &img, &str, &fnt, &sz, &fg, &bg, &px, &py, &sp, &wd, &ang, &aas) == FAILURE) {
RETURN_FALSE;
}
- convert_to_string_ex(str);
- convert_to_long_ex(sz);
convert_to_long_ex(sp);
- convert_to_long_ex(fg);
- convert_to_long_ex(bg);
- convert_to_long_ex(px);
- convert_to_long_ex(py);
- x = (*px)->value.lval;
- y = (*py)->value.lval;
- convert_to_long_ex(sp);
- space = (*sp)->value.lval;
convert_to_long_ex(aas);
- aa_steps = (*aas)->value.lval;
convert_to_long_ex(wd);
- width = (*wd)->value.lval;
convert_to_double_ex(ang);
- angle = (*ang)->value.dval;
+ space = Z_LVAL_PP(sp);
+ aa_steps = Z_LVAL_PP(aas);
+ width = Z_LVAL_PP(wd);
+ angle = Z_DVAL_PP(ang);
break;
default:
WRONG_PARAM_COUNT;
ZEND_FETCH_RESOURCE(bg_img, gdImagePtr, img, -1, "Image", GDG(le_gd));
ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", GDG(le_ps_font));
- fg_rd = gdImageRed(bg_img, (*fg)->value.lval);
- fg_gr = gdImageGreen(bg_img, (*fg)->value.lval);
- fg_bl = gdImageBlue(bg_img, (*fg)->value.lval);
- bg_rd = gdImageRed(bg_img, (*bg)->value.lval);
- bg_gr = gdImageGreen(bg_img, (*bg)->value.lval);
- bg_bl = gdImageBlue(bg_img, (*bg)->value.lval);
+ x = Z_LVAL_PP(px);
+ y = Z_LVAL_PP(py);
+ _fg = Z_LVAL_PP(fg);
+ _bg = Z_LVAL_PP(bg);
+
+ fg_rd = gdImageRed (bg_img, _fg);
+ fg_gr = gdImageGreen(bg_img, _fg);
+ fg_bl = gdImageBlue (bg_img, _fg);
+
+ bg_rd = gdImageRed (bg_img, _bg);
+ bg_gr = gdImageGreen(bg_img, _bg);
+ bg_bl = gdImageBlue (bg_img, _bg);
for (i = 0; i < aa_steps; i++) {
rd = bg_rd+(double)(fg_rd-bg_rd)/aa_steps*(i+1);
transform = T1_RotateMatrix(NULL, angle);
}
+ _str = Z_STRVAL_PP(str);
+
if (width) {
extend = T1_GetExtend(*f_ind);
- str_path = T1_GetCharOutline(*f_ind, (*str)->value.str.val[0], (*sz)->value.lval, transform);
+ str_path = T1_GetCharOutline(*f_ind, _str[0], Z_LVAL_PP(sz), transform);
- for (i = 1; i < (*str)->value.str.len; i++) {
- amount_kern = (int) T1_GetKerning(*f_ind, (*str)->value.str.val[i-1], (*str)->value.str.val[i]);
- amount_kern += (*str)->value.str.val[i-1] == ' ' ? space : 0;
+ for (i = 1; i < Z_STRLEN_PP(str); i++) {
+ amount_kern = (int) T1_GetKerning(*f_ind, _str[i-1], _str[i]);
+ amount_kern += _str[i-1] == ' ' ? space : 0;
add_width = (int) (amount_kern+width)/extend;
- char_path = T1_GetMoveOutline(*f_ind, add_width, 0, 0, (*sz)->value.lval, transform);
+ char_path = T1_GetMoveOutline(*f_ind, add_width, 0, 0, Z_LVAL_PP(sz), transform);
str_path = T1_ConcatOutlines(str_path, char_path);
- char_path = T1_GetCharOutline(*f_ind, (*str)->value.str.val[i], (*sz)->value.lval, transform);
+ char_path = T1_GetCharOutline(*f_ind, _str[i], Z_LVAL_PP(sz), transform);
str_path = T1_ConcatOutlines(str_path, char_path);
}
str_img = T1_AAFillOutline(str_path, 0);
} else {
- str_img = T1_AASetString(*f_ind, (*str)->value.str.val, (*str)->value.str.len,
- space, T1_KERNING, (*sz)->value.lval, transform);
+ str_img = T1_AASetString(*f_ind, _str, Z_STRLEN_PP(str), space, T1_KERNING, Z_LVAL_PP(sz), transform);
}
if (T1_errno) {
if (zend_get_parameters_ex(3, &str, &fnt, &sz) == FAILURE) {
RETURN_FALSE;
}
- convert_to_string_ex(str);
- convert_to_long_ex(sz);
space = 0;
break;
case 6:
if (zend_get_parameters_ex(6, &str, &fnt, &sz, &sp, &wd, &ang) == FAILURE) {
RETURN_FALSE;
}
- convert_to_string_ex(str);
- convert_to_long_ex(sz);
convert_to_long_ex(sp);
- space = (*sp)->value.lval;
convert_to_long_ex(wd);
- add_width = (*wd)->value.lval;
convert_to_double_ex(ang);
- angle = (*ang)->value.dval * M_PI / 180;
+ space = Z_LVAL_PP(sp);
+ add_width = Z_LVAL_PP(wd);
+ angle = Z_DVAL_PP(ang) * M_PI / 180;
sin_a = sin(angle);
cos_a = cos(angle);
per_char = add_width || angle ? 1 : 0;
ZEND_FETCH_RESOURCE(f_ind, int *, fnt, -1, "Type 1 font", GDG(le_ps_font));
+ convert_to_string_ex(str);
+ convert_to_long_ex(sz);
+
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
#define new_x(a, b) (int) ((a) * cos_a - (b) * sin_a)