iliaa           Tue Mar 11 20:02:41 2003 EDT

  Added files:                 (Branch: PHP_4_3)
    /php4/ext/gd/libgd  xbm.c 

  Modified files:              
    /php4/ext/gd        config.m4 gd_bundled.dsp 
    /php4/ext/gd/libgd  gd.c 
  Log:
  MFH (XBM patch by Marcus Börger)
  
  
Index: php4/ext/gd/config.m4
diff -u php4/ext/gd/config.m4:1.120.2.8 php4/ext/gd/config.m4:1.120.2.9
--- php4/ext/gd/config.m4:1.120.2.8     Thu Jan 23 01:22:42 2003
+++ php4/ext/gd/config.m4       Tue Mar 11 20:02:39 2003
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: config.m4,v 1.120.2.8 2003/01/23 06:22:42 sniper Exp $
+dnl $Id: config.m4,v 1.120.2.9 2003/03/12 01:02:39 iliaa Exp $
 dnl
 
 dnl
@@ -257,7 +257,8 @@
                  libgd/gd_io_file.c libgd/gd_ss.c libgd/gd_io_ss.c libgd/gd_png.c 
libgd/gd_jpeg.c \
                  libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c libgd/gdfontmb.c 
libgd/gdfontl.c \
                  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/wbmp.c libgd/gd_wbmp.c libgd/gdhelpers.c libgd/gd_topal.c 
libgd/gd_gif_in.c \
+                 libgd/xbm.c"
 
 dnl check for fabsf and floorf which are available since C99
   AC_CHECK_FUNCS(fabsf floorf)
@@ -287,6 +288,7 @@
   AC_DEFINE(HAVE_GD_WBMP,             1, [ ])
   AC_DEFINE(HAVE_GD_GD2,              1, [ ])
   AC_DEFINE(HAVE_GD_PNG,              1, [ ])
+  AC_DEFINE(HAVE_GD_XBM,              1, [ ])
   AC_DEFINE(HAVE_GD_BUNDLED,          1, [ ])
   AC_DEFINE(HAVE_GD_GIF_READ,          1, [ ])
 
Index: php4/ext/gd/gd_bundled.dsp
diff -u php4/ext/gd/gd_bundled.dsp:1.7.2.4 php4/ext/gd/gd_bundled.dsp:1.7.2.5
--- php4/ext/gd/gd_bundled.dsp:1.7.2.4  Sun Feb  9 01:26:45 2003
+++ php4/ext/gd/gd_bundled.dsp  Tue Mar 11 20:02:40 2003
@@ -43,8 +43,8 @@
 # PROP Intermediate_Dir "Release_TS"
 # PROP Ignore_Export_Lib 0
 # PROP Target_Dir ""
-# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I 
"..\..\..\bindlib_w32" /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_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
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I 
"..\..\..\bindlib_w32" /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_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_GD2" /D HAVE_GD_STRINGFTEX=1 /D HAVE_GD_IMAGESETBRUSH=1 /D 
HAVE_GD_IMAGESETTILE=1 /FR /FD /c
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I 
"..\..\..\bindlib_w32" /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_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
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I 
"..\..\..\bindlib_w32" /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_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_GD2" /D HAVE_GD_STRINGFTEX=1 /D 
HAVE_GD_IMAGESETBRUSH=1 /D HAVE_GD_IMAGESETTILE=1 /FR /FD /c
 # SUBTRACT CPP /YX
 # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
@@ -515,6 +515,21 @@
 # Begin Source File
 
 SOURCE=.\libgd\wbmp.c
+
+!IF  "$(CFG)" == "gd_bundled - Win32 Release_TS GD2"
+
+# PROP Intermediate_Dir "Release_TS_bundled"
+
+!ELSEIF  "$(CFG)" == "gd_bundled - Win32 Debug_TS GD2"
+
+# PROP Intermediate_Dir "Debug_TS_bundled"
+
+!ENDIF 
+
+# End Source File
+# Begin Source File
+
+SOURCE=.\libgd\xbm.c
 
 !IF  "$(CFG)" == "gd_bundled - Win32 Release_TS GD2"
 
Index: php4/ext/gd/libgd/gd.c
diff -u php4/ext/gd/libgd/gd.c:1.24.2.5 php4/ext/gd/libgd/gd.c:1.24.2.6
--- php4/ext/gd/libgd/gd.c:1.24.2.5     Wed Mar  5 11:04:20 2003
+++ php4/ext/gd/libgd/gd.c      Tue Mar 11 20:02:40 2003
@@ -2857,134 +2857,6 @@
 }
 /* End Rotate function */
 
-#if MBO_0
-gdImagePtr
-gdImageCreateFromXbm (FILE * fd)
-{
-  gdImagePtr im;
-  int bit;
-  int w, h;
-  int bytes;
-  int ch;
-  int i, x, y;
-  char *sp;
-  char s[161];
-  if (!fgets (s, 160, fd))
-    {
-      return 0;
-    }
-  sp = &s[0];
-  /* Skip #define */
-  sp = strchr (sp, ' ');
-  if (!sp)
-    {
-      return 0;
-    }
-  /* Skip width label */
-  sp++;
-  sp = strchr (sp, ' ');
-  if (!sp)
-    {
-      return 0;
-    }
-  /* Get width */
-  w = atoi (sp + 1);
-  if (!w)
-    {
-      return 0;
-    }
-  if (!fgets (s, 160, fd))
-    {
-      return 0;
-    }
-  sp = s;
-  /* Skip #define */
-  sp = strchr (sp, ' ');
-  if (!sp)
-    {
-      return 0;
-    }
-  /* Skip height label */
-  sp++;
-  sp = strchr (sp, ' ');
-  if (!sp)
-    {
-      return 0;
-    }
-  /* Get height */
-  h = atoi (sp + 1);
-  if (!h)
-    {
-      return 0;
-    }
-  /* Skip declaration line */
-  if (!fgets (s, 160, fd))
-    {
-      return 0;
-    }
-  bytes = (w * h / 8) + 1;
-  im = gdImageCreate (w, h);
-  gdImageColorAllocate (im, 255, 255, 255);
-  gdImageColorAllocate (im, 0, 0, 0);
-  x = 0;
-  y = 0;
-  for (i = 0; (i < bytes); i++)
-    {
-      char h[3];
-      unsigned int b;
-      /* Skip spaces, commas, CRs, 0x */
-      while (1)
-       {
-         ch = getc (fd);
-         if (ch == EOF)
-           {
-             goto fail;
-           }
-         if (ch == 'x')
-           {
-             break;
-           }
-       }
-      /* Get hex value */
-      ch = getc (fd);
-      if (ch == EOF)
-       {
-         goto fail;
-       }
-      h[0] = ch;
-      ch = getc (fd);
-      if (ch == EOF)
-       {
-         goto fail;
-       }
-      h[1] = ch;
-      h[2] = '\0';
-      sscanf (h, "%x", &b);
-      for (bit = 1; (bit <= 128); (bit = bit << 1))
-       {
-         gdImageSetPixel (im, x++, y, (b & bit) ? 1 : 0);
-         if (x == im->sx)
-           {
-             x = 0;
-             y++;
-             if (y == im->sy)
-               {
-                 return im;
-               }
-             /* Fix 8/8/95 */
-             break;
-           }
-       }
-    }
-  /* Shouldn't happen */
-  php_gd_error("Error: bug in gdImageCreateFromXbm\n");
-  return 0;
-fail:
-  gdImageDestroy (im);
-  return 0;
-}
-#endif /* MBO_0 */
-
 void
 gdImagePolygon (gdImagePtr im, gdPointPtr p, int n, int c)
 {

Index: php4/ext/gd/libgd/xbm.c
+++ php4/ext/gd/libgd/xbm.c
/*
   +----------------------------------------------------------------------+
   | PHP Version 4                                                        |
   +----------------------------------------------------------------------+
   | Copyright (c) 1997-2003 The PHP Group                                |
   +----------------------------------------------------------------------+
   | This source file is subject to version 2.02 of the PHP license,      |
   | that is bundled with this package in the file LICENSE, and is        |
   | available at through the world-wide-web at                           |
   | http://www.php.net/license/2_02.txt.                                 |
   | If you did not receive a copy of the PHP license and are unable to   |
   | obtain it through the world-wide-web, please send a note to          |
   | [EMAIL PROTECTED] so we can mail you a copy immediately.               |
   +----------------------------------------------------------------------+
   | Author: Marcus Boerger <[EMAIL PROTECTED]>                               |
   +----------------------------------------------------------------------+
 */

/* $Id: xbm.c,v 1.1 2003/02/02 01:34:54 helly Exp $ */

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include "gd.h"
#include "gdhelpers.h"

#include "php.h"

#define MAX_XBM_LINE_SIZE 255

gdImagePtr
gdImageCreateFromXbm (FILE * fd)
{
        char fline[MAX_XBM_LINE_SIZE];
        char iname[MAX_XBM_LINE_SIZE];
        char *type;
        int value;
        unsigned int width = 0, height = 0;
        int fail = 0;
        int max_bit = 0;

        gdImagePtr im;
        int bytes = 0, i;
        int bit, x = 0, y = 0;
        int ch;
        char h[8];
        unsigned int b;
        
        rewind(fd);
        while (fgets(fline, MAX_XBM_LINE_SIZE, fd)) {
                fline[MAX_XBM_LINE_SIZE-1] = '\0';
                if (strlen(fline) == MAX_XBM_LINE_SIZE-1) {
                        return 0;
                }
                if (sscanf(fline, "#define %s %d", iname, &value) == 2) {
                        if (!(type = strrchr(iname, '_'))) {
                                type = iname;
                        } else {
                                type++;
                        }
        
                        if (!strcmp("width", type)) {
                                width = (unsigned int) value;
                        }
                        if (!strcmp("height", type)) {
                                height = (unsigned int) value;
                        }
                } else {
                        if ( sscanf(fline, "static unsigned char %s = {", iname) == 1
                          || sscanf(fline, "static char %s = {", iname) == 1)
                        {
                                max_bit = 128;
                        } else if (sscanf(fline, "static unsigned short %s = {", 
iname) == 1
                                        || sscanf(fline, "static short %s = {", iname) 
== 1)
                        {
                                max_bit = 32768;
                        }
                        if (max_bit) {
                                bytes = (width * height / 8) + 1;
                                if (!bytes) {
                                        return 0;
                                }
                                if (!(type = strrchr(iname, '_'))) {
                                        type = iname;
                                } else {
                                        type++;
                                }
                                if (!strcmp("bits[]", type)) {
                                        break;
                                }
                        }
                }
        }
        if (!bytes || !max_bit) {
                return 0;
        }

        im = gdImageCreate(width, height);
        gdImageColorAllocate(im, 255, 255, 255);
        gdImageColorAllocate(im, 0, 0, 0);
        h[2] = '\0';
        h[4] = '\0';
        for (i = 0; i < bytes; i++) {
                while (1) {
                        ch = getc(fd);
                        if (ch == EOF)
                        {
                                fail = 1;
                                break;
                        }
                        if (ch == 'x')
                        {
                                break;
                        }
                }
                if (fail) {
                        break;
                }
                /* Get hex value */
                if ((ch=getc(fd)) == EOF) break;
                h[0] = ch;
                if ((ch=getc(fd)) == EOF) break;
                h[1] = ch;
                if (max_bit == 32768) {
                        if ((ch=getc(fd)) == EOF) break;
                        h[2] = ch;
                        if ((ch=getc(fd)) == EOF) break;
                        h[3] = ch;
                }
                sscanf(h, "%x", &b);
                for (bit = 1; bit <= max_bit; bit = bit << 1) {
                        gdImageSetPixel (im, x++, y, (b & bit) ? 1 : 0);
                        if (x == im->sx)
                        {
                                x = 0;
                                y++;
                                if (y == im->sy)
                                {
                                        return im;
                                }
                                break;
                        }
                }
        }

        php_gd_error("EOF before image was complete\n");
        gdImageDestroy(im);
        return 0;
}

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to