Skip to content

Implement TASImage::Paint() for PDF#22344

Open
vvolkl wants to merge 1 commit into
root-project:masterfrom
vvolkl:tasimage-draw-pdf-xobject
Open

Implement TASImage::Paint() for PDF#22344
vvolkl wants to merge 1 commit into
root-project:masterfrom
vvolkl:tasimage-draw-pdf-xobject

Conversation

@vvolkl
Copy link
Copy Markdown
Contributor

@vvolkl vvolkl commented May 19, 2026

This Pull request:

Changes or fixes:

Previously TImage/TASImage only rendered to raster outputs: drawing an image and saving to PDF produced nothing but a Warning in <TASImage::Paint>: PDF not implemented yet.
TPDF::CellArrayBegin/CellArrayFill/CellArrayEnd were warning-only stubs and TASImage::Paint bailed out early for the PDF case. This changeset implements bitmap rendering to PDF. The early-return branch in TASImage::Paint is removed so PDF output flows through the same CellArray* path already used for PostScript, and TPDF now implements that API:
pixels accumulated by CellArrayFill are Flate-compressed and emitted as a proper PDF image XObject, the page's /Resources carries an /XObject name dictionary, and the page content
-stream only references the bitmap with a placement matrix and a /ImN Do operator. A new fixed object number is reserved for the shared image dictionary, shifting the first page object
from 51 to 52, and the XObjects are allocated and written at Close() since a PDF object cannot be opened while a page content stream is still in progress. A gtest under
graf2d/gpad/test renders a four-colour synthetic TImage to PDF and verifies both the XObject structure and that the embedded pixels decode back to the colours drawn. Verified on
single-page and multi-page documents with the cross-reference table validated; SVG output, which already worked, is unaffected.

Checklist:

  • tested changes locally
  • updated the docs (if necessary) (I don't think any docs referenced this functionality)

This PR fixes #22251

Assisted-by: Claude:claude-4.7-opus

@vvolkl vvolkl requested review from bellenot and couet as code owners May 19, 2026 16:17
@vvolkl
Copy link
Copy Markdown
Contributor Author

vvolkl commented May 19, 2026

Note that since the indices are changed any reference pdfs need to be updated. I think there are some in roottest but not sure if they are still used/up to date?

@dpiparo dpiparo requested a review from linev May 19, 2026 18:10
Comment thread graf2d/postscript/inc/TPDF.h
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 19, 2026

Test Results

    22 files      22 suites   3d 9h 33m 11s ⏱️
 3 856 tests  3 509 ✅   0 💤 347 ❌
76 152 runs  75 403 ✅ 402 💤 347 ❌

For more details on these failures, see this check.

Results for commit 9300257.

♻️ This comment has been updated with latest results.

Copy link
Copy Markdown
Member

@linev linev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few weeks ago I was asking myself - why it is not implemented?
And now it is there! Grate job!

I tested on my node - it works as expected.

I let Olivier @couet approve and merge PR - once he is back.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Embedded raster images in pdf plotting output

3 participants