mirror of
https://github.com/php/php-src.git
synced 2025-08-18 23:18:56 +02:00
- [DOC] add alpha support for imagefilter's IMG_FILTER_COLORIZE
This commit is contained in:
parent
336111e4e9
commit
fd15282c77
3 changed files with 16 additions and 11 deletions
1
NEWS
1
NEWS
|
@ -11,6 +11,7 @@ PHP NEWS
|
||||||
|
|
||||||
- Upgraded PCRE to version 7.3 (Nuno)
|
- Upgraded PCRE to version 7.3 (Nuno)
|
||||||
- Added optional parameter $provide_object to debug_backtrace(). (Sebastian)
|
- Added optional parameter $provide_object to debug_backtrace(). (Sebastian)
|
||||||
|
- Added alpha support for imagefilter's IMG_FILTER_COLORIZE
|
||||||
|
|
||||||
- Fixed Bug #42596 (session.save_path MODE option does not work). (Ilia)
|
- Fixed Bug #42596 (session.save_path MODE option does not work). (Ilia)
|
||||||
- Fixed bug #42590 (Make the engine recornize \v and \f escape sequences).
|
- Fixed bug #42590 (Make the engine recornize \v and \f escape sequences).
|
||||||
|
|
|
@ -5178,8 +5178,9 @@ static void php_image_filter_colorize(INTERNAL_FUNCTION_PARAMETERS)
|
||||||
zval *SIM;
|
zval *SIM;
|
||||||
gdImagePtr im_src;
|
gdImagePtr im_src;
|
||||||
long r,g,b,tmp;
|
long r,g,b,tmp;
|
||||||
|
long a = 0;
|
||||||
|
|
||||||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllll", &SIM, &tmp, &r, &g, &b) == FAILURE) {
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllll|l", &SIM, &tmp, &r, &g, &b, &a) == FAILURE) {
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5189,7 +5190,7 @@ static void php_image_filter_colorize(INTERNAL_FUNCTION_PARAMETERS)
|
||||||
RETURN_FALSE;
|
RETURN_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gdImageColor(im_src, (int) r, (int) g, (int) b) == 1) {
|
if (gdImageColor(im_src, (int) r, (int) g, (int) b, (int) a) == 1) {
|
||||||
RETURN_TRUE;
|
RETURN_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5298,7 +5299,7 @@ PHP_FUNCTION(imagefilter)
|
||||||
php_image_filter_smooth
|
php_image_filter_smooth
|
||||||
};
|
};
|
||||||
|
|
||||||
if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > 5) {
|
if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > 6) {
|
||||||
WRONG_PARAM_COUNT;
|
WRONG_PARAM_COUNT;
|
||||||
} else if (zend_parse_parameters(2 TSRMLS_CC, "rl", &tmp, &filtertype) == FAILURE) {
|
} else if (zend_parse_parameters(2 TSRMLS_CC, "rl", &tmp, &filtertype) == FAILURE) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -3807,15 +3807,14 @@ int gdImageContrast(gdImagePtr src, double contrast)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int gdImageColor(gdImagePtr src, int red, int green, int blue)
|
int gdImageColor(gdImagePtr src, const int red, const int green, const int blue, const int alpha)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
int r,g,b,a;
|
|
||||||
int new_pxl, pxl;
|
int new_pxl, pxl;
|
||||||
typedef int (*FuncPtr)(gdImagePtr, int, int);
|
typedef int (*FuncPtr)(gdImagePtr, int, int);
|
||||||
FuncPtr f;
|
FuncPtr f;
|
||||||
|
|
||||||
if (src==NULL || (red<-255||red>255) || (green<-255||green>255) || (blue<-255||blue>255)) {
|
if (src == NULL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3823,6 +3822,8 @@ int gdImageColor(gdImagePtr src, int red, int green, int blue)
|
||||||
|
|
||||||
for (y=0; y<src->sy; ++y) {
|
for (y=0; y<src->sy; ++y) {
|
||||||
for (x=0; x<src->sx; ++x) {
|
for (x=0; x<src->sx; ++x) {
|
||||||
|
int r,g,b,a;
|
||||||
|
|
||||||
pxl = f(src, x, y);
|
pxl = f(src, x, y);
|
||||||
r = gdImageRed(src, pxl);
|
r = gdImageRed(src, pxl);
|
||||||
g = gdImageGreen(src, pxl);
|
g = gdImageGreen(src, pxl);
|
||||||
|
@ -3832,14 +3833,16 @@ int gdImageColor(gdImagePtr src, int red, int green, int blue)
|
||||||
r = r + red;
|
r = r + red;
|
||||||
g = g + green;
|
g = g + green;
|
||||||
b = b + blue;
|
b = b + blue;
|
||||||
|
a = a + alpha;
|
||||||
|
|
||||||
r = (r > 255)? 255 : ((r < 0)? 0 : r);
|
r = (r > 255)? 255 : ((r < 0)? 0 : r);
|
||||||
g = (g > 255)? 255 : ((g < 0)? 0 : g);
|
g = (g > 255)? 255 : ((g < 0)? 0 : g);
|
||||||
b = (b > 255)? 255 : ((b < 0)? 0 : b);
|
b = (b > 255)? 255 : ((b < 0)? 0 : b);
|
||||||
|
a = (a > 127)? 127 : ((a < 0)? 0 : a);
|
||||||
|
|
||||||
new_pxl = gdImageColorAllocateAlpha(src, (int)r, (int)g, (int)b, a);
|
new_pxl = gdImageColorAllocateAlpha(src, r, g, b, a);
|
||||||
if (new_pxl == -1) {
|
if (new_pxl == -1) {
|
||||||
new_pxl = gdImageColorClosestAlpha(src, (int)r, (int)g, (int)b, a);
|
new_pxl = gdImageColorClosestAlpha(src, r, g, b, a);
|
||||||
}
|
}
|
||||||
gdImageSetPixel (src, x, y, new_pxl);
|
gdImageSetPixel (src, x, y, new_pxl);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue