From abef221c7c985e087a631bc7136d3ed99dec853c Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Mon, 10 Jan 2011 14:36:19 -0600 Subject: [PATCH 1/5] windowscodecs: Ignore the alpha channel of ICO files if it's empty. --- dlls/windowscodecs/icoformat.c | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/dlls/windowscodecs/icoformat.c b/dlls/windowscodecs/icoformat.c index e6a590f..1e939d7 100644 --- a/dlls/windowscodecs/icoformat.c +++ b/dlls/windowscodecs/icoformat.c @@ -277,6 +277,30 @@ static HRESULT ReadIcoDib(IStream *stream, IcoFrameDecode *result) IWICBitmapFrameDecode_Release(framedecode); } + if (SUCCEEDED(hr) && has_alpha) + { + /* If the alpha channel is fully transparent, we should ignore it. */ + int nonzero_alpha = 0; + int i; + + for (i=0; i<(result->height*result->width); i++) + { + if (result->bits[i*4+3] != 0) + { + nonzero_alpha = 1; + break; + } + } + + if (!nonzero_alpha) + { + for (i=0; i<(result->height*result->width); i++) + result->bits[i*4+3] = 0xff; + + has_alpha = FALSE; + } + } + if (SUCCEEDED(hr) && !has_alpha) { /* set alpha data based on the AND mask */ -- 1.7.1