-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Fix alpha not applying to tinted image #3748
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
[description] Fix the issue where alpha values do not apply to the image.
|
This is designed behavior. You should add new enum option to control the blend mode. Such as I use the Atop for the original use case which mixed the target rect's color, this API is not designed to be the same effect as UIImage.tintColor at my original introduction there are also maybe use case which need other blend modes |
|
|
||
| // blend mode, see https://en.wikipedia.org/wiki/Alpha_compositing | ||
| CGBlendMode blendMode = kCGBlendModeSourceAtop; | ||
| CGBlendMode blendMode = kCGBlendModeSourceIn; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need new CGBlendMode and fix for CIFilter code path as well.
|
I've created #3749 for this. You can use Note: this But, in my original design, it's more like If you really want to change the |
|
Thanks for your reply. I will also take a look at the PR. |
|
@exponentChoi I decided to follow your idea. Change the default blend mode to For user who still want the This is a behavior break changes and I'll notify user on release changelog |


New Pull Request Checklist
I have read and understood the CONTRIBUTING guide
I have read the Documentation
I have searched for a similar pull request in the project and found none
I have updated this branch with the latest master to avoid conflicts (via merge from master or rebase)
I have added the required tests to prove the fix/feature I am adding
I have updated the documentation (if necessary)
I have run the tests and they pass
I have run the lint and it passes (
pod lib lint)This merge request fixes / refers to the following issues: ...
Pull Request Description
Fix the issue where alpha values do not apply to the image.
While using SDWebImage, I discovered that the alpha value for the image color was not being applied. The issue was caused by the CGBlendMode setting. When using kCGBlendModeSourceATop as before, the A color was being overwritten. To resolve this, I switched to using kCGBlendModeSourceIn, which effectively replaced the color. This change ensures that the alpha value is applied to the tintColor of UIImage, similar to how it behaves natively. I discovered this issue while testing with SVG images.
Reference
documentation - https://developer.apple.com/documentation/coregraphics/cgblendmode/