diff options
Diffstat (limited to 'php_imlib.c')
| -rw-r--r-- | php_imlib.c | 950 |
1 files changed, 324 insertions, 626 deletions
diff --git a/php_imlib.c b/php_imlib.c index 0d437d9..383fddd 100644 --- a/php_imlib.c +++ b/php_imlib.c @@ -37,7 +37,17 @@ int gd_imlib_id; zend_imlib_globals imlib_globals; #endif -static + ZEND_BEGIN_ARG_INFO(second_arg_force_ref, 0) + ZEND_ARG_PASS_INFO(0) + ZEND_ARG_PASS_INFO(1) + ZEND_END_ARG_INFO(); + + ZEND_BEGIN_ARG_INFO(third_arg_force_ref, 0) + ZEND_ARG_PASS_INFO(0) + ZEND_ARG_PASS_INFO(0) + ZEND_ARG_PASS_INFO(1) + ZEND_END_ARG_INFO(); + ZEND_BEGIN_ARG_INFO(third_and_fourth_arg_force_ref, 0) ZEND_ARG_PASS_INFO(0) ZEND_ARG_PASS_INFO(0) @@ -45,7 +55,6 @@ static ZEND_ARG_PASS_INFO(1) ZEND_END_ARG_INFO(); -static ZEND_BEGIN_ARG_INFO(second_through_fifth_arg_force_ref, 0) ZEND_ARG_PASS_INFO(0) ZEND_ARG_PASS_INFO(1) @@ -54,7 +63,6 @@ static ZEND_ARG_PASS_INFO(1) ZEND_END_ARG_INFO(); -static ZEND_BEGIN_ARG_INFO(third_through_sixth_arg_force_ref, 0) ZEND_ARG_PASS_INFO(0) ZEND_ARG_PASS_INFO(0) @@ -936,19 +944,18 @@ static int _php_handle_imlib_error(INTERNAL_FUNCTION_PARAMETERS, static void _php_imlib_draw_something(INTERNAL_FUNCTION_PARAMETERS, void (*func)(), char *func_name) { - zval **img, **d1, **d2, **d3, **d4, **dr, **dg, **db, **da, **dbox; - int x,y,w,h,r,g,b,a,cx,cy,cw,ch,argc; + int argc; + int cx, cy, cw, ch; + zval *img, *dbox; + long x,y,w,h,r,g,b,a; Imlib_Image im; argc = ZEND_NUM_ARGS(); - if (argc < 9 || argc > 10 || zend_get_parameters_ex(argc, &img, &d1, &d2, &d3, &d4, &dr, &dg, &db, &da, &dbox) == FAILURE) { - WRONG_PARAM_COUNT; + if (zend_parse_parameters(argc TSRMLS_CC, "rllllllll|a", &img, &x, &y, &w, &h, &r, &g, &b, &a, &dbox) == FAILURE) { + return; } - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); - - _php_convert_four_longs(d1,d2,d3,d4,&x,&y,&w,&h); - _php_convert_four_longs(dr,dg,db,da,&r,&g,&b,&a); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(im); imlib_context_set_color(r,g,b,a); @@ -958,7 +965,7 @@ static void _php_imlib_draw_something(INTERNAL_FUNCTION_PARAMETERS, void (*func) if (argc > 9) { - if (!_php_handle_cliprect_array(dbox, func_name, &cx,&cy,&cw,&ch TSRMLS_CC)) + if (!_php_handle_cliprect_array(&dbox, func_name, &cx,&cy,&cw,&ch TSRMLS_CC)) RETURN_FALSE; imlib_context_set_cliprect(cx,cy,cw,ch); } @@ -970,14 +977,12 @@ static void _php_imlib_draw_something(INTERNAL_FUNCTION_PARAMETERS, void (*func) static void _php_imlib_single_arg(INTERNAL_FUNCTION_PARAMETERS, void (*func)()) { - zval **img; + zval *img; Imlib_Image im; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &img) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(1 TSRMLS_CC, "r", &img) == FAILURE) return; - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(im); (*func)(); @@ -995,19 +1000,13 @@ static void _php_wrap_draw_line(int x1, int y1, int x2, int y2) Add a color to a color range at a specified distance from the previous color in the range. A distance of 0 centers it */ PHP_FUNCTION(imlib_add_color_to_color_range) { - zval **crange, **cx, **cr, **cg, **cb, **ca; - int x,r,g,b,a; + zval *crange; + long x,r,g,b,a; Imlib_Color_Range range; - if (ZEND_NUM_ARGS() != 6 || zend_get_parameters_ex(6, &crange, &cx, &cr, &cg, &cb, &ca) == FAILURE) { - WRONG_PARAM_COUNT; - } - - ZEND_FETCH_RESOURCE(range, Imlib_Color_Range, crange, -1, "Imlib Color Range", le_imlib_cr); + if (zend_parse_parameters(6 TSRMLS_CC, "rlllll", &crange, &x, &r, &g, &b, &a) == FAILURE) return; - convert_to_long_ex(cx); - x = Z_LVAL_PP(cx); - _php_convert_four_longs(cr,cg,cb,ca,&r,&g,&b,&a); + ZEND_FETCH_RESOURCE(range, Imlib_Color_Range, &crange, -1, "Imlib Color Range", le_imlib_cr); imlib_context_set_color_range(range); imlib_context_set_color(r,g,b,a); @@ -1020,29 +1019,15 @@ PHP_FUNCTION(imlib_add_color_to_color_range) Blend a rectangular area from an image onto an area of another image, scaling as necessary */ PHP_FUNCTION(imlib_blend_image_onto_image) { - zval **dstimg, **srcimg, **malpha, **srcx, **srcy, **srcw, **srch, **dstx, **dsty, **dstw, **dsth, **dither, **blend, **alias; + zval *dstimg, *srcimg; Imlib_Image dst,src; - int sx,sy,sw,sh,dx,dy,dw,dh; - int calias, calpha, cblend, cdither; - - if (ZEND_NUM_ARGS() != 14 || zend_get_parameters_ex(14, &dstimg, &srcimg, &malpha, &srcx, &srcy, &srcw, &srch, &dstx, &dsty, &dstw, &dsth, &dither, &blend, &alias) == FAILURE) { - WRONG_PARAM_COUNT; - } - - ZEND_FETCH_RESOURCE(src, Imlib_Image, srcimg, -1, "Imlib Image", le_imlib_img); - ZEND_FETCH_RESOURCE(dst, Imlib_Image, dstimg, -1, "Imlib Image", le_imlib_img); + long sx,sy,sw,sh,dx,dy,dw,dh; + long calias, calpha, cblend, cdither; - _php_convert_four_longs(srcx,srcy,srcw,srch,&sx,&sy,&sw,&sh); - _php_convert_four_longs(dstx,dsty,dstw,dsth,&dx,&dy,&dw,&dh); + if (zend_parse_parameters(14 TSRMLS_CC, "rrllllllllllll", &dstimg, &srcimg, &calpha, &sx, &sy, &sw, &sh, &dx, &dy, &dw, &dh, &cdither, &cblend, &calias) == FAILURE) return; - convert_to_long_ex(malpha); - convert_to_long_ex(dither); - convert_to_long_ex(blend); - convert_to_long_ex(alias); - calpha = Z_LVAL_PP(malpha); - cdither = Z_LVAL_PP(dither); - cblend = Z_LVAL_PP(blend); - calias = Z_LVAL_PP(alias); + ZEND_FETCH_RESOURCE(src, Imlib_Image, &srcimg, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(dst, Imlib_Image, &dstimg, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(dst); imlib_context_set_anti_alias(calias); @@ -1058,14 +1043,12 @@ PHP_FUNCTION(imlib_blend_image_onto_image) Duplicate an image */ PHP_FUNCTION(imlib_clone_image) { - zval **img; + zval *img; Imlib_Image src,dst; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &img) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(1 TSRMLS_CC, "r", &img) == FAILURE) return; - ZEND_FETCH_RESOURCE(src, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(src, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(src); dst = imlib_clone_image(); @@ -1122,17 +1105,13 @@ PHP_FUNCTION(imlib_create_color_modifier) Create an image from a cropped region of another image */ PHP_FUNCTION(imlib_create_cropped_image) { - zval **img, **srcx, **srcy, **srcw, **srch; - int sx,sy,sw,sh; + zval *img; + long sx,sy,sw,sh; Imlib_Image src,dst; - if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &img, &srcx, &srcy, &srcw, &srch) == FAILURE) { - WRONG_PARAM_COUNT; - } - - ZEND_FETCH_RESOURCE(src, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); + if (zend_parse_parameters(5 TSRMLS_CC, "rllll", &img, &sx, &sy, &sw, &sh) == FAILURE) return; - _php_convert_four_longs(srcx,srcy,srcw,srch,&sx,&sy,&sw,&sh); + ZEND_FETCH_RESOURCE(src, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(src); dst = imlib_create_cropped_image(sx,sy,sw,sh); @@ -1146,22 +1125,13 @@ PHP_FUNCTION(imlib_create_cropped_image) Create a scaled image from a cropped region of another image */ PHP_FUNCTION(imlib_create_cropped_scaled_image) { - zval **img, **srcx, **srcy, **srcw, **srch, **dstw, **dsth; - int sx,sy,sw,sh,dw,dh; + zval *img; + long sx,sy,sw,sh,dw,dh; Imlib_Image src,dst; - if (ZEND_NUM_ARGS() != 7 || zend_get_parameters_ex(7, &img, &srcx, &srcy, &srcw, - &srch, &dstw, &dsth) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(7 TSRMLS_CC, "rllllll", &img, &sx, &sy, &sw, &sh, &dw, &dh) == FAILURE) return; - ZEND_FETCH_RESOURCE(src, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); - - _php_convert_four_longs(srcx,srcy,srcw,srch,&sx,&sy,&sw,&sh); - convert_to_long_ex(dstw); - convert_to_long_ex(dsth); - dw = Z_LVAL_PP(dstw); - dh = Z_LVAL_PP(dsth); + ZEND_FETCH_RESOURCE(src, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(src); dst = imlib_create_cropped_scaled_image(sx,sy, sw,sh, dw,dh); @@ -1175,18 +1145,10 @@ PHP_FUNCTION(imlib_create_cropped_scaled_image) Create a new image with the specified dimensions */ PHP_FUNCTION(imlib_create_image) { - zval **nx, **ny; Imlib_Image im; - int x,y; + long x,y; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &nx, &ny) == FAILURE) { - WRONG_PARAM_COUNT; - } - - convert_to_long_ex(nx); - convert_to_long_ex(ny); - x = Z_LVAL_PP(nx); - y = Z_LVAL_PP(ny); + if (zend_parse_parameters(2 TSRMLS_CC, "ll", &x, &y) == FAILURE) return; im = imlib_create_image(x,y); @@ -1207,29 +1169,17 @@ PHP_FUNCTION(imlib_create_rotated_image) /* Contributed by Gareth Ardron */ - zval **srcimg, **cangle, **crads; - double angle, radians, pi = 3.141592654; + zval *srcimg; + double angle, radians; int argc; Imlib_Image src, dst; argc = ZEND_NUM_ARGS(); - if (argc < 2 || argc > 3 || zend_get_parameters_ex(argc, &srcimg, &cangle, &crads) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(argc TSRMLS_CC, "rd|d", &srcimg, &angle, &radians) == FAILURE) return; - ZEND_FETCH_RESOURCE(src, Imlib_Image, srcimg, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(src, Imlib_Image, &srcimg, -1, "Imlib Image", le_imlib_img); - if (argc > 2) - { - convert_to_double_ex(crads); - radians = Z_DVAL_PP(crads); - } - else - { - convert_to_double_ex(cangle); - angle = Z_DVAL_PP(cangle); - radians = angle * pi/180; - } + if (argc == 2) radians = angle * M_PI/180; imlib_context_set_image(src); dst = imlib_create_rotated_image(radians); @@ -1243,15 +1193,14 @@ PHP_FUNCTION(imlib_create_rotated_image) Create a scaled copy of an image. If dstw or dsth is left blank, the aspect ratio of the source image will be preserved. */ PHP_FUNCTION(imlib_create_scaled_image) { - zval **img, **dstw, **dsth; - int sw,sh,dw,dh; + zval *img; + zval **dstw, **dsth; + long sw,sh,dw,dh; Imlib_Image src,dst; - if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &img, &dstw, &dsth) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(3 TSRMLS_CC, "rZZ", &img, &dstw, &dsth) == FAILURE) return; - ZEND_FETCH_RESOURCE(src, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(src, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); convert_to_long_ex(dstw); convert_to_long_ex(dsth); @@ -1266,10 +1215,10 @@ PHP_FUNCTION(imlib_create_scaled_image) sw = imlib_image_get_width(); sh = imlib_image_get_height(); if (!dw) { - dw = (int) (((double)dh * sw) / sh); + dw = (long) (((double)dh * sw) / sh); } if (!dh) { - dh = (int) (((double) dw * sh) / sw); + dh = (long) (((double) dw * sh) / sw); } dst = imlib_create_cropped_scaled_image(0,0, sw,sh, dw,dh); @@ -1283,24 +1232,23 @@ PHP_FUNCTION(imlib_create_scaled_image) Output an image at an optional quality setting */ PHP_FUNCTION(imlib_dump_image) { - int argc, q, retval; + int argc, retval; + long q; FILE *tmp; char *tmpfile; - zval **img, **quality, **err; + zval *img, **err; Imlib_Image im; Imlib_Load_Error im_err; argc = ZEND_NUM_ARGS(); - if (argc < 1 || argc > 3 || zend_get_parameters_ex(argc, &img, &err, &quality) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(argc TSRMLS_CC, "r|Zl", &img, &err, &q) == FAILURE) return; if (argc > 1) { zval_dtor(*err); ZVAL_LONG(*err,0); } - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); tmp = php_open_temporary_file("", "", &tmpfile TSRMLS_CC); if (tmp == NULL) { @@ -1315,8 +1263,6 @@ PHP_FUNCTION(imlib_dump_image) if (argc > 2) { - convert_to_long_ex(quality); - q = Z_LVAL_PP(quality); imlib_image_attach_data_value("quality",NULL,q,NULL); } @@ -1365,15 +1311,13 @@ PHP_FUNCTION(imlib_dump_image) Free a color range */ PHP_FUNCTION(imlib_free_color_range) { - zval **fcr; + zval *fcr; Imlib_Color_Range cr; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &fcr) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(1 TSRMLS_CC, "r", &fcr) == FAILURE) return; - ZEND_FETCH_RESOURCE(cr, Imlib_Color_Range, fcr, -1, "Imlib Color Range", le_imlib_cr); - zend_list_delete(Z_LVAL_PP(fcr)); + ZEND_FETCH_RESOURCE(cr, Imlib_Color_Range, &fcr, -1, "Imlib Color Range", le_imlib_cr); + zend_list_delete(Z_LVAL_PP(&fcr)); } /* }}} */ @@ -1382,15 +1326,13 @@ PHP_FUNCTION(imlib_free_color_range) Free a color modifier */ PHP_FUNCTION(imlib_free_color_modifier) { - zval **fcm; + zval *fcm; PHP_Imlib_Color_Modifier cm; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &fcm) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(1 TSRMLS_CC, "r", &fcm) == FAILURE) return; - ZEND_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, fcm, -1, "Imlib Color Modifier", le_imlib_cm); - zend_list_delete(Z_LVAL_PP(fcm)); + ZEND_FETCH_RESOURCE(cm, PHP_Imlib_Color_Modifier, &fcm, -1, "Imlib Color Modifier", le_imlib_cm); + zend_list_delete(Z_LVAL_PP(&fcm)); } /* }}} */ @@ -1398,15 +1340,13 @@ PHP_FUNCTION(imlib_free_color_modifier) Free a font */ PHP_FUNCTION(imlib_free_font) { - zval **font; + zval *font; PHP_Imlib_Font fn; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &font) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(1 TSRMLS_CC, "r", &font) == FAILURE) return; - ZEND_FETCH_RESOURCE(fn, PHP_Imlib_Font, font, -1, "Imlib Font", le_imlib_font); - zend_list_delete(Z_LVAL_PP(font)); + ZEND_FETCH_RESOURCE(fn, PHP_Imlib_Font, &font, -1, "Imlib Font", le_imlib_font); + zend_list_delete(Z_LVAL_PP(&font)); } /* }}} */ @@ -1415,15 +1355,13 @@ PHP_FUNCTION(imlib_free_font) Free an image */ PHP_FUNCTION(imlib_free_image) { - zval **img; + zval *img; Imlib_Image im; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &img) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(1 TSRMLS_CC, "r", &img) == FAILURE) return; - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); - zend_list_delete(Z_LVAL_PP(img)); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); + zend_list_delete(Z_LVAL_PP(&img)); } /* }}} */ @@ -1432,33 +1370,23 @@ PHP_FUNCTION(imlib_free_image) Determines the horizontal and vertical advance of a string if drawn with a given font in the specified direction*/ PHP_FUNCTION(imlib_get_text_advance) { - zval **font, **textstr, **thoriz_adv, **tvert_adv, **tdir; + zval *font; + zval **thoriz_adv, **tvert_adv; PHP_Imlib_Font fn; const char *text = NULL; - int horiz_adv, vert_adv, dir; - - if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &font, &textstr, &thoriz_adv, &tvert_adv, &tdir) == FAILURE) { - WRONG_PARAM_COUNT; - } + int text_len, horiz_adv, vert_adv; + long dir; - ZEND_FETCH_RESOURCE(fn, PHP_Imlib_Font, font, -1, "Imlib Font", le_imlib_font); + if (zend_parse_parameters(5 TSRMLS_CC, "rsZZl", &font, &text, &text_len, &thoriz_adv, &tvert_adv, &dir) == FAILURE) return; - zval_dtor(*thoriz_adv); - zval_dtor(*tvert_adv); - - convert_to_string_ex(textstr); - convert_to_long_ex(thoriz_adv); - convert_to_long_ex(tvert_adv); - convert_to_long_ex(tdir); - text = Z_STRVAL_PP(textstr); - horiz_adv = Z_LVAL_PP(thoriz_adv); - vert_adv = Z_LVAL_PP(tvert_adv); - dir = Z_LVAL_PP(tdir); + ZEND_FETCH_RESOURCE(fn, PHP_Imlib_Font, &font, -1, "Imlib Font", le_imlib_font); imlib_context_set_font(fn->font); imlib_context_set_direction(dir); imlib_get_text_advance(text, &horiz_adv, &vert_adv); + zval_dtor(*thoriz_adv); + zval_dtor(*tvert_adv); ZVAL_LONG(*thoriz_adv,horiz_adv); ZVAL_LONG(*tvert_adv,vert_adv); } @@ -1469,29 +1397,20 @@ PHP_FUNCTION(imlib_get_text_advance) Determines the width and height of a string if drawn with a given font in the specified direction */ PHP_FUNCTION(imlib_get_text_size) { - zval **font, **textstr, **tw, **th, **tdir; + zval *font; + zval **tw, **th; PHP_Imlib_Font fn; const char *text = NULL; - int w,h,dir; + int text_len, w,h; + long dir; - if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &font, &textstr, &tw, &th, &tdir) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(5 TSRMLS_CC, "rsZZl", &font, &text, &text_len, &tw, &th, &dir) == FAILURE) return; - ZEND_FETCH_RESOURCE(fn, PHP_Imlib_Font, font, -1, "Imlib Font", le_imlib_font); + ZEND_FETCH_RESOURCE(fn, PHP_Imlib_Font, &font, -1, "Imlib Font", le_imlib_font); zval_dtor(*tw); zval_dtor(*th); - convert_to_string_ex(textstr); - convert_to_long_ex(tw); - convert_to_long_ex(th); - convert_to_long_ex(tdir); - text = Z_STRVAL_PP(textstr); - w = Z_LVAL_PP(tw); - h = Z_LVAL_PP(th); - dir = Z_LVAL_PP(tdir); - imlib_context_set_font(fn->font); imlib_context_set_direction(dir); imlib_get_text_size(text, &w, &h); @@ -1506,18 +1425,13 @@ PHP_FUNCTION(imlib_get_text_size) Blur an image with a given blur radius */ PHP_FUNCTION(imlib_image_blur) { - zval **img, **radius; - int r; + zval *img; + long r; Imlib_Image im; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &img, &radius) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(2 TSRMLS_CC, "rl", &img, &r) == FAILURE) return; - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); - - convert_to_long_ex(radius); - r = Z_LVAL_PP(radius); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(im); imlib_image_blur(r); @@ -1549,31 +1463,25 @@ PHP_FUNCTION(imlib_image_draw_line) Draw the defined polygon on an image */ PHP_FUNCTION(imlib_image_draw_polygon) { - zval **img, **polygon, **pclosed, **pr, **pg, **pb, **pa, **dbox; - int r,g,b,a,cx,cy,cw,ch,argc; + zval *img, *polygon, *dbox; + long r,g,b,a; + int cx,cy,cw,ch,argc; Imlib_Image im; ImlibPolygon poly; - int closed; + zend_bool closed; argc = ZEND_NUM_ARGS(); - if (argc < 7 || argc > 8 || zend_get_parameters_ex(argc, &img, &polygon, &pclosed, &pr, &pg, &pb, &pa, &dbox) == FAILURE) { - WRONG_PARAM_COUNT; - } - - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); - ZEND_FETCH_RESOURCE(poly, ImlibPolygon, polygon, -1, "Imlib Polygon", le_imlib_poly); - - _php_convert_four_longs(pr,pg,pb,pa,&r,&g,&b,&a); + if (zend_parse_parameters(argc TSRMLS_CC, "rrbllll|a", &img, &polygon, &closed, &r, &g, &b, &a, &dbox) == FAILURE) return; - convert_to_long_ex(pclosed); - closed = Z_LVAL_PP(pclosed); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly); imlib_context_set_image(im); imlib_context_set_color(r,g,b,a); if (argc > 7) { - if (!_php_handle_cliprect_array(dbox, "imlib_image_draw_polygon", &cx, &cy, &cw, &ch TSRMLS_CC)) + if (!_php_handle_cliprect_array(&dbox, "imlib_image_draw_polygon", &cx, &cy, &cw, &ch TSRMLS_CC)) RETURN_FALSE; imlib_context_set_cliprect(cx,cy,cw,ch); } @@ -1598,30 +1506,25 @@ PHP_FUNCTION(imlib_image_draw_rectangle) Fill a rectangle with a color range at a given angle on an image */ PHP_FUNCTION(imlib_image_fill_color_range_rectangle) { - zval **fim, **fcr, **fx, **fy, **fwidth, **fheight, **fangle, **fbox; - int x,y,width,height,argc,cx,cy,cw,ch; + zval *fim, *fcr, *fbox; + long x,y,width,height; + int argc,cx,cy,cw,ch; double angle; Imlib_Image im; Imlib_Color_Range cr; argc = ZEND_NUM_ARGS(); - if (argc < 7 || argc > 8 || zend_get_parameters_ex(argc, &fim, &fcr, &fx, &fy, &fwidth, &fheight, &fangle, &fbox) == FAILURE) { - WRONG_PARAM_COUNT; - } - - _php_convert_four_longs(fx,fy,fwidth,fheight,&x,&y,&width,&height); - convert_to_double_ex(fangle); - angle = Z_DVAL_PP(fangle); + if (zend_parse_parameters(argc TSRMLS_CC, "rrlllld|a", &fim, &fcr, &x, &y, &width, &height, &angle, &fbox) == FAILURE) return; - ZEND_FETCH_RESOURCE(cr, Imlib_Color_Range, fcr, -1, "Imlib Color Range", le_imlib_cr); - ZEND_FETCH_RESOURCE(im, Imlib_Image, fim, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(cr, Imlib_Color_Range, &fcr, -1, "Imlib Color Range", le_imlib_cr); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &fim, -1, "Imlib Image", le_imlib_img); imlib_context_set_color_range(cr); imlib_context_set_image(im); if (argc > 7) { - if (!_php_handle_cliprect_array(fbox, "imlib_image_fill_color_range_rectangle", &cx,&cy,&cw,&ch TSRMLS_CC)) + if (!_php_handle_cliprect_array(&fbox, "imlib_image_fill_color_range_rectangle", &cx,&cy,&cw,&ch TSRMLS_CC)) RETURN_FALSE; imlib_context_set_cliprect(cx,cy,cw,ch); } @@ -1647,27 +1550,24 @@ PHP_FUNCTION(imlib_image_fill_ellipse) Draw and fill the defined polygon on an image */ PHP_FUNCTION(imlib_image_fill_polygon) { - zval **img, **polygon, **pr, **pg, **pb, **pa, **dbox; - int r,g,b,a,cx,cy,cw,ch,argc; + zval *img, *polygon, *dbox; + long r,g,b,a; + int cx,cy,cw,ch,argc; Imlib_Image im; ImlibPolygon poly; argc = ZEND_NUM_ARGS(); - if (argc < 6 || argc > 7 || zend_get_parameters_ex(argc, &img, &polygon, &pr, &pg, &pb, &pa, &dbox) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(argc TSRMLS_CC, "rrllll|a", &img, &polygon, &r, &g, &b, &a, &dbox) == FAILURE) return; - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); - ZEND_FETCH_RESOURCE(poly, ImlibPolygon, polygon, -1, "Imlib Polygon", le_imlib_poly); - - _php_convert_four_longs(pr,pg,pb,pa,&r,&g,&b,&a); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly); imlib_context_set_image(im); imlib_context_set_color(r,g,b,a); if (argc > 6) { - if (!_php_handle_cliprect_array(dbox, "imlib_image_fill_polygon", &cx, &cy, &cw, &ch TSRMLS_CC)) + if (!_php_handle_cliprect_array(&dbox, "imlib_image_fill_polygon", &cx, &cy, &cw, &ch TSRMLS_CC)) RETURN_FALSE; imlib_context_set_cliprect(cx,cy,cw,ch); } @@ -1723,18 +1623,15 @@ PHP_FUNCTION(imlib_image_orientate) /* Contributed by Gareth Ardron */ - zval **img, **stepping; - int r; + zval *img; + long r; Imlib_Image im; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &img, &stepping) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(2 TSRMLS_CC, "rl", &img, &r) == FAILURE) return; - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(im); - r = Z_LVAL_PP(stepping); imlib_image_orientate(r); } /* }}} */ @@ -1744,15 +1641,13 @@ PHP_FUNCTION(imlib_image_orientate) Returns the image format of an image */ PHP_FUNCTION(imlib_image_format) { - zval **img; + zval *img; Imlib_Image im; char *name; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &img) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(1 TSRMLS_CC, "r", &img) == FAILURE) return; - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(im); name = imlib_image_format(); @@ -1768,15 +1663,13 @@ PHP_FUNCTION(imlib_image_format) Returns the filename of an image */ PHP_FUNCTION(imlib_image_get_filename) { - zval **img; + zval *img; Imlib_Image im; const char *name = NULL; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &img) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(1 TSRMLS_CC, "r", &img) == FAILURE) return; - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(im); name = imlib_image_get_filename(); @@ -1792,15 +1685,13 @@ PHP_FUNCTION(imlib_image_get_filename) Returns the height of an image */ PHP_FUNCTION(imlib_image_get_height) { - zval **img; + zval *img; Imlib_Image im; int height; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &img) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(1 TSRMLS_CC, "r", &img) == FAILURE) return; - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(im); height = imlib_image_get_height(); @@ -1814,15 +1705,13 @@ PHP_FUNCTION(imlib_image_get_height) Returns the width of an image */ PHP_FUNCTION(imlib_image_get_width) { - zval **img; + zval *img; Imlib_Image im; int width; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &img) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(1 TSRMLS_CC, "r", &img) == FAILURE) return; - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(im); width = imlib_image_get_width(); @@ -1836,14 +1725,12 @@ PHP_FUNCTION(imlib_image_get_width) Return a boolean for whether or not an image has an alpha channel */ PHP_FUNCTION(imlib_image_has_alpha) { - zval **img; + zval *img; Imlib_Image im; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &img) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(1 TSRMLS_CC, "r", &img) == FAILURE) return; - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(im); if (imlib_image_has_alpha()) @@ -1862,21 +1749,18 @@ PHP_FUNCTION(imlib_image_has_alpha) Set the alpha channel of an image, or modify it if one was already present */ PHP_FUNCTION(imlib_image_modify_alpha) { - zval **img, **alpha; + zval *img; Imlib_Image im; DATA8 map[256]; Imlib_Color_Modifier *cmod; - int malpha, i; + long malpha; + int i; double ratio; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &img, &alpha) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(2 TSRMLS_CC, "rl", &img, &malpha) == FAILURE) return; - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); - convert_to_long_ex(alpha); - malpha = Z_LVAL_PP(alpha); ratio = ((double)malpha) / 255; imlib_context_set_image(im); @@ -1905,21 +1789,14 @@ PHP_FUNCTION(imlib_image_modify_alpha) Sets the image format of an image. */ PHP_FUNCTION(imlib_image_set_format) { - zval **img, **zformat; + zval *img; Imlib_Image im; char *format; + int format_len; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &img, &zformat) == FAILURE) { - WRONG_PARAM_COUNT; - } - - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); + if (zend_parse_parameters(2 TSRMLS_CC, "rs", &img, &format, &format_len) == FAILURE) return; - convert_to_string_ex(zformat); - format = Z_STRVAL_PP(zformat); - if (!format) { - RETURN_FALSE; - } + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(im); imlib_image_set_format(format); @@ -1933,18 +1810,13 @@ PHP_FUNCTION(imlib_image_set_format) Sharpen an image with a given sharpen radius */ PHP_FUNCTION(imlib_image_sharpen) { - zval **img, **radius; - int r; + zval *img; + long r; Imlib_Image im; - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &img, &radius) == FAILURE) { - WRONG_PARAM_COUNT; - } - - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); + if (zend_parse_parameters(2 TSRMLS_CC, "rl", &img, &r) == FAILURE) return; - convert_to_long_ex(radius); - r = Z_LVAL_PP(radius); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); imlib_context_set_image(im); imlib_image_sharpen(r); @@ -2009,26 +1881,22 @@ PHP_FUNCTION(imlib_list_fonts) Load a font */ PHP_FUNCTION(imlib_load_font) { - zval **fontname; + char *fontname; + int fontname_len; PHP_Imlib_Font fn; int argc; - argc=ZEND_NUM_ARGS(); - if (argc != 1 || zend_get_parameters_ex(argc, &fontname) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(1 TSRMLS_CC, "s", &fontname, &fontname_len) == FAILURE) return; fn=(PHP_Imlib_Font)emalloc(sizeof(PHP_Imlib_Font_struct)); if (!fn) RETURN_FALSE; - convert_to_string_ex(fontname); - - fn->font = imlib_load_font(Z_STRVAL_PP(fontname)); + fn->font = imlib_load_font(fontname); if (!fn->font) { efree(fn); - php_error(E_WARNING, "%s - Could not load font.", Z_STRVAL_PP(fontname)); + php_error(E_WARNING, "%s - Could not load font.", fontname); RETURN_FALSE; } @@ -2041,25 +1909,24 @@ PHP_FUNCTION(imlib_load_font) Load a file into an image, optionally fetch an error parameter */ PHP_FUNCTION(imlib_load_image) { - zval **img, **err; + zval **err; int argc; Imlib_Image im; Imlib_Load_Error im_err; FILE* f; char* filename; + char* img; + int img_len; argc = ZEND_NUM_ARGS(); - if (argc < 1 || argc > 2 || zend_get_parameters_ex(argc, &img, &err) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(argc TSRMLS_CC, "s|Z", &img, &img_len, &err) == FAILURE) return; - convert_to_string_ex(img); if (argc == 2) { zval_dtor(*err); ZVAL_LONG(*err,0); } - f = php_stream_open_wrapper_as_file(Z_STRVAL_PP(img), "rb", IGNORE_PATH | ENFORCE_SAFE_MODE | REPORT_ERRORS, &filename); + f = php_stream_open_wrapper_as_file(img, "rb", IGNORE_PATH | ENFORCE_SAFE_MODE | REPORT_ERRORS, &filename); if (f == NULL) RETURN_FALSE; im = imlib_load_image_with_error_return(filename, &im_err); @@ -2073,7 +1940,7 @@ PHP_FUNCTION(imlib_load_image) ZVAL_LONG(*err,im_err); } _php_handle_imlib_error(INTERNAL_FUNCTION_PARAM_PASSTHRU, - im_err,Z_STRVAL_PP(img)); + im_err,img); RETURN_FALSE; } else @@ -2088,20 +1955,13 @@ PHP_FUNCTION(imlib_load_image) Add a point to a given polygon */ PHP_FUNCTION(imlib_polygon_add_point) { - zval **polygon, **px, **py; - int x,y; + zval *polygon; + long x,y; ImlibPolygon poly; - if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &polygon, &px, &py) == FAILURE) { - WRONG_PARAM_COUNT; - } - - ZEND_FETCH_RESOURCE(poly, ImlibPolygon, polygon, -1, "Imlib Polygon", le_imlib_poly); + if (zend_parse_parameters(3 TSRMLS_CC, "rll", &polygon, &x, &y) == FAILURE) return; - convert_to_long_ex(px); - convert_to_long_ex(py); - x = Z_LVAL_PP(px); - y = Z_LVAL_PP(py); + ZEND_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly); imlib_polygon_add_point(poly,x,y); } @@ -2112,20 +1972,14 @@ PHP_FUNCTION(imlib_polygon_add_point) Check if a give point is inside a polygon */ PHP_FUNCTION(imlib_polygon_contains_point) { - zval **polygon, **px, **py; - int x,y,ret; + zval *polygon; + long x,y; + int ret; ImlibPolygon poly; - if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &polygon, &px, &py) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(3 TSRMLS_CC, "rll", &polygon, &x, &y) == FAILURE) return; - ZEND_FETCH_RESOURCE(poly, ImlibPolygon, polygon, -1, "Imlib Polygon", le_imlib_poly); - - convert_to_long_ex(px); - convert_to_long_ex(py); - x = Z_LVAL_PP(px); - y = Z_LVAL_PP(py); + ZEND_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly); ret = imlib_polygon_contains_point(poly,x,y); @@ -2145,15 +1999,13 @@ PHP_FUNCTION(imlib_polygon_contains_point) Free a polygon */ PHP_FUNCTION(imlib_polygon_free) { - zval **polygon; + zval *polygon; ImlibPolygon poly; - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &polygon) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(1 TSRMLS_CC, "r", &polygon) == FAILURE) return; - ZEND_FETCH_RESOURCE(poly, ImlibPolygon, polygon, -1, "Imlib Polygon", le_imlib_poly); - zend_list_delete(Z_LVAL_PP(polygon)); + ZEND_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly); + zend_list_delete(Z_LVAL_PP(&polygon)); } /* }}} */ @@ -2162,15 +2014,14 @@ PHP_FUNCTION(imlib_polygon_free) Get the bounding coords of a polygon */ PHP_FUNCTION(imlib_polygon_get_bounds) { - zval **polygon, **px1, **py1, **px2, **py2; + zval *polygon; + zval **px1, **py1, **px2, **py2; int x1,y1,x2,y2; ImlibPolygon poly; - if (ZEND_NUM_ARGS() != 5 || zend_get_parameters_ex(5, &polygon, &px1, &py1, &px2, &py2) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(5 TSRMLS_CC, "rZZZZ", &polygon, &px1, &py1, &px2, &py2) == FAILURE) return; - ZEND_FETCH_RESOURCE(poly, ImlibPolygon, polygon, -1, "Imlib Polygon", le_imlib_poly); + ZEND_FETCH_RESOURCE(poly, ImlibPolygon, &polygon, -1, "Imlib Polygon", le_imlib_poly); zval_dtor(*px1); zval_dtor(*py1); @@ -2207,21 +2058,21 @@ PHP_FUNCTION(imlib_polygon_new) Save an image to a file, at an optional quality level (1-100) for jpegs. For pngs, the value will be converted to a compression level (0-9) */ PHP_FUNCTION(imlib_save_image) { - zval **img, **name, **quality, **err; + zval *img, **err; + char* name; + int name_len; Imlib_Image im; Imlib_Load_Error im_err; - int argc, q; + int argc; + long q; char* filename; FILE* f; argc = ZEND_NUM_ARGS(); - if (argc < 2 || argc > 4 || zend_get_parameters_ex(argc, &img, &name, &err, &quality) == FAILURE) { - WRONG_PARAM_COUNT; - } + if (zend_parse_parameters(argc TSRMLS_CC, "rs|Zl", &img, &name, &name_len, &err, &q) == FAILURE) return; - ZEND_FETCH_RESOURCE(im, Imlib_Image, img, -1, "Imlib Image", le_imlib_img); + ZEND_FETCH_RESOURCE(im, Imlib_Image, &img, -1, "Imlib Image", le_imlib_img); - convert_to_string_ex(name); imlib_context_set_image(im); if (argc > 2) { @@ -2231,12 +2082,10 @@ PHP_FUNCTION(imlib_sa |
