Skip to content

Commit

Permalink
For bug 70996
Browse files Browse the repository at this point in the history
  • Loading branch information
K0R0L committed Nov 8, 2024
1 parent ab2ab7a commit 9a5240c
Showing 1 changed file with 45 additions and 44 deletions.
89 changes: 45 additions & 44 deletions DesktopEditor/graphics/GraphicsRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -955,61 +955,62 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
}

Aggplus::CBrushTexture* pTextureBrush = NULL;

if (NULL != m_pCache)
{
pCacheImage = (CCacheImage*)m_pCache->Lock(m_oBrush.TexturePath);

pTextureBrush = new Aggplus::CBrushTexture(pCacheImage->GetImage(), oMode);
if (NULL != m_oBrush.Image)
{
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.Image, oMode);
}
else
else if (m_oBrush.TexturePath.find(L"data:") == 0)
{
#ifdef BUILDING_WASM_MODULE
if (NULL != m_oBrush.Image)
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.Image, oMode);
else if (m_oBrush.TexturePath.find(L"data:") == 0)
bool bIsOnlyOfficeHatch = false;
if (m_oBrush.TexturePath.find(L"onlyoffice_hatch") != std::wstring::npos)
bIsOnlyOfficeHatch = true;

int countErase = (int)(m_oBrush.TexturePath.find(',') + 1);
int nInputSize = (int)(m_oBrush.TexturePath.length() - countErase);
const wchar_t* pInputSrc = m_oBrush.TexturePath.c_str() + countErase;

int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(nInputSize);
BYTE* pImageData = new BYTE[nDecodeLen];
if (TRUE == NSBase64::Base64Decode(pInputSrc, nInputSize, pImageData, &nDecodeLen))
{
bool bIsOnlyOfficeHatch = false;
if (m_oBrush.TexturePath.find(L"onlyoffice_hatch") != std::wstring::npos)
bIsOnlyOfficeHatch = true;
std::string sBase64MultyByte(m_oBrush.TexturePath.begin(), m_oBrush.TexturePath.end());
sBase64MultyByte.erase(0, sBase64MultyByte.find(',') + 1);
int nDecodeLen = NSBase64::Base64DecodeGetRequiredLength(sBase64MultyByte.length());
BYTE* pImageData = new BYTE[nDecodeLen + 64];
if (TRUE == NSBase64::Base64Decode(sBase64MultyByte.c_str(), sBase64MultyByte.length(), pImageData, &nDecodeLen))
CBgraFrame oFrame;
if (bIsOnlyOfficeHatch)
{
CBgraFrame oFrame;
if (bIsOnlyOfficeHatch)
{
int nSize = (int)sqrt(nDecodeLen >> 2);
oFrame.put_IsRGBA(true);
oFrame.put_Data(pImageData);
oFrame.put_Width(nSize);
oFrame.put_Height(nSize);
oFrame.put_Stride(4 * nSize);
}
else
{
oFrame.put_IsRGBA(false);
oFrame.Decode(pImageData, nDecodeLen);
RELEASEARRAYOBJECTS(pImageData);
}
// pImage отдается pTextureBrush и освобождается вместе с pBrush
Aggplus::CImage* pImage = new Aggplus::CImage();
pImage->Create(oFrame.get_Data(), oFrame.get_Width(), oFrame.get_Height(), oFrame.get_Stride());
oFrame.ClearNoAttack();
pTextureBrush = new Aggplus::CBrushTexture(pImage, oMode);
pTextureBrush->m_bReleaseImage = TRUE;
int nSize = (int)sqrt(nDecodeLen >> 2);
oFrame.put_IsRGBA(true);
oFrame.put_Data(pImageData);
oFrame.put_Width(nSize);
oFrame.put_Height(nSize);
oFrame.put_Stride(4 * nSize);
}
else
{
oFrame.put_IsRGBA(false);
oFrame.Decode(pImageData, nDecodeLen);
RELEASEARRAYOBJECTS(pImageData);
}
// pImage отдается pTextureBrush и освобождается вместе с pBrush
Aggplus::CImage* pImage = new Aggplus::CImage();
pImage->Create(oFrame.get_Data(), oFrame.get_Width(), oFrame.get_Height(), oFrame.get_Stride());
oFrame.ClearNoAttack();
pTextureBrush = new Aggplus::CBrushTexture(pImage, oMode);
pTextureBrush->m_bReleaseImage = TRUE;
}
#else
if (NULL != m_oBrush.Image)
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.Image, oMode);
else
RELEASEARRAYOBJECTS(pImageData);
}
else
{
if (NULL != m_pCache)
{
pCacheImage = (CCacheImage*)m_pCache->Lock(m_oBrush.TexturePath);
pTextureBrush = new Aggplus::CBrushTexture(pCacheImage->GetImage(), oMode);
}
else
{
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.TexturePath, oMode);
#endif
}
}

if( pTextureBrush )
Expand Down

0 comments on commit 9a5240c

Please sign in to comment.