Skip to content

Implement TASImage::Paint() for PDF#22344

Merged
linev merged 1 commit into
root-project:masterfrom
vvolkl:tasimage-draw-pdf-xobject
Jun 2, 2026
Merged

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

Conversation

@vvolkl

@vvolkl vvolkl commented May 19, 2026

Copy link
Copy Markdown
Contributor

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

vvolkl commented May 19, 2026

Copy link
Copy Markdown
Contributor Author

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

github-actions Bot commented May 19, 2026

Copy link
Copy Markdown

Test Results

    22 files      22 suites   3d 10h 50m 36s ⏱️
 3 865 tests  3 865 ✅ 0 💤 0 ❌
76 256 runs  76 256 ✅ 0 💤 0 ❌

Results for commit a7c1cfd.

♻️ This comment has been updated with latest results.

@linev linev left a comment

Copy link
Copy Markdown
Member

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.

@linev linev force-pushed the tasimage-draw-pdf-xobject branch from 908eee5 to a7c1cfd Compare June 2, 2026 11:27
@linev

linev commented Jun 2, 2026

Copy link
Copy Markdown
Member

I rebase pr once again - because of other changes in stressGraphics

@linev linev merged commit 8dba2b7 into root-project:master Jun 2, 2026
33 checks passed
@linev

linev commented Jun 2, 2026

Copy link
Copy Markdown
Member

@vvolkl

Thanks again.
And I really like green ROOT CI :)

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

4 participants