mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Fix ReadImage
This commit is contained in:
@ -4125,7 +4125,7 @@ namespace PdfReader
|
|||||||
return isMask;
|
return isMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RendererOutputDev::ReadDCT(Aggplus::CImage* pImageRes, Object *pRef, Stream *pStream)
|
bool RendererOutputDev::ReadImage(Aggplus::CImage* pImageRes, Object *pRef, Stream *pStream)
|
||||||
{
|
{
|
||||||
Object oIm;
|
Object oIm;
|
||||||
int nLength = 0;
|
int nLength = 0;
|
||||||
@ -4140,35 +4140,39 @@ namespace PdfReader
|
|||||||
if (!nLength)
|
if (!nLength)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
BYTE* pBuffer = new BYTE[nLength];
|
|
||||||
StreamKind nSKB = pStream->getBaseStream()->getKind();
|
StreamKind nSKB = pStream->getBaseStream()->getKind();
|
||||||
|
Stream* pStrIn = NULL;
|
||||||
if (nSKB == strFile)
|
if (nSKB == strFile)
|
||||||
{
|
pStrIn = (FileStream*)(pStream->getBaseStream());
|
||||||
FileStream* pFS = (FileStream*)(pStream->getBaseStream());
|
|
||||||
int nReadData = pFS->getBlock((char*)pBuffer, nLength);
|
|
||||||
if (nReadData != nLength)
|
|
||||||
{
|
|
||||||
RELEASEARRAYOBJECTS(pBuffer);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (nSKB == strWeird)
|
else if (nSKB == strWeird)
|
||||||
{
|
pStrIn = dynamic_cast<MemStream*>(pStream->getBaseStream());
|
||||||
MemStream* pMemory = dynamic_cast<MemStream*>(pStream->getBaseStream());
|
|
||||||
if (pMemory)
|
BYTE* pBuffer = new BYTE[nLength];
|
||||||
{
|
if (!pStrIn)
|
||||||
int nReadData = pMemory->getBlock((char*)pBuffer, nLength);
|
|
||||||
if (nReadData != nLength)
|
|
||||||
{
|
{
|
||||||
RELEASEARRAYOBJECTS(pBuffer);
|
RELEASEARRAYOBJECTS(pBuffer);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int nFileType = 0;
|
unsigned int nFileType = 0;
|
||||||
if (pStream->getKind() == strDCT)
|
StreamKind nSK = pStream->getKind();
|
||||||
|
if (nSK == strDCT)
|
||||||
|
{
|
||||||
nFileType = _CXIMAGE_FORMAT_JPG;
|
nFileType = _CXIMAGE_FORMAT_JPG;
|
||||||
|
if (pStrIn->getBlock((char*)pBuffer, nLength) != nLength)
|
||||||
|
{
|
||||||
|
RELEASEARRAYOBJECTS(pBuffer);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (nSK == strFlate)
|
||||||
|
{
|
||||||
|
if (pStrIn->getBlock((char*)pBuffer, nLength) != nLength)
|
||||||
|
{
|
||||||
|
RELEASEARRAYOBJECTS(pBuffer);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CBgraFrame oFrame;
|
CBgraFrame oFrame;
|
||||||
if (oFrame.Decode(pBuffer, nLength, nFileType))
|
if (oFrame.Decode(pBuffer, nLength, nFileType))
|
||||||
@ -4190,7 +4194,7 @@ namespace PdfReader
|
|||||||
StreamKind nSK = pStream->getKind();
|
StreamKind nSK = pStream->getKind();
|
||||||
|
|
||||||
// Чтение jpeg через cximage происходит быстрее чем через xpdf на ~40%
|
// Чтение jpeg через cximage происходит быстрее чем через xpdf на ~40%
|
||||||
if (nSK != strDCT || !ReadDCT(&oImage, pRef, pStream))
|
if ((nSK != strDCT && nSK != strFlate) || !ReadImage(&oImage, pRef, pStream))
|
||||||
{
|
{
|
||||||
int nBufferSize = 4 * nWidth * nHeight;
|
int nBufferSize = 4 * nWidth * nHeight;
|
||||||
if (nBufferSize < 1)
|
if (nBufferSize < 1)
|
||||||
|
|||||||
@ -222,7 +222,7 @@ namespace PdfReader
|
|||||||
virtual GBool beginMCOShapes(GfxState *state, GString *s, Object *ref) override;
|
virtual GBool beginMCOShapes(GfxState *state, GString *s, Object *ref) override;
|
||||||
virtual void endMarkedContent(GfxState *state) override;
|
virtual void endMarkedContent(GfxState *state) override;
|
||||||
//----- Вывод картинок
|
//----- Вывод картинок
|
||||||
bool ReadDCT(Aggplus::CImage* pImageRes, Object *pRef, Stream *pStream);
|
bool ReadImage(Aggplus::CImage* pImageRes, Object *pRef, Stream *pStream);
|
||||||
virtual void drawImageMask(GfxState *pGState, Object *pRef, Stream *pStream, int nWidth, int nHeight, GBool bInvert, GBool bInlineImage, GBool interpolate) override;
|
virtual void drawImageMask(GfxState *pGState, Object *pRef, Stream *pStream, int nWidth, int nHeight, GBool bInvert, GBool bInlineImage, GBool interpolate) override;
|
||||||
virtual void setSoftMaskFromImageMask(GfxState *pGState, Object *pRef, Stream *pStream, int nWidth, int nHeight, GBool bInvert, GBool bInlineImage, GBool interpolate) override;
|
virtual void setSoftMaskFromImageMask(GfxState *pGState, Object *pRef, Stream *pStream, int nWidth, int nHeight, GBool bInvert, GBool bInlineImage, GBool interpolate) override;
|
||||||
virtual void drawImage(GfxState *pGState, Object *pRef, Stream *pStream, int nWidth, int nHeight, GfxImageColorMap *pColorMap, int *pMaskColors, GBool bInlineImg, GBool interpolate) override;
|
virtual void drawImage(GfxState *pGState, Object *pRef, Stream *pStream, int nWidth, int nHeight, GfxImageColorMap *pColorMap, int *pMaskColors, GBool bInlineImg, GBool interpolate) override;
|
||||||
|
|||||||
Reference in New Issue
Block a user