Commit 67173592 authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander Trofimov

Исправлено падение при чтении файлов, в которых присутствовал клип по тексту....

Исправлено падение при чтении файлов, в которых присутствовал клип по тексту. Исправлен баг с клипом по тексту, когда размер текста задавался через матрицу преобразования. Исправлен баг с отрисовкой картинок с альфа-маской, у которых маска была больше, чем сама картинка.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@65192 954022d7-b5bf-4e40-9824-e11837661b57
parent 5a76c1d8
......@@ -129,7 +129,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions);_CRT_SECURE_NO_WARNINGS;NOMINMAX</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\DesktopEditor\agg-2.4\include;..\DesktopEditor\freetype-2.5.2\include;..\DesktopEditor\cximage\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
......
......@@ -1478,9 +1478,9 @@ namespace PdfReader
{
for (int nIndex = 0; nIndex < m_nTextsCount; ++nIndex)
{
FreeWString(m_pTexts->wsText);
FreeWString(m_pTexts->wsFontName);
FreeWString(m_pTexts->wsFontPath);
FreeWString(m_pTexts[nIndex].wsText);
FreeWString(m_pTexts[nIndex].wsFontName);
FreeWString(m_pTexts[nIndex].wsFontPath);
}
MemUtilsFree(m_pTexts);
MemUtilsFree(m_pMatrix);
......@@ -1490,7 +1490,9 @@ namespace PdfReader
{
for (int nIndex = 0; nIndex < m_nTextsCount; ++nIndex)
{
FreeWString(m_pTexts->wsText);
FreeWString(m_pTexts[nIndex].wsText);
FreeWString(m_pTexts[nIndex].wsFontName);
FreeWString(m_pTexts[nIndex].wsFontPath);
}
MemUtilsFree(m_pTexts);
MemUtilsFree(m_pMatrix);
......
......@@ -1193,7 +1193,7 @@ namespace PdfReader
case fontCIDType0:
case fontCIDType0C:
{
// TODO: Проверить, почему получение данной кодировки было отключено
//// TODO: Проверить, почему получение данной кодировки было отключено
//if ((pT1CFontFile = CFontFileType1C::LoadFromFile((wchar_t*)wsFileName.c_str())))
//{
// pCodeToGID = pT1CFontFile->GetCIDToGIDMap(&nLen);
......@@ -2732,7 +2732,6 @@ namespace PdfReader
double dShiftX = 0, dShiftY = 0;
DoTransform(pMatrix, &dShiftX, &dShiftY, true);
m_pRenderer->BeginCommand(c_nClipType);
m_pRenderer->put_ClipMode(c_nClipRegionTypeWinding | c_nClipRegionUnion);
m_pRenderer->PathCommandEnd();
......@@ -2929,6 +2928,20 @@ namespace PdfReader
//arrMatrix[4] += dAscentShiftX;
//arrMatrix[5] += dAscentShiftY;
if (true)
{
double dDet = sqrt(arrMatrix[0] * arrMatrix[3] - arrMatrix[1] * arrMatrix[2]);
arrMatrix[0] /= dDet;
arrMatrix[1] /= dDet;
arrMatrix[2] /= dDet;
arrMatrix[3] /= dDet;
double dSize = 1;
m_pRenderer->get_FontSize(&dSize);
m_pRenderer->put_FontSize(dSize * dDet);
}
double dShiftX = 0, dShiftY = 0;
DoTransform(arrMatrix, &dShiftX, &dShiftY, true);
......@@ -3016,7 +3029,7 @@ namespace PdfReader
{
m_pRenderer->BeginCommand(c_nStrokeTextType);
m_pRenderer->PathCommandEnd();
//m_pRenderer->PathCommandEnd();
//m_pRenderer->PathCommandText( bsText, PDFCoordsToMM( 0 + dShiftX ), PDFCoordsToMM( /*-fabs(pFont->GetFontBBox()[3]) * dTfs*/ + dShiftY ), PDFCoordsToMM( 0 ), PDFCoordsToMM( 0 ), PDFCoordsToMM( 0 ) );
......@@ -3301,8 +3314,7 @@ namespace PdfReader
{
ImageStream *pSMaskStream = new ImageStream(pMaskStream, nMaskWidth, pMaskColorMap->GetComponentsCount(), pMaskColorMap->GetBitsPerComponent());
unsigned char *pAlpha = new unsigned char[nMaskWidth * nMaskHeight];
if (pMaskStream && pAlpha)
if (pSMaskStream && pAlpha)
{
pSMaskStream->Reset();
......@@ -3320,8 +3332,50 @@ namespace PdfReader
}
delete pSMaskStream;
double dScaleWidth = (double)nMaskWidth / (double)nWidth;
double dScaleHeight = (double)nMaskHeight / (double)nHeight;
int nMaxW = std::max(nWidth, nMaskWidth);
int nMaxH = std::max(nHeight, nMaskHeight);
if (nWidth != nMaxW || nHeight != nMaxH)
{
unsigned char* pImageBuffer = pBufferPtr;
int nNewBufferSize = 4 * nMaxW * nMaxH;
pBufferPtr = new unsigned char[nNewBufferSize];
if (!pBufferPtr)
{
delete[] pImageBuffer;
delete[] pAlpha;
return;
}
oImage.Create(pBufferPtr, nMaxW, nMaxH, -4 * nMaxW);
double dImageScaleWidth = (double)nWidth / (double)nMaxW;
double dImageScaleHeight = (double)nHeight / (double)nMaxH;
double dAlphaScaleWidth = (double)nMaskWidth / (double)nMaxW;
double dAlphaScaleHeight = (double)nMaskHeight / (double)nMaxH;
for (int nY = nMaxH - 1; nY >= 0; nY--)
{
for (int nX = 0; nX < nMaxW; nX++)
{
int nIndex = 4 * (nY * nMaxW + nX);
int nNearestAlphaMatch = (((int)((nMaxH - 1 - nY) * dAlphaScaleHeight) * nMaskWidth) + ((int)(nX * dAlphaScaleWidth)));
int nNearestImageMatch = 4 * (((int)((nMaxH - 1 - nY) * dImageScaleHeight) * nWidth) + ((int)(nX * dImageScaleWidth)));
pBufferPtr[nIndex + 0] = pImageBuffer[nNearestImageMatch + 0];
pBufferPtr[nIndex + 1] = pImageBuffer[nNearestImageMatch + 1];
pBufferPtr[nIndex + 2] = pImageBuffer[nNearestImageMatch + 2];
pBufferPtr[nIndex + 3] = (unsigned char)(pAlpha[nNearestAlphaMatch] * dAlphaKoef);
}
}
delete[] pImageBuffer;
}
else
{
double dAlphaScaleWidth = (double)nMaskWidth / (double)nWidth;
double dAlphaScaleHeight = (double)nMaskHeight / (double)nHeight;
for (int nY = nHeight - 1; nY >= 0; nY--)
{
......@@ -3329,21 +3383,22 @@ namespace PdfReader
{
int nIndex = 4 * (nY * nWidth + nX);
int nNearestMatch = (((int)((nHeight - 1 - nY) * dScaleHeight) * nMaskWidth) + ((int)(nX * dScaleWidth)));
int nNearestAlphaMatch = (((int)((nHeight - 1 - nY) * dAlphaScaleHeight) * nMaskWidth) + ((int)(nX * dAlphaScaleWidth)));
pBufferPtr[nIndex + 3] = (unsigned char)(pAlpha[nNearestMatch] * dAlphaKoef);
pBufferPtr[nIndex + 3] = (unsigned char)(pAlpha[nNearestAlphaMatch] * dAlphaKoef);
}
}
}
delete pAlpha;
delete[] pAlpha;
}
else
{
if (pAlpha)
delete pAlpha;
delete[] pAlpha;
if (pMaskStream)
delete pMaskStream;
if (pSMaskStream)
delete pSMaskStream;
bResize = false;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment