Skip to content

Instantly share code, notes, and snippets.

@pierrejoye
Created February 13, 2015 17:12
Show Gist options
  • Select an option

  • Save pierrejoye/dfdc7b045a83a3e48e9e to your computer and use it in GitHub Desktop.

Select an option

Save pierrejoye/dfdc7b045a83a3e48e9e to your computer and use it in GitHub Desktop.
diff --git a/Zend/zend_language_scanner.c b/Zend/zend_language_scanner.c
index 53d8eb2..be37e0c 100644
--- a/Zend/zend_language_scanner.c
+++ b/Zend/zend_language_scanner.c
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Sun Dec 22 13:03:33 2013 */
+/* Generated by re2c 0.13.5 */
#line 1 "Zend/zend_language_scanner.l"
/*
+----------------------------------------------------------------------+
diff --git a/Zend/zend_language_scanner_defs.h b/Zend/zend_language_scanner_defs.h
index 70ce8b8..5926e3c 100644
--- a/Zend/zend_language_scanner_defs.h
+++ b/Zend/zend_language_scanner_defs.h
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.13.5 on Sun Dec 22 13:03:33 2013 */
+/* Generated by re2c 0.13.5 */
#line 3 "Zend/zend_language_scanner_defs.h"
enum YYCONDTYPE {
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c
index d73f094..0c6199d 100644
--- a/ext/gd/libgd/gd.c
+++ b/ext/gd/libgd/gd.c
@@ -2149,6 +2149,94 @@ void gdImageFilledRectangle (gdImagePtr im, int x1, int y1, int x2, int y2, int
}
}
+
+gdImagePtr gdImageClone(gdImagePtr src) {
+ gdImagePtr dst;
+ register int i, x;
+
+ if (src->trueColor) {
+ dst = gdImageCreateTrueColor(src->sx , src->sy);
+ } else {
+ dst = gdImageCreate(src->sx , src->sy);
+ }
+
+ if (dst == NULL) {
+ return NULL;
+ }
+
+ if (src->trueColor == 0) {
+ dst->colorsTotal = src->colorsTotal;
+ for (i = 0; i < gdMaxColors; i++) {
+ dst->red[i] = src->red[i];
+ dst->green[i] = src->green[i];
+ dst->blue[i] = src->blue[i];
+ dst->alpha[i] = src->alpha[i];
+ dst->open[i] = src->open[i];
+ }
+ for (i = 0; i < src->sy; i++) {
+ for (x = 0; x < src->sx; x++) {
+ dst->pixels[i][x] = src->pixels[i][x];
+ }
+ }
+ } else {
+ for (i = 0; i < src->sy; i++) {
+ for (x = 0; x < src->sx; x++) {
+ dst->tpixels[i][x] = src->tpixels[i][x];
+ }
+ }
+ }
+
+ if (src->styleLength > 0) {
+ dst->styleLength = src->styleLength;
+ dst->stylePos = src->stylePos;
+ for (i = 0; i < src->styleLength; i++) {
+ dst->style[i] = src->style[i];
+ }
+ }
+
+ dst->interlace = src->interlace;
+
+ dst->alphaBlendingFlag = src->alphaBlendingFlag;
+ dst->saveAlphaFlag = src->saveAlphaFlag;
+ dst->AA = src->AA;
+ dst->AA_color = src->AA_color;
+ dst->AA_dont_blend = src->AA_dont_blend;
+
+ dst->cx1 = src->cx1;
+ dst->cy1 = src->cy1;
+ dst->cx2 = src->cx2;
+ dst->cy2 = src->cy2;
+
+ dst->interpolation_id = src->interpolation_id;
+ dst->interpolation = src->interpolation;
+
+ if (src->brush) {
+ dst->brush = gdImageClone(src->brush);
+ }
+
+ if (src->tile) {
+ dst->tile = gdImageClone(src->tile);
+ }
+
+ if (src->style) {
+ gdImageSetStyle(dst, src->style, src->styleLength);
+ }
+
+ for (i = 0; i < gdMaxColors; i++) {
+ dst->brushColorMap[i] = src->brushColorMap[i];
+ dst->tileColorMap[i] = src->tileColorMap[i];
+ }
+
+ if (src->polyAllocated > 0) {
+ dst->polyAllocated = src->polyAllocated;
+ for (i = 0; i < src->polyAllocated; i++) {
+ dst->polyInts[i] = src->polyInts[i];
+ }
+ }
+
+ return dst;
+}
+
void gdImageCopy (gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h)
{
int c;
diff --git a/ext/gd/libgd/gd.h b/ext/gd/libgd/gd.h
index 7251510..21cb5db 100644
--- a/ext/gd/libgd/gd.h
+++ b/ext/gd/libgd/gd.h
@@ -667,6 +667,7 @@ void gdImageArc(gdImagePtr im, int cx, int cy, int w, int h, int s, int e, int c
void gdImageFilledEllipse(gdImagePtr im, int cx, int cy, int w, int h, int color);
void gdImageFillToBorder(gdImagePtr im, int x, int y, int border, int color);
void gdImageFill(gdImagePtr im, int x, int y, int color);
+gdImagePtr gdImageClone(gdImagePtr src);
void gdImageCopy(gdImagePtr dst, gdImagePtr src, int dstX, int dstY, int srcX, int srcY, int w, int h);
void gdImageCopyMerge(gdImagePtr dst, gdImagePtr src, int dstX, int dstY,
int srcX, int srcY, int w, int h, int pct);
diff --git a/ext/gd/libgd/gd_interpolation.c b/ext/gd/libgd/gd_interpolation.c
index 65e2360..626b471 100644
--- a/ext/gd/libgd/gd_interpolation.c
+++ b/ext/gd/libgd/gd_interpolation.c
@@ -1060,6 +1060,11 @@ gdImagePtr gdImageScaleTwoPass(const gdImagePtr src, const unsigned int src_widt
{
gdImagePtr tmp_im;
gdImagePtr dst;
+#
+ /* First, handle the trivial case. */
+ if (src_width == new_width && src_height == new_height) {
+ return gdImageClone(src);
+ }
tmp_im = gdImageCreateTrueColor(new_width, src_height);
if (tmp_im == NULL) {
@@ -1653,7 +1658,18 @@ gdImagePtr gdImageScale(const gdImagePtr src, const unsigned int new_width, cons
if (src->interpolation == NULL) {
return NULL;
}
- im_scaled = gdImageScaleTwoPass(src, src->sx, src->sy, new_width, new_height);
+
+ /* Convert to truecolor if it isn't; this code requires it. */
+ if (!src->trueColor) {
+ gdImagePtr src_tc = gdImageClone(src);
+ if (src_tc == NULL) {
+ return NULL;
+ }
+ gdImagePaletteToTrueColor(src_tc);
+ im_scaled = gdImageScaleTwoPass(src_tc, src_tc->sx, src_tc->sy, new_width, new_height);
+ } else {
+ im_scaled = gdImageScaleTwoPass(src, src->sx, src->sy, new_width, new_height);
+ }
break;
}
return im_scaled;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment