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);
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);
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;
im->saveAlphaFlag = saveAlphaArg;
}
-static int gdLayerOverlay (int dst, int src)
+int gdLayerOverlay (int dst, int src)
{
int a1, a2;
a1 = gdAlphaMax - gdTrueColorGetAlpha(dst);
}
}
+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) {
#define gdEffectAlphaBlend 1
#define gdEffectNormal 2
#define gdEffectOverlay 3
+#define gdEffectMultiply 4
#define GD_TRUE 1
#define GD_FALSE 0
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