]> granicus.if.org Git - php/commitdiff
- [DOC] always enable imagecolormatch
authorPierre Joye <pajoye@php.net>
Wed, 27 May 2009 08:12:07 +0000 (08:12 +0000)
committerPierre Joye <pajoye@php.net>
Wed, 27 May 2009 08:12:07 +0000 (08:12 +0000)
ext/gd/config.m4
ext/gd/config.w32
ext/gd/gd.c
ext/gd/libgd/gd_color.c [new file with mode: 0644]
ext/gd/libgd/gd_topal.c
ext/gd/php_gd.h

index 4e3d2423326b418ed668fcc38d7348e4140010f5..6021f9885df1e96c257ad59d8f4adf14c29a85a4 100644 (file)
@@ -275,7 +275,7 @@ if test "$PHP_GD" = "yes"; then
                  libgd/gdfontg.c libgd/gdtables.c libgd/gdft.c libgd/gdcache.c libgd/gdkanji.c \
                  libgd/wbmp.c libgd/gd_wbmp.c libgd/gdhelpers.c libgd/gd_topal.c libgd/gd_gif_in.c \
                  libgd/xbm.c libgd/gd_gif_out.c libgd/gd_security.c libgd/gd_filter.c \
-                 libgd/gd_pixelate.c libgd/gd_arc.c libgd/gd_rotate.c"
+                 libgd/gd_pixelate.c libgd/gd_arc.c libgd/gd_rotate.c libgd/gd_color.c"
 
 dnl check for fabsf and floorf which are available since C99
   AC_CHECK_FUNCS([fabsf floorf])
@@ -312,7 +312,8 @@ elif test "$PHP_GD" != "no"; then
   PHP_ADD_BUILD_DIR($ext_builddir/libgd)
 
   GD_MODULE_TYPE=external
-  extra_sources="gdcache.c libgd/gd_compat.c libgd/gd_filter.c libgd/gd_pixelate.c libgd/gd_arc.c libgd/gd_rotate.c"
+  extra_sources="gdcache.c libgd/gd_compat.c libgd/gd_filter.c libgd/gd_pixelate.c libgd/gd_arc.c \
+                 libgd/gd_rotate.c libgd/gd_color.c"
 
   GD_FEATURES=`$GDLIB_CONFIG --features`
 
index 3d96da18300cf8455be46832e8b457748eb8af99..3e96d7a7143d5f5648b0f9089cffbc8e8d80383b 100644 (file)
@@ -34,7 +34,7 @@ if (PHP_GD != "no") {
                        gdft.c gd_gd2.c gd_gd.c gd_gif_in.c gd_gif_out.c gdhelpers.c gd_io.c gd_io_dp.c \
                        gd_io_file.c gd_io_ss.c gd_jpeg.c gdkanji.c gd_png.c gd_ss.c \
                        gdtables.c gd_topal.c gd_wbmp.c gdxpm.c wbmp.c xbm.c gd_security.c \
-                       gd_filter.c gd_pixelate.c gd_arc.c gd_rotate.c", "gd");
+                       gd_filter.c gd_pixelate.c gd_arc.c gd_rotate.c gd_color.c", "gd");
                AC_DEFINE('HAVE_LIBGD', 1, 'GD support');
                ADD_FLAG("CFLAGS_GD", " \
 /D HAVE_GD_BUNDLED=1  \
index df57171743a6f51652236de0b214ae8e50334b34..99b97713cf175939bbea2cef8b9554457fe19429 100644 (file)
@@ -167,12 +167,10 @@ ZEND_BEGIN_ARG_INFO(arginfo_imagetruecolortopalette, 0)
        ZEND_ARG_INFO(0, colorsWanted)
 ZEND_END_ARG_INFO()
 
-#if HAVE_GD_BUNDLED
 ZEND_BEGIN_ARG_INFO(arginfo_imagecolormatch, 0)
        ZEND_ARG_INFO(0, im1)
        ZEND_ARG_INFO(0, im2)
 ZEND_END_ARG_INFO()
-#endif
 
 ZEND_BEGIN_ARG_INFO(arginfo_imagesetthickness, 0)
        ZEND_ARG_INFO(0, im)
@@ -980,9 +978,11 @@ const zend_function_entry gd_functions[] = {
        PHP_FE(image2wbmp,                                                              arginfo_image2wbmp)
 #if HAVE_GD_BUNDLED
        PHP_FE(imagelayereffect,                                                arginfo_imagelayereffect)
-       PHP_FE(imagecolormatch,                                                 arginfo_imagecolormatch)
        PHP_FE(imagexbm,                                arginfo_imagexbm)
 #endif
+
+       PHP_FE(imagecolormatch,                                                 arginfo_imagecolormatch)
+
 /* gd filters */
        PHP_FE(imagefilter,                                                     arginfo_imagefilter)
        PHP_FE(imageconvolution,                                                arginfo_imageconvolution)
@@ -1555,7 +1555,6 @@ PHP_FUNCTION(imagetruecolortopalette)
 }
 /* }}} */
 
-#if HAVE_GD_BUNDLED
 /* {{{ proto bool imagecolormatch(resource im1, resource im2) U
    Makes the colors of the palette version of an image more closely match the true color version */
 PHP_FUNCTION(imagecolormatch)
@@ -1594,7 +1593,6 @@ PHP_FUNCTION(imagecolormatch)
        RETURN_TRUE;
 }
 /* }}} */
-#endif
 
 /* {{{ proto bool imagesetthickness(resource im, int thickness) U
    Set line thickness for drawing lines, ellipses, rectangles, polygons etc. */
diff --git a/ext/gd/libgd/gd_color.c b/ext/gd/libgd/gd_color.c
new file mode 100644 (file)
index 0000000..2d061a5
--- /dev/null
@@ -0,0 +1,65 @@
+#if HAVE_GD_BUNDLED
+# include "gd.h"
+#else
+# include <gd.h>
+#endif
+
+#include "gd_intern.h"
+#include "php.h"
+
+/* bring the palette colors in im2 to be closer to im1
+ *
+ */
+int gdImageColorMatch (gdImagePtr im1, gdImagePtr im2)
+{
+       unsigned long *buf; /* stores our calculations */
+       unsigned long *bp; /* buf ptr */
+       int color, rgb;
+       int x,y;
+       int count;
+
+       if( !im1->trueColor ) {
+               return -1; /* im1 must be True Color */
+       }
+       if( im2->trueColor ) {
+               return -2; /* im2 must be indexed */
+       }
+       if( (im1->sx != im2->sx) || (im1->sy != im2->sy) ) {
+               return -3; /* the images are meant to be the same dimensions */
+       }
+       if (im2->colorsTotal<1) {
+               return -4; /* At least 1 color must be allocated */
+       }
+
+       buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 * im2->colorsTotal, 0);
+       memset( buf, 0, sizeof(unsigned long) * 5 * im2->colorsTotal );
+
+       for (x=0; x<im1->sx; x++) {
+               for( y=0; y<im1->sy; y++ ) {
+                       color = im2->pixels[y][x];
+                       rgb = im1->tpixels[y][x];
+                       bp = buf + (color * 5);
+                       (*(bp++))++;
+                       *(bp++) += gdTrueColorGetRed(rgb);
+                       *(bp++) += gdTrueColorGetGreen(rgb);
+                       *(bp++) += gdTrueColorGetBlue(rgb);
+                       *(bp++) += gdTrueColorGetAlpha(rgb);
+               }
+       }
+       bp = buf;
+       for (color=0; color<im2->colorsTotal; color++) {
+               count = *(bp++);
+               if( count > 0 ) {
+                       im2->red[color]         = *(bp++) / count;
+                       im2->green[color]       = *(bp++) / count;
+                       im2->blue[color]        = *(bp++) / count;
+                       im2->alpha[color]       = *(bp++) / count;
+               } else {
+                       bp += 4;
+               }
+       }
+       gdFree(buf);
+       return 0;
+}
+
+
index d2cd13f5b9e0a0e06fad4df4d3ded7f70b0fbc09..8a48fdd881e9128831cefc0ca62064f3152f0519 100644 (file)
@@ -2066,61 +2066,4 @@ success:
 #endif
 }
 
-
-/* bring the palette colors in im2 to be closer to im1
- *
- */
-int gdImageColorMatch (gdImagePtr im1, gdImagePtr im2)
-{
-       unsigned long *buf; /* stores our calculations */
-       unsigned long *bp; /* buf ptr */
-       int color, rgb;
-       int x,y;
-       int count;
-
-       if( !im1->trueColor ) {
-               return -1; /* im1 must be True Color */
-       }
-       if( im2->trueColor ) {
-               return -2; /* im2 must be indexed */
-       }
-       if( (im1->sx != im2->sx) || (im1->sy != im2->sy) ) {
-               return -3; /* the images are meant to be the same dimensions */
-       }
-       if (im2->colorsTotal<1) {
-               return -4; /* At least 1 color must be allocated */
-       }
-
-       buf = (unsigned long *)safe_emalloc(sizeof(unsigned long), 5 * im2->colorsTotal, 0);
-       memset( buf, 0, sizeof(unsigned long) * 5 * im2->colorsTotal );
-
-       for (x=0; x<im1->sx; x++) {
-               for( y=0; y<im1->sy; y++ ) {
-                       color = im2->pixels[y][x];
-                       rgb = im1->tpixels[y][x];
-                       bp = buf + (color * 5);
-                       (*(bp++))++;
-                       *(bp++) += gdTrueColorGetRed(rgb);
-                       *(bp++) += gdTrueColorGetGreen(rgb);
-                       *(bp++) += gdTrueColorGetBlue(rgb);
-                       *(bp++) += gdTrueColorGetAlpha(rgb);
-               }
-       }
-       bp = buf;
-       for (color=0; color<im2->colorsTotal; color++) {
-               count = *(bp++);
-               if( count > 0 ) {
-                       im2->red[color]         = *(bp++) / count;
-                       im2->green[color]       = *(bp++) / count;
-                       im2->blue[color]        = *(bp++) / count;
-                       im2->alpha[color]       = *(bp++) / count;
-               } else {
-                       bp += 4;
-               }
-       }
-       gdFree(buf);
-       return 0;
-}
-
-
 #endif
index 5e3572697a27957d348aef603f6c669ed82f5087..15c786f3535fa643da923698dfc817b667a0b98c 100644 (file)
@@ -190,10 +190,11 @@ PHP_FUNCTION(image2wbmp);
 
 #if HAVE_GD_BUNDLED
 PHP_FUNCTION(imagelayereffect);
-PHP_FUNCTION(imagecolormatch);
 PHP_FUNCTION(imagexbm);
 #endif
 
+PHP_FUNCTION(imagecolormatch);
+
 PHP_FUNCTION(imagefilter);
 PHP_FUNCTION(imageconvolution);