mirror of
https://github.com/ONLYOFFICE/desktop-sdk.git
synced 2026-02-10 18:15:05 +08:00
Fix tile dpi scale
This commit is contained in:
@ -866,7 +866,8 @@ namespace NSEditorApi
|
||||
virtual void InitRenderer(void* pRenderer, void* pFontManager) {}
|
||||
|
||||
virtual void PrepareBitBlt(void* pRenderer, const int& nRasterX, const int& nRasterY, const int& nRasterW, const int& nRasterH,
|
||||
const double& x, const double& y, const double& w, const double& h, const double& dAngle) {}
|
||||
const double& x, const double& y, const double& w, const double& h, const double& dAngle,
|
||||
const double& tileScaleX, const double& tileScaleY) {}
|
||||
|
||||
virtual void SetPageOrientation(int nOrientaion) {}
|
||||
|
||||
|
||||
@ -77,7 +77,8 @@ public:
|
||||
virtual void InitRenderer(void* pRenderer, void* pFontManager);
|
||||
|
||||
virtual void PrepareBitBlt(void* pRenderer, const int& nRasterX, const int& nRasterY, const int& nRasterW, const int& nRasterH,
|
||||
const double& x, const double& y, const double& w, const double& h, const double& dAngle);
|
||||
const double& x, const double& y, const double& w, const double& h, const double& dAngle,
|
||||
const double& tileScaleX, const double& tileScaleY);
|
||||
|
||||
virtual void SetPageOrientation(int nOrientaion);
|
||||
|
||||
|
||||
@ -465,14 +465,19 @@ namespace NSConversions
|
||||
double dDpiY = dTileDpi;
|
||||
pRenderer->get_DpiX(&dDpiX);
|
||||
pRenderer->get_DpiY(&dDpiY);
|
||||
double dTileScaleX = 1.0;
|
||||
double dTileScaleY = 1.0;
|
||||
pRenderer->GetTileScaleX(dTileScaleX);
|
||||
pRenderer->GetTileScaleY(dTileScaleY);
|
||||
|
||||
double dScaleX = dDpiX / (dTileDpi * pRenderer->GetCoordTransform().m11());
|
||||
double dScaleY = dDpiY / (dTileDpi * pRenderer->GetCoordTransform().m22());
|
||||
|
||||
double dScaleX = dDpiX / (dTileDpi * pRenderer->GetCoordTransform().m11() * dTileScaleX);
|
||||
double dScaleY = dDpiY / (dTileDpi * pRenderer->GetCoordTransform().m22() * dTileScaleY);
|
||||
|
||||
if (pLogicBrush && pLogicBrush->Rectable)
|
||||
{
|
||||
double dOffsetX = (oPathBounds.left() - (pLogicBrush->Rect.X + pLogicBrush->OffsetX)) / nImageWidth;
|
||||
double dOffsetY = (oPathBounds.top() - (pLogicBrush->Rect.Y + pLogicBrush->OffsetY)) / nImageHeight;
|
||||
double dOffsetX = (oPathBounds.left() - pLogicBrush->Rect.X) / nImageWidth;
|
||||
double dOffsetY = (oPathBounds.top() - pLogicBrush->Rect.Y) / nImageHeight;
|
||||
|
||||
//dOffsetX *= (dDpiX / dTileDpi);
|
||||
//dOffsetY *= (dDpiY / dTileDpi);
|
||||
@ -517,6 +522,9 @@ void NSQRenderer::CQRenderer::InitDefaults()
|
||||
m_nPixelWidth = 0;
|
||||
m_nPixelHeight = 0;
|
||||
|
||||
m_dTileScaleX = 1.0;
|
||||
m_dTileScaleY = 1.0;
|
||||
|
||||
m_lCurrentCommand = c_nNone;
|
||||
m_oSimpleGraphicsConverter.SetRenderer(this);
|
||||
|
||||
@ -2020,11 +2028,15 @@ void NSQRenderer::CQRenderer::ResetBaseTransform()
|
||||
}
|
||||
|
||||
void NSQRenderer::CQRenderer::PrepareBitBlt(const int& nRasterX, const int& nRasterY, const int& nRasterW, const int& nRasterH,
|
||||
const double& x, const double& y, const double& w, const double& h, const double& dAngle)
|
||||
const double& x, const double& y, const double& w, const double& h, const double& dAngle,
|
||||
const double& tileScaleX, const double& tileScaleY)
|
||||
{
|
||||
m_nPixelWidth = nRasterW;
|
||||
m_nPixelHeight = nRasterH;
|
||||
|
||||
m_dTileScaleX = tileScaleX;
|
||||
m_dTileScaleY = tileScaleY;
|
||||
|
||||
int nPhysicalX = 0;
|
||||
int nPhysicalY = 0;
|
||||
int nPhysicalW = 0;
|
||||
@ -2080,6 +2092,16 @@ void NSQRenderer::CQRenderer::PrepareBitBlt(const int& nRasterX, const int& nRas
|
||||
}
|
||||
}
|
||||
|
||||
void NSQRenderer::CQRenderer::GetTileScaleX(double& sx) const
|
||||
{
|
||||
sx = m_dTileScaleX;
|
||||
}
|
||||
|
||||
void NSQRenderer::CQRenderer::GetTileScaleY(double& sy) const
|
||||
{
|
||||
sy = m_dTileScaleY;
|
||||
}
|
||||
|
||||
QTransform& NSQRenderer::CQRenderer::GetCoordTransform()
|
||||
{
|
||||
return m_oCoordTransform;
|
||||
|
||||
@ -262,10 +262,11 @@ void QAscPrinterContext::BitBlt(unsigned char* pBGRA, const int& nRasterX, const
|
||||
}
|
||||
|
||||
void QAscPrinterContext::PrepareBitBlt(void* pRenderer, const int& nRasterX, const int& nRasterY, const int& nRasterW, const int& nRasterH,
|
||||
const double& x, const double& y, const double& w, const double& h, const double& dAngle)
|
||||
const double& x, const double& y, const double& w, const double& h, const double& dAngle,
|
||||
const double& tileScaleX, const double& tileScaleY)
|
||||
{
|
||||
((NSQRenderer::CQRenderer*)pRenderer)->PrepareBitBlt(nRasterX, nRasterY, nRasterW, nRasterH,
|
||||
x, y, w, h, dAngle);
|
||||
x, y, w, h, dAngle, tileScaleX, tileScaleY);
|
||||
}
|
||||
|
||||
void QAscPrinterContext::DrawImage(QPainter* painter, const QImage& image, const QRect& rect, const QRect& rectSrc)
|
||||
|
||||
@ -797,6 +797,15 @@ void CPrintData::Print(NSEditorApi::CAscPrinterContextBase* pContext, const CAsc
|
||||
|
||||
int nRasterW = (int)(oPagePrintData.WidthPix + 0.5);
|
||||
int nRasterH = (int)(oPagePrintData.HeightPix + 0.5);
|
||||
|
||||
double dTileScaleX = 1.0;
|
||||
double dTileScaleY = 1.0;
|
||||
|
||||
if (oPagePrintData.PageWidth * oPagePrintData.PrintHeightMM > oPagePrintData.PrintWidthMM * oPagePrintData.PageHeight)
|
||||
dTileScaleX = dTileScaleY = oPagePrintData.PageWidth / oPagePrintData.PrintWidthMM;
|
||||
else
|
||||
dTileScaleX = dTileScaleY = oPagePrintData.PageHeight / oPagePrintData.PrintHeightMM;
|
||||
|
||||
#ifdef _XCODE
|
||||
// 16 bit align pixPerRow
|
||||
nRasterW += 8;
|
||||
@ -853,7 +862,7 @@ void CPrintData::Print(NSEditorApi::CAscPrinterContextBase* pContext, const CAsc
|
||||
pContext->SaveState();
|
||||
|
||||
pContext->PrepareBitBlt(pNativeRenderer, 0, 0, nRasterW, nRasterH,
|
||||
oPagePrintData.LeftPix, oPagePrintData.TopPix, oPagePrintData.WidthPix, oPagePrintData.HeightPix, oPagePrintData.Angle);
|
||||
oPagePrintData.LeftPix, oPagePrintData.TopPix, oPagePrintData.WidthPix, oPagePrintData.HeightPix, oPagePrintData.Angle, dTileScaleX, dTileScaleY);
|
||||
|
||||
pContext->InitRenderer(pNativeRenderer, m_pFontManager);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user