- GD:
. Fixed bug #55005 (imagepolygon num_points requirement). (cmb)
. Replaced gd resources with objects. (Mark Randall)
+ . Made the $num_points parameter of php_imagepolygon optional. (cmb)
. Removed deprecated image2wbmp(). (cmb)
. Removed deprecated png2wbmp() and jpeg2wbmp(). (cmb)
9. Other Changes to Extensions
========================================
+- GD:
+ . The $num_points parameter of imagepolygon(), imageopenpolygon() and
+ imagefilledpolygon() is now optional, i.e. these functions may be called
+ with either 3 or 4 arguments. If the arguments is omitted, it is calculated
+ as count($points)/2.
+
========================================
10. New Global Constants
========================================
gdPointPtr points;
int npoints, col, nelem, i;
- if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oall", &IM, gd_image_ce, &POINTS, &NPOINTS, &COL) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS(), "Oal|l", &IM, gd_image_ce, &POINTS, &NPOINTS, &COL) == FAILURE) {
return;
}
+ if (ZEND_NUM_ARGS() == 3) {
+ COL = NPOINTS;
+ NPOINTS = zend_hash_num_elements(Z_ARRVAL_P(POINTS));
+ if (NPOINTS % 2 != 0) {
+ zend_value_error("Points array must have an even number of elements");
+ return;
+ }
+ NPOINTS /= 2;
+ }
im = php_gd_libgdimageptr_from_zval_p(IM);
function imageinterlace(GdImage $im, int $interlace = UNKNOWN): ?int {}
-function imagepolygon(GdImage $im, array $points, int $num_pos, int $col): bool {}
+function imagepolygon(GdImage $im, array $points, int $num_points_or_col, int $col = UNKNOWN): bool {}
-function imageopenpolygon(GdImage $im, array $points, int $num_pos, int $col): bool {}
+function imageopenpolygon(GdImage $im, array $points, int $num_points_or_col, int $col = UNKNOWN): bool {}
-function imagefilledpolygon(GdImage $im, array $points, int $num_pos, int $col): bool {}
+function imagefilledpolygon(GdImage $im, array $points, int $num_points_or_col, int $col = UNKNOWN): bool {}
function imagefontwidth(int $font): int {}
ZEND_ARG_TYPE_INFO(0, interlace, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagepolygon, 0, 4, _IS_BOOL, 0)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_imagepolygon, 0, 3, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, im, GdImage, 0)
ZEND_ARG_TYPE_INFO(0, points, IS_ARRAY, 0)
- ZEND_ARG_TYPE_INFO(0, num_pos, IS_LONG, 0)
+ ZEND_ARG_TYPE_INFO(0, num_points_or_col, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, col, IS_LONG, 0)
ZEND_END_ARG_INFO()
$sin_t = sin(deg2rad($delta_t));
for ($angle = 0.0, $i = 0; $angle < 360.0; $angle += $delta_t, $i++) {
$bbox = imagettftext($g, 24, $angle, 400+$x, 400+$y, $black, $font, 'ABCDEF');
- imagepolygon($g, $bbox, 4, $red);
+ imagepolygon($g, $bbox, $red);
printf("%2d: ", $i);
for ($j = 0; $j < 8; $j++) {
if ($bbox[$j] >= $exp[$i][$j] - 1 && $bbox[$j] <= $exp[$i][$j] + 1) {
}
// draw bounding box:
- imagepolygon($g, $bboxDrawn, 4, $red);
+ imagepolygon($g, $bboxDrawn, $red);
// draw baseline:
$width = sqrt(pow($bboxDrawn[2] - $bboxDrawn[0], 2) + pow($bboxDrawn[3] - $bboxDrawn[1], 2));
fn () => imagepolygon($g, array(200,10, 200,100, 280,100), 2, $fgnd)\r
);\r
?>\r
---EXPECT--\r
+--EXPECTF--\r
!! [ValueError] Polygon must have at least 3 points\r
!! [ValueError] Polygon must have at least 3 points\r
100, 200,
100, 300
);
-imagefilledpolygon($im, $points, 3, 0xFFFF00);
+imagefilledpolygon($im, $points, 0xFFFF00);
$points = array(
300, 200,
400, 200,
500, 200
);
-imagefilledpolygon($im, $points, 3, 0xFFFF00);
+imagefilledpolygon($im, $points, 0xFFFF00);
$ex = imagecreatefrompng(__DIR__ . '/bug64641.png');
if (($diss = calc_image_dissimilarity($ex, $im)) < 1e-5) {
$col_poly = imagecolorallocate($image, 0, 255, 0);
// draw the polygon
-imagefilledpolygon($image, $points, count($points)/2, $col_poly);
+imagefilledpolygon($image, $points, $col_poly);
// output the picture to a file
imagepng($image, $dest);
$blue = imagecolorallocate($im, 0, 0, 255);
imagefilledrectangle($im, 0,0, 99,99, $white);
-imageopenpolygon($im, [10,10, 49,89, 89,10], 3, $black);
-imageopenpolygon($im, [10,89, 35,10, 60,89, 85,10], 4, $red);
-imageopenpolygon($im, [10,49, 30,89, 50,10, 70,89, 90,10], 5, $green);
-imageopenpolygon($im, [10,50, 25,10, 40,89, 55,10, 80,89, 90,50], 6, $blue);
+imageopenpolygon($im, [10,10, 49,89, 89,10], $black);
+imageopenpolygon($im, [10,89, 35,10, 60,89, 85,10], $red);
+imageopenpolygon($im, [10,49, 30,89, 50,10, 70,89, 90,10], $green);
+imageopenpolygon($im, [10,50, 25,10, 40,89, 55,10, 80,89, 90,50], $blue);
test_image_equals_file(__DIR__ . DIRECTORY_SEPARATOR . 'imageopenpolygon.png', $im);
?>
imagefilledrectangle($im, 0,0, 99,99, $white);
imageantialias($im, true);
-imagepolygon($im, [10,10, 49,89, 89,49], 3, $black);
+imagepolygon($im, [10,10, 49,89, 89,49], $black);
test_image_equals_file(__DIR__ . DIRECTORY_SEPARATOR . 'imagepolygon_aa.png', $im);
?>
100, 200,
300, 200
),
- 3,
$col_poly);
// output the picture to a file
$x+$d, ($top+$bot)/2,
$x, $bot
);
-imagefilledpolygon($im, $points, 5, $yellow);
+imagefilledpolygon($im, $points, $yellow);
// left-facing M not on baseline
$top = 40;
$left, $bot,
($left+$right)/2, ($top+$bot)/2
);
-imagefilledpolygon($im, $points, 5, $purple);
+imagefilledpolygon($im, $points, $purple);
// left-facing M on baseline
$top = 240;
$left, $bot,
($left+$right)/2, ($top+$bot)/2
);
-imagefilledpolygon($im, $points, 5, $magenta);
+imagefilledpolygon($im, $points, $magenta);
// left-facing M on ceiling
$top = -15;
$left, $bot,
($left+$right)/2, ($top+$bot)/2
);
-imagefilledpolygon($im, $points, 5, $blue);
+imagefilledpolygon($im, $points, $blue);
$d = 30;
$x = 150;
$y = 150;
$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
-imagefilledpolygon($im, $diamond, 4, $green);
+imagefilledpolygon($im, $diamond, $green);
$x = 180;
$y = 225;
$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
-imagefilledpolygon($im, $diamond, 4, $red);
+imagefilledpolygon($im, $diamond, $red);
$x = 225;
$y = 255;
$diamond = array($x-$d, $y, $x, $y+$d, $x+$d, $y, $x, $y-$d);
-imagefilledpolygon($im, $diamond, 4, $cyan);
+imagefilledpolygon($im, $diamond, $cyan);
// M (bridge) not touching bottom boundary
$top = 100;
$x+$d, ($top+$bot)/2,
$x, $bot
);
-imagefilledpolygon($im, $points, 5, $black);
+imagefilledpolygon($im, $points, $black);
include_once __DIR__ . '/func.inc';
test_image_equals_file(__DIR__ . '/libgd00100.png', $im);