derick Wed Jan 24 01:24:27 2001 EDT
Modified files:
/php4/ext/gdgd.c php_gd.h
Log:
- Commited a patch that adds support for converting Images to WBMP format.
(Thanx to Denis Gasparin [EMAIL PROTECTED])
@- Added support for converting images from JPG/PNG on the fly with the GD
@ extension, which is usefull for creating dynamic WAP-sites (Derick)
Index: php4/ext/gd/gd.c
diff -u php4/ext/gd/gd.c:1.106 php4/ext/gd/gd.c:1.107
--- php4/ext/gd/gd.c:1.106 Tue Jan 16 14:34:19 2001
+++ php4/ext/gd/gd.cWed Jan 24 01:24:26 2001
@@ -18,7 +18,7 @@
+--+
*/
-/* $Id: gd.c,v 1.106 2001/01/16 22:34:19 sniper Exp $ */
+/* $Id: gd.c,v 1.107 2001/01/24 09:24:26 derick Exp $ */
/* gd 1.2 is copyright 1994, 1995, Quest Protein Database Center,
Cold Spring Harbor Labs. */
@@ -176,6 +176,11 @@
PHP_FE(imagepstext,
NULL)
PHP_FE(imagepsbbox,
NULL)
PHP_FE(imagetypes,
NULL)
+
+ PHP_FE(jpeg2wbmp,
+ NULL)
+ PHP_FE(png2wbmp,
+ NULL)
+ PHP_FE(image2wbmp,
+ NULL)
+
{NULL, NULL, NULL}
};
@@ -788,6 +793,9 @@
int output = 1, q = -1;
GDLS_FETCH();
+ /* The quality parameter for Wbmp stands for the threshold
+ So the q variable */
+
if (argc 1 || argc 3 || zend_get_parameters_ex(argc, imgind, file,
quality) == FAILURE)
{
WRONG_PARAM_COUNT;
@@ -815,10 +823,20 @@
php_error(E_WARNING, "%s: unable to open '%s' for writing",
get_active_function_name(), fn);
RETURN_FALSE;
}
- if (image_type == PHP_GDIMG_TYPE_JPG) {
- (*func_p)(im, fp, q);
- } else {
- (*func_p)(im, fp);
+
+ switch(image_type) {
+ case PHP_GDIMG_TYPE_JPG:
+ (*func_p)(im, fp, q);
+ break;
+ case PHP_GDIMG_TYPE_WBM:
+ if(q0||q255) {
+ php_error(E_WARNING, "%s: invalid threshold
+value '%d'. It must be between 0 and 255",get_active_function_name(), q);
+ }
+ (*func_p)(im, q, fp);
+ break;
+ default:
+ (*func_p)(im, fp);
+ break;
}
fflush(fp);
fclose(fp);
@@ -834,11 +852,21 @@
}
output = php_header();
if (output) {
- if (image_type == PHP_GDIMG_TYPE_JPG) {
- (*func_p)(im, tmp, q);
- } else {
- (*func_p)(im, tmp);
+ switch(image_type) {
+ case PHP_GDIMG_TYPE_JPG:
+ (*func_p)(im, tmp, q);
+ break;
+ case PHP_GDIMG_TYPE_WBM:
+ if(q0||q255) {
+ php_error(E_WARNING, "%s: invalid
+threshold value '%d'. It must be between 0 and 255",get_active_function_name(), q);
+ }
+ (*func_p)(im, q, fp);
+ break;
+ default:
+ (*func_p)(im, fp);
+ break;
}
+
fseek(tmp, 0, SEEK_SET);
#if APACHE defined(CHARSET_EBCDIC)
SLS_FETCH();
@@ -2617,8 +2645,270 @@
}
/* }}} */
-#endif /* HAVE_LIBGD */
+/* {{{ proto int image2wbmp(int im [, string filename [, int threshold]])
+ Output WBMP image to browser or file */
+PHP_FUNCTION(image2wbmp)
+{
+#ifdef HAVE_GD_WBMP
+ _php_image_output (INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_WBM,
+"WBMP", _php_image_bw_convert);
+#else /* HAVE_GD_WBMP */
+ php_error(E_WARNING, "Image2Wbmp: No WBMP support in this PHP build");
+ RETURN_FALSE;
+#endif /* HAVE_GD_WBMP */
+}
+
+
+/* {{{ proto void jpeg2wbmp (string f_org, string f_dest, d_height, d_width)
+ Convert Jpeg Image to Wbmp image */
+PHP_FUNCTION(jpeg2wbmp)
+{
+#ifdef HAVE_GD_JPG
+ _php_image_convert