mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-20 03:08:28 +08:00
fix fonts in folder, xps in folder
This commit is contained in:
@ -168,6 +168,46 @@ void CXpsFile::DrawPageOnRenderer(IRenderer* pRenderer, int nPageIndex, bool* pB
|
||||
|
||||
m_pInternal->m_pDocument->DrawPage(nPageIndex, pRenderer, pBreak);
|
||||
}
|
||||
BYTE* CXpsFile::ConvertToPixels(int nPageIndex, int nRasterW, int nRasterH)
|
||||
{
|
||||
NSFonts::IFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* pFontCache = NSFonts::NSFontCache::Create();
|
||||
pFontCache->SetStreams(m_pInternal->m_pAppFonts->GetStreams());
|
||||
pFontManager->SetOwnerCache(pFontCache);
|
||||
|
||||
NSGraphics::IGraphicsRenderer* pRenderer = NSGraphics::Create();
|
||||
pRenderer->SetFontManager(pFontManager);
|
||||
|
||||
double dPageDpiX, dPageDpiY;
|
||||
double dWidth, dHeight;
|
||||
GetPageInfo(nPageIndex, &dWidth, &dHeight, &dPageDpiX, &dPageDpiY);
|
||||
|
||||
int nWidth = (nRasterW > 0) ? nRasterW : ((int)dWidth * 96 / dPageDpiX);
|
||||
int nHeight = (nRasterH > 0) ? nRasterH : ((int)dHeight * 96 / dPageDpiX);
|
||||
|
||||
BYTE* pBgraData = new BYTE[nWidth * nHeight * 4];
|
||||
if (!pBgraData)
|
||||
return NULL;
|
||||
|
||||
memset(pBgraData, 0xff, nWidth * nHeight * 4);
|
||||
CBgraFrame oFrame;
|
||||
oFrame.put_Data(pBgraData);
|
||||
oFrame.put_Width(nWidth);
|
||||
oFrame.put_Height(nHeight);
|
||||
oFrame.put_Stride(-4 * nWidth);
|
||||
|
||||
pRenderer->CreateFromBgraFrame(&oFrame);
|
||||
pRenderer->SetSwapRGB(false);
|
||||
pRenderer->put_Width(dWidth);
|
||||
pRenderer->put_Height(dHeight);
|
||||
|
||||
bool bBreak = false;
|
||||
DrawPageOnRenderer(pRenderer, nPageIndex, &bBreak);
|
||||
|
||||
RELEASEINTERFACE(pFontManager);
|
||||
RELEASEOBJECT(pRenderer);
|
||||
return pBgraData;
|
||||
}
|
||||
void CXpsFile::ConvertToRaster(int nPageIndex, const std::wstring& wsDstPath, int nImageType, const int nRasterW, const int nRasterH)
|
||||
{
|
||||
NSFonts::IFontManager *pFontManager = m_pInternal->m_pAppFonts->GenerateFontManager();
|
||||
|
||||
Reference in New Issue
Block a user