ladybird/Tests/LibGfx
Nico Weber 3a50cadddf Tests/LibGfx: Add a jbig2 file using basic symbol and text segments
I created this file using `jbig2` (see below for details), but as
far as I can tell `jbig2` does not produce spec-compliant files:

1. It always writes to 0s for the run lengths that specify how
   many symbols to export at the end of a symbol segment

2. It doesn't write any referred-to segments for text segments.
   I think it's supposed to write a referred-to segment that
   mentions the symbol segment the text segment refers to (?)

I locally tweaked `jbig2` to fix these two defects (*), so the image
added in this commit is correct as best I can tell. It opens fine
using `image` and `jbig2`'s decode mode, and via
`Meta/jbig2_to_pdf.py` in Firefox and Chrome. Without my tweaks,
the image decodes fine with `jbig2`, but not with any of the other
three. The image (in a pdf) does _not_ decode in Preview.app,
either with or without my local `jbig2` tweaks.

*: 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

    I=Build/lagom/bin/image
    S=Tests/LibGfx/test-inputs/bmp/bitmap.bmp

    $I "$S" --crop 232,70,120,250  -o mouth.bmp
    $I "$S" --crop 135,100,100,100 -o nose.bmp
    $I "$S" --crop 50,108,30,30    -o top_eye.bmp
    $I "$S" --crop 60,265,30,30    -o bottom_eye.bmp

    # I then manually converted those to 1bpp using Photoshop
    # (Image->Mode->Grayscale, then Image->Mode->Bitmap...,
    # File->Save As..., bmp) since `jbig2` gets confused by non-1bpp
    # bmp files and `image` can't write 1bpp files :/
    #
    # (I tried `convert ${in} -monochrome ${in}-1bpp.bmp` via
    # https://cancerberosgx.github.io/magic/playground/index.html
    # first, but that produced bmp files that neither Preview.app nor
    # `jbig2` could handle.)
    #
    # -HeightClass: Number of height classes
    # -WidthClass: Maximum number of symbols in one height class
    # -Simple means no refinement; the number after is the symbol's ID
    # The 3 numbers afer `-ID` are id, y, x. The `-ID` are sorted by x.
    # -RefCorner 1 means "top left".
    #
    # `jbig2` writes symbol and text segments as specified in the ini
    # file, and then only stores the bits of the input image that aren't
    # already set through symbol and text segments.

    cat << EOF > jbig2-symbol.ini
    -sym -Seg 1
    -sym -file -numClass -HeightClass 3 -WidthClass 2
    -sym -file -numSymbol 4
    -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 -Width 30 -Simple 3 bottom_eye-1bpp.bmp
    -sym -file -EndOfHeightClass
    -sym -Param -Huff_DH 0
    -sym -Param -Huff_DW 0

    -txt -Seg 2
    -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 -F jb2 -ini jbig2-symbol.ini
2024-03-23 08:18:15 -04:00
..
test-inputs Tests/LibGfx: Add a jbig2 file using basic symbol and text segments 2024-03-23 08:18:15 -04:00
BenchmarkGfxPainter.cpp Tests: Propagate errors with TRY_OR_FAIL() where possible 2024-02-14 17:46:06 -05:00
BenchmarkJPEGLoader.cpp Tests: Move jpg test images into jpg/ subfolder 2023-06-19 06:42:00 -04:00
CMakeLists.txt LibGfx: Fix off-by-some in Painter::draw_scaled_bitmap_with_transform() 2024-01-10 09:38:13 +01:00
TestDeltaE.cpp LibGfx: Add DeltaE() function 2023-04-30 05:57:20 +02:00
TestFontHandling.cpp LibGfx: Allow extracting paths from fonts and add Gfx::Path::text() 2023-11-05 02:46:46 +01:00
TestGfxBitmap.cpp LibGfx: Fix serializing Gfx::Bitmaps 2023-10-15 20:34:29 +02:00
TestICCProfile.cpp LibGfx/ICC: Implement conversion between different connection spaces 2023-12-04 08:02:36 +00:00
TestImageDecoder.cpp Tests/LibGfx: Consolidate jbig2 decode tests 2024-03-22 11:29:27 +01:00
TestPainter.cpp Tests: Remove logspam from TestPainter 2024-03-14 10:56:13 -04:00
TestParseISOBMFF.cpp LibGfx: Add initial ISO BMFF parsing and a utility to print file info 2023-07-27 12:02:37 +01:00
TestRect.cpp LibGfx: Add Rect::unite_{horizontally,vertically}() 2023-07-13 05:09:08 +02:00
TestScalingFunctions.cpp LibGfx+Everywhere: Change Gfx::Rect to be endpoint exclusive 2023-05-23 12:35:42 +02:00
TestWOFF.cpp LibGfx/WOFF: Ensure header totalSfntSize matches expected value 2023-10-24 07:29:09 +02:00
TestWOFF2.cpp LibGfx/WOFF2: Ensure numTables is within expected range 2023-10-26 08:39:26 +02:00