mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Switch to libgd anti-aliased drawing API
Instead of rolling our own in the bundled libgd, we use libgd's anti-aliased drawing API. This way imageantialias() is also available, when built against a system libgd.
This commit is contained in:
parent
1c74398520
commit
d0f14a4429
9 changed files with 16 additions and 42 deletions
|
@ -96,10 +96,11 @@ PHP 7.2 UPGRADE NOTES
|
|||
Samsung, DJI, Panasonic, Sony, Pentax, Minolta & Sigma/Foveon.
|
||||
|
||||
- GD:
|
||||
. Removed --enable-gd-native-ttf configuration option which was unused as
|
||||
of PHP 5.5.0 anyway.
|
||||
. imagegd() stores truecolor images as real truecolor images. Formerly, they
|
||||
have been converted to palette.
|
||||
. Removed --enable-gd-native-ttf configuration option which was unused as
|
||||
of PHP 5.5.0 anyway.
|
||||
. imagegd() stores truecolor images as real truecolor images. Formerly, they
|
||||
have been converted to palette.
|
||||
. imageantialias() is now also available if compiled with a system libgd.
|
||||
|
||||
- Mbstring
|
||||
. mb_check_encoding() accepts array parameter. Both key and value
|
||||
|
|
23
ext/gd/gd.c
23
ext/gd/gd.c
|
@ -786,12 +786,10 @@ ZEND_BEGIN_ARG_INFO(arginfo_imageflip, 0)
|
|||
ZEND_ARG_INFO(0, mode)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#ifdef HAVE_GD_BUNDLED
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_imageantialias, 0)
|
||||
ZEND_ARG_INFO(0, im)
|
||||
ZEND_ARG_INFO(0, on)
|
||||
ZEND_END_ARG_INFO()
|
||||
#endif
|
||||
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_imagecrop, 0)
|
||||
ZEND_ARG_INFO(0, im)
|
||||
|
@ -884,9 +882,7 @@ const zend_function_entry gd_functions[] = {
|
|||
PHP_FE(imagerotate, arginfo_imagerotate)
|
||||
PHP_FE(imageflip, arginfo_imageflip)
|
||||
|
||||
#ifdef HAVE_GD_BUNDLED
|
||||
PHP_FE(imageantialias, arginfo_imageantialias)
|
||||
#endif
|
||||
PHP_FE(imagecrop, arginfo_imagecrop)
|
||||
PHP_FE(imagecropauto, arginfo_imagecropauto)
|
||||
PHP_FE(imagescale, arginfo_imagescale)
|
||||
|
@ -3111,14 +3107,11 @@ PHP_FUNCTION(imageline)
|
|||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GD_BUNDLED
|
||||
if (im->antialias) {
|
||||
gdImageAALine(im, x1, y1, x2, y2, col);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
gdImageLine(im, x1, y1, x2, y2, col);
|
||||
if (im->AA) {
|
||||
gdImageSetAntiAliased(im, col);
|
||||
col = gdAntiAliased;
|
||||
}
|
||||
gdImageLine(im, x1, y1, x2, y2, col);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -3398,6 +3391,10 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
|
|||
}
|
||||
}
|
||||
|
||||
if (im->AA) {
|
||||
gdImageSetAntiAliased(im, col);
|
||||
col = gdAntiAliased;
|
||||
}
|
||||
if (filled) {
|
||||
gdImageFilledPolygon(im, points, npoints, col);
|
||||
} else {
|
||||
|
@ -4601,7 +4598,6 @@ PHP_FUNCTION(imageflip)
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
#ifdef HAVE_GD_BUNDLED
|
||||
/* {{{ proto bool imageantialias(resource im, bool on)
|
||||
Should antialiased functions used or not*/
|
||||
PHP_FUNCTION(imageantialias)
|
||||
|
@ -4617,11 +4613,10 @@ PHP_FUNCTION(imageantialias)
|
|||
if ((im = (gdImagePtr)zend_fetch_resource(Z_RES_P(IM), "Image", le_gd)) == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
gdImageAntialias(im, alias);
|
||||
gdImageSetAntiAliased(im, 0);
|
||||
RETURN_TRUE;
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
|
||||
/* {{{ proto void imagecrop(resource im, array rect)
|
||||
Crop an image using the given coordinates and size, x, y, width and height. */
|
||||
|
|
|
@ -2608,24 +2608,17 @@ void gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c)
|
|||
{
|
||||
int i;
|
||||
int lx, ly;
|
||||
typedef void (*image_line)(gdImagePtr im, int x1, int y1, int x2, int y2, int color);
|
||||
image_line draw_line;
|
||||
|
||||
if (n <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( im->antialias) {
|
||||
draw_line = gdImageAALine;
|
||||
} else {
|
||||
draw_line = gdImageLine;
|
||||
}
|
||||
lx = p->x;
|
||||
ly = p->y;
|
||||
draw_line(im, lx, ly, p[n - 1].x, p[n - 1].y, c);
|
||||
gdImageLine(im, lx, ly, p[n - 1].x, p[n - 1].y, c);
|
||||
for (i = 1; i < n; i++) {
|
||||
p++;
|
||||
draw_line(im, lx, ly, p->x, p->y, c);
|
||||
gdImageLine(im, lx, ly, p->x, p->y, c);
|
||||
lx = p->x;
|
||||
ly = p->y;
|
||||
}
|
||||
|
@ -2953,13 +2946,6 @@ void gdImageAlphaBlending (gdImagePtr im, int alphaBlendingArg)
|
|||
im->alphaBlendingFlag = alphaBlendingArg;
|
||||
}
|
||||
|
||||
void gdImageAntialias (gdImagePtr im, int antialias)
|
||||
{
|
||||
if (im->trueColor){
|
||||
im->antialias = antialias;
|
||||
}
|
||||
}
|
||||
|
||||
void gdImageSaveAlpha (gdImagePtr im, int saveAlphaArg)
|
||||
{
|
||||
im->saveAlphaFlag = saveAlphaArg;
|
||||
|
|
|
@ -222,8 +222,6 @@ typedef struct gdImageStruct {
|
|||
To do that, build your image as a truecolor image,
|
||||
then quantize down to 8 bits. */
|
||||
int alphaBlendingFlag;
|
||||
/* Should antialias functions be used */
|
||||
int antialias;
|
||||
/* Should the alpha channel of the image be saved? This affects
|
||||
PNG at the moment; other future formats may also
|
||||
have that capability. JPEG doesn't. */
|
||||
|
|
|
@ -123,9 +123,7 @@ PHP_FUNCTION(imagerotate);
|
|||
|
||||
PHP_FUNCTION(imageflip);
|
||||
|
||||
#ifdef HAVE_GD_BUNDLED
|
||||
PHP_FUNCTION(imageantialias);
|
||||
#endif
|
||||
|
||||
PHP_FUNCTION(imagecrop);
|
||||
PHP_FUNCTION(imagecropauto);
|
||||
|
|
|
@ -3,7 +3,6 @@ Bug #28147 (Crash with anti-aliased line)
|
|||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded('gd')) die("skip gd extension not available\n");
|
||||
if (!function_exists("imageantialias")) die("skip requires bundled GD library\n");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
|
|
@ -5,7 +5,6 @@ Bug #42434 (ImageLine w/ antialias = 1px shorter)
|
|||
if (!extension_loaded('gd')) {
|
||||
die('skip gd extension not available');
|
||||
}
|
||||
if (!GD_BUNDLED) die("skip requires bundled GD library\n");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
|
|
@ -6,7 +6,6 @@ Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com>
|
|||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("gd")) die("skip GD not present");
|
||||
if (!GD_BUNDLED) die("skip requires bundled GD library\n");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
|
|
@ -6,7 +6,6 @@ Guilherme Blanco <guilhermeblanco [at] hotmail [dot] com>
|
|||
--SKIPIF--
|
||||
<?php
|
||||
if (!extension_loaded("gd")) die("skip GD not present");
|
||||
if (!GD_BUNDLED) die("skip requires bundled GD library\n");
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue