Commit 45c2bd0
committed
Render inline images (BI/ID/EI) and clean up FQN code-style issues
Implements the inline-image roadmap item: instead of pre-stripping inline
image blocks, the preprocessor now promotes each one into a synthetic Image
XObject and substitutes a `/__inline_image__N Do` invocation into the
content stream. The rest of the renderer treats it exactly like a regular
Image XObject and reuses the existing buildGrayImage / buildRgbImage /
buildCmykImage / ImageIO decode paths.
Two framing strategies are used so the parser doesn't get confused by
binary data:
- For DCT / DCTDecode / JPXDecode filters, find the JPEG end-of-image
marker (FFD9) instead of scanning for "EI" bounded by whitespace, since
JPEG payloads routinely contain byte sequences that look like EI by
accident.
- For other filters (including no filter and FlateDecode), keep the
whitespace-bounded EI heuristic but stop trimming "trailing whitespace"
greedily -- image bytes can legitimately be 0x00 or 0x0A and the spec
guarantees exactly one whitespace byte before EI.
Abbreviated dict keys (/W, /H, /BPC, /CS, /F) and full names (/Width,
/Height, ...) are both accepted; abbreviated colorspace values (/G, /RGB,
/CMYK) and full names map to component counts.
Tests:
- inlineImageRendersAtCtmLocation builds a 2x2 DeviceGray inline image
with a [black, white; white, black] checker, scales it 120x via a cm,
and asserts the rendered page contains dark pixels in the right region.
- jpegInlineImageDecodes uses PdfContentByte.addImage(image, ..., true)
to embed a green JPEG as an inline image, then asserts the rendered
page contains green pixels.
README's status section now says inline images render, and the
limitations list no longer mentions them.
Also addresses Codacy's "unnecessary fully qualified name" warning on
java.util.List / java.util.Set usage. The class now imports List, Set,
Arrays, ByteArrayOutputStream, StandardCharsets and Rectangle2D directly
instead of inlining the FQNs; 7 call sites simplified.
Module test suite: 86 tests, 0 failures.1 parent 2db7c3f commit 45c2bd0
3 files changed
Lines changed: 392 additions & 45 deletions
File tree
- openpdf-renderer
- src
- main/java/org/openpdf/renderer/core
- test/java/org/openpdf/renderer/core
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
139 | 142 | | |
140 | 143 | | |
141 | 144 | | |
| |||
158 | 161 | | |
159 | 162 | | |
160 | 163 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
0 commit comments