}
/* }}} */
-#define CHECK_RGB_RANGE(component, name) \
- if (component < 0 || component > 255) { \
+#define CHECK_RGBA_RANGE(component, name) \
+ if (component < 0 || component > gd##name##Max) { \
php_error_docref(NULL, E_WARNING, #name " component is out of range"); \
RETURN_FALSE; \
}
RETURN_FALSE;
}
- CHECK_RGB_RANGE(red, Red);
- CHECK_RGB_RANGE(green, Green);
- CHECK_RGB_RANGE(blue, Blue);
+ CHECK_RGBA_RANGE(red, Red);
+ CHECK_RGBA_RANGE(green, Green);
+ CHECK_RGBA_RANGE(blue, Blue);
+ CHECK_RGBA_RANGE(alpha, Alpha);
ct = gdImageColorAllocateAlpha(im, red, green, blue, alpha);
if (ct < 0) {
RETURN_FALSE;
}
+ CHECK_RGBA_RANGE(red, Red);
+ CHECK_RGBA_RANGE(green, Green);
+ CHECK_RGBA_RANGE(blue, Blue);
+ CHECK_RGBA_RANGE(alpha, Alpha);
+
RETURN_LONG(gdImageColorResolveAlpha(im, red, green, blue, alpha));
}
/* }}} */
RETURN_FALSE;
}
+ CHECK_RGBA_RANGE(red, Red);
+ CHECK_RGBA_RANGE(green, Green);
+ CHECK_RGBA_RANGE(blue, Blue);
+ CHECK_RGBA_RANGE(alpha, Alpha);
+
RETURN_LONG(gdImageColorClosestAlpha(im, red, green, blue, alpha));
}
/* }}} */
RETURN_FALSE;
}
+ CHECK_RGBA_RANGE(red, Red);
+ CHECK_RGBA_RANGE(green, Green);
+ CHECK_RGBA_RANGE(blue, Blue);
+ CHECK_RGBA_RANGE(alpha, Alpha);
+
RETURN_LONG(gdImageColorExactAlpha(im, red, green, blue, alpha));
}
/* }}} */
RETURN_FALSE;
}
- CHECK_RGB_RANGE(red, Red);
- CHECK_RGB_RANGE(green, Green);
- CHECK_RGB_RANGE(blue, Blue);
+ CHECK_RGBA_RANGE(red, Red);
+ CHECK_RGBA_RANGE(green, Green);
+ CHECK_RGBA_RANGE(blue, Blue);
ct = gdImageColorAllocate(im, red, green, blue);
if (ct < 0) {
RETURN_FALSE;
}
+ CHECK_RGBA_RANGE(red, Red);
+ CHECK_RGBA_RANGE(green, Green);
+ CHECK_RGBA_RANGE(blue, Blue);
+
RETURN_LONG(gdImageColorClosest(im, red, green, blue));
}
/* }}} */
RETURN_FALSE;
}
+ CHECK_RGBA_RANGE(red, Red);
+ CHECK_RGBA_RANGE(green, Green);
+ CHECK_RGBA_RANGE(blue, Blue);
+
RETURN_LONG(gdImageColorClosestHWB(im, red, green, blue));
}
/* }}} */
RETURN_FALSE;
}
+ CHECK_RGBA_RANGE(red, Red);
+ CHECK_RGBA_RANGE(green, Green);
+ CHECK_RGBA_RANGE(blue, Blue);
+
RETURN_LONG(gdImageColorResolve(im, red, green, blue));
}
/* }}} */
RETURN_FALSE;
}
+ CHECK_RGBA_RANGE(red, Red);
+ CHECK_RGBA_RANGE(green, Green);
+ CHECK_RGBA_RANGE(blue, Blue);
+
RETURN_LONG(gdImageColorExact(im, red, green, blue));
}
/* }}} */
RETURN_FALSE;
}
+ CHECK_RGBA_RANGE(red, Red);
+ CHECK_RGBA_RANGE(green, Green);
+ CHECK_RGBA_RANGE(blue, Blue);
+ CHECK_RGBA_RANGE(alpha, Alpha);
+
col = color;
if (col >= 0 && col < gdImageColorsTotal(im)) {