summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/gd/gd.c3
-rw-r--r--ext/gd/libgd/gd.c30
-rw-r--r--ext/gd/libgd/gd.h3
3 files changed, 32 insertions, 4 deletions
diff --git a/ext/gd/gd.c b/ext/gd/gd.c
index 6ff2a1c940..f8569779ba 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -1098,6 +1098,9 @@ PHP_MINIT_FUNCTION(gd)
REGISTER_LONG_CONSTANT("IMG_EFFECT_ALPHABLEND", gdEffectAlphaBlend, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IMG_EFFECT_NORMAL", gdEffectNormal, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IMG_EFFECT_OVERLAY", gdEffectOverlay, CONST_CS | CONST_PERSISTENT);
+#ifdef gdEffectMultiply
+ REGISTER_LONG_CONSTANT("IMG_EFFECT_MULTIPLY", gdEffectMultiply, CONST_CS | CONST_PERSISTENT);
+#endif
REGISTER_LONG_CONSTANT("IMG_CROP_DEFAULT", GD_CROP_DEFAULT, CONST_CS | CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("IMG_CROP_TRANSPARENT", GD_CROP_TRANSPARENT, CONST_CS | CONST_PERSISTENT);
diff --git a/ext/gd/libgd/gd.c b/ext/gd/libgd/gd.c
index 5c3593ed1b..afa8e287cc 100644
--- a/ext/gd/libgd/gd.c
+++ b/ext/gd/libgd/gd.c
@@ -93,7 +93,6 @@ extern int gdSinT[];
static void gdImageBrushApply(gdImagePtr im, int x, int y);
static void gdImageTileApply(gdImagePtr im, int x, int y);
-static int gdLayerOverlay(int dst, int src);
static int gdAlphaOverlayColor(int src, int dst, int max);
int gdImageGetTrueColorPixel(gdImagePtr im, int x, int y);
@@ -756,14 +755,15 @@ void gdImageSetPixel (gdImagePtr im, int x, int y, int color)
im->tpixels[y][x] = color;
break;
case gdEffectAlphaBlend:
- im->tpixels[y][x] = gdAlphaBlend(im->tpixels[y][x], color);
- break;
case gdEffectNormal:
im->tpixels[y][x] = gdAlphaBlend(im->tpixels[y][x], color);
break;
case gdEffectOverlay :
im->tpixels[y][x] = gdLayerOverlay(im->tpixels[y][x], color);
break;
+ case gdEffectMultiply :
+ im->tpixels[y][x] = gdLayerMultiply(im->tpixels[y][x], color);
+ break;
}
} else {
im->pixels[y][x] = color;
@@ -2951,7 +2951,7 @@ void gdImageSaveAlpha (gdImagePtr im, int saveAlphaArg)
im->saveAlphaFlag = saveAlphaArg;
}
-static int gdLayerOverlay (int dst, int src)
+int gdLayerOverlay (int dst, int src)
{
int a1, a2;
a1 = gdAlphaMax - gdTrueColorGetAlpha(dst);
@@ -2984,6 +2984,28 @@ static int gdAlphaOverlayColor (int src, int dst, int max )
}
}
+int gdLayerMultiply (int dst, int src)
+{
+ int a1, a2, r1, r2, g1, g2, b1, b2;
+ a1 = gdAlphaMax - gdTrueColorGetAlpha(src);
+ a2 = gdAlphaMax - gdTrueColorGetAlpha(dst);
+
+ r1 = gdRedMax - (a1 * (gdRedMax - gdTrueColorGetRed(src))) / gdAlphaMax;
+ r2 = gdRedMax - (a2 * (gdRedMax - gdTrueColorGetRed(dst))) / gdAlphaMax;
+ g1 = gdGreenMax - (a1 * (gdGreenMax - gdTrueColorGetGreen(src))) / gdAlphaMax;
+ g2 = gdGreenMax - (a2 * (gdGreenMax - gdTrueColorGetGreen(dst))) / gdAlphaMax;
+ b1 = gdBlueMax - (a1 * (gdBlueMax - gdTrueColorGetBlue(src))) / gdAlphaMax;
+ b2 = gdBlueMax - (a2 * (gdBlueMax - gdTrueColorGetBlue(dst))) / gdAlphaMax ;
+
+ a1 = gdAlphaMax - a1;
+ a2 = gdAlphaMax - a2;
+ return ( ((a1*a2/gdAlphaMax) << 24) +
+ ((r1*r2/gdRedMax) << 16) +
+ ((g1*g2/gdGreenMax) << 8) +
+ ((b1*b2/gdBlueMax))
+ );
+}
+
void gdImageSetClip (gdImagePtr im, int x1, int y1, int x2, int y2)
{
if (x1 < 0) {
diff --git a/ext/gd/libgd/gd.h b/ext/gd/libgd/gd.h
index 12832ded34..4b6f86e28c 100644
--- a/ext/gd/libgd/gd.h
+++ b/ext/gd/libgd/gd.h
@@ -92,6 +92,7 @@ void php_gd_error(const char *format, ...);
#define gdEffectAlphaBlend 1
#define gdEffectNormal 2
#define gdEffectOverlay 3
+#define gdEffectMultiply 4
#define GD_TRUE 1
#define GD_FALSE 0
@@ -104,6 +105,8 @@ void php_gd_error(const char *format, ...);
The resulting color is opaque. */
int gdAlphaBlend(int dest, int src);
+int gdLayerOverlay(int dst, int src);
+int gdLayerMultiply(int dest, int src);
/**
* Group: Transform