Skip to content

Commit 2f6846f

Browse files
sense-zzz-timehuangwei1024
authored andcommitted
ReFix bug: PremultipliedAlpha is not working for png (cocos2d#19138)
1 parent f22d1e2 commit 2f6846f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

cocos/platform/CCImage.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,9 +1145,18 @@ bool Image::initWithPngData(const unsigned char * data, ssize_t dataLen)
11451145
png_read_end(png_ptr, nullptr);
11461146

11471147
// premultiplied alpha for RGBA8888
1148-
if (PNG_PREMULTIPLIED_ALPHA_ENABLED && color_type == PNG_COLOR_TYPE_RGB_ALPHA)
1148+
if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
11491149
{
1150-
premultipliedAlpha();
1150+
if (PNG_PREMULTIPLIED_ALPHA_ENABLED)
1151+
{
1152+
premultipliedAlpha();
1153+
}
1154+
else
1155+
{
1156+
#if CC_ENABLE_PREMULTIPLIED_ALPHA != 0
1157+
_hasPremultipliedAlpha = true;
1158+
#endif
1159+
}
11511160
}
11521161

11531162
if (row_pointers != nullptr)

0 commit comments

Comments
 (0)