From 1570751d64aaf5250b6b5327002cdbae9986e53d Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Tue, 26 Mar 2024 18:57:36 -0400 Subject: [PATCH] Tests/LibGfx: Add a jbig2 file using refinement in the symbol segment This adds a test for the code added in #23710. I created this file using `jbig2` (see below for details), but as usual it required a bunch of changes to it to make it actually produce spec-compliant output. See the PR adding this image for my local diff. I created the test image file by running this shell script with `jbig2` tweaked as described above: #!/bin/bash set -eu S=Tests/LibGfx/test-inputs/bmp/bitmap.bmp # See make-symbol-jbig.sh (the script in #23659) for the general # setup and some comments. See also make-symbol-textrefine.sh (in # #23713). # # `-Ref` takes 5 arguments: # 1. The symbol ID of this symbol (like after a `-Simple`) # 2. A bmp file that the base symbol gets refined to # 3. The ID of the base symbol # 4. dx, dy cat << EOF > jbig2-symbol-symbolrefine.ini -sym -Seg 1 -sym -file -numClass -HeightClass 3 -WidthClass 1 -sym -file -numSymbol 3 -sym -file -Height 250 -sym -file -Width 120 -Simple 0 mouth-1bpp.bmp -sym -file -EndOfHeightClass -sym -file -Height 100 -sym -file -Width 100 -Simple 1 nose-1bpp.bmp -sym -file -EndOfHeightClass -sym -file -Height 30 -sym -file -Width 30 -Simple 2 top_eye-1bpp.bmp -sym -file -EndOfHeightClass -sym -Param -Huff_DH 0 -sym -Param -Huff_DW 0 -sym -Seg 2 -sym -file -numClass -HeightClass 1 -WidthClass 1 -sym -file -numSymbol 1 -sym -file -Height 30 -sym -file -Width 30 -Ref 3 bottom_eye-1bpp.bmp 2 0 0 -sym -file -EndOfHeightClass -sym -Param -Huff_DH 0 -sym -Param -Huff_DW 0 -sym -Param -RefTemplate 1 -txt -Seg 3 -txt -Param -numInst 4 -ID 2 108 50 -ID 3 265 60 -ID 1 100 135 -ID 0 70 232 -txt -Param -RefCorner 1 -txt -Param -Xlocation 0 -txt -Param -Ylocation 0 -txt -Param -W 399 -txt -Param -H 400 EOF J=$HOME/Downloads/T-REC-T.88-201808-I\!\!SOFT-ZST-E/Software J=$J/JBIG2_SampleSoftware-A20180829/source/jbig2 $J -i "${S%.bmp}" -f bmp -o symbol-symbolrefine -F jb2 \ -ini jbig2-symbol-symbolrefine.ini --- Tests/LibGfx/TestImageDecoder.cpp | 1 + .../jbig2/bitmap-symbol-symbolrefine.jbig2 | Bin 0 -> 447 bytes 2 files changed, 1 insertion(+) create mode 100644 Tests/LibGfx/test-inputs/jbig2/bitmap-symbol-symbolrefine.jbig2 diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp index dd80d2b75a0..1824b67d072 100644 --- a/Tests/LibGfx/TestImageDecoder.cpp +++ b/Tests/LibGfx/TestImageDecoder.cpp @@ -365,6 +365,7 @@ TEST_CASE(test_jbig2_decode) TEST_INPUT("jbig2/bitmap-template3-tpgdon.jbig2"sv), TEST_INPUT("jbig2/bitmap-symbol.jbig2"sv), TEST_INPUT("jbig2/bitmap-symbol-textrefine.jbig2"sv), + TEST_INPUT("jbig2/bitmap-symbol-symbolrefine.jbig2"sv), }; for (auto test_input : test_inputs) { diff --git a/Tests/LibGfx/test-inputs/jbig2/bitmap-symbol-symbolrefine.jbig2 b/Tests/LibGfx/test-inputs/jbig2/bitmap-symbol-symbolrefine.jbig2 new file mode 100644 index 0000000000000000000000000000000000000000..bb8bc016351e339f7b6c1fdb76da003cff1e337c GIT binary patch literal 447 zcmbR4{1d0ohNuF1O{bJ*?Au9?Yw^GiCbd+eFi z{oHmBs_YC37s<=7KF0gy`5oP?ZI2y}J?Z#g_iC#3AsfZNy7kU&)<2H^%if_axmC%u zv+{WD?97UqMNfOK7(F|@=3USfU#0*0#!3Ye$%ijzug;F`_~y@0Cp`7N_FtyiTbV__ z-EZ_rhzjdGdgg$N7{kGSvC7QtKQm8TJ{Rv4TJHFF_4`8)KXeJs4Y8aaRTRgVKPhmF zciq|#YML8Xp2_%jPk=Q<^`6{T>#qlvhyMq9k%>Wp5#)Jw0VX8Rvj9aH)th5xR_bc+ zKeWc|j9;UoLo2&~JxB{Py8;tPiyBZ3N@z0hNC1UddhfYTKJa_7@Ahs(j!Li&7Ikm{ U%c5&wf(Q5-Mv%#@hL9Km05K+>8vp