Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 098ada5

Browse files
authored
Convert animated unpremul images to premul during decode (#8698)
Skia allows drawing unpremul images, but filtering them can look bad. Internally Skia performs this transformation when creating SkImages from encoded data (so this already happens for MakeCrossContextFromEncoded), and for consistency/quality it should be done here, too. Fixes #28785
1 parent c63d1cf commit 098ada5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/ui/painting/codec.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,10 @@ sk_sp<SkImage> MultiFrameCodec::GetNextFrameImage(
401401
: SkBitmap();
402402
const bool frameAlreadyCached = bitmap.getPixels();
403403
if (!frameAlreadyCached) {
404-
const SkImageInfo info = codec_->getInfo().makeColorType(kN32_SkColorType);
404+
SkImageInfo info = codec_->getInfo().makeColorType(kN32_SkColorType);
405+
if (info.alphaType() == kUnpremul_SkAlphaType) {
406+
info = info.makeAlphaType(kPremul_SkAlphaType);
407+
}
405408
bitmap.allocPixels(info);
406409

407410
SkCodec::Options options;

0 commit comments

Comments
 (0)