Repository navigation
Paint image masks as stencils in the fill color - #582
Merged
Merged
Conversation
Image masks (/ImageMask true) were decoded as opaque grayscale images, so they ignored the current non-stroking color and covered the page where the mask leaves samples unpainted. They now decode to coverage in a new PixelFormat::Alpha8, which the canvas paints in the fill color with the coverage as alpha, for both image XObjects and inline images. An explicit /Decode array on a mask now yields coverage like the default one does, instead of the inverse. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
/ImageMask true) were decoded as opaque grayscale images, so they ignored the current non-stroking color and painted over the page where the mask leaves samples unpainted.PixelFormat::Alpha8. The canvas paints that coverage in the fill color with the coverage as alpha, for both image XObjects and inline images. Backends still receive RGBA or Gray8 only; Skia mapsAlpha8to its native alpha type./Decodearray on a mask now yields coverage like the default does, instead of the inverse.Test plan
cargo conformance renderon a 1-bit interpolated image mask drawn with1 0 0 rg: paints red on a transparent background, matching PDFium. Variants without/Decode(opposite bits painted) and withca 0.5(half-transparent red) also checked.cargo testfor pdf-image, pdf-resources, pdf-canvas, pdf-document, pdf-renderer and pdf-graphicscargo clippyon the library crates andcargo fmt --check🤖 Generated with Claude Code