From ecd66f774df4f39c3a74dcfb91b6f33bb51207ca Mon Sep 17 00:00:00 2001 From: James Zern Date: Mon, 8 Oct 2012 18:15:30 -0700 Subject: [PATCH] cwebp: fix jpg encodes on XP correct has_alpha check; previously it was controlled by keep_alpha, which overrode the source format check. fixes issue #127 Change-Id: I949be90419b03610c64900be0fd37f83b70cbe73 --- examples/cwebp.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/examples/cwebp.c b/examples/cwebp.c index 8441e94c..7b76c83f 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -179,18 +179,19 @@ static HRESULT ReadPictureWithWIC(const char* filename, IFS(IWICBitmapFrameDecode_GetPixelFormat(pFrame, &srcPixelFormat)); IFS(IWICBitmapDecoder_GetContainerFormat(pDecoder, &srcContainerFormat)); - has_alpha = keep_alpha; - for (i = 0; - has_alpha && i < sizeof(alphaContainers)/sizeof(alphaContainers[0]); - ++i) { - if (IsEqualGUID(MAKE_REFGUID(srcContainerFormat), - MAKE_REFGUID(*alphaContainers[i]))) { - has_alpha = - IsEqualGUID(MAKE_REFGUID(srcPixelFormat), - MAKE_REFGUID(GUID_WICPixelFormat32bppRGBA_)) || - IsEqualGUID(MAKE_REFGUID(srcPixelFormat), - MAKE_REFGUID(GUID_WICPixelFormat32bppBGRA_)); - break; + if (keep_alpha) { + for (i = 0; + i < sizeof(alphaContainers) / sizeof(alphaContainers[0]); + ++i) { + if (IsEqualGUID(MAKE_REFGUID(srcContainerFormat), + MAKE_REFGUID(*alphaContainers[i]))) { + has_alpha = + IsEqualGUID(MAKE_REFGUID(srcPixelFormat), + MAKE_REFGUID(GUID_WICPixelFormat32bppRGBA_)) || + IsEqualGUID(MAKE_REFGUID(srcPixelFormat), + MAKE_REFGUID(GUID_WICPixelFormat32bppBGRA_)); + break; + } } }