GraphicsMagick: coders/wpg.c: Do not store palette into image st...

GraphicsMagick Commits <[email protected]> Wed, 18 Oct 2023 15:41:35 -0500
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.9722.1697661706.1370.graphicsmagick-commit@lists.sourceforge.net>
changeset 511fffe6a1bf in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=511fffe6a1bf
summary: coders/wpg.c: Do not store palette into image structure before a raster chunk is found. Implemented for WPG l1 only.

diffstat:

 ChangeLog    |   5 +++++
 coders/wpg.c |  21 ++++++++++++---------
 2 files changed, 17 insertions(+), 9 deletions(-)

diffs (87 lines):

diff -r d636c63bb3a9 -r 511fffe6a1bf ChangeLog
--- a/ChangeLog	Tue Oct 17 23:18:59 2023 +0200
+++ b/ChangeLog	Wed Oct 18 22:41:14 2023 +0200
@@ -1,3 +1,8 @@
+2023-10-18  Fojtik Jaroslav  <[email protected]>
+
+	* coders/wpg.c: Do not store palette into image structure before
+	a raster chunk is found. Implemented for WPG l1 only.
+
 2023-10-17  Bob Friesenhahn  <[email protected]>
 
 	* coders/wpg.c (ReadWPGImage): If a colormap is provided, make
diff -r d636c63bb3a9 -r 511fffe6a1bf coders/wpg.c
--- a/coders/wpg.c	Tue Oct 17 23:18:59 2023 +0200
+++ b/coders/wpg.c	Wed Oct 18 22:41:14 2023 +0200
@@ -1372,15 +1372,17 @@
                 image->colormap[0].red = image->colormap[0].green = image->colormap[0].blue = 0;
                 image->colormap[1].red = image->colormap[1].green = image->colormap[1].blue = MaxRGB;
                 image->colormap[0].opacity = image->colormap[1].opacity = OpaqueOpacity;
+                goto UnpackRaster1bpp;	/* bypass cached palette for 1bpp. */
               }
               goto UnpackRaster;
 
             case 0x0E:  /*Color palette */
+/*
 ///////Temporary fix, should be removed//////////////////////////
-              /* Make sure that indexes contain initialized data if
-                 promoting from DirectClass.  This is a stop-gap
-                 measure until independent colormap support is
-                 developed. */
+              // Make sure that indexes contain initialized data if
+              //   promoting from DirectClass.  This is a stop-gap
+              //   measure until independent colormap support is
+              //   developed.
               if (PseudoClass != image->storage_class)
                 {
                   unsigned long y;
@@ -1409,10 +1411,11 @@
                     ThrowReaderException(CacheError,UnableToGetPixelsFromCache,image);
                 }
 /////////////////////////////////////////////////////////////////
-
+*/
               WPG_Palette.StartIndex=ReadBlobLSBShort(image);
               WPG_Palette.NumOfEntries=ReadBlobLSBShort(image);
 
+/*
 		// This should be replaced with commented stuff.
               image->colors=WPG_Palette.NumOfEntries;
               if (!AllocateImageColormap(image,image->colors))
@@ -1426,8 +1429,8 @@
                   image->colormap[i].blue=ScaleCharToQuantum(ReadBlobByte(image));
                   image->colormap[i].opacity = OpaqueOpacity;
                 }
+*/
 
-/*
               PaletteItems = WPG_Palette.NumOfEntries;
               if(pPalette==NULL)
               {
@@ -1445,7 +1448,6 @@
                   ThrowReaderException(CorruptImageError,ImproperImageHeader,image);
               if(ReadBlob(image,PaletteItems*3,pPalette+3*WPG_Palette.StartIndex) != PaletteItems*3)
                   ThrowReaderException(ResourceLimitError,MemoryAllocationFailed,image);
-*/
               break;
 
             case 0x11:  /* Start PS l1 */
@@ -1506,6 +1508,7 @@
                 }
               }
 
+UnpackRaster1bpp:
               if ((image->storage_class != PseudoClass) && (bpp != 24) && bpp!=1)
                 {
                   image->colors=1 << bpp;
@@ -1536,8 +1539,8 @@
               if(bpp == 1)
                 {
                   if(image->colors<=0)
-                                  {
-                                image->colormap[0].red =
+                    {
+                      image->colormap[0].red =
                         image->colormap[0].green =
                         image->colormap[0].blue = 0;
                       image->colormap[0].opacity = OpaqueOpacity;