diff options
| author | Ondřej Surý <ondrej@sury.org> | 2013-07-22 08:22:22 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2013-07-22 08:22:22 +0200 |
| commit | d837b4550418036e76d6adb3c7dad94b1e3a5a6a (patch) | |
| tree | 1f1c808039c898d7d891975d3788531a2a6550f1 /ext/gd/libgd | |
| parent | 706ac6417162d94eb701952d40df136cd9528b56 (diff) | |
| download | php-d837b4550418036e76d6adb3c7dad94b1e3a5a6a.tar.gz | |
New upstream version 5.5.1+dfsgupstream/5.5.1+dfsg
Diffstat (limited to 'ext/gd/libgd')
| -rw-r--r-- | ext/gd/libgd/gd.c | 8 | ||||
| -rw-r--r-- | ext/gd/libgd/gd_crop.c | 2 | ||||
| -rw-r--r-- | ext/gd/libgd/gd_interpolation.c | 39 | ||||
| -rw-r--r-- | ext/gd/libgd/gd_webp.c | 33 | ||||
| -rw-r--r-- | ext/gd/libgd/webpimg.h | 2 |
5 files changed, 42 insertions, 42 deletions
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c index 81eba52c8..7ed6617c5 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_crop.c b/ext/gd/libgd/gd_crop.c index 9ce48273b..f0b888a4f 100644 --- a/ext/gd/libgd/gd_crop.c +++ b/ext/gd/libgd/gd_crop.c @@ -69,7 +69,7 @@ printf("rect->x: %i\nrect->y: %i\nrect->width: %i\nrect->height: %i\n", crop->x, if (src->trueColor) { unsigned int dst_y = 0; while (y < (crop->y + (crop->height - 1))) { - /* TODO: replace 4 w/byte per channel||pitch once avaiable */ + /* TODO: replace 4 w/byte per channel||pitch once available */ memcpy(dst->tpixels[dst_y++], src->tpixels[y++] + crop->x, crop->width * 4); } } else { diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c index 9652a3a18..e3247a78c 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: diff --git a/ext/gd/libgd/gd_webp.c b/ext/gd/libgd/gd_webp.c index 889f5f10a..bf9ac9dd0 100644 --- a/ext/gd/libgd/gd_webp.c +++ b/ext/gd/libgd/gd_webp.c @@ -58,11 +58,13 @@ gdImagePtr gdImageCreateFromWebpPtr (int size, void *data) return im; } +#define GD_WEBP_ALLOC_STEP (4*1024) + gdImagePtr gdImageCreateFromWebpCtx (gdIOCtx * infile) { int width, height, ret; - unsigned char *filedata; - unsigned char dummy[1024]; + unsigned char *filedata = NULL; + unsigned char *read, *temp; unsigned char *Y = NULL; unsigned char *U = NULL; unsigned char *V = NULL; @@ -70,16 +72,25 @@ gdImagePtr gdImageCreateFromWebpCtx (gdIOCtx * infile) gdImagePtr im; do { - n = gdGetBuf(dummy, 1024, infile); - size += n; - } while (n != EOF); + temp = gdRealloc(filedata, size+GD_WEBP_ALLOC_STEP); + if (temp) { + filedata = temp; + read = temp + size; + } else { + if (filedata) { + gdFree(filedata); + } + php_gd_error("WebP decode: realloc failed"); + return NULL; + } + + n = gdGetBuf(read, GD_WEBP_ALLOC_STEP, infile); + /* differs from upstream where gdGetBuf return 0 instead of EOF */ + if (n>0 && n!=EOF) { + size += n; + } + } while (n>0 && n!=EOF); - filedata = gdMalloc(size); - if (!filedata) { - php_gd_error("WebP decode: alloc failed"); - return NULL; - } - gdGetBuf(filedata, size, infile); ret = WebPDecode(filedata, size, &Y, &U, &V, &width, &height); gdFree(filedata); if (ret != webp_success) { diff --git a/ext/gd/libgd/webpimg.h b/ext/gd/libgd/webpimg.h index 8a05429a7..db23de5bb 100644 --- a/ext/gd/libgd/webpimg.h +++ b/ext/gd/libgd/webpimg.h @@ -84,7 +84,7 @@ WebPResult WebPDecode(const uint8* data, * height. * 6. y_stride: The width (in bytes) of one row of Y data. This may not * match width if there is end of row padding (e.g., for 32 - * bit row aligment). + * bit row alignment). * 7. QP: the quantization parameter. This parameter controls the * compression vs quality tradeoff. Use smaller numbers for better * quality (compression will be lesser) and vice versa. 20 is a |
