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

Исправлен баг в графическом рендерере с текстурным брашем. Доработка WMF,...

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

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62380 954022d7-b5bf-4e40-9824-e11837661b57
parent 360230eb
......@@ -555,9 +555,11 @@ namespace Aggplus
}
double dWidth = pPen->Size;
if (0 == dWidth && !m_bIntegerGrid)
double dWidthMinSize = 1.0 / sqrt(m_oCoordTransform.m_agg_mtx.determinant());
if ((0 == dWidth && !m_bIntegerGrid) || dWidth < dWidthMinSize)
{
dWidth = 1.0 / sqrt(m_oCoordTransform.m_agg_mtx.determinant());
dWidth = dWidthMinSize;
}
double dblMiterLimit = pPen->MiterLimit;
......
......@@ -831,17 +831,29 @@ HRESULT CGraphicsRenderer::DrawPath(const LONG& nType)
if (m_oBrush.Type == c_BrushTypeTexture || m_oBrush.Type == c_BrushTypePattern)
{
Aggplus::WrapMode oMode = Aggplus::WrapModeClamp;
switch (m_oBrush.TextureMode)
{
case c_BrushTextureModeTile:
oMode = Aggplus::WrapModeTile;
break;
case c_BrushTextureModeTileCenter:
oMode = Aggplus::WrapModeTile;
break;
default:
break;
}
Aggplus::CBrushTexture* pTextureBrush = NULL;
if (NULL != m_pCache)
{
pCacheImage = m_pCache->Lock(m_oBrush.TexturePath);
pTextureBrush = new Aggplus::CBrushTexture(pCacheImage->GetImage(), /*(Aggplus::WrapMode)TextureMode*/Aggplus::WrapModeClamp);
pTextureBrush = new Aggplus::CBrushTexture(pCacheImage->GetImage(), oMode);
}
else
{
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.TexturePath, /*(Aggplus::WrapMode)TextureMode*/Aggplus::WrapModeClamp);
pTextureBrush = new Aggplus::CBrushTexture(m_oBrush.TexturePath, oMode);
}
if( pTextureBrush )
......
......@@ -17,22 +17,22 @@ namespace MetaFile
virtual void End() = 0;
// pBuffer - BGRA ulWidth, ulHeight,
virtual void DrawBitmap(int nX, int nY, int nW, int nH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight) = 0;
virtual void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight) = 0;
virtual void DrawString(std::wstring& wsText, unsigned int unCharsCount, int nX, int nY, int nTextW, bool bWithOutLast) = 0;
virtual void DrawString(std::wstring& wsText, unsigned int unCharsCount, double dX, double dY, int nTextW, bool bWithOutLast) = 0;
virtual void StartPath() = 0;
virtual void MoveTo(int nX, int nY) = 0;
virtual void LineTo(int nX, int nY) = 0;
virtual void CurveTo(int nX1, int nY1, int nX2, int nY2, int nXe, int nYe) = 0;
virtual void ArcTo(int nLeft, int nTop, int nRight, int nBottom, double dStartAngle, double dSweepAngle) = 0;
virtual void MoveTo(double dX, double dY) = 0;
virtual void LineTo(double dX, double dY) = 0;
virtual void CurveTo(double dX1, double dY1, double dX2, double dY2, double dXe, double dYe) = 0;
virtual void ArcTo(double dLeft, double dTop, double dRight, double dBottom, double dStartAngle, double dSweepAngle) = 0;
virtual void ClosePath() = 0;
virtual void DrawPath(int nType = 0) = 0;
virtual void EndPath() = 0;
virtual void ResetClip() = 0;
virtual void IntersectClip(int nLeft, int nTop, int nRight, int nBottom) = 0;
virtual void StartClipPath(unsigned int unMode) = 0;
virtual void IntersectClip(double dLeft, double dTop, double dRight, double dBottom) = 0;
virtual void StartClipPath(unsigned int unMode, int nFillMode = -1) = 0;
virtual void EndClipPath(unsigned int unMode) = 0;
virtual void UpdateDC() = 0;
......
......@@ -26,8 +26,8 @@ namespace MetaFile
virtual void PlayMetaFile() = 0;
virtual void ClearFile() {/* , */}
virtual double TranslateX(int nX) = 0;
virtual double TranslateY(int nY) = 0;
//virtual double TranslateX(int nX) = 0;
//virtual double TranslateY(int nY) = 0;
virtual TRect* GetDCBounds() = 0;
virtual double GetPixelHeight() = 0;
virtual double GetPixelWidth() = 0;
......@@ -39,12 +39,13 @@ namespace MetaFile
virtual unsigned int GetTextBgMode() = 0;
virtual int GetTextBgColor() = 0;
virtual unsigned int GetFillMode() = 0;
virtual TPointL GetCurPos() = 0;
virtual TPointD GetCurPos() = 0;
virtual TXForm* GetInverseTransform() = 0;
virtual TXForm* GetTransform() = 0;
virtual unsigned int GetMiterLimit() = 0;
virtual unsigned int GetRop2Mode() = 0;
virtual IClip* GetClip() = 0;
virtual int GetCharSpace() = 0;
bool OpenFromFile(const wchar_t* wsFilePath)
{
......
......@@ -57,7 +57,7 @@ namespace MetaFile
CheckEndPath();
}
void DrawBitmap(int lX, int lY, int lW, int lH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight)
void DrawBitmap(double dX, double dY, double dW, double dH, BYTE* pBuffer, unsigned int unWidth, unsigned int unHeight)
{
if (!pBuffer || 0 == unWidth || 0 == unHeight)
return;
......@@ -80,11 +80,11 @@ namespace MetaFile
pBufferPtr += 4;
}
TPointD oTL = TranslatePoint(lX, lY);
TPointD oBR = TranslatePoint(lX + lW, lY + lH);
TPointD oTL = TranslatePoint(dX, dY);
TPointD oBR = TranslatePoint(dX + dW, dY + dH);
m_pRenderer->DrawImage(&oImage, oTL.x, oTL.y, oBR.x - oTL.x, oBR.y - oTL.y);
}
void DrawString(std::wstring& wsText, unsigned int ulCharsCount, int lX, int lY, int nTextW, bool bWithOutLast)
void DrawString(std::wstring& wsText, unsigned int ulCharsCount, double _dX, double _dY, int nTextW, bool bWithOutLast)
{
CheckEndPath();
......@@ -101,7 +101,7 @@ namespace MetaFile
if (lLogicalFontHeight < 0.01)
lLogicalFontHeight = 18;
double dFontHeight = lLogicalFontHeight * m_dScaleY * m_pFile->GetPixelHeight() / 25.4 * 72;
double dFontHeight = abs(lLogicalFontHeight * m_dScaleY * m_pFile->GetPixelHeight() / 25.4 * 72);
std::wstring wsFaceName = pFont->GetFaceName();
m_pRenderer->put_FontName(wsFaceName);
......@@ -126,23 +126,19 @@ namespace MetaFile
float fL = 0, fT = 0, fW = 0, fH = 0;
float fUndX1 = 0, fUndY1 = 0, fUndX2 = 0, fUndY2 = 0, fUndSize = 1;
m_pRenderer->put_FontCharSpace(0);
double dFontCharSpace = m_pFile->GetCharSpace() * m_dScaleX * m_pFile->GetPixelWidth();
m_pRenderer->put_FontCharSpace(dFontCharSpace);
CFontManager* pFontManager = m_pFile->GetFontManager();
if (pFontManager)
{
pFontManager->SetCharSpacing(0);
pFontManager->LoadFontByName(wsFaceName, dFontHeight, lStyle, 72, 72);
pFontManager->SetCharSpacing(dFontCharSpace * 72 / 25.4);
double dMmToPt = 25.4 / 72;
double dFHeight = dFontHeight * pFontManager->m_pFont->GetHeight() / pFontManager->m_pFont->m_lUnits_Per_Em * dMmToPt;
double dFDescent = dFontHeight * pFontManager->m_pFont->GetDescender() / pFontManager->m_pFont->m_lUnits_Per_Em * dMmToPt;
double dFAscent = dFHeight - std::abs(dFDescent);
//
pFontManager->GetUnderline(&fUndX1, &fUndY1, &fUndX2, &fUndY2, &fUndSize);
fUndX1 *= (float)dMmToPt; fUndY1 *= (float)dMmToPt;
fUndX2 *= (float)dMmToPt; fUndY2 *= (float)dMmToPt;
fUndSize *= (float)dMmToPt / 2;
if (0 != nTextW && ulCharsCount > 1)
{
std::wstring wsTempText = wsText;
......@@ -162,10 +158,8 @@ namespace MetaFile
if (dCharSpace > 0.001 || dCharSpace < -0.001)
{
pFontManager->SetCharSpacing(dCharSpace);
double dRendDpiX;
m_pRenderer->get_DpiX(&dRendDpiX);
m_pRenderer->put_FontCharSpace(dCharSpace * 25.4 / 72);
pFontManager->SetCharSpacing(dFontCharSpace + dCharSpace);
m_pRenderer->put_FontCharSpace((dFontCharSpace + dCharSpace) * 25.4 / 72);
}
pFontManager->LoadString1(wsText, 0, 0);
......@@ -184,8 +178,15 @@ namespace MetaFile
fT = (float)dMmToPt * (oBox.fMinY);
fW = (float)dMmToPt * (oBox.fMaxX - oBox.fMinX);
fH = (float)dMmToPt * (oBox.fMaxY - oBox.fMinY);
}
//
pFontManager->GetUnderline(&fUndX1, &fUndY1, &fUndX2, &fUndY2, &fUndSize);
fUndX1 *= (float)dMmToPt; fUndY1 *= (float)dMmToPt;
fUndX2 *= (float)dMmToPt; fUndY2 *= (float)dMmToPt;
fUndSize *= (float)dMmToPt / 2;
if (std::abs(fT) < dFAscent)
{
if (fT < 0)
......@@ -198,7 +199,7 @@ namespace MetaFile
fH = (float)dFHeight;
}
TPointD oTextPoint = TranslatePoint(lX, lY);
TPointD oTextPoint = TranslatePoint(_dX, _dY);
double dX = oTextPoint.x;
double dY = oTextPoint.y;
......@@ -330,33 +331,33 @@ namespace MetaFile
m_bStartedPath = true;
}
void MoveTo(int lX, int lY)
void MoveTo(double dX, double dY)
{
CheckStartPath(true);
TPointD oPoint = TranslatePoint(lX, lY);
TPointD oPoint = TranslatePoint(dX, dY);
m_pRenderer->PathCommandMoveTo(oPoint.x, oPoint.y);
}
void LineTo(int lX, int lY)
void LineTo(double dX, double dY)
{
CheckStartPath(false);
TPointD oPoint = TranslatePoint(lX, lY);
TPointD oPoint = TranslatePoint(dX, dY);
m_pRenderer->PathCommandLineTo(oPoint.x, oPoint.y);
}
void CurveTo(int lX1, int lY1, int lX2, int lY2, int lXe, int lYe)
void CurveTo(double dX1, double dY1, double dX2, double dY2, double dXe, double dYe)
{
CheckStartPath(false);
TPointD oPoint1 = TranslatePoint(lX1, lY1);
TPointD oPoint2 = TranslatePoint(lX2, lY2);
TPointD oPointE = TranslatePoint(lXe, lYe);
TPointD oPoint1 = TranslatePoint(dX1, dY1);
TPointD oPoint2 = TranslatePoint(dX2, dY2);
TPointD oPointE = TranslatePoint(dXe, dYe);
m_pRenderer->PathCommandCurveTo(oPoint1.x, oPoint1.y, oPoint2.x, oPoint2.y, oPointE.x, oPointE.y);
}
void ArcTo(int lLeft, int lTop, int lRight, int lBottom, double dStart, double dSweep)
void ArcTo(double dLeft, double dTop, double dRight, double dBottom, double dStart, double dSweep)
{
CheckStartPath(false);
TPointD oTL = TranslatePoint(lLeft, lTop);
TPointD oBR = TranslatePoint(lRight, lBottom);
TPointD oTL = TranslatePoint(dLeft, dTop);
TPointD oBR = TranslatePoint(dRight, dBottom);
m_pRenderer->PathCommandArcTo(oTL.x, oTL.y, oBR.x - oTL.x, oBR.y - oTL.y, dStart, dSweep);
}
void ClosePath()
......@@ -377,21 +378,21 @@ namespace MetaFile
bool bStroke = lType & 1 ? true : false;
bool bFill = lType & 2 ? true : false;
int m_lEndType = -1;
int nEndType = -1;
if (bStroke && (m_lDrawPathType & c_nStroke))
m_lEndType = c_nStroke;
nEndType = c_nStroke;
if (bFill)
{
if (m_lDrawPathType & c_nWindingFillMode)
m_lEndType = (-1 == m_lDrawPathType ? c_nWindingFillMode : m_lDrawPathType | c_nWindingFillMode);
nEndType = (-1 == nEndType ? c_nWindingFillMode : nEndType | c_nWindingFillMode);
else if (m_lDrawPathType & c_nEvenOddFillMode)
m_lEndType = (-1 == m_lDrawPathType ? c_nEvenOddFillMode : m_lDrawPathType | c_nEvenOddFillMode);
nEndType = (-1 == nEndType ? c_nEvenOddFillMode : nEndType | c_nEvenOddFillMode);
}
if (-1 != m_lEndType)
m_pRenderer->DrawPath(m_lEndType);
if (-1 != nEndType)
m_pRenderer->DrawPath(nEndType);
}
}
void EndPath()
......@@ -410,7 +411,7 @@ namespace MetaFile
m_pRenderer->BeginCommand(c_nResetClipType);
m_pRenderer->EndCommand(c_nResetClipType);
}
void IntersectClip(int lLeft, int lTop, int lRight, int lBottom)
void IntersectClip(double dLeft, double dTop, double dRight, double dBottom)
{
m_pRenderer->put_ClipMode(c_nClipRegionTypeWinding | c_nClipRegionIntersect);
......@@ -418,8 +419,8 @@ namespace MetaFile
m_pRenderer->BeginCommand(c_nPathType);
m_pRenderer->PathCommandStart();
TPointD oTL = TranslatePoint(lLeft, lTop);
TPointD oBR = TranslatePoint(lRight, lBottom);
TPointD oTL = TranslatePoint(dLeft, dTop);
TPointD oBR = TranslatePoint(dRight, dBottom);
m_pRenderer->PathCommandMoveTo(oTL.x, oTL.y);
m_pRenderer->PathCommandLineTo(oTL.x, oBR.y);
......@@ -431,7 +432,7 @@ namespace MetaFile
m_pRenderer->EndCommand(c_nClipType);
m_pRenderer->PathCommandEnd();
}
void StartClipPath(unsigned int unMode)
void StartClipPath(unsigned int unMode, int nFillMode = -1)
{
CheckEndPath();
......@@ -447,7 +448,8 @@ namespace MetaFile
default: unClipMode = c_nClipRegionIntersect; break;
}
unsigned int unFillMode = m_pFile->GetFillMode();
unsigned int unFillMode = -1 == nFillMode ? m_pFile->GetFillMode() : nFillMode;
if (ALTERNATE == unFillMode)
unClipMode |= c_nClipRegionTypeEvenOdd;
else //if (WINDING == unFillMode)
......@@ -477,7 +479,7 @@ namespace MetaFile
if (!bMoveTo)
{
TPointL oCurPos = m_pFile->GetCurPos();
TPointD oCurPos = m_pFile->GetCurPos();
MoveTo(oCurPos.x, oCurPos.y);
}
}
......@@ -491,24 +493,8 @@ namespace MetaFile
}
}
TPointD TranslatePoint(int nX, int nY)
TPointD TranslatePoint(double dX, double dY)
{
double dX = m_pFile->TranslateX(nX);
double dY = m_pFile->TranslateY(nY);
// . ,
// .
TRect* pBounds = m_pFile->GetDCBounds();
double dT = pBounds->nTop;
double dL = pBounds->nLeft;
TEmfXForm* pInverse = m_pFile->GetInverseTransform();
TEmfXForm* pTransform = m_pFile->GetTransform();
pTransform->Apply(dX, dY);
dX -= dL;
dY -= dT;
pInverse->Apply(dX, dY);
TPointD oPoint;
oPoint.x = m_dScaleX * dX + m_dX;
oPoint.y = m_dScaleY * dY + m_dY;
......@@ -530,11 +516,44 @@ namespace MetaFile
m_pRenderer->put_BrushTextureMode(c_BrushTextureModeTile);
m_pRenderer->put_BrushTexturePath(pBrush->GetDibPatterPath());
}
else if (BS_HATCHED == unBrushStyle)
{
m_pRenderer->put_BrushType(c_BrushTypeHatch1);
std::wstring wsBrushType = L"horz";
switch (pBrush->GetHatch())
{
case HS_HORIZONTAL: wsBrushType = L"horz"; break;
case HS_VERTICAL: wsBrushType = L"vert"; break;
case HS_FDIAGONAL: wsBrushType = L"dnDiag"; break;
case HS_BDIAGONAL: wsBrushType = L"upDiag"; break;
case HS_CROSS: wsBrushType = L"cross"; break;
case HS_DIAGCROSS: wsBrushType = L"diagCross"; break;
}
// TODO: , Hatch RGB, BGR
if (TRANSPARENT == m_pFile->GetTextBgMode())
m_pRenderer->put_BrushAlpha2(0);
else
{
m_pRenderer->put_BrushAlpha2(255);
TColor oBgColor(m_pFile->GetTextBgColor());
oBgColor.SwapRGBtoBGR();
m_pRenderer->put_BrushColor2(oBgColor.ToInt());
}
TColor oFgColor(pBrush->GetColor());
oFgColor.SwapRGBtoBGR();
m_pRenderer->put_BrushTexturePath(wsBrushType);
m_pRenderer->put_BrushAlpha1(255);
m_pRenderer->put_BrushColor1(oFgColor.ToInt());
}
else //if (BS_SOLID == unBrushStyle)
{
m_pRenderer->put_BrushType(c_BrushTypeSolid);
m_pRenderer->put_BrushColor1(pBrush->GetColor());
m_pRenderer->put_BrushAlpha1(pBrush->GetAlpha());
m_pRenderer->put_BrushType(c_BrushTypeSolid);
}
return true;
......@@ -586,13 +605,88 @@ namespace MetaFile
double dMiterLimit = m_pFile->GetMiterLimit() * m_dScaleX * dPixelWidth;
// TODO: , PS_SOLID.
// TODO: PS_USERSTYLE
BYTE nDashStyle;
if (PS_ALTERNATE == ulPenStyle || PS_USERSTYLE == ulPenStyle || PS_INSIDEFRAME == ulPenStyle)
nDashStyle = (BYTE)PS_SOLID;
else if (PS_NULL != ulPenStyle)
nDashStyle = (BYTE)ulPenStyle;
BYTE nDashStyle = Aggplus::DashStyleSolid;;
// WinGDI 1px PS_SOLID
if (1 == pPen->GetWidth() && PS_SOLID != ulPenStyle)
{
dWidth = 0; // 1p
double dDpiX;
m_pRenderer->get_DpiX(&dDpiX);
double dPixelW = dDpiX > 1 ? 25.4 / dDpiX : 25.4 / 72;
double dDashOff = 0;
double* pDashPattern = NULL;
int nDashLen = 0;
switch (ulPenStyle)
{
case PS_DASH:
{
dDashOff = 0 * dPixelW;
nDashLen = 2;
pDashPattern = new double[2];
if (pDashPattern)
{
pDashPattern[0] = 18 * dPixelW;
pDashPattern[1] = 3 * dPixelW;
}
break;
}
case PS_DOT:
{
dDashOff = 4 * dPixelW;
nDashLen = 2;
pDashPattern = new double[2];
if (pDashPattern)
{
pDashPattern[0] = 3 * dPixelW;
pDashPattern[1] = 3 * dPixelW;
}
break;
}
case PS_DASHDOT:
{
dDashOff = 22 * dPixelW;
nDashLen = 4;
pDashPattern = new double[4];
if (pDashPattern)
{
pDashPattern[0] = 9 * dPixelW;
pDashPattern[1] = 6 * dPixelW;
pDashPattern[2] = 3 * dPixelW;
pDashPattern[3] = 6 * dPixelW;
}
break;
}
case PS_DASHDOTDOT:
{
dDashOff = 22 * dPixelW;
nDashLen = 6;
pDashPattern = new double[6];
if (pDashPattern)
{
pDashPattern[0] = 9 * dPixelW;
pDashPattern[1] = 3 * dPixelW;
pDashPattern[2] = 3 * dPixelW;
pDashPattern[3] = 3 * dPixelW;
pDashPattern[4] = 3 * dPixelW;
pDashPattern[5] = 3 * dPixelW;
}
break;
}
}
if (NULL != pDashPattern)
{
m_pRenderer->put_PenDashOffset(dDashOff);
m_pRenderer->PenDashPattern(pDashPattern, nDashLen);
nDashStyle = Aggplus::DashStyleCustom;
delete[] pDashPattern;
}
}
m_pRenderer->put_PenDashStyle(nDashStyle);
m_pRenderer->put_PenLineJoin(nJoinStyle);
......
......@@ -16,6 +16,8 @@ typedef unsigned char BYTE;
#define NULL 0
#endif
#define METAFILE_RGBA(r, g, b) ((unsigned int)( ( (unsigned char)(r) )| ( ( (unsigned char)(g) ) << 8 ) | ( ( (unsigned char)(b) ) << 16 ) | ( (unsigned char)(0) << 24 ) ) )
#if !defined (_WIN32) && !defined(_WIN64)
#define BLACKONWHITE 1
#define WHITEONBLACK 2
......@@ -301,6 +303,17 @@ namespace MetaFile
{
double x;
double y;
TPointD()
{
x = 0;
y = 0;
}
TPointD(double _x, double _y)
{
x = _x;
y = _y;
}
};
struct TColor
......@@ -308,6 +321,29 @@ namespace MetaFile
unsigned char r;
unsigned char g;
unsigned char b;
TColor()
{
r = 0;
g = 0;
b = 0;
}
TColor(int nValue)
{
r = (nValue & 0xFF);
g = (nValue >> 8) & 0xFF;
b = (nValue >> 16) & 0xFF;
}
int ToInt()
{
return METAFILE_RGBA(r, g, b);
}
void SwapRGBtoBGR()
{
unsigned char t = r;
r = b;
b = t;
}
};
struct TXForm
......@@ -319,6 +355,26 @@ namespace MetaFile
double Dx;
double Dy;
TXForm()
{
M11 = 1;
M12 = 0;
M21 = 0;
M22 = 1;
Dx = 0;
Dy = 0;
}
TXForm(double m11, double m12, double m21, double m22, double dx, double dy)
{
M11 = m11;
M12 = m12;
M21 = m21;
M22 = m22;
Dx = dx;
Dy = dy;
}
void Init()
{
M11 = 1;
......
......@@ -196,7 +196,7 @@ namespace MetaFile
{
// ,
nBitCount = nLastBitCount;
nAlpha = 0;
//nAlpha = 0;
}
for (int nBitIndex = nBitCount; nBitIndex > 0; nBitIndex /= 2)
......@@ -860,7 +860,8 @@ namespace MetaFile
{
unsigned int unIndex = (unY * unWidth + unX) * 4;
if (0xff == pCur[unIndex + 0] && 0xff == pCur[unIndex + 1] && 0xff == pCur[unIndex + 2])
if ((0xff == pCur[unIndex + 0] && 0xff == pCur[unIndex + 1] && 0xff == pCur[unIndex + 2]) ||
(0x00 == pCur[unIndex + 0] && 0x00 == pCur[unIndex + 1] && 0x00 == pCur[unIndex + 2]))
pCur[unIndex + 3] = 0;
}
}
......@@ -874,7 +875,8 @@ namespace MetaFile
{
unsigned int unIndex = (unY * unWidth + unX) * 4;
if (0 == pCur[unIndex + 0] && 0 == pCur[unIndex + 1] && 0 == pCur[unIndex + 2])
if ((0xff == pCur[unIndex + 0] && 0xff == pCur[unIndex + 1] && 0xff == pCur[unIndex + 2]) ||
(0x00 == pCur[unIndex + 0] && 0x00 == pCur[unIndex + 1] && 0x00 == pCur[unIndex + 2]))
pCur[unIndex + 3] = 0;
}
}
......
......@@ -12,8 +12,6 @@
namespace MetaFile
{
#define METAFILE_RGBA(r, g, b) ((DWORD)( ( (BYTE)(r) )| ( ( (BYTE)(g) ) << 8 ) | ( ( (BYTE)(b) ) << 16 ) | ( (BYTE)(0) << 24 ) ) )
struct TRgbQuad
{
unsigned char r;
......
......@@ -284,10 +284,15 @@ namespace MetaFile
{
return m_pDC->GetFillMode();
}
TPointL GetCurPos()
TPointD GetCurPos()
{
TPointL oPoint = m_pDC->GetCurPos();
return oPoint;
// TODO:
TPointD oRes;
oRes.x = oPoint.x;
oRes.y = oPoint.y;
return oRes;
}
TXForm* GetInverseTransform()
{
......@@ -313,6 +318,10 @@ namespace MetaFile
return (IClip*)pClip;
}
int GetCharSpace()
{
return 0;
}
private:
......
......@@ -2,7 +2,7 @@
#define _METAFILE_EMF_EMFOBJECTS_H
#include "EmfTypes.h"
#include "../../common/Types.h"
//#include "../../common/Types.h"
#include "../Common/MetaFileObjects.h"
#include "../../../common/File.h"
......
......@@ -157,6 +157,10 @@ namespace MetaFile
double dHeight = nHeight ;//* 72 / 25.4 / dDpiY;
BYTE* pBgraData = new BYTE[nWidth * nHeight * 4];
if (!pBgraData)
return;
memset(pBgraData, 0x00, nWidth * nHeight * 4);
CBgraFrame oFrame;
oFrame.put_Data(pBgraData);
oFrame.put_Width(nWidth);
......
#ifndef _METAFILE_H
#define _METAFILE_H
#define NEW_WMF 1
#include "../../fontengine/ApplicationFonts.h"
#include "../../graphics/IRenderer.h"
......
......@@ -118,8 +118,10 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>..\..\agg-2.4\include;..\..\freetype-2.5.2\include;..\..\cximage\jasper\include;..\..\cximage\jpeg;..\..\cximage\png;..\..\cximage\zlib;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<DisableSpecificWarnings>4005;4018</DisableSpecificWarnings>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
......
......@@ -21,13 +21,13 @@ namespace MetaFile
case WMF_CLIPCOMMAND_INTERSECT:
{
CWmfClipCommandIntersect* pI = (CWmfClipCommandIntersect*)pCommand;
pNewCommand = new CWmfClipCommandIntersect(pI->m_shL, pI->m_shT, pI->m_shR, pI->m_shB);
pNewCommand = new CWmfClipCommandIntersect(pI->m_dL, pI->m_dT, pI->m_dR, pI->m_dB);
break;
}
case WMF_CLIPCOMMAND_EXCLUDE:
{
CWmfClipCommandExclude* pE = (CWmfClipCommandExclude*)pCommand;
pNewCommand = new CWmfClipCommandExclude(pE->m_shL, pE->m_shT, pE->m_shR, pE->m_shB, pE->m_oBB);
pNewCommand = new CWmfClipCommandExclude(pE->m_dL, pE->m_dT, pE->m_dR, pE->m_dB, pE->m_dWindowL, pE->m_dWindowT, pE->m_dWindowR, pE->m_dWindowB);
break;
}
}
......@@ -40,18 +40,18 @@ namespace MetaFile
{
Clear();
}
bool CWmfClip::Intersect(short shL, short shT, short shR, short shB)
bool CWmfClip::Intersect(double dL, double dT, double dR, double dB)
{
CWmfClipCommandBase* pCommand = new CWmfClipCommandIntersect(shL, shT, shR, shB);
CWmfClipCommandBase* pCommand = new CWmfClipCommandIntersect(dL, dT, dR, dB);
if (!pCommand)
return false;
m_vCommands.push_back(pCommand);
return true;
}
bool CWmfClip::Exclude(short shL, short shT, short shR, short shB, TRect oBB)
bool CWmfClip::Exclude(double dL, double dT, double dR, double dB, double dWindowL, double dWindowT, double dWindowR, double dWindowB)
{
CWmfClipCommandBase* pCommand = new CWmfClipCommandExclude(shL, shT, shR, shB, oBB);
CWmfClipCommandBase* pCommand = new CWmfClipCommandExclude(dL, dT, dR, dB, dWindowL, dWindowT, dWindowR, dWindowB);
if (!pCommand)
return false;
......@@ -82,11 +82,11 @@ namespace MetaFile
{
CWmfClipCommandIntersect* pIntersect = (CWmfClipCommandIntersect*)pCommand;
pOutput->StartClipPath(RGN_AND);
pOutput->MoveTo(pIntersect->m_shL, pIntersect->m_shT);
pOutput->LineTo(pIntersect->m_shR, pIntersect->m_shT);
pOutput->LineTo(pIntersect->m_shR, pIntersect->m_shB);
pOutput->LineTo(pIntersect->m_shL, pIntersect->m_shB);
pOutput->StartClipPath(RGN_AND, ALTERNATE);
pOutput->MoveTo(pIntersect->m_dL, pIntersect->m_dT);
pOutput->LineTo(pIntersect->m_dR, pIntersect->m_dT);
pOutput->LineTo(pIntersect->m_dR, pIntersect->m_dB);
pOutput->LineTo(pIntersect->m_dL, pIntersect->m_dB);
pOutput->ClosePath();
pOutput->EndClipPath(RGN_AND);
......@@ -96,20 +96,21 @@ namespace MetaFile
{
CWmfClipCommandExclude* pExclude = (CWmfClipCommandExclude*)pCommand;
pOutput->StartClipPath(RGN_AND);
pOutput->StartClipPath(RGN_AND, ALTERNATE);
pOutput->MoveTo(pExclude->m_oBB.nLeft, pExclude->m_oBB.nTop);
pOutput->LineTo(pExclude->m_oBB.nRight, pExclude->m_oBB.nTop);
pOutput->LineTo(pExclude->m_oBB.nRight, pExclude->m_oBB.nBottom);
pOutput->LineTo(pExclude->m_oBB.nLeft, pExclude->m_oBB.nBottom);
pOutput->MoveTo(pExclude->m_dL, pExclude->m_dT);
pOutput->LineTo(pExclude->m_dR, pExclude->m_dT);
pOutput->LineTo(pExclude->m_dR, pExclude->m_dB);
pOutput->LineTo(pExclude->m_dL, pExclude->m_dB);
pOutput->ClosePath();
pOutput->MoveTo(pExclude->m_shL, pExclude->m_shT);
pOutput->LineTo(pExclude->m_shR, pExclude->m_shT);
pOutput->LineTo(pExclude->m_shR, pExclude->m_shB);
pOutput->LineTo(pExclude->m_shL, pExclude->m_shB);
pOutput->MoveTo(pExclude->m_dWindowL, pExclude->m_dWindowT);
pOutput->LineTo(pExclude->m_dWindowR, pExclude->m_dWindowT);
pOutput->LineTo(pExclude->m_dWindowR, pExclude->m_dWindowB);
pOutput->LineTo(pExclude->m_dWindowL, pExclude->m_dWindowB);
pOutput->ClosePath();
pOutput->EndClipPath(RGN_AND);
break;
......
......@@ -33,12 +33,12 @@ namespace MetaFile
class CWmfClipCommandIntersect : public CWmfClipCommandBase
{
public:
CWmfClipCommandIntersect(short shL, short shT, short shR, short shB)
CWmfClipCommandIntersect(double dL, double dT, double dR, double dB)
{
m_shL = shL;
m_shT = shT;
m_shR = shR;
m_shB = shB;
m_dL = dL;
m_dT = dT;
m_dR = dR;
m_dB = dB;
}
~CWmfClipCommandIntersect()
{
......@@ -50,21 +50,24 @@ namespace MetaFile
public:
short m_shL;
short m_shT;
short m_shR;
short m_shB;
double m_dL;
double m_dT;
double m_dR;
double m_dB;
};
class CWmfClipCommandExclude : public CWmfClipCommandBase
{
public:
CWmfClipCommandExclude(short shL, short shT, short shR, short shB, TRect oBB)
CWmfClipCommandExclude(double dL, double dT, double dR, double dB, double dWindowL, double dWindowT, double dWindowR, double dWindowB)
{
m_shL = shL;
m_shT = shT;
m_shR = shR;
m_shB = shB;
m_oBB = oBB;
m_dL = dL;
m_dT = dT;
m_dR = dR;
m_dB = dB;
m_dWindowL = dWindowL;
m_dWindowT = dWindowT;
m_dWindowR = dWindowR;
m_dWindowB = dWindowB;
}
~CWmfClipCommandExclude()
{
......@@ -76,11 +79,14 @@ namespace MetaFile
public:
TRect m_oBB;
short m_shL;
short m_shT;
short m_shR;
short m_shB;
double m_dL;
double m_dT;
double m_dR;
double m_dB;
double m_dWindowL;
double m_dWindowT;
double m_dWindowR;
double m_dWindowB;
};
class CWmfClip : public IClip
......@@ -91,8 +97,8 @@ namespace MetaFile
void operator=(CWmfClip& oClip);
void Reset();
bool Intersect(short shL, short shT, short shR, short shB);
bool Exclude(short shL, short shT, short shR, short shB, TRect oBB);
bool Intersect(double dL, double dT, double dR, double dB);
bool Exclude(double dL, double dT, double dR, double dB, double dLbb, double dTbb, double dRbb, double dBbb);
// IClip
void ClipOnRenderer(IOutputDevice* pOutput);
......
......@@ -71,6 +71,7 @@ namespace MetaFile
m_oStream >> ushType;
m_unRecordSize = unSize * 2; // Размер указан в WORD
switch (ushType)
{
//-----------------------------------------------------------
......@@ -193,27 +194,6 @@ namespace MetaFile
m_oPlayer.Clear();
m_pDC = m_oPlayer.GetDC();
}
double TranslateX(int nSrcX)
{
double dDstX;
TWmfWindow* pWindow = m_pDC->GetWindow();
TWmfWindow* pViewport = m_pDC->GetViewport();
dDstX = (double)((double)(nSrcX - pWindow->x) * m_pDC->GetPixelWidth()) + pViewport->x;
return dDstX;
}
double TranslateY(int nSrcY)
{
double dDstY;
TWmfWindow* pWindow = m_pDC->GetWindow();
TWmfWindow* pViewport = m_pDC->GetViewport();
dDstY = (double)((double)(nSrcY - pWindow->y) * m_pDC->GetPixelHeight()) + pViewport->y;
return dDstY;
}
TRect* GetDCBounds()
{
TWmfWindow* pViewport = m_pDC->GetViewport();
......@@ -294,10 +274,12 @@ namespace MetaFile
{
return (unsigned int)m_pDC->GetPolyFillMode();
}
TPointL GetCurPos()
TPointD GetCurPos()
{
TPointL oPoint = m_pDC->GetCurPos();
return oPoint;
double dX, dY;
TranslatePoint(oPoint.x, oPoint.y, dX, dY);
return TPointD(dX, dY);
}
TXForm* GetInverseTransform()
{
......@@ -323,9 +305,35 @@ namespace MetaFile
return (IClip*)pClip;
}
int GetCharSpace()
{
return m_pDC->GetCharSpacing();
}
private:
void TranslatePoint(short shX, short shY, double& dX, double &dY)
{
TWmfWindow* pWindow = m_pDC->GetWindow();
TWmfWindow* pViewport = m_pDC->GetViewport();
dX = (double)((double)(shX - pWindow->x) * m_pDC->GetPixelWidth()) + pViewport->x;
dY = (double)((double)(shY - pWindow->y) * m_pDC->GetPixelHeight()) + pViewport->y;
// Координаты приходят уже с примененной матрицей. Поэтому сначала мы умножаем на матрицу преобразования,
// вычитаем начальные координаты и умножаем на обратную матрицу преобразования.
TRect* pBounds = GetDCBounds();
double dT = pBounds->nTop;
double dL = pBounds->nLeft;
TEmfXForm* pInverse = GetInverseTransform();
TEmfXForm* pTransform = GetTransform();
pTransform->Apply(dX, dY);
dX -= dL;
dY -= dT;
pInverse->Apply(dX, dY);
}
TRect GetBoundingBox()
{
TRect oBB;
......@@ -369,7 +377,9 @@ namespace MetaFile
{
if (m_pOutput)
{
m_pOutput->MoveTo(shX, shY);
double dX, dY;
TranslatePoint(shX, shY, dX, dY);
m_pOutput->MoveTo(dX, dY);
}
else
{
......@@ -381,7 +391,9 @@ namespace MetaFile
{
if (m_pOutput)
{
m_pOutput->LineTo(shX, shY);
double dX, dY;
TranslatePoint(shX, shY, dX, dY);
m_pOutput->LineTo(dX, dY);
}
else
{
......@@ -395,7 +407,10 @@ namespace MetaFile
// Текущая точка обновляется на том уровне, на котором вызывалась данная функция.
if (m_pOutput)
{
m_pOutput->ArcTo(shL, shT, shR, shB, dStart, dSweep);
double dL, dT, dR, dB;
TranslatePoint(shL, shT, dL, dT);
TranslatePoint(shR, shB, dR, dB);
m_pOutput->ArcTo(dL, dT, dR, dB, dStart, dSweep);
}
else
{
......@@ -431,8 +446,6 @@ namespace MetaFile
nY = m_pDC->GetCurPos().y;
}
if (m_pOutput)
{
IFont* pFont = GetFont();
NSString::CConverter::ESingleByteEncoding eCharSet = NSString::CConverter::ESingleByteEncoding::SINGLE_BYTE_ENCODING_DEFAULT;;
if (pFont)
......@@ -485,14 +498,133 @@ namespace MetaFile
}
std::wstring wsText = NSString::CConverter::GetUnicodeFromSingleByteString((const unsigned char*)pString, (long)unCharsCount, eCharSet);
m_pOutput->DrawString(wsText, unCharsCount, nX, nY, nTextW, bWithOutLast);
if (m_pOutput)
{
double dX, dY;
TranslatePoint(nX, nY, dX, dY);
m_pOutput->DrawString(wsText, unCharsCount, dX, dY, nTextW, bWithOutLast);
}
else
{
// TODO: Здесь идет точное повторение кода из CMetaFileRenderer->DrawString
// неплохо бы перенести этот пересчет в базовый класс IMetaFileBase.
CFontManager* pFontManager = GetFontManager();
if (pFont && pFontManager)
{
int lLogicalFontHeight = pFont->GetHeight();
if (lLogicalFontHeight < 0)
lLogicalFontHeight = -lLogicalFontHeight;
if (lLogicalFontHeight < 0.01)
lLogicalFontHeight = 18;
double dFontHeight = lLogicalFontHeight;
std::wstring wsFaceName = pFont->GetFaceName();
int lStyle = 0;
if (pFont->GetWeight() > 550)
lStyle |= 0x01;
if (pFont->IsItalic())
lStyle |= 0x02;
float fL = 0, fT = 0, fW = 0, fH = 0;
pFontManager->LoadFontByName(wsFaceName, dFontHeight, lStyle, 72, 72);
pFontManager->SetCharSpacing(GetCharSpace());
double dFHeight = dFontHeight * pFontManager->m_pFont->GetHeight() / pFontManager->m_pFont->m_lUnits_Per_Em;
double dFDescent = dFontHeight * pFontManager->m_pFont->GetDescender() / pFontManager->m_pFont->m_lUnits_Per_Em;
double dFAscent = dFHeight - std::abs(dFDescent);
pFontManager->LoadString1(wsText, 0, 0);
TBBox oBox = pFontManager->MeasureString2();
fL = (float)(oBox.fMinX);
fT = (float)(oBox.fMinY);
fW = (float)(oBox.fMaxX - oBox.fMinX);
fH = (float)(oBox.fMaxY - oBox.fMinY);
if (std::abs(fT) < dFAscent)
{
if (fT < 0)
fT = (float)-dFAscent;
else
fT = (float)dFAscent;
}
if (fH < dFHeight)
fH = (float)dFHeight;
double dTheta = -((((double)pFont->GetEscapement()) / 10) * 3.14159265358979323846 / 180);
double dCosTheta = (float)cos(dTheta);
double dSinTheta = (float)sin(dTheta);
double dX = (double)nX;
double dY = (double)nY;
// Найдем начальную точку текста
unsigned int ulTextAlign = GetTextAlign();
if (ulTextAlign & TA_BASELINE)
{
// Ничего не делаем
}
else if (ulTextAlign & TA_BOTTOM)
{
float fTemp = -(-fT + fH);
dX += -fTemp * dSinTheta;
dY += fTemp * dCosTheta;
}
else // if (ulTextAlign & TA_TOP)
{
float fTemp = -fT;
dX += -fTemp * dSinTheta;
dY += fTemp * dCosTheta;
}
if (ulTextAlign & TA_CENTER)
{
dX += -fW / 2 * dCosTheta;
dY += -fW / 2 * dSinTheta;
}
else if (ulTextAlign & TA_RIGHT)
{
dX += -fW * dCosTheta;
dY += -fW * dSinTheta;
}
else //if (ulTextAlign & TA_LEFT)
{
// Ничего не делаем
}
double dX0 = dX + fL, dY0 = dY + fT;
double dX1 = dX + fL + fW, dY1 = dY + fT;
double dX2 = dX + fL + fW, dY2 = dY + fT + fH;
double dX3 = dX + fL, dY3 = dY + fT + fH;
if (0 != pFont->GetEscapement())
{
TXForm oForm(dCosTheta, dSinTheta, -dSinTheta, dCosTheta, dX - dX * dCosTheta + dY * dSinTheta, dY - dX * dSinTheta - dY * dCosTheta);
oForm.Apply(dX0, dY0);
oForm.Apply(dX1, dY1);
oForm.Apply(dX2, dY2);
oForm.Apply(dX3, dY3);
}
RegisterPoint((short)dX0, (short)dY0);
RegisterPoint((short)dX1, (short)dY1);
RegisterPoint((short)dX2, (short)dY2);
RegisterPoint((short)dX3, (short)dY3);
}
else
{
// TODO: Возможно нужно регистрировать более точно, с учетом размеров текста
RegisterPoint(nX, nY);
}
}
m_pDC->SetCurPos(nX + nTextW, nY);
}
void RegisterPoint(short shX, short shY)
{
if (m_bFirstPoint)
......@@ -526,6 +658,36 @@ namespace MetaFile
MetaFile::ReadImage(pBuffer, unRemainBytes, ushColorUsage, ppBgraBuffer, pulWidth, pulHeight);
return true;
}
void DrawImage(int nX, int nY, int nW, int nH, unsigned int unColorUsage, unsigned int unRasterOperation)
{
if (m_pOutput)
{
BYTE* pBgra = NULL;
unsigned int unWidth, unHeight;
if (ReadImage(unColorUsage, &pBgra, &unWidth, &unHeight))
{
ProcessRasterOperation(unRasterOperation, &pBgra, unWidth, unHeight);
double dX, dY, dX1, dY1;
TranslatePoint(nX, nY, dX, dY);
TranslatePoint(nX + nW, nY + nH, dX1, dY1);
m_pOutput->DrawBitmap(dX, dY, abs(dX1 - dX), abs(dY1 - dY), pBgra, unWidth, unHeight);
}
if (pBgra)
delete[] pBgra;
int nRemainingBytes = GetRecordRemainingBytesCount();
if (nRemainingBytes < 0)
return SetError();
}
else
{
RegisterPoint(nX, nY);
RegisterPoint(nX + nW, nY + nH);
}
}
void UpdateOutputDC()
{
if (m_pOutput)
......@@ -646,27 +808,7 @@ namespace MetaFile
}
else
{
if (m_pOutput)
{
BYTE* pBgra;
unsigned int unWidth, unHeight;
if (ReadImage(0, &pBgra, &unWidth, &unHeight))
{
m_pOutput->DrawBitmap(oBitmap.XDest, oBitmap.YDest, oBitmap.Width, oBitmap.Height, pBgra, unWidth, unHeight);
}
if (pBgra)
delete[] pBgra;
}
else
{
RegisterPoint(oBitmap.XDest, oBitmap.YDest);
RegisterPoint(oBitmap.XDest + oBitmap.Width, oBitmap.YDest + oBitmap.Height);
}
int nRemainingBytes = GetRecordRemainingBytesCount();
if (nRemainingBytes < 0)
return SetError();
DrawImage(oBitmap.XDest, oBitmap.YDest, oBitmap.Width, oBitmap.Height, 0, oBitmap.RasterOperation);
}
}
void Read_META_DIBSTRETCHBLT()
......@@ -683,29 +825,7 @@ namespace MetaFile
}
else
{
if (m_pOutput)
{
BYTE* pBgra;
unsigned int unWidth, unHeight;
if (ReadImage(0, &pBgra, &unWidth, &unHeight))
{
ProcessRasterOperation(oBitmap.RasterOperation, &pBgra, unWidth, unHeight);
m_pOutput->DrawBitmap(oBitmap.XDest, oBitmap.YDest, oBitmap.DestWidth, oBitmap.DestHeight, pBgra, unWidth, unHeight);
}
if (pBgra)
delete[] pBgra;
}
else
{
RegisterPoint(oBitmap.XDest, oBitmap.YDest);
RegisterPoint(oBitmap.XDest + oBitmap.DestWidth, oBitmap.YDest + oBitmap.DestHeight);
}
int nRemainingBytes = GetRecordRemainingBytesCount();
if (nRemainingBytes < 0)
return SetError();
DrawImage(oBitmap.XDest, oBitmap.YDest, oBitmap.DestWidth, oBitmap.DestHeight, 0, oBitmap.RasterOperation);
}
}
void Read_META_SETDIBTODEV()
......@@ -713,28 +833,8 @@ namespace MetaFile
TWmfSetDibToDev oBitmap;
m_oStream >> oBitmap;
if (m_pOutput)
{
// TODO: Тут надо делать обрезку в зависимости от ScanCount и StartScan. Как встретится файл сделать.
BYTE* pBgra;
unsigned int unWidth, unHeight;
if (ReadImage(oBitmap.ColorUsage, &pBgra, &unWidth, &unHeight))
{
m_pOutput->DrawBitmap(oBitmap.xDest, oBitmap.yDest, oBitmap.Width, oBitmap.Height, pBgra, unWidth, unHeight);
}
if (pBgra)
delete[] pBgra;
}
else
{
RegisterPoint(oBitmap.xDest, oBitmap.yDest);
RegisterPoint(oBitmap.xDest + oBitmap.Width, oBitmap.yDest + oBitmap.Height);
}
int nRemainingBytes = GetRecordRemainingBytesCount();
if (nRemainingBytes < 0)
return SetError();
DrawImage(oBitmap.xDest, oBitmap.yDest, oBitmap.Width, oBitmap.Height, oBitmap.ColorUsage, 0);
}
void Read_META_STRETCHBLT()
{
......@@ -773,27 +873,7 @@ namespace MetaFile
TWmfStretchDib oBitmap;
m_oStream >> oBitmap;
if (m_pOutput)
{
BYTE* pBgra;
unsigned int unWidth, unHeight;
if (ReadImage(oBitmap.ColorUsage, &pBgra, &unWidth, &unHeight))
{
m_pOutput->DrawBitmap(oBitmap.xDst, oBitmap.yDst, oBitmap.DestWidth, oBitmap.DestHeight, pBgra, unWidth, unHeight);
}
if (pBgra)
delete[] pBgra;
}
else
{
RegisterPoint(oBitmap.xDst, oBitmap.yDst);
RegisterPoint(oBitmap.xDst + oBitmap.DestWidth, oBitmap.yDst + oBitmap.DestHeight);
}
int nRemainingBytes = GetRecordRemainingBytesCount();
if (nRemainingBytes < 0)
return SetError();
DrawImage(oBitmap.xDst, oBitmap.yDst, oBitmap.DestWidth, oBitmap.DestHeight, oBitmap.ColorUsage, oBitmap.RasterOperation);
}
void Read_META_ARC()
{
......@@ -1215,14 +1295,53 @@ namespace MetaFile
{
short shLeft, shTop, shRight, shBottom;
m_oStream >> shBottom >> shRight >> shTop >> shLeft;
m_pDC->GetClip()->Exclude(shLeft, shTop, shRight, shBottom, GetBoundingBox());
double dL, dT, dR, dB;
// Поскольку мы реализовываем данный тип клипа с помощью разницы внешнего ректа и заданного, и
// пересечением с полученной областью, то нам надо вычесть границу заданного ректа.
if (shLeft < shRight)
{
shLeft--;
shRight++;
}
else
{
shLeft++;
shRight--;
}
if (shTop < shBottom)
{
shTop--;
shBottom++;
}
else
{
shTop++;
shBottom--;
}
TranslatePoint(shLeft, shTop, dL, dT);
TranslatePoint(shRight, shBottom, dR, dB);
TWmfWindow* pWindow = m_pDC->GetWindow();
double dWindowL, dWindowT, dWindowR, dWindowB;
TranslatePoint(pWindow->x, pWindow->y, dWindowL, dWindowT);
TranslatePoint(pWindow->x + pWindow->w, pWindow->y + pWindow->h, dWindowR, dWindowB);
m_pDC->GetClip()->Exclude(dL, dT, dR, dB, dWindowL, dWindowT, dWindowR, dWindowB);
UpdateOutputDC();
}
void Read_META_INTERSECTCLIPRECT()
{
short shLeft, shTop, shRight, shBottom;
m_oStream >> shBottom >> shRight >> shTop >> shLeft;
m_pDC->GetClip()->Intersect(shLeft, shTop, shRight, shBottom);
double dL, dT, dR, dB;
TranslatePoint(shLeft, shTop, dL, dT);
TranslatePoint(shRight, shBottom, dR, dB);
m_pDC->GetClip()->Intersect(dL, dT, dR, dB);
UpdateOutputDC();
}
void Read_META_MOVETO()
......
......@@ -8,9 +8,7 @@ namespace MetaFile
CWmfDC* pDC = new CWmfDC();
if (!pDC)
{
#ifdef NEW_WMF
pFile->SetError();
#endif
return;
}
......@@ -53,9 +51,7 @@ namespace MetaFile
CWmfDC* pDC = new CWmfDC();
if (!pDC)
{
#ifdef NEW_WMF
m_pFile->SetError();
#endif
return;
}
......@@ -68,18 +64,14 @@ namespace MetaFile
{
if (!m_pDC)
{
#ifdef NEW_WMF
m_pFile->SetError();
#endif
return NULL;
}
CWmfDC* pNewDC = m_pDC->Copy();
if (!pNewDC)
{
#ifdef NEW_WMF
m_pFile->SetError();
#endif
return NULL;
}
......@@ -91,9 +83,7 @@ namespace MetaFile
{
if (m_vDCStack.size() <= 1)
{
#ifdef NEW_WMF
m_pFile->SetError();
#endif
return m_pDC;
}
......@@ -223,9 +213,9 @@ namespace MetaFile
m_oTextColor.Set(0, 0, 0);
m_oTextBgColor.Set(255, 255, 255);
m_oCurPos.Set(0, 0);
m_ushTextBgMode = TRANSPARENT;
m_ushTextBgMode = OPAQUE;
m_ushLayout = LAYOUT_LTR;
m_ushPolyFillMode = WINDING;
m_ushPolyFillMode = ALTERNATE;
m_ushRop2Mode = R2_COPYPEN;
m_ushStretchBltMode = COLORONCOLOR;
m_ushTextAlign = TA_TOP | TA_LEFT | TA_NOUPDATECP;
......
#pragma once
#ifdef _DEBUG
#pragma comment(lib, "../../Qt_build/graphics/project/debug/graphics.lib")
#else
#pragma comment(lib, "../../Qt_build/graphics/project/release/graphics.lib")
#endif
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