Fix PDF transparent gradient alpha loss on SMask.#1442
Merged
Conversation
shlzxjp
approved these changes
May 22, 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.
修复 PDF 导出带透明度的线性/径向/锥形/菱形渐变时颜色错误的问题。
CreateSmaskGraphicState 构造 luminosity SMask 用的渐变副本时,只把每个 stop 的 alpha 清成 1.0,没有把原 alpha 编码进 RGB。luminosity SMask 取颜色亮度作为 alpha mask,因此 RGB 必须等于 (alpha, alpha, alpha) 才能表达透明度;否则 SMask 渲染为纯白(亮度=1),相当于完全不透明,原 alpha 信息丢失。
修复方式:将原 alpha 写入 RGB 三通道后再将 alpha 设为 1.0,luminosity 正确反映各 stop 的透明度。
新增测试 PDFExportTest.LinearGradientWhiteAlpha,覆盖 50% 到 10% 白色透明渐变叠在黑底上的导出场景。