mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Redesigned work with the alpha mask
This commit is contained in:
@ -22,6 +22,7 @@ namespace Aggplus
|
||||
BYTE* GetBuffer();
|
||||
|
||||
void SetDefaultSettings();
|
||||
void ClearBuffer(bool bDeleteData = true);
|
||||
|
||||
void SetSettings(const TGraphicsLayerSettings& oSettings);
|
||||
const TGraphicsLayerSettings& GetSettings() const;
|
||||
@ -31,7 +32,7 @@ namespace Aggplus
|
||||
template <class SrcPixelFormatRenderer>
|
||||
void BlendTo(SrcPixelFormatRenderer& oSrc)
|
||||
{
|
||||
if (NULL == m_pBuffer)
|
||||
if (NULL == m_pBuffer || 0 == oSrc.width() || 0 == oSrc.height())
|
||||
return;
|
||||
|
||||
typedef typename SrcPixelFormatRenderer::order_type order_type;
|
||||
@ -71,6 +72,40 @@ namespace Aggplus
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class AlphaMaskFunction, class SrcPixelFormatRenderer>
|
||||
void BlendTo(SrcPixelFormatRenderer& oSrc, BYTE* pAlphaMaskBuffer, UINT unAlphaMaskStep)
|
||||
{
|
||||
if (NULL == m_pBuffer || 0 == oSrc.width() || 0 == oSrc.height())
|
||||
return;
|
||||
|
||||
typedef typename SrcPixelFormatRenderer::order_type order_type;
|
||||
typedef typename SrcPixelFormatRenderer::value_type value_type;
|
||||
|
||||
int nStep = 4;
|
||||
BYTE* pSrcBuffer = m_pBuffer;
|
||||
value_type* pDstBuffer = NULL;
|
||||
BYTE* pSrcAlphaMaskBuffer = pAlphaMaskBuffer;
|
||||
|
||||
unsigned int unSrcW = oSrc.width();
|
||||
unsigned int unSrcH = oSrc.height();
|
||||
|
||||
for (unsigned int unY = 0; unY < unSrcH; ++unY)
|
||||
{
|
||||
pDstBuffer = oSrc.row_ptr(unY);
|
||||
for (unsigned int unX = 0; unX < unSrcW; ++unX)
|
||||
{
|
||||
pDstBuffer[order_type::R] = pSrcBuffer[order_type::R];
|
||||
pDstBuffer[order_type::G] = pSrcBuffer[order_type::G];
|
||||
pDstBuffer[order_type::B] = pSrcBuffer[order_type::B];
|
||||
pDstBuffer[order_type::A] = ((SrcPixelFormatRenderer::base_mask + (value_type)m_oSettings.m_dOpacity * pSrcBuffer[order_type::A] * AlphaMaskFunction::calculate(pSrcAlphaMaskBuffer)) >> 8);;
|
||||
|
||||
pSrcBuffer += nStep;
|
||||
pDstBuffer += nStep;
|
||||
pSrcAlphaMaskBuffer += unAlphaMaskStep;
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
BYTE* m_pBuffer;
|
||||
bool m_bExternalBuffer;
|
||||
|
||||
Reference in New Issue
Block a user