diff --git a/Include/Library/OcCompressionLib.h b/Include/Library/OcCompressionLib.h index 29d9801d..8cf47594 100644 --- a/Include/Library/OcCompressionLib.h +++ b/Include/Library/OcCompressionLib.h @@ -127,6 +127,7 @@ DecompressZLIB ( @param[in] SrcLen Source buffer size. @param[in] Mask Source buffer. @param[in] MaskLen Source buffer size. + @param[in] Premultiply Multiply source channels by alpha. @return DecompressedLen on success otherwise 0. **/ @@ -137,7 +138,8 @@ DecompressMaskedRLE24 ( IN UINT8 *Src, IN UINT32 SrcLen, IN UINT8 *Mask, - IN UINT32 MaskLen + IN UINT32 MaskLen, + IN BOOLEAN Premultiply ); #endif // OC_COMPRESSION_LIB_H diff --git a/Library/OcCompressionLib/OcCompressionLib.c b/Library/OcCompressionLib/OcCompressionLib.c index 8afbcffd..00915e08 100644 --- a/Library/OcCompressionLib/OcCompressionLib.c +++ b/Library/OcCompressionLib/OcCompressionLib.c @@ -21,7 +21,8 @@ DecompressMaskedRLE24 ( IN UINT8 *Src, IN UINT32 SrcLen, IN UINT8 *Mask, - IN UINT32 MaskLen + IN UINT32 MaskLen, + IN BOOLEAN Premultiply ) { // @@ -113,13 +114,26 @@ DecompressMaskedRLE24 ( } // - // Put mask to the resulting image. + // Add mask to the resulting BGRA image. // - DstCur = Dst + RunIndex; - DstEnd = Dst + MaskLen * sizeof (UINT32); - while (DstCur < DstEnd) { - *DstCur = *Mask++; - DstCur += sizeof (UINT32); + if (Premultiply) { + DstCur = Dst; + SrcEnd = Mask + MaskLen; + while (Mask < SrcEnd) { + DstValue = *Mask++; + DstCur[0] = (UINT8) ((DstCur[0] * DstValue) / 0xFF); + DstCur[1] = (UINT8) ((DstCur[1] * DstValue) / 0xFF); + DstCur[2] = (UINT8) ((DstCur[2] * DstValue) / 0xFF); + DstCur[3] = DstValue; + DstCur += sizeof (UINT32); + } + } else { + DstCur = Dst + 3; + SrcEnd = Mask + MaskLen; + while (Mask < SrcEnd) { + *DstCur = *Mask++; + DstCur += sizeof (UINT32); + } } return MaskLen * sizeof (UINT32); diff --git a/Platform/OpenCanopy/OpenCanopy.c b/Platform/OpenCanopy/OpenCanopy.c index fc28bba1..bb793abd 100644 --- a/Platform/OpenCanopy/OpenCanopy.c +++ b/Platform/OpenCanopy/OpenCanopy.c @@ -1325,7 +1325,8 @@ GuiIcnsToImageIcon ( RecordIT32->Data + sizeof (UINT32), SwapBytes32 (RecordIT32->Size) - sizeof (APPLE_ICNS_RECORD) - sizeof (UINT32), RecordT8MK->Data, - SwapBytes32 (RecordT8MK->Size) - sizeof (APPLE_ICNS_RECORD) + SwapBytes32 (RecordT8MK->Size) - sizeof (APPLE_ICNS_RECORD), + TRUE ); if (DecodedBytes != ImageSize) {