Add a pixel test for /SMaskInData in JPEG2000 images.
In images using the JPXDecode filter, if /SMaskInData is set to 1, then
the image data stream includes soft-mask values for use as a source of
mask shape or mask opacity.
The sample JPEG2000 image is generated from a PNG with alpha using
OpenJPEG. The image has to be a binary for /SMaskInData 1 to work. i.e.
No additional filters.
Bug: pdfium:1469
Change-Id: Id40ec19ee587fcdfd930e1f3a6644326990948a3
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/67330
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
diff --git a/testing/SUPPRESSIONS b/testing/SUPPRESSIONS
index ae9cec0..f1270f8 100644
--- a/testing/SUPPRESSIONS
+++ b/testing/SUPPRESSIONS
@@ -343,6 +343,9 @@
# TODO(pdfium:1466): Remove after associated bug is fixed
bug_1449.in linux * *
+# TODO(pdfium:1469): Remove after associated bug is fixed
+bug_1469.in * * *
+
# xfa_specific
# TODO(pdfium:1107): Remove after associated bug is fixed
diff --git a/testing/resources/bug_1469.jp2 b/testing/resources/bug_1469.jp2
new file mode 100644
index 0000000..892e8fa
--- /dev/null
+++ b/testing/resources/bug_1469.jp2
Binary files differ
diff --git a/testing/resources/pixel/bug_1469.in b/testing/resources/pixel/bug_1469.in
new file mode 100644
index 0000000..8eb970d
--- /dev/null
+++ b/testing/resources/pixel/bug_1469.in
@@ -0,0 +1,98 @@
+{{header}}
+{{object 1 0}} <<
+ /Type /Catalog
+ /Pages 2 0 R
+>>
+endobj
+{{object 2 0}} <<
+ /Type /Pages
+ /Count 1
+ /Kids [3 0 R]
+>>
+endobj
+{{object 3 0}} <<
+ /Type /Page
+ /Parent 2 0 R
+ /Contents 4 0 R
+ /MediaBox [0 0 300 100]
+ /Resources <<
+ /XObject <<
+ % All 3 images are BGRA with the same data but interpreted differently.
+ /ImNoSMaskInData 5 0 R
+ /ImSMaskInData0 6 0 R
+ /ImSMaskInData1 7 0 R
+ >>
+ >>
+>>
+endobj
+{{object 4 0}} <<
+ {{streamlen}}
+>>
+stream
+q
+0 1 0 rg
+0 0 300 100 re f
+Q
+q
+64 0 0 64 0 0 cm
+/ImNoSMaskInData Do
+Q
+q
+64 0 0 64 100 0 cm
+/ImSMaskInData0 Do
+Q
+q
+64 0 0 64 200 0 cm
+/ImSMaskInData1 Do
+Q
+endstream
+endobj
+{{object 5 0}} <<
+ /Type /XObject
+ /Subtype /Image
+ /BitsPerComponent 8
+ /ColorSpace /DeviceRGB
+ /Filter /JPXDecode
+ /Height 64
+ % No /SMaskInData here.
+ /Width 64
+ {{streamlen}}
+>>
+stream
+{{include ../bug_1469.jp2}}
+endstream
+endobj
+{{object 6 0}} <<
+ /Type /XObject
+ /Subtype /Image
+ /BitsPerComponent 8
+ /ColorSpace /DeviceRGB
+ /Filter /JPXDecode
+ /Height 64
+ /SMaskInData 0
+ /Width 64
+ {{streamlen}}
+>>
+stream
+{{include ../bug_1469.jp2}}
+endstream
+endobj
+{{object 7 0}} <<
+ /Type /XObject
+ /Subtype /Image
+ /BitsPerComponent 8
+ /ColorSpace /DeviceRGB
+ /Filter /JPXDecode
+ /Height 64
+ /SMaskInData 1
+ /Width 64
+ {{streamlen}}
+>>
+stream
+{{include ../bug_1469.jp2}}
+endstream
+endobj
+{{xref}}
+{{trailer}}
+{{startxref}}
+%%EOF
diff --git a/testing/resources/pixel/bug_1469_expected.pdf.0.png b/testing/resources/pixel/bug_1469_expected.pdf.0.png
new file mode 100644
index 0000000..a87b79d
--- /dev/null
+++ b/testing/resources/pixel/bug_1469_expected.pdf.0.png
Binary files differ