]> granicus.if.org Git - php/commitdiff
- add wbmp read/write tests
authorPierre Joye <pajoye@php.net>
Wed, 14 Dec 2005 22:33:34 +0000 (22:33 +0000)
committerPierre Joye <pajoye@php.net>
Wed, 14 Dec 2005 22:33:34 +0000 (22:33 +0000)
- remove HAVE_GD_WBMP, always available

ext/gd/config.m4
ext/gd/config.w32
ext/gd/gd.c
ext/gd/gd.dsp
ext/gd/tests/createfromwbmp.phpt [new file with mode: 0644]
ext/gd/tests/imagewbmp.phpt [new file with mode: 0644]
ext/gd/tests/src.wbmp [new file with mode: 0644]

index 879a850782f1a868bf89e3d5d8d415f54b4932de..3228655a41a34748d09be4bb73205595b7f63bf6 100644 (file)
@@ -327,7 +327,6 @@ if test "$PHP_GD" != "no"; then
 
 dnl These defines are always available
 dnl FIXME: Cleanup the sources so that these are not needed!
-  AC_DEFINE(HAVE_GD_WBMP,             1, [ ])
   AC_DEFINE(HAVE_LIBGD13,             1, [ ])
   AC_DEFINE(HAVE_LIBGD15,             1, [ ])
   AC_DEFINE(HAVE_LIBGD20,             1, [ ])
index bb3c0b008fd5af30f1b96f54c5ff6abb89e33dbd..b46c9c0b10b941bb7137b5348853a748dfadb9ee 100644 (file)
@@ -43,7 +43,6 @@ if (PHP_GD != "no") {
 /D HAVE_GD_PNG  \
 /D HAVE_GD_STRINGFTEX=1  \
 /D HAVE_GD_STRINGTTF=1  \
-/D HAVE_GD_WBMP  \
 /D HAVE_GD_XBM  \
 /D HAVE_LIBFREETYPE=1  \
 /D HAVE_LIBGD13=1  \
index 84c477e5f29ca92588abb416cb8a370c1ed6880f..b8cc209020ceed0cf4da3ab565ca5aa12354967d 100644 (file)
@@ -64,9 +64,8 @@ static void php_free_ps_enc(zend_rsrc_list_entry *rsrc TSRMLS_DC);
 #include <gdfontmb.h> /* 3 Medium bold font */
 #include <gdfontl.h>  /* 4 Large font */
 #include <gdfontg.h>  /* 5 Giant font */
-#ifdef HAVE_GD_WBMP
 #include "libgd/wbmp.h"
-#endif
+
 #ifdef ENABLE_GD_TTF
 # ifdef HAVE_LIBFREETYPE
 #  include <ft2build.h>
@@ -229,9 +228,7 @@ zend_function_entry gd_functions[] = {
 #ifdef HAVE_GD_JPG
        PHP_FE(imagecreatefromjpeg,                                             NULL)
 #endif
-#ifdef HAVE_GD_WBMP
        PHP_FE(imagecreatefromwbmp,                                             NULL)
-#endif
 #ifdef HAVE_GD_XBM
        PHP_FE(imagecreatefromxbm,                                              NULL)
 #endif
@@ -250,9 +247,7 @@ zend_function_entry gd_functions[] = {
 #ifdef HAVE_GD_JPG
        PHP_FE(imagejpeg,                                                               NULL)
 #endif
-#ifdef HAVE_GD_WBMP
        PHP_FE(imagewbmp,                               NULL)
-#endif
        PHP_FE(imagegd,                                                                 NULL)
        PHP_FE(imagegd2,                                                                NULL)
 
@@ -299,15 +294,13 @@ zend_function_entry gd_functions[] = {
 #endif
        PHP_FE(imagetypes,                                                              NULL)
 
-#if defined(HAVE_GD_JPG) && defined(HAVE_GD_WBMP)
+#if defined(HAVE_GD_JPG)
        PHP_FE(jpeg2wbmp,                                                               NULL)
 #endif
-#if defined(HAVE_GD_PNG) && defined(HAVE_GD_WBMP)
+#if defined(HAVE_GD_PNG)
        PHP_FE(png2wbmp,                                                                NULL)
 #endif
-#ifdef HAVE_GD_WBMP
        PHP_FE(image2wbmp,                                                              NULL)
-#endif
 #if HAVE_GD_BUNDLED
        PHP_FE(imagelayereffect,                                                NULL)
        PHP_FE(imagecolormatch,                                                 NULL)
@@ -512,9 +505,7 @@ PHP_MINFO_FUNCTION(gd)
 #ifdef HAVE_GD_PNG
        php_info_print_table_row(2, "PNG Support", "enabled");
 #endif
-#ifdef HAVE_GD_WBMP
        php_info_print_table_row(2, "WBMP Support", "enabled");
-#endif
 #if defined(HAVE_GD_XPM) && defined(HAVE_GD_BUNDLED)
        php_info_print_table_row(2, "XPM Support", "enabled");
 #endif
@@ -577,11 +568,7 @@ PHP_FUNCTION(gd_info)
 #else
        add_assoc_bool(return_value, "PNG Support", 0);
 #endif
-#ifdef HAVE_GD_WBMP
        add_assoc_bool(return_value, "WBMP Support", 1);
-#else
-       add_assoc_bool(return_value, "WBMP Support", 0);
-#endif
 #if defined(HAVE_GD_XPM) && defined(HAVE_GD_BUNDLED)
        add_assoc_bool(return_value, "XPM Support", 1);
 #else
@@ -1293,9 +1280,7 @@ PHP_FUNCTION(imagetypes)
 #ifdef HAVE_GD_PNG
        ret |= 4;
 #endif
-#ifdef HAVE_GD_WBMP
        ret |= 8;
-#endif
 #if defined(HAVE_GD_XPM) && defined(HAVE_GD_BUNDLED)
        ret |= 16;
 #endif
@@ -1332,7 +1317,6 @@ static int _php_image_type (char data[8])
        } else if (!memcmp(data, php_sig_gif, 3)) {
                return PHP_GDIMG_TYPE_GIF;
        }
-#ifdef HAVE_GD_WBMP
        else {
                gdIOCtx *io_ctx;
                io_ctx = gdNewDynamicCtxEx(8, data, 0);
@@ -1353,7 +1337,6 @@ static int _php_image_type (char data[8])
                        }
                }
        }
-#endif
        return -1;
 #endif
 }
@@ -1436,12 +1419,7 @@ PHP_FUNCTION(imagecreatefromstring)
                        break;
 
                case PHP_GDIMG_TYPE_WBM:
-#ifdef HAVE_GD_WBMP
                        im = _php_image_create_from_string(data, "WBMP", gdImageCreateFromWBMPCtx TSRMLS_CC);
-#else
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "No WBMP support in this PHP build");
-                       RETURN_FALSE;
-#endif
                        break;
 
                case PHP_GDIMG_TYPE_GD2:
@@ -1625,7 +1603,6 @@ PHP_FUNCTION(imagecreatefromxpm)
 /* }}} */
 #endif
 
-#ifdef HAVE_GD_WBMP
 /* {{{ proto resource imagecreatefromwbmp(string filename)
    Create a new image from WBMP file or URL */
 PHP_FUNCTION(imagecreatefromwbmp)
@@ -1633,7 +1610,6 @@ PHP_FUNCTION(imagecreatefromwbmp)
        _php_image_create_from(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_WBM, "WBMP", gdImageCreateFromWBMP, gdImageCreateFromWBMPCtx);
 }
 /* }}} */
-#endif /* HAVE_GD_WBMP */
 
 /* {{{ proto resource imagecreatefromgd(string filename)
    Create a new image from GD file or URL */
@@ -1703,7 +1679,6 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
                }
 
                switch (image_type) {
-#ifdef HAVE_GD_WBMP
                        case PHP_GDIMG_CONVERT_WBM:
                                if (q == -1) {
                                        q = 0;
@@ -1713,7 +1688,6 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
                                }
                                gdImageWBMP(im, q, fp);
                                break;
-#endif
                        case PHP_GDIMG_TYPE_JPG:
                                (*func_p)(im, fp, q);
                                break;
@@ -1753,7 +1727,6 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
                }
 
                switch (image_type) {
-#ifdef HAVE_GD_WBMP
                        case PHP_GDIMG_CONVERT_WBM:
                                if (q == -1) {
                                        q = 0;
@@ -1763,7 +1736,6 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
                                }
                                gdImageWBMP(im, q, tmp);
                                break;
-#endif
                        case PHP_GDIMG_TYPE_JPG:
                                (*func_p)(im, tmp, q);
                                break;
@@ -1854,7 +1826,6 @@ PHP_FUNCTION(imagejpeg)
 /* }}} */
 #endif /* HAVE_GD_JPG */
 
-#ifdef HAVE_GD_WBMP
 /* {{{ proto bool imagewbmp(resource im [, string filename, [, int foreground]])
    Output WBMP image to browser or file */
 PHP_FUNCTION(imagewbmp)
@@ -1866,7 +1837,6 @@ PHP_FUNCTION(imagewbmp)
 #endif
 }
 /* }}} */
-#endif /* HAVE_GD_WBMP */
 
 /* {{{ proto bool imagegd(resource im [, string filename])
    Output GD image to browser or file */
@@ -3649,7 +3619,6 @@ PHP_FUNCTION(imagepsbbox)
 /* }}} */
 #endif
 
-#ifdef HAVE_GD_WBMP
 /* {{{ proto bool image2wbmp(resource im [, string filename [, int threshold]])
    Output WBMP image to browser or file */
 PHP_FUNCTION(image2wbmp)
@@ -3657,9 +3626,8 @@ PHP_FUNCTION(image2wbmp)
        _php_image_output(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_CONVERT_WBM, "WBMP", _php_image_bw_convert);
 }
 /* }}} */
-#endif /* HAVE_GD_WBMP */
 
-#if defined(HAVE_GD_JPG) && defined(HAVE_GD_WBMP)
+#if defined(HAVE_GD_JPG)
 /* {{{ proto bool jpeg2wbmp (string f_org, string f_dest, int d_height, int d_width, int threshold)
    Convert JPEG image to WBMP image */
 PHP_FUNCTION(jpeg2wbmp)
@@ -3669,7 +3637,7 @@ PHP_FUNCTION(jpeg2wbmp)
 /* }}} */
 #endif
 
-#if defined(HAVE_GD_PNG) && defined(HAVE_GD_WBMP)
+#if defined(HAVE_GD_PNG)
 /* {{{ proto bool png2wbmp (string f_org, string f_dest, int d_height, int d_width, int threshold)
    Convert PNG image to WBMP image */
 PHP_FUNCTION(png2wbmp)
@@ -3679,7 +3647,6 @@ PHP_FUNCTION(png2wbmp)
 /* }}} */
 #endif
 
-#ifdef HAVE_GD_WBMP
 /* {{{ _php_image_bw_convert
  * It converts a gd Image to bw using a threshold value */
 static void _php_image_bw_convert(gdImagePtr im_org, gdIOCtx *out, int threshold)
@@ -3920,7 +3887,6 @@ static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type )
        RETURN_TRUE;
 }
 /* }}} */
-#endif /* HAVE_GD_WBMP */
 
 #endif /* HAVE_LIBGD */
 
index a1f87856b222c88ace04c51b0adf845bd5358603..7d0c448062174124df49d35cd0b64d28e4ffce69 100644 (file)
@@ -43,8 +43,8 @@ RSC=rc.exe
 # PROP Intermediate_Dir "Release_TS"\r
 # PROP Ignore_Export_Lib 0\r
 # PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GD_GIF_CREATE=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D "HAVE_GD_WBMP" /D "HAVE_GD_XBM" /D HAVE_LIBGD13=1 /D HAVE_LIBGD=1 /D HAVE_LIBGD15=1 /D HAVE_LIBGD204=1 /FR /YX /FD /c\r
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /I "libgd" /D ZEND_DEBUG=0 /D HAVE_LIBGD15=1 /D HAVE_LIBGD204=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GD_GIF_CREATE=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D "HAVE_GD_WBMP" /D "HAVE_GD_XBM" /D HAVE_LIBGD=1 /D HAVE_LIBGD13=1 /D HAVE_LIBGD20=1 /D "USE_GD_IOCTX" /D HAVE_LIBFREETYPE=1 /D "USE_GD_IMGSTRTTF" /D HAVE_GD_STRINGTTF=1 /D HAVE_GD_BUNDLED=1 /D "MSWIN32" /D "HAVE_LIBPNG" /D "HAVE_LIBJPEG" /D HAVE_GD_STRINGFTEX=1 /D HAVE_GD_IMAGESETBRUSH=1 /D HAVE_GD_IMAGESETTILE=1 /FR /FD /c\r
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /D ZEND_DEBUG=0 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GD_GIF_CREATE=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D "HAVE_GD_XBM" /D HAVE_LIBGD13=1 /D HAVE_LIBGD=1 /D HAVE_LIBGD15=1 /D HAVE_LIBGD204=1 /FR /YX /FD /c\r
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /I "libgd" /D ZEND_DEBUG=0 /D HAVE_LIBGD15=1 /D HAVE_LIBGD204=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GD_GIF_CREATE=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D "HAVE_GD_XBM" /D HAVE_LIBGD=1 /D HAVE_LIBGD13=1 /D HAVE_LIBGD20=1 /D "USE_GD_IOCTX" /D HAVE_LIBFREETYPE=1 /D "USE_GD_IMGSTRTTF" /D HAVE_GD_STRINGTTF=1 /D HAVE_GD_BUNDLED=1 /D "MSWIN32" /D "HAVE_LIBPNG" /D "HAVE_LIBJPEG" /D HAVE_GD_STRINGFTEX=1 /D HAVE_GD_IMAGESETBRUSH=1 /D HAVE_GD_IMAGESETTILE=1 /FR /FD /c\r
 # SUBTRACT CPP /YX\r
 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
@@ -73,8 +73,8 @@ LINK32=link.exe
 # PROP Intermediate_Dir "Debug_TS"\r
 # PROP Ignore_Export_Lib 0\r
 # PROP Target_Dir ""\r
-# ADD BASE CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GD_GIF_CREATE=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D "HAVE_GD_WBMP" /D HAVE_LIBGD13=1 /D HAVE_LIBGD=1 /D HAVE_LIBGD15=1 /D HAVE_LIBGD204=1 /FR /YX /FD /c\r
-# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /I "libgd" /D ZEND_DEBUG=1 /D "HAVE_LIBGD15" /D HAVE_LIBGD204=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GD_GIF_CREATE=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D "HAVE_GD_WBMP" /D HAVE_LIBGD=1 /D HAVE_LIBGD13=1 /D HAVE_LIBGD20=1 /D "USE_GD_IOCTX" /D HAVE_LIBFREETYPE=1 /D "USE_GD_IMGSTRTTF" /D HAVE_GD_STRINGTTF=1 /D HAVE_GD_BUNDLED=1 /D "MSWIN32" /D "HAVE_LIBPNG" /D "HAVE_LIBJPEG" /D HAVE_GD_STRINGFTEX=1 /D HAVE_GD_IMAGESETBRUSH=1 /D HAVE_GD_IMAGESETTILE=1 /FR /FD /c\r
+# ADD BASE CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /D ZEND_DEBUG=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GD_GIF_CREATE=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D HAVE_LIBGD13=1 /D HAVE_LIBGD=1 /D HAVE_LIBGD15=1 /D HAVE_LIBGD204=1 /FR /YX /FD /c\r
+# ADD CPP /nologo /MDd /W3 /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\..\zlib" /I "..\..\TSRM" /I "libgd" /D ZEND_DEBUG=1 /D "HAVE_LIBGD15" /D HAVE_LIBGD204=1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "COMPILE_DL_GD" /D ZTS=1 /D "ZEND_WIN32" /D "PHP_WIN32" /D HAVE_GD_GIF_READ=1 /D HAVE_GD_GIF_CREATE=1 /D HAVE_GDIMAGECOLORRESOLVE=1 /D "HAVE_GD_PNG" /D "HAVE_GD_JPG" /D HAVE_LIBGD=1 /D HAVE_LIBGD13=1 /D HAVE_LIBGD20=1 /D "USE_GD_IOCTX" /D HAVE_LIBFREETYPE=1 /D "USE_GD_IMGSTRTTF" /D HAVE_GD_STRINGTTF=1 /D HAVE_GD_BUNDLED=1 /D "MSWIN32" /D "HAVE_LIBPNG" /D "HAVE_LIBJPEG" /D HAVE_GD_STRINGFTEX=1 /D HAVE_GD_IMAGESETBRUSH=1 /D HAVE_GD_IMAGESETTILE=1 /FR /FD /c\r
 # SUBTRACT CPP /YX\r
 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32\r
diff --git a/ext/gd/tests/createfromwbmp.phpt b/ext/gd/tests/createfromwbmp.phpt
new file mode 100644 (file)
index 0000000..5e48f23
--- /dev/null
@@ -0,0 +1,18 @@
+--TEST--
+imagecreatefromwbmp
+--SKIPIF--
+<?php
+        if (!function_exists('imagecreatefromwbmp')) die("skip gd extension not available\n");
+        if (!GD_BUNDLED) die('skip external GD libraries always fail');
+?>
+--FILE--
+<?php
+$file = dirname(__FILE__) . '/src.wbmp';
+
+$im2 = imagecreatefromwbmp($file);
+echo 'test create from wbmp: ';
+echo imagecolorat($im2, 3,3) == 0x0 ? 'ok' : 'failed';
+echo "\n";
+?>
+--EXPECT--
+test create from wbmp: ok
diff --git a/ext/gd/tests/imagewbmp.phpt b/ext/gd/tests/imagewbmp.phpt
new file mode 100644 (file)
index 0000000..cea464e
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+imagewbmp
+--SKIPIF--
+<?php
+        if (!function_exists('imagecreatefromwbmp')) die("skip gd extension not available\n");
+        if (!GD_BUNDLED) die('skip external GD libraries always fail');
+?>
+--FILE--
+<?php
+$file = dirname(__FILE__) . '/im.wbmp';
+
+$im = imagecreatetruecolor(6,6);
+imagefill($im, 0,0, 0xffffff);
+imagesetpixel($im, 3,3, 0x0);
+imagewbmp($im, $file);
+
+$im2 = imagecreatefromwbmp($file);
+echo 'test create wbmp: ';
+$c = imagecolorsforindex($im2, imagecolorat($im2, 3,3));
+$failed = false;
+foreach ($c as $v) {
+       if ($v != 0) {
+               $failed = true;
+       }
+}
+echo !$failed ? 'ok' : 'failed';
+echo "\n";
+unlink($file);
+?>
+--EXPECT--
+test create wbmp: ok
diff --git a/ext/gd/tests/src.wbmp b/ext/gd/tests/src.wbmp
new file mode 100644 (file)
index 0000000..d38c742
Binary files /dev/null and b/ext/gd/tests/src.wbmp differ