summaryrefslogtreecommitdiff
path: root/ext/gd
diff options
context:
space:
mode:
authorPierre Joye <pierre.php@gmail.com>2013-06-20 22:19:33 +0200
committerPierre Joye <pierre.php@gmail.com>2013-06-20 22:19:33 +0200
commit07e52857b5f7a65c1552628e14a8a6aeeea24508 (patch)
tree1596ff1db3d7627a62164cf405c1d45109ea11c7 /ext/gd
parent0a6ec7a2c96589a6a7922137907173f3640c3e9c (diff)
downloadphp-git-07e52857b5f7a65c1552628e14a8a6aeeea24508.tar.gz
fix #65070, bgcolor does not use the same format as the input image with imagerotate
Diffstat (limited to 'ext/gd')
-rw-r--r--ext/gd/libgd/gd.c8
-rw-r--r--ext/gd/libgd/gd_interpolation.c39
2 files changed, 18 insertions, 29 deletions
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c
index 81eba52c82..7ed6617c57 100644
--- a/ext/gd/libgd/gd.c
+++ b/ext/gd/libgd/gd.c
@@ -3044,7 +3044,7 @@ int gdImagePaletteToTrueColor(gdImagePtr src)
for (x = 0; x < sx; x++) {
const unsigned char c = *(src_row + x);
if (c == src->transparent) {
- *(dst_row + x) = gdTrueColorAlpha(0, 0, 0, 127);;
+ *(dst_row + x) = gdTrueColorAlpha(0, 0, 0, 127);
} else {
*(dst_row + x) = gdTrueColorAlpha(src->red[c], src->green[c], src->blue[c], src->alpha[c]);
}
@@ -3061,6 +3061,12 @@ int gdImagePaletteToTrueColor(gdImagePtr src)
src->pixels = NULL;
src->alphaBlendingFlag = 0;
src->saveAlphaFlag = 1;
+
+ if (src->transparent >= 0) {
+ const unsigned char c = src->transparent;
+ src->transparent = gdTrueColorAlpha(src->red[c], src->green[c], src->blue[c], src->alpha[c]);
+ }
+
return 1;
clean_on_error:
diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c
index 9652a3a18a..e3247a78c1 100644
--- a/ext/gd/libgd/gd_interpolation.c
+++ b/ext/gd/libgd/gd_interpolation.c
@@ -1674,13 +1674,6 @@ gdImagePtr gdImageRotateNearestNeighbour(gdImagePtr src, const float degrees, co
unsigned int i;
gdImagePtr dst;
- /* impact perf a bit, but not that much. Implementation for palette
- images can be done at a later point.
- */
- if (src->trueColor == 0) {
- gdImagePaletteToTrueColor(src);
- }
-
dst = gdImageCreateTrueColor(new_width, new_height);
if (!dst) {
return NULL;
@@ -1736,12 +1729,6 @@ gdImagePtr gdImageRotateGeneric(gdImagePtr src, const float degrees, const int b
f_slop_x > f_slop_y ? gd_divfx(f_slop_y, f_slop_x) : gd_divfx(f_slop_x, f_slop_y)
: 0;
- /* impact perf a bit, but not that much. Implementation for palette
- images can be done at a later point.
- */
- if (src->trueColor == 0) {
- gdImagePaletteToTrueColor(src);
- }
dst = gdImageCreateTrueColor(new_width, new_height);
if (!dst) {
@@ -1796,13 +1783,6 @@ gdImagePtr gdImageRotateBilinear(gdImagePtr src, const float degrees, const int
unsigned int src_offset_x, src_offset_y;
gdImagePtr dst;
- /* impact perf a bit, but not that much. Implementation for palette
- images can be done at a later point.
- */
- if (src->trueColor == 0) {
- gdImagePaletteToTrueColor(src);
- }
-
dst = gdImageCreateTrueColor(new_width, new_height);
if (dst == NULL) {
return NULL;
@@ -1922,13 +1902,6 @@ gdImagePtr gdImageRotateBicubicFixed(gdImagePtr src, const float degrees, const
unsigned int i;
gdImagePtr dst;
- /* impact perf a bit, but not that much. Implementation for palette
- images can be done at a later point.
- */
- if (src->trueColor == 0) {
- gdImagePaletteToTrueColor(src);
- }
-
dst = gdImageCreateTrueColor(new_width, new_height);
if (dst == NULL) {
@@ -2177,11 +2150,21 @@ gdImagePtr gdImageRotateBicubicFixed(gdImagePtr src, const float degrees, const
gdImagePtr gdImageRotateInterpolated(const gdImagePtr src, const float angle, int bgcolor)
{
const int angle_rounded = (int)floor(angle * 100);
-
+
if (bgcolor < 0) {
return NULL;
}
+ /* impact perf a bit, but not that much. Implementation for palette
+ images can be done at a later point.
+ */
+ if (src->trueColor == 0) {
+ if (bgcolor >= 0) {
+ bgcolor = gdTrueColorAlpha(src->red[bgcolor], src->green[bgcolor], src->blue[bgcolor], src->alpha[bgcolor]);
+ }
+ gdImagePaletteToTrueColor(src);
+ }
+
/* no interpolation needed here */
switch (angle_rounded) {
case 9000: