GraphicsMagick: coders/wpg.c Bilevel image must be allways monoc...

GraphicsMagick Commits <[email protected]>
Newsgroups gmane.comp.video.graphicsmagick.cvs
Message-ID <mailman.11612.1667257707.1350.graphicsmagick-commit@lists.sourceforge.net>
changeset 931d5636ccf6 in /hg/GraphicsMagick
details: http://hg.GraphicsMagick.org/hg/GraphicsMagick?cmd=changeset;node=931d5636ccf6
summary: coders/wpg.c Bilevel image must be allways monochrome. New testcase with bilevel monochrome WPG image.

diffstat:

 ChangeLog                 |    9 +++++++++
 PerlMagick/t/input1_1.wpg |  Bin 
 PerlMagick/t/read.t       |    6 +++++-
 coders/wpg.c              |    5 +++--
 4 files changed, 17 insertions(+), 3 deletions(-)

diffs (63 lines):

diff -r bb7f2ca233e9 -r 931d5636ccf6 ChangeLog
--- a/ChangeLog	Mon Oct 31 19:48:00 2022 +0100
+++ b/ChangeLog	Tue Nov 01 00:07:46 2022 +0100
@@ -1,3 +1,12 @@
+2022-11-01  Fojtik Jaroslav  <[email protected]>
+
+	* coders/wpg.c Bilevel image must be allways monochrome.
+        Discard palette if exists.
+	* PerlMagick/t/input1_1.wpg
+	* PerlMagick/t/reference/read/input1_1.wpg.miff New testcase
+        with bilevel monochrome image.
+	* PerlMagick/t/read.t: Added input1_1.wpg to PerlMagick test suite.
+
 2022-10-31  Fojtik Jaroslav  <[email protected]>
 
 	* coders/xpm.c (ReadXPMImage): Output intelligent messag when colormap 
diff -r bb7f2ca233e9 -r 931d5636ccf6 PerlMagick/t/input1_1.wpg
Binary file PerlMagick/t/input1_1.wpg has changed
diff -r bb7f2ca233e9 -r 931d5636ccf6 PerlMagick/t/read.t
--- a/PerlMagick/t/read.t	Mon Oct 31 19:48:00 2022 +0100
+++ b/PerlMagick/t/read.t	Tue Nov 01 00:07:46 2022 +0100
@@ -13,7 +13,7 @@
 # Whenever a new test is added/removed, be sure to update the
 # 1..n ouput.
 #
-BEGIN { $| = 1; $test=1; print "TAP version 13\n1..86\n"; }
+BEGIN { $| = 1; $test=1; print "TAP version 13\n1..87\n"; }
 END {print "not ok $test\n" unless $loaded;}
 use Graphics::Magick;
 $loaded=1;
@@ -311,6 +311,10 @@
 ++$test;
 testReadCompare('input.wbmp', 'reference/read/input_wbmp.miff', q//, 0, 0);
 
+print("WPG (Word Perfect Graphics image, bilevel WPG level 1) ...\n");
+++$test;
+testReadCompare('input1_1.wpg', 'reference/read/input1_1_wpg.miff', q//, 0, 0);
+
 print("WPG (Word Perfect Graphics image, 4 bit depth WPG level 1) ...\n");
 ++$test;
 testReadCompare('input1_4.wpg', 'reference/read/input1_4_wpg.miff', q//, 0, 0);
diff -r bb7f2ca233e9 -r 931d5636ccf6 coders/wpg.c
--- a/coders/wpg.c	Mon Oct 31 19:48:00 2022 +0100
+++ b/coders/wpg.c	Tue Nov 01 00:07:46 2022 +0100
@@ -1303,7 +1303,8 @@
               image->columns=BitmapHeader1.Width;
               image->rows=BitmapHeader1.Heigth;
               bpp=BitmapHeader1.Depth;
-
+				// Whole palette is useless for bilevel image.
+              if(bpp==1) image->storage_class=DirectClass;
               goto UnpackRaster;
 
             case 0x0E:  /*Color palette */
@@ -1365,7 +1366,7 @@
               if(bpp>24)
                 {ThrowReaderException(CoderError,ColorTypeNotSupported,image)}
 
-              if ((image->storage_class != PseudoClass) && (bpp != 24))
+              if ((image->storage_class != PseudoClass) && (bpp != 24) && bpp!=1)
                 {
                   image->colors=1 << bpp;
                   if (!AllocateImageColormap(image,image->colors))
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.