-
Notifications
You must be signed in to change notification settings - Fork 7.1k
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
Fix bug: PremultipliedAlpha is not working for png #19112
Conversation
@@ -1149,6 +1149,11 @@ bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen) | |||
{ | |||
premultipliedAlpha(); | |||
} | |||
else | |||
{ | |||
_hasPremultipliedAlpha = true; |
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.
Why enable premultipliedAlpha
even png format isn't RGBA8888, any errors? maybe you use CCImage
in wrong way.
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.
@drelaptop
oh, yes, if png format is not RGBA8888, premultipliedAlpha should not be true.
But, there is a case, I want to use PMA pngs to improve performance and prevent blend artifacts, so I use Image::setPNGPremultipliedAlphaEnabled(false)
, but it doesn't work, because CCImage.hasPremultipliedAlpha()
will return false at Texture2D::initWithImage
if you don't set premultipliedAlpha to true when png format is RGBA8888.
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.
@drelaptop The new PR is #19138, you can check it.
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.
sorry, you hope CCImage.hasPremultipliedAlpha()
return true
, but you did setPNGPremultipliedAlphaEnabled(false)
before. that is confusing.
no need to new a PR for same bug fix, you can commit to same branch, then PR will auto update.
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.
@drelaptop setPNGPremultipliedAlphaEnabled(false)
changes PNG_PREMULTIPLIED_ALPHA_ENABLED
to false, it tells cocos2dx that pngs have been PMAed by developers, so cocos2dx needn't to do premultipliedAlpha
, premultipliedAlpha
takes about 40ms for 2048*2048 pngs.
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.
@drelaptop I read CCImage.cpp
, and setPNGPremultipliedAlphaEnabled(false)
maybe the only way to use PMAed pngs.
Doesn't cocos2dx support PMAed pngs?
New PR is #19138. |
No description provided.