Re: cvs: php4 /ext/gd/libgd gd_gd2.c gd_png.c

From: Date: Tue, 03 Dec 2002 19:13:45 +0000
Subject: Re: cvs: php4 /ext/gd/libgd gd_gd2.c gd_png.c
References: 1  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-16872@lists.php.net to get a copy of this message
Ah great now it waorks! Should we add a test for ImageGd() then, verify it isn't a true color image? And what about MFH? marcus At 16:43 03.12.2002, Ilia Alshanetsky wrote:
iliaa           Tue Dec  3 10:43:18 2002 EDT
Modified files:
    /php4/ext/gd/libgd  gd_gd2.c gd_png.c
Log: Fixed a crash that occurs during the last step of png/jpeg -> gd2 -> png/jpeg conversion. The same crash still occures with png/jpeg -> gd -> png/jpeg, because apparently gd format cannot handle truecolor images. Turned off debug messages inside gd_gd2.c. Index: php4/ext/gd/libgd/gd_gd2.c diff -u php4/ext/gd/libgd/gd_gd2.c:1.8 php4/ext/gd/libgd/gd_gd2.c:1.9
--- php4/ext/gd/libgd/gd_gd2.c:1.8      Sun Dec  1 06:43:54 2002
+++ php4/ext/gd/libgd/gd_gd2.c Tue Dec 3 10:43:17 2002 @@ -25,8 +25,8 @@ /* Use this for commenting out debug-print statements. */ /* Just use the first '#define' to allow all the prints... */ -#define GD2_DBG(s) (s) -//#define GD2_DBG(s) +/* #define GD2_DBG(s) (s) */ +#define GD2_DBG(s) typedef struct { @@ -184,7 +184,7 @@
       goto fail1;
     }
- im = gdImageCreate (*sx, *sy); + im = gdImageCreateTrueColor(*sx, *sy); if (im == NULL)
     {
       GD2_DBG(php_gd_error("Could not create gdImage\n"));
@@ -393,7 +393,7 @@
                          int r = chunkBuf[chunkPos++] << 16;
                          int g = chunkBuf[chunkPos++] << 8;
                          int b = chunkBuf[chunkPos++];
-                         im->pixels[y][x] = a + r + g + b;
+                         im->tpixels[y][x] = a + r + g + b;
                        }
                      else
                        {
@@ -818,10 +818,10 @@
                {
                  for (x = xlo; x < xhi; x++)
                    {
-                     int p = im->pixels[y][x];
                      GD2_DBG(php_gd_error("%d...",x));
                      if (im->trueColor)
                        {
+                         int p = im->tpixels[y][x];
                          chunkData[chunkLen++] = gdTrueColorGetAlpha (p);
                          chunkData[chunkLen++] = gdTrueColorGetRed (p);
                          chunkData[chunkLen++] = gdTrueColorGetGreen (p);
@@ -829,7 +829,7 @@
                        }
                      else
                        {
-                         chunkData[chunkLen++] = p;
+                         chunkData[chunkLen++] = im->pixels[y][x];
                        }
                    };
                }
Index: php4/ext/gd/libgd/gd_png.c diff -u php4/ext/gd/libgd/gd_png.c:1.8 php4/ext/gd/libgd/gd_png.c:1.9
--- php4/ext/gd/libgd/gd_png.c:1.8      Sun Dec  1 06:43:54 2002
+++ php4/ext/gd/libgd/gd_png.c Tue Dec 3 10:43:17 2002 @@ -667,20 +667,10 @@
       /* Our little 7-bit alpha channel trick costs us a bit here. */
       png_bytep *row_pointers;
       row_pointers = gdMalloc (sizeof (png_bytep) * height);
-      if (row_pointers == NULL)
-       {
-         php_gd_error("gd-png error: unable to allocate row_pointers\n");
-       }
       for (j = 0; j < height; ++j)
        {
          int bo = 0;
-         if ((row_pointers[j] = (png_bytep) gdMalloc (width * channels)) == NULL)
-           {
-             php_gd_error("gd-png error: unable to allocate rows\n");
-             for (i = 0; i < j; ++i)
-               gdFree (row_pointers[i]);
-             return;
-           }
+         row_pointers[j] = (png_bytep) gdMalloc (width * channels);
          for (i = 0; i < width; ++i)
            {
              unsigned char a;
@@ -714,20 +704,10 @@
        {
          png_bytep *row_pointers;
          row_pointers = gdMalloc (sizeof (png_bytep) * height);
-         if (row_pointers == NULL)
-           {
-             php_gd_error("gd-png error: unable to allocate row_pointers\n");
-           }
          for (j = 0; j < height; ++j)
            {
-             if ((row_pointers[j] = (png_bytep) gdMalloc (width)) == NULL)
-               {
-                 php_gd_error("gd-png error: unable to allocate rows\n");
-                 for (i = 0; i < j; ++i)
-                   gdFree (row_pointers[i]);
-                 return;
-               }
-             for (i = 0; i < width; ++i)
+             row_pointers[j] = (png_bytep) gdMalloc (width);
+             for (i = 0; i < width; ++i)
                row_pointers[j][i] = mapping[im->pixels[j][i]];
            }
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


« previous php.cvs (#16872) next »