Repository navigation
fix: color allocation offset in RasterizedImage for LUT indexes - #745
Merged
Merged
Conversation
Contributor
Author
|
On page 42 of issue-235; the stored image was produced by the old lookup, so index 2 was saved as near-white (255, 254, 254) rather than the black (0, 0, 0) stored in the PDF. The indexed image stores a black rounded frame. However, every one of those pixels has alpha 0 in its /SMask, so a PDF viewer does not paint it. This library recognizes /SMask as a dictionary key and does not apply it when rasterizing, So that image extraction sample is still somewhat wrong. |
Owner
|
Thanks for the targeted and minimal PR! There's already an open issue for softmasks, images are currently not as fully functional as text but we're getting there! |
PrinsFrank
approved these changes
Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This issue was analyzed by cursor. The code and pull request was reviewed by me for correctness before submitting.
Is there an existing issue for this?
Are you using the latest version of this package?
Did you experience this in a real-world PDF?
Can other PDF readers read the file?
When running this snippet
issf-10m-air-rifle-target.pdf
I run into the following issue/exception
The image is gray/white instead of the original black/white.

Code fix
RasterizedImage::toPNGlooks up an indexed color one byte into the palette instead of one color into the palette.For
RGBthat is bytesi,i + 1, andi + 2. It should be bytesi * 3,i * 3 + 1, andi * 3 + 2.The
CMYKcase is also corrected.The
Graycase needs no correction because it is 1 byte per pixel.You should be aware this uses the
enum Components->valuedirectly. It is currently equal to the nr of bytes per pixel.The image is now equal to when viewed in a Adobe Acrobat.

Do you allow attachment files to be used in tests to prevent regressions?
The issf-10m-air-rifle-target.pdf file is a page 197 from the following document: ISSF Rule Book 2026 v3. I do not have the authorization to give permission for reuse.