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

Переделано открытие EMF на манер WMF, т.е. теперь первоначальный обсчет всех...

Переделано открытие EMF на манер WMF, т.е. теперь первоначальный обсчет всех точек делается в классе CEmfFile, чтобы не было проблем с клипом как в WMF. Реализованы записи ExcludeClipRect и SetArcDirection. Исправлены мелкие баги при открытии EMF.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@62391 954022d7-b5bf-4e40-9824-e11837661b57
parent 0ddbb6af
......@@ -26,8 +26,6 @@ namespace MetaFile
virtual void PlayMetaFile() = 0;
virtual void ClearFile() {/* , */}
//virtual double TranslateX(int nX) = 0;
//virtual double TranslateY(int nY) = 0;
virtual TRect* GetDCBounds() = 0;
virtual double GetPixelHeight() = 0;
virtual double GetPixelWidth() = 0;
......
......@@ -608,7 +608,7 @@ namespace MetaFile
BYTE nDashStyle = Aggplus::DashStyleSolid;;
// WinGDI 1px PS_SOLID
if (1 == pPen->GetWidth() && PS_SOLID != ulPenStyle)
if (1 >= pPen->GetWidth() && PS_SOLID != ulPenStyle)
{
dWidth = 0; // 1p
......
......@@ -121,6 +121,9 @@ typedef unsigned char BYTE;
#define PS_GEOMETRIC 0x00010000
#define PS_TYPE_MASK 0x000F0000
#define AD_COUNTERCLOCKWISE 1
#define AD_CLOCKWISE 2
/* Text Alignment Options */
#define TA_NOUPDATECP 0
#define TA_UPDATECP 1
......
......@@ -864,8 +864,7 @@ namespace MetaFile
{
unsigned int unIndex = (unY * unWidth + unX) * 4;
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]))
if (0xff == pCur[unIndex + 0] && 0xff == pCur[unIndex + 1] && 0xff == pCur[unIndex + 2])
pCur[unIndex + 3] = 0;
}
}
......@@ -879,8 +878,7 @@ namespace MetaFile
{
unsigned int unIndex = (unY * unWidth + unX) * 4;
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]))
if (0 == pCur[unIndex + 0] && 0 == pCur[unIndex + 1] && 0 == pCur[unIndex + 2])
pCur[unIndex + 3] = 0;
}
}
......
......@@ -535,13 +535,11 @@ namespace MetaFile
unsigned short* pUnicode = NULL;
if (oText.fuOptions & ETO_SMALL_CHARS)
{
unsigned char* pString = new unsigned char[oText.cChars + 1];
unsigned char* pString = new unsigned char[oText.cChars];
if (!pString)
return *this;
pString[oText.cChars] = 0x00;
ReadBytes(pString, oText.cChars);
oText.cChars++;
pUnicode = new unsigned short[oText.cChars];
if (!pUnicode)
......@@ -558,13 +556,11 @@ namespace MetaFile
}
else
{
pUnicode = new unsigned short[oText.cChars + 1];
pUnicode = new unsigned short[oText.cChars];
if (!pUnicode)
return *this;
pUnicode[oText.cChars] = 0x0000;
ReadBytes(pUnicode, oText.cChars);
oText.cChars++;
}
oText.TextString = pUnicode;
}
......@@ -920,7 +916,6 @@ namespace MetaFile
void ReadEmrTextA(TEmfEmrText& oText, unsigned int unOffset)
{
ReadEmrTextBase<unsigned char>(oText, unOffset);
// TODO: Charset
}
void ReadEmrTextW(TEmfEmrText& oText, unsigned int unOffset)
{
......
......@@ -30,6 +30,12 @@ namespace MetaFile
pNewCommand = new CEmfClipCommandPath(&pPathCommand->m_oPath, pPathCommand->m_unMode);
break;
}
case EMF_CLIPCOMMAND_EXCLUDE:
{
CEmfClipCommandExclude* pExclude = (CEmfClipCommandExclude*)pCommand;
pNewCommand = new CEmfClipCommandExclude(pExclude->m_oClip, pExclude->m_oBB);
break;
}
}
if (pNewCommand)
......@@ -40,7 +46,7 @@ namespace MetaFile
{
Clear();
}
bool CEmfClip::Intersect(TEmfRectL& oRect)
bool CEmfClip::Intersect(TRectD& oRect)
{
CEmfClipCommandBase* pCommand = new CEmfClipCommandIntersect(oRect);
if (!pCommand)
......@@ -49,6 +55,15 @@ namespace MetaFile
m_vCommands.push_back(pCommand);
return true;
}
bool CEmfClip::Exclude(TRectD& oClip, TRectD& oBB)
{
CEmfClipCommandBase* pCommand = new CEmfClipCommandExclude(oClip, oBB);
if (!pCommand)
return false;
m_vCommands.push_back(pCommand);
return true;
}
bool CEmfClip::SetPath(CEmfPath* pPath, unsigned int unMode)
{
CEmfClipCommandBase* pCommand = new CEmfClipCommandPath(pPath, unMode);
......@@ -72,7 +87,7 @@ namespace MetaFile
case EMF_CLIPCOMMAND_INTERSECT:
{
CEmfClipCommandIntersect* pIntersect = (CEmfClipCommandIntersect*)pCommand;
pOutput->IntersectClip(pIntersect->m_oRect.lLeft, pIntersect->m_oRect.lTop, pIntersect->m_oRect.lRight, pIntersect->m_oRect.lBottom);
pOutput->IntersectClip(pIntersect->m_oRect.dLeft, pIntersect->m_oRect.dTop, pIntersect->m_oRect.dRight, pIntersect->m_oRect.dBottom);
break;
}
case EMF_CLIPCOMMAND_SETPATH:
......@@ -81,6 +96,30 @@ namespace MetaFile
pClipPath->m_oPath.Draw(pOutput, false, false, pClipPath->m_unMode);
break;
}
case EMF_CLIPCOMMAND_EXCLUDE:
{
CEmfClipCommandExclude* pExclude = (CEmfClipCommandExclude*)pCommand;
pOutput->StartClipPath(RGN_AND, ALTERNATE);
TRectD& oClip = pExclude->m_oClip;
TRectD& oBB = pExclude->m_oBB;
pOutput->MoveTo(oClip.dLeft, oClip.dTop);
pOutput->LineTo(oClip.dRight, oClip.dTop);
pOutput->LineTo(oClip.dRight, oClip.dBottom);
pOutput->LineTo(oClip.dLeft, oClip.dBottom);
pOutput->ClosePath();
pOutput->MoveTo(oBB.dLeft, oBB.dTop);
pOutput->LineTo(oBB.dRight, oBB.dTop);
pOutput->LineTo(oBB.dRight, oBB.dBottom);
pOutput->LineTo(oBB.dLeft, oBB.dBottom);
pOutput->ClosePath();
pOutput->EndClipPath(RGN_AND);
break;
}
}
}
......
......@@ -12,7 +12,8 @@ namespace MetaFile
{
EMF_CLIPCOMMAND_UNKNOWN = 0x00,
EMF_CLIPCOMMAND_INTERSECT = 0x01,
EMF_CLIPCOMMAND_SETPATH = 0x02
EMF_CLIPCOMMAND_SETPATH = 0x02,
EMF_CLIPCOMMAND_EXCLUDE = 0x03
} EEmfClipCommandType;
class CEmfClipCommandBase
......@@ -32,7 +33,7 @@ namespace MetaFile
class CEmfClipCommandIntersect : public CEmfClipCommandBase
{
public:
CEmfClipCommandIntersect(TEmfRectL& oRect) : m_oRect(oRect)
CEmfClipCommandIntersect(TRectD& oRect) : m_oRect(oRect)
{
}
~CEmfClipCommandIntersect()
......@@ -44,7 +45,7 @@ namespace MetaFile
}
public:
TEmfRectL m_oRect;
TRectD m_oRect;
};
class CEmfClipCommandPath : public CEmfClipCommandBase
{
......@@ -65,6 +66,24 @@ namespace MetaFile
CEmfPath m_oPath;
unsigned int m_unMode;
};
class CEmfClipCommandExclude : public CEmfClipCommandBase
{
public:
CEmfClipCommandExclude(TRectD& oClip, TRectD& oBB) : m_oClip(oClip), m_oBB(oBB)
{
}
~CEmfClipCommandExclude()
{
}
EEmfClipCommandType GetType()
{
return EMF_CLIPCOMMAND_INTERSECT;
}
public:
TRectD m_oClip;
TRectD m_oBB;
};
class CEmfClip : public IClip
{
......@@ -74,7 +93,8 @@ namespace MetaFile
void operator=(CEmfClip& oClip);
void Reset();
bool Intersect(TEmfRectL& oRect);
bool Intersect(TRectD& oRect);
bool Exclude(TRectD& oClip, TRectD& oBB);
bool SetPath(CEmfPath* pPath, unsigned int umMode);
void ClipOnRenderer(IOutputDevice* pOutput);
......
......@@ -74,6 +74,7 @@ namespace MetaFile
//-----------------------------------------------------------
// 2.3.2 Clipping
//-----------------------------------------------------------
case EMR_EXCLUDECLIPRECT: Read_EMR_EXCLUDECLIPRECT(); break;
case EMR_EXTSELECTCLIPRGN: Read_EMR_EXTSELECTCLIPRGN(); break;
case EMR_INTERSECTCLIPRECT: Read_EMR_INTERSECTCLIPRECT(); break;
case EMR_SELECTCLIPPATH: Read_EMR_SELECTCLIPPATH(); break;
......@@ -148,6 +149,7 @@ namespace MetaFile
// 2.3.11 State
//-----------------------------------------------------------
case EMR_MOVETOEX: Read_EMR_MOVETOEX(); break;
case EMR_SETARCDIRECTION: Read_EMR_SETARCDIRECTION(); break;
case EMR_SAVEDC: Read_EMR_SAVEDC(); break;
case EMR_RESTOREDC: Read_EMR_RESTOREDC(); break;
case EMR_SETTEXTCOLOR: Read_EMR_SETTEXTCOLOR(); break;
......@@ -205,27 +207,6 @@ namespace MetaFile
m_oPlayer.Clear();
m_pDC = m_oPlayer.GetDC();
}
double TranslateX(int nSrcX)
{
double dDstX;
TEmfWindow* pWindow = m_pDC->GetWindow();
TEmfWindow* pViewport = m_pDC->GetViewport();
dDstX = (double)((double)(nSrcX - pWindow->lX) * m_pDC->GetPixelWidth()) + pViewport->lX;
return dDstX;
}
double TranslateY(int nSrcY)
{
double dDstY;
TEmfWindow* pWindow = m_pDC->GetWindow();
TEmfWindow* pViewport = m_pDC->GetViewport();
dDstY = (double)((double)(nSrcY - pWindow->lY) * m_pDC->GetPixelHeight()) + pViewport->lY;
return dDstY;
}
TRect* GetDCBounds()
{
return &m_oHeader.oFrameToBounds;
......@@ -287,11 +268,8 @@ namespace MetaFile
TPointD GetCurPos()
{
TPointL oPoint = m_pDC->GetCurPos();
// TODO:
TPointD oRes;
oRes.x = oPoint.x;
oRes.y = oPoint.y;
TranslatePoint(oPoint.x, oPoint.y, oRes.x, oRes.y);
return oRes;
}
TXForm* GetInverseTransform()
......@@ -325,6 +303,31 @@ namespace MetaFile
private:
void TranslatePoint(TEmfPointL& oPoint, double& dX, double& dY)
{
TranslatePoint(oPoint.x, oPoint.y, dX, dY);
}
void TranslatePoint(int nX, int nY, double& dX, double &dY)
{
TEmfWindow* pWindow = m_pDC->GetWindow();
TEmfWindow* pViewport = m_pDC->GetViewport();
dX = (double)((double)(nX - pWindow->lX) * m_pDC->GetPixelWidth()) + pViewport->lX;
dY = (double)((double)(nY - pWindow->lY) * m_pDC->GetPixelHeight()) + pViewport->lY;
// . ,
// .
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);
}
CEmfDC* GetDC()
{
return m_pDC;
......@@ -353,32 +356,25 @@ namespace MetaFile
m_oStream.Skip(lHeaderOffset);
BYTE* pHeaderBuffer = new BYTE[ulHeaderSize];
if (!pHeaderBuffer)
{
SetError();
return false;
}
m_oStream.ReadBytes(pHeaderBuffer, ulHeaderSize);
m_oStream.Skip(lBitsOffset);
BYTE* pBitsBuffer = new BYTE[ulBitsSize];
if (!pBitsBuffer)
{
delete[] pHeaderBuffer;
SetError();
return false;
}
m_oStream.ReadBytes(pBitsBuffer, ulBitsSize);
BYTE* pHeaderBuffer = m_oStream.GetCurPtr();
m_oStream.Skip(ulHeaderSize + lBitsOffset);
BYTE* pBitsBuffer = m_oStream.GetCurPtr();
m_oStream.Skip(ulBitsSize);
MetaFile::ReadImage(pHeaderBuffer, ulHeaderSize, pBitsBuffer, ulBitsSize, ppBgraBuffer, pulWidth, pulHeight);
delete[] pBitsBuffer;
delete[] pHeaderBuffer;
return true;
}
void DrawImage(int nX, int nY, int nW, int nH, BYTE* pImageBuffer, unsigned int unImageW, unsigned int unImageH)
{
if (m_pOutput)
{
double dX, dY, dR, dB;
TranslatePoint(nX, nY, dX, dY);
TranslatePoint(nX + nW, nY + nH, dR, dB);
m_pOutput->DrawBitmap(dX, dY, dR - dX, dB - dY, pImageBuffer, unImageW, unImageH);
}
}
void MoveTo(TEmfPointL& oPoint)
{
MoveTo(oPoint.x, oPoint.y);
......@@ -387,33 +383,39 @@ namespace MetaFile
{
MoveTo(oPoint.x, oPoint.y);
}
void MoveTo(int lX, int lY)
void MoveTo(int nX, int nY)
{
double dX, dY;
TranslatePoint(nX, nY, dX, dY);
if (m_pPath)
{
if (!m_pPath->MoveTo(lX, lY))
if (!m_pPath->MoveTo(dX, dY))
return SetError();
}
else if (m_pOutput)
{
m_pOutput->MoveTo(lX, lY);
m_pOutput->MoveTo(dX, dY);
}
m_pDC->SetCurPos(lX, lY);
m_pDC->SetCurPos(nX, nY);
}
void LineTo(int lX, int lY)
void LineTo(int nX, int nY)
{
double dX, dY;
TranslatePoint(nX, nY, dX, dY);
if (m_pPath)
{
if (!m_pPath->LineTo(lX, lY))
if (!m_pPath->LineTo(dX, dY))
return SetError();
}
else if (m_pOutput)
{
m_pOutput->LineTo(lX, lY);
m_pOutput->LineTo(dX, dY);
}
m_pDC->SetCurPos(lX, lY);
m_pDC->SetCurPos(nX, nY);
}
void LineTo(TEmfPointL& oPoint)
{
......@@ -425,14 +427,19 @@ namespace MetaFile
}
void CurveTo(int nX1, int nY1, int nX2, int nY2, int nXe, int nYe)
{
double dX1, dY1, dX2, dY2, dXe, dYe;
TranslatePoint(nX1, nY1, dX1, dY1);
TranslatePoint(nX2, nY2, dX2, dY2);
TranslatePoint(nXe, nYe, dXe, dYe);
if (m_pPath)
{
if (!m_pPath->CurveTo(nX1, nY1, nX2, nY2, nXe, nYe))
if (!m_pPath->CurveTo(dX1, dY1, dX2, dY2, dXe, dYe))
return SetError();
}
else if (m_pOutput)
{
m_pOutput->CurveTo(nX1, nY1, nX2, nY2, nXe, nYe);
m_pOutput->CurveTo(dX1, dY1, dX2, dY2, dXe, dYe);
}
m_pDC->SetCurPos(nXe, nYe);
......@@ -455,25 +462,28 @@ namespace MetaFile
else if (m_pOutput)
m_pOutput->ClosePath();
}
void ArcTo(int lL, int lT, int lR, int lB, double dStart, double dSweep)
void ArcTo(int nL, int nT, int nR, int nB, double dStart, double dSweep)
{
double dL, dT, dR, dB;
TranslatePoint(nL, nT, dL, dT);
TranslatePoint(nR, nB, dR, dB);
if (m_pPath)
{
if (!m_pPath->ArcTo(lL, lT, lR, lB, dStart, dSweep))
if (!m_pPath->ArcTo(dL, dT, dR, dB, dStart, dSweep))
return SetError();
}
else if (m_pOutput)
{
m_pOutput->ArcTo(lL, lT, lR, lB, dStart, dSweep);
m_pOutput->ArcTo(dL, dT, dR, dB, dStart, dSweep);
}
// TODO:
//
}
void DrawPath(bool bStroke, bool bFill)
{
if (m_pPath && m_pOutput)
{
//m_pPath->Draw(m_pOutput, bStroke, bFill);
{
}
else if (m_pOutput)
{
......@@ -487,7 +497,7 @@ namespace MetaFile
if (m_pOutput)
m_pOutput->UpdateDC();
}
void DrawText(std::wstring& wsString, unsigned int unCharsCount, int _nX, int _nY, int nTextW, bool bWithOutLast)
void DrawText(std::wstring& wsString, unsigned int unCharsCount, int _nX, int _nY, int* pnDx = NULL)
{
int nX = _nX;
int nY = _nY;
......@@ -500,7 +510,34 @@ namespace MetaFile
if (m_pOutput)
{
m_pOutput->DrawString(wsString, unCharsCount, nX, nY, NULL);
double dX, dY;
TranslatePoint(nX, nY, dX, dY);
double* pdDx = NULL;
if (pnDx)
{
pdDx = new double[unCharsCount];
if (pdDx)
{
int nCurX = nX;
double dCurX = dX;
for (unsigned int unCharIndex = 0; unCharIndex < unCharsCount; unCharIndex++)
{
int nX1 = nCurX + pnDx[unCharIndex];
double dX1, dY1;
TranslatePoint(nX1, nY, dX1, dY1);
pdDx[unCharIndex] = dX1 - dCurX;
nCurX = nX1;
dCurX = dX1;
}
}
}
m_pOutput->DrawString(wsString, unCharsCount, dX, dY, pdDx);
if (pdDx)
delete[] pdDx;
}
}
void DrawTextA(TEmfEmrText& oText)
......@@ -561,24 +598,27 @@ namespace MetaFile
std::wstring wsText = NSString::CConverter::GetUnicodeFromSingleByteString((unsigned char*)oText.OutputString, oText.Chars, eCharSet);
int nTextW = 0;
bool bWithOutLast = false;
int* pDx = NULL;
if (oText.OutputDx)
{
for (unsigned int unIndex = 0; unIndex < oText.Chars; unIndex++)
pDx = new int[oText.Chars];
if (pDx)
{
nTextW += oText.OutputDx[unIndex];
if ((oText.Chars - 1 == unIndex || (oText.Options & ETO_PDY && oText.Chars - 2 == unIndex)) && 0 == oText.OutputDx[unIndex])
bWithOutLast = true;
for (unsigned int unIndex = 0; unIndex < oText.Chars; unIndex++)
{
pDx[unIndex] = oText.OutputDx[unIndex];
// Y
if (oText.Options & ETO_PDY)
unIndex++;
// Y
if (oText.Options & ETO_PDY)
unIndex++;
}
}
}
DrawText(wsText, oText.Chars, oText.Reference.x, oText.Reference.y, nTextW, bWithOutLast);
DrawText(wsText, oText.Chars, oText.Reference.x, oText.Reference.y, pDx);
if (pDx)
delete[] pDx;
}
void DrawTextW(TEmfEmrText& oText)
{
......@@ -587,24 +627,27 @@ namespace MetaFile
std::wstring wsText = NSString::CConverter::GetUnicodeFromUTF16((unsigned short*)oText.OutputString, oText.Chars);
int nTextW = 0;
bool bWithOutLast = false;
int* pDx = NULL;
if (oText.OutputDx)
{
for (unsigned int unIndex = 0; unIndex < oText.Chars; unIndex++)
pDx = new int[oText.Chars];
if (pDx)
{
nTextW += oText.OutputDx[unIndex];
if ((oText.Chars - 1 == unIndex || (oText.Options & ETO_PDY && oText.Chars - 2 == unIndex)) && 0 == oText.OutputDx[unIndex])
bWithOutLast = true;
for (unsigned int unIndex = 0; unIndex < oText.Chars; unIndex++)
{
pDx[unIndex] = oText.OutputDx[unIndex];
// Y
if (oText.Options & ETO_PDY)
unIndex++;
// Y
if (oText.Options & ETO_PDY)
unIndex++;
}
}
}
DrawText(wsText, oText.Chars, oText.Reference.x, oText.Reference.y, nTextW, bWithOutLast);
DrawText(wsText, oText.Chars, oText.Reference.x, oText.Reference.y, pDx);
if (pDx)
delete[] pDx;
}
void Read_EMR_HEADER()
......@@ -686,7 +729,7 @@ namespace MetaFile
}
m_pOutput->DrawBitmap(oBitmap.xDest, oBitmap.yDest, oBitmap.cxDest, oBitmap.cyDest, pBgraBuffer, unWidth, unHeight);
DrawImage(oBitmap.xDest, oBitmap.yDest, oBitmap.cxDest, oBitmap.cyDest, pBgraBuffer, unWidth, unHeight);
}
}
......@@ -706,7 +749,7 @@ namespace MetaFile
if (m_pOutput)
{
ProcessRasterOperation(oBitmap.BitBltRasterOperation, &pBgraBuffer, ulWidth, ulHeight);
m_pOutput->DrawBitmap(oBitmap.xDest, oBitmap.yDest, oBitmap.cxDest, oBitmap.cyDest, pBgraBuffer, ulWidth, ulHeight);
DrawImage(oBitmap.xDest, oBitmap.yDest, oBitmap.cxDest, oBitmap.cyDest, pBgraBuffer, ulWidth, ulHeight);
}
}
......@@ -723,8 +766,7 @@ namespace MetaFile
if (ReadImage(oBitmap.offBmiSrc, oBitmap.cbBmiSrc, oBitmap.offBitsSrc, oBitmap.cbBitsSrc, sizeof(TEmfBitBlt) + 8, &pBgraBuffer, &ulWidth, &ulHeight))
{
if (m_pOutput)
m_pOutput->DrawBitmap(oBitmap.xDest, oBitmap.yDest, oBitmap.cxDest, oBitmap.cyDest, pBgraBuffer, ulWidth, ulHeight);
DrawImage(oBitmap.xDest, oBitmap.yDest, oBitmap.cxDest, oBitmap.cyDest, pBgraBuffer, ulWidth, ulHeight);
}
if (m_pOutput)
......@@ -803,7 +845,7 @@ namespace MetaFile
}
if (pBgraBuffer)
m_pOutput->DrawBitmap(oBitmap.xDest, oBitmap.yDest, oBitmap.cxDest, oBitmap.cyDest, pBgraBuffer, ulWidth, ulHeight);
DrawImage(oBitmap.xDest, oBitmap.yDest, oBitmap.cxDest, oBitmap.cyDest, pBgraBuffer, ulWidth, ulHeight);
}
if (pBgraBuffer)
......@@ -819,8 +861,7 @@ namespace MetaFile
if (ReadImage(oBitmap.offBmiSrc, oBitmap.cbBmiSrc, oBitmap.offBitsSrc, oBitmap.cbBitsSrc, sizeof(TEmfSetDiBitsToDevice) + 8, &pBgraBuffer, &ulWidth, &ulHeight))
{
// TODO: oBitmap.iStartScan oBitmap.cScans
if (m_pOutput)
m_pOutput->DrawBitmap(oBitmap.Bounds.lLeft, oBitmap.Bounds.lTop, oBitmap.Bounds.lRight - oBitmap.Bounds.lLeft, oBitmap.Bounds.lBottom - oBitmap.Bounds.lTop, pBgraBuffer, ulWidth, ulHeight);
DrawImage(oBitmap.Bounds.lLeft, oBitmap.Bounds.lTop, oBitmap.Bounds.lRight - oBitmap.Bounds.lLeft, oBitmap.Bounds.lBottom - oBitmap.Bounds.lTop, pBgraBuffer, ulWidth, ulHeight);
}
if (pBgraBuffer)
......@@ -1033,7 +1074,10 @@ namespace MetaFile
SetError();
// MoveTo BeginPath
m_pPath->MoveTo(m_pDC->GetCurPos());
TEmfPointL oPoint = m_pDC->GetCurPos();
double dX, dY;
TranslatePoint(oPoint, dX, dY);
m_pPath->MoveTo(dX, dY);
}
void Read_EMR_ENDPATH()
{
......@@ -1068,7 +1112,14 @@ namespace MetaFile
TEmfPointL oPoint;
m_oStream >> oPoint;
MoveTo(oPoint);
}
}
void Read_EMR_SETARCDIRECTION()
{
unsigned int unDirection;
m_oStream >> unDirection;
m_pDC->SetArcDirection(unDirection);
// DC Output, .. .
}
void Read_EMR_FILLPATH()
{
TEmfRectL oBounds;
......@@ -1159,8 +1210,49 @@ namespace MetaFile
{
TEmfColor oColor;
m_oStream >> oColor;
// TODO:
m_pDC->SetBgColor(oColor);
UpdateOutputDC();
}
void Read_EMR_EXCLUDECLIPRECT()
{
// TODO:
TEmfRectL oClip;
m_oStream >> oClip;
TRectD oClipRect, oBB;
// ,
// , .
if (oClip.lLeft < oClip.lRight)
{
oClip.lLeft--;
oClip.lRight++;
}
else
{
oClip.lLeft++;
oClip.lRight--;
}
if (oClip.lTop < oClip.lBottom)
{
oClip.lTop--;
oClip.lBottom++;
}
else
{
oClip.lTop++;
oClip.lBottom--;
}
TranslatePoint(oClip.lLeft, oClip.lTop, oClipRect.dLeft, oClipRect.dTop);
TranslatePoint(oClip.lRight, oClip.lBottom, oClipRect.dRight, oClipRect.dBottom);
TRect* pRect = GetDCBounds();
TranslatePoint(pRect->nLeft, pRect->nTop, oBB.dLeft, oBB.dTop);
TranslatePoint(pRect->nRight, pRect->nBottom, oBB.dRight, oBB.dBottom);
m_pDC->GetClip()->Exclude(oClipRect, oBB);
UpdateOutputDC();
}
void Read_EMR_EXTSELECTCLIPRGN()
......@@ -1169,7 +1261,10 @@ namespace MetaFile
m_oStream >> ulRgnDataSize >> ulRegionMode;
m_oStream.Skip(m_ulRecordSize - 8);
// TODO:
// . , ..
// .
m_pDC->GetClip()->Reset();
}
void Read_EMR_SETMETARGN()
{
......@@ -1208,7 +1303,11 @@ namespace MetaFile
{
TEmfRectL oClip;
m_oStream >> oClip;
m_pDC->GetClip()->Intersect(oClip);
TRectD oClipRect;
TranslatePoint(oClip.lLeft, oClip.lTop, oClipRect.dLeft, oClipRect.dTop);
TranslatePoint(oClip.lRight, oClip.lBottom, oClipRect.dRight, oClipRect.dBottom);
m_pDC->GetClip()->Intersect(oClipRect);
}
void Read_EMR_SETLAYOUT()
{
......@@ -1245,6 +1344,12 @@ namespace MetaFile
// TODO:
if (dSweepAngle < 0.001)
dSweepAngle += 360;
// TODO:
if (AD_COUNTERCLOCKWISE != m_pDC->GetArcDirection())
{
dSweepAngle = dSweepAngle - 360;
}
}
void Read_EMR_ARC()
{
......@@ -1700,10 +1805,20 @@ namespace MetaFile
TEmfRectL oBox;
m_oStream >> oBox;
MoveTo(oBox.lLeft, oBox.lTop);
LineTo(oBox.lRight, oBox.lTop);
LineTo(oBox.lRight, oBox.lBottom);
LineTo(oBox.lLeft, oBox.lBottom);
if (AD_COUNTERCLOCKWISE == m_pDC->GetArcDirection())
{
MoveTo(oBox.lLeft, oBox.lTop);
LineTo(oBox.lLeft, oBox.lBottom);
LineTo(oBox.lRight, oBox.lBottom);
LineTo(oBox.lRight, oBox.lTop);
}
else
{
MoveTo(oBox.lLeft, oBox.lTop);
LineTo(oBox.lRight, oBox.lTop);
LineTo(oBox.lRight, oBox.lBottom);
LineTo(oBox.lLeft, oBox.lBottom);
}
ClosePath();
DrawPath(true, true);
}
......@@ -1719,15 +1834,31 @@ namespace MetaFile
int lRoundW = (std::min)((int)oCorner.cx, lBoxW / 2);
int lRoundH = (std::min)((int)oCorner.cy, lBoxH / 2);
MoveTo(oBox.lLeft + lRoundW, oBox.lTop);
LineTo(oBox.lRight - lRoundW, oBox.lTop);
ArcTo(oBox.lRight - lRoundW, oBox.lTop, oBox.lRight, oBox.lTop + lRoundH, -90, 90);
LineTo(oBox.lRight, oBox.lBottom - lRoundH);
ArcTo(oBox.lRight - lRoundW, oBox.lBottom - lRoundH, oBox.lRight, oBox.lBottom, 0, 90);
LineTo(oBox.lLeft + lRoundW, oBox.lBottom);
ArcTo(oBox.lLeft, oBox.lBottom - lRoundH, oBox.lLeft + lRoundW, oBox.lBottom, 90, 90);
LineTo(oBox.lLeft, oBox.lTop + lRoundH);
ArcTo(oBox.lLeft, oBox.lTop, oBox.lLeft + lRoundW, oBox.lTop + lRoundH, 180, 90);
if (AD_COUNTERCLOCKWISE == m_pDC->GetArcDirection())
{
MoveTo(oBox.lLeft + lRoundW, oBox.lTop);
ArcTo(oBox.lLeft, oBox.lTop, oBox.lLeft + lRoundW, oBox.lTop + lRoundH, 270, -90);
LineTo(oBox.lLeft, oBox.lBottom - lRoundH);
ArcTo(oBox.lLeft, oBox.lBottom - lRoundH, oBox.lLeft + lRoundW, oBox.lBottom, 180, -90);
LineTo(oBox.lRight - lRoundW, oBox.lBottom);
ArcTo(oBox.lRight - lRoundW, oBox.lBottom - lRoundH, oBox.lRight, oBox.lBottom, 90, -90);
LineTo(oBox.lRight, oBox.lTop + lRoundH);
ArcTo(oBox.lRight - lRoundW, oBox.lTop, oBox.lRight, oBox.lTop + lRoundH, 0, -90);
LineTo(oBox.lLeft + lRoundW, oBox.lTop);
}
else
{
MoveTo(oBox.lLeft + lRoundW, oBox.lTop);
LineTo(oBox.lRight - lRoundW, oBox.lTop);
ArcTo(oBox.lRight - lRoundW, oBox.lTop, oBox.lRight, oBox.lTop + lRoundH, -90, 90);
LineTo(oBox.lRight, oBox.lBottom - lRoundH);
ArcTo(oBox.lRight - lRoundW, oBox.lBottom - lRoundH, oBox.lRight, oBox.lBottom, 0, 90);
LineTo(oBox.lLeft + lRoundW, oBox.lBottom);
ArcTo(oBox.lLeft, oBox.lBottom - lRoundH, oBox.lLeft + lRoundW, oBox.lBottom, 90, 90);
LineTo(oBox.lLeft, oBox.lTop + lRoundH);
ArcTo(oBox.lLeft, oBox.lTop, oBox.lLeft + lRoundW, oBox.lTop + lRoundH, 180, 90);
}
ClosePath();
DrawPath(true, true);
}
......@@ -1746,8 +1877,7 @@ namespace MetaFile
pBgraBuffer[2] = oColor.r;
pBgraBuffer[3] = 0xff;
if (m_pOutput)
m_pOutput->DrawBitmap(oPoint.x, oPoint.y, 1, 1, pBgraBuffer, 1, 1);
DrawImage(oPoint.x, oPoint.y, 1, 1, pBgraBuffer, 1, 1);
}
void Read_EMR_SMALLTEXTOUT()
{
......
......@@ -50,90 +50,30 @@ namespace MetaFile
CEmfPath::~CEmfPath()
{
Clear();
}
bool CEmfPath::MoveTo(TEmfPointS& oPoint)
{
CEmfPathCommandBase* pCommand = new CEmfPathMoveTo(oPoint);
if (!pCommand)
return false;
m_pCommands.push_back(pCommand);
return true;
}
bool CEmfPath::MoveTo(TEmfPointL& oPoint)
{
CEmfPathCommandBase* pCommand = new CEmfPathMoveTo(oPoint);
if (!pCommand)
return false;
m_pCommands.push_back(pCommand);
return true;
}
bool CEmfPath::MoveTo(int lX, int lY)
}
bool CEmfPath::MoveTo(double dX, double dY)
{
CEmfPathCommandBase* pCommand = new CEmfPathMoveTo(lX, lY);
CEmfPathCommandBase* pCommand = new CEmfPathMoveTo(dX, dY);
if (!pCommand)
return false;
m_pCommands.push_back(pCommand);
return true;
}
bool CEmfPath::LineTo(TEmfPointS& oPoint)
{
CEmfPathCommandBase* pCommand = new CEmfPathLineTo(oPoint);
if (!pCommand)
return false;
m_pCommands.push_back(pCommand);
return true;
}
bool CEmfPath::LineTo(TEmfPointL& oPoint)
}
bool CEmfPath::LineTo(double dX, double dY)
{
CEmfPathCommandBase* pCommand = new CEmfPathLineTo(oPoint);
CEmfPathCommandBase* pCommand = new CEmfPathLineTo(dX, dY);
if (!pCommand)
return false;
m_pCommands.push_back(pCommand);
return true;
}
bool CEmfPath::LineTo(int lX, int lY)
{
CEmfPathCommandBase* pCommand = new CEmfPathLineTo(lX, lY);
if (!pCommand)
return false;
m_pCommands.push_back(pCommand);
return true;
}
bool CEmfPath::CurveTo(TEmfPointS& oPoint1, TEmfPointS& oPoint2, TEmfPointS& oPointE)
{
CEmfPathCommandBase* pCommand = new CEmfPathCurveTo(oPoint1, oPoint2, oPointE);
if (!pCommand)
return false;
m_pCommands.push_back(pCommand);
return true;
}
bool CEmfPath::CurveTo(TEmfPointL& oPoint1, TEmfPointL& oPoint2, TEmfPointL& oPointE)
{
CEmfPathCommandBase* pCommand = new CEmfPathCurveTo(oPoint1, oPoint2, oPointE);
if (!pCommand)
return false;
m_pCommands.push_back(pCommand);
return true;
}
bool CEmfPath::CurveTo(int lX1, int lY1, int lX2, int lY2, int lXE, int lYE)
}
bool CEmfPath::CurveTo(double dX1, double dY1, double dX2, double dY2, double dXE, double dYE)
{
CEmfPathCommandBase* pCommand = new CEmfPathCurveTo(lX1, lY1, lX2, lY2, lXE, lYE);
CEmfPathCommandBase* pCommand = new CEmfPathCurveTo(dX1, dY1, dX2, dY2, dXE, dYE);
if (!pCommand)
return false;
......@@ -141,9 +81,9 @@ namespace MetaFile
return true;
}
bool CEmfPath::ArcTo(int lL, int lT, int lR, int lB, double dStart, double dSweep)
bool CEmfPath::ArcTo(double dL, double dT, double dR, double dB, double dStart, double dSweep)
{
CEmfPathCommandBase* pCommand = new CEmfPathArcTo(lL, lT, lR, lB, dStart, dSweep);
CEmfPathCommandBase* pCommand = new CEmfPathArcTo(dL, dT, dR, dB, dStart, dSweep);
if (!pCommand)
return false;
......
......@@ -32,20 +32,10 @@ namespace MetaFile
class CEmfPathMoveTo : public CEmfPathCommandBase
{
public:
CEmfPathMoveTo(TEmfPointL& oPoint)
CEmfPathMoveTo(double dX, double dY)
{
x = oPoint.x;
y = oPoint.y;
}
CEmfPathMoveTo(TEmfPointS& oPoint)
{
x = oPoint.x;
y = oPoint.y;
}
CEmfPathMoveTo(int lX, int lY)
{
x = lX;
y = lY;
x = dX;
y = dY;
}
virtual ~CEmfPathMoveTo()
{
......@@ -57,26 +47,16 @@ namespace MetaFile
public:
int x;
int y;
double x;
double y;
};
class CEmfPathLineTo : public CEmfPathCommandBase
{
public:
CEmfPathLineTo(TEmfPointL& oPoint)
{
x = oPoint.x;
y = oPoint.y;
}
CEmfPathLineTo(TEmfPointS& oPoint)
CEmfPathLineTo(double dX, double dY)
{
x = oPoint.x;
y = oPoint.y;
}
CEmfPathLineTo(int lX, int lY)
{
x = lX;
y = lY;
x = dX;
y = dY;
}
virtual ~CEmfPathLineTo()
{
......@@ -88,38 +68,20 @@ namespace MetaFile
public:
int x;
int y;
double x;
double y;
};
class CEmfPathCurveTo : public CEmfPathCommandBase
{
public:
CEmfPathCurveTo(TEmfPointL& oPoint1, TEmfPointL& oPoint2, TEmfPointL& oPointE)
{
x1 = oPoint1.x;
y1 = oPoint1.y;
x2 = oPoint2.x;
y2 = oPoint2.y;
xE = oPointE.x;
yE = oPointE.y;
}
CEmfPathCurveTo(TEmfPointS& oPoint1, TEmfPointS& oPoint2, TEmfPointS& oPointE)
{
x1 = oPoint1.x;
y1 = oPoint1.y;
x2 = oPoint2.x;
y2 = oPoint2.y;
xE = oPointE.x;
yE = oPointE.y;
}
CEmfPathCurveTo(int lX1, int lY1, int lX2, int lY2, int lXE, int lYE)
CEmfPathCurveTo(double dX1, double dY1, double dX2, double dY2, double dXE, double dYE)
{
x1 = lX1;
y1 = lY1;
x2 = lX2;
y2 = lY2;
xE = lXE;
yE = lYE;
x1 = dX1;
y1 = dY1;
x2 = dX2;
y2 = dY2;
xE = dXE;
yE = dYE;
}
virtual ~CEmfPathCurveTo()
{
......@@ -131,22 +93,22 @@ namespace MetaFile
public:
int x1;
int y1;
int x2;
int y2;
int xE;
int yE;
double x1;
double y1;
double x2;
double y2;
double xE;
double yE;
};
class CEmfPathArcTo : public CEmfPathCommandBase
{
public:
CEmfPathArcTo(int lL, int lT, int lR, int lB, double dStart, double dSweep)
CEmfPathArcTo(double dL, double dT, double dR, double dB, double dStart, double dSweep)
{
left = lL;
top = lT;
right = lR;
bottom = lB;
left = dL;
top = dT;
right = dR;
bottom = dB;
start = dStart;
sweep = dSweep;
}
......@@ -160,10 +122,10 @@ namespace MetaFile
public:
int left;
int top;
int right;
int bottom;
double left;
double top;
double right;
double bottom;
double start;
double sweep;
};
......@@ -192,16 +154,10 @@ namespace MetaFile
CEmfPath(CEmfPath* pPath);
~CEmfPath();
bool MoveTo(TEmfPointS& oPoint);
bool MoveTo(TEmfPointL& oPoint);
bool MoveTo(int lX, int lY);
bool LineTo(TEmfPointS& oPoint);
bool LineTo(TEmfPointL& oPoint);
bool LineTo(int lX, int lY);
bool CurveTo(TEmfPointS& oPoint1, TEmfPointS& oPoint2, TEmfPointS& oPointE);
bool CurveTo(TEmfPointL& oPoint1, TEmfPointL& oPoint2, TEmfPointL& oPointE);
bool CurveTo(int lX1, int lY1, int lX2, int lY2, int lXE, int lYE);
bool ArcTo(int lL, int lT, int lR, int lB, double dStart, double dSweep);
bool MoveTo(double dX, double dY);
bool LineTo(double dX, double dY);
bool CurveTo(double dX1, double dY1, double dX2, double dY2, double dXE, double dYE);
bool ArcTo(double dL, double dT, double dR, double dB, double dStart, double dSweep);
bool Close();
void Draw(IOutputDevice* pOutput, bool bStroke, bool bFill, unsigned int unClipMode = -1);
......
......@@ -33,7 +33,7 @@ namespace MetaFile
}
m_mObjects.clear();
}
void CEmfPlayer::Clear()
void CEmfPlayer::Clear()
{
for (int nIndex = 0; nIndex < m_vDCStack.size(); nIndex++)
{
......@@ -59,6 +59,9 @@ namespace MetaFile
m_pDC = pDC;
m_vDCStack.push_back(pDC);
InitStockObjects();
SelectObject(0x80000007); // BLACK_PEN
SelectObject(0x80000000); // WHITE_BRUSH
}
CEmfDC* CEmfPlayer::SaveDC()
{
......@@ -99,7 +102,7 @@ namespace MetaFile
{
return m_pDC;
}
void CEmfPlayer::RegisterObject(unsigned int ulIndex, CEmfObjectBase* pObject)
void CEmfPlayer::RegisterObject(unsigned int ulIndex, CEmfObjectBase* pObject)
{
CEmfObjectMap::const_iterator oPos = m_mObjects.find(ulIndex);
if (m_mObjects.end() != oPos)
......@@ -111,7 +114,7 @@ namespace MetaFile
m_mObjects.insert(std::pair<unsigned int, CEmfObjectBase*>(ulIndex, pObject));
}
void CEmfPlayer::SelectObject(unsigned int ulIndex)
void CEmfPlayer::SelectObject(unsigned int ulIndex)
{
CEmfObjectMap::const_iterator oPos = m_mObjects.find(ulIndex);
if (m_mObjects.end() != oPos)
......@@ -126,7 +129,7 @@ namespace MetaFile
}
}
}
void CEmfPlayer::SelectPalette(unsigned int ulIndex)
void CEmfPlayer::SelectPalette(unsigned int ulIndex)
{
// DEFAULT_PALETTE
if (ulIndex == 0x8000000F)
......@@ -140,7 +143,7 @@ namespace MetaFile
m_pDC->SetPalette((CEmfLogPalette*)pObject);
}
}
void CEmfPlayer::DeleteObject(unsigned int ulIndex)
void CEmfPlayer::DeleteObject(unsigned int ulIndex)
{
// TODO: DC_BRUSH DC_PEN
......@@ -165,7 +168,7 @@ namespace MetaFile
m_mObjects.erase(ulIndex);
}
}
void CEmfPlayer::InitStockObjects()
void CEmfPlayer::InitStockObjects()
{
InitStockBrush(false, 0xff, 0xff, 0xff, 0x80000000);
InitStockBrush(false, 0xc0, 0xc0, 0xc0, 0x80000001);
......@@ -180,7 +183,7 @@ namespace MetaFile
// DC_BRUSH DC_PEN
}
void CEmfPlayer::InitStockBrush(bool bNull, unsigned char r, unsigned char g, unsigned char b, unsigned int ulIndex)
void CEmfPlayer::InitStockBrush(bool bNull, unsigned char r, unsigned char g, unsigned char b, unsigned int ulIndex)
{
CEmfLogBrushEx* pBrush = new CEmfLogBrushEx();
if (!pBrush)
......@@ -196,7 +199,7 @@ namespace MetaFile
RegisterObject(ulIndex, (CEmfObjectBase*)pBrush);
}
void CEmfPlayer::InitStockPen(bool bNull, unsigned char r, unsigned char g, unsigned char b, unsigned int ulIndex)
void CEmfPlayer::InitStockPen(bool bNull, unsigned char r, unsigned char g, unsigned char b, unsigned int ulIndex)
{
CEmfLogPen* pPen = new CEmfLogPen();
if (!pPen)
......@@ -216,8 +219,8 @@ namespace MetaFile
CEmfDC::CEmfDC()
{
m_ulMapMode = MM_TEXT;
m_pBrush = &m_oDefaultBrush;
m_pPen = &m_oDefaultPen;
m_pBrush = NULL;
m_pPen = NULL;
m_pFont = NULL;
m_oTransform.Init();
m_oInverseTransform.Init();
......@@ -232,45 +235,45 @@ namespace MetaFile
m_oViewport.Init();
m_dPixelHeight = 1;
m_dPixelWidth = 1;
m_pPen = NULL;
m_pFont = NULL;
m_oCurPos.x = 0;
m_oCurPos.y = 0;
m_unArcDirection = AD_COUNTERCLOCKWISE;
}
CEmfDC::~CEmfDC()
{
}
CEmfDC* CEmfDC::Copy()
CEmfDC* CEmfDC::Copy()
{
CEmfDC* pNewDC = new CEmfDC();
if (!pNewDC)
return NULL;
pNewDC->m_ulMapMode = m_ulMapMode;
pNewDC->m_pBrush = m_pBrush;
pNewDC->m_pPen = m_pPen;
pNewDC->m_pFont = m_pFont;
pNewDC->m_pPalette = m_pPalette;
pNewDC->m_ulMapMode = m_ulMapMode;
pNewDC->m_pBrush = m_pBrush;
pNewDC->m_pPen = m_pPen;
pNewDC->m_pFont = m_pFont;
pNewDC->m_pPalette = m_pPalette;
pNewDC->m_oTransform.Copy(&m_oTransform);
pNewDC->m_oInverseTransform.Copy(&m_oInverseTransform);
pNewDC->m_oTextColor.Copy(&m_oTextColor);
pNewDC->m_oBgColor.Copy(&m_oBgColor);
pNewDC->m_ulTextAlign = m_ulTextAlign;
pNewDC->m_ulBgMode = m_ulBgMode;
pNewDC->m_ulMiterLimit = m_ulMiterLimit;
pNewDC->m_ulFillMode = m_ulFillMode;
pNewDC->m_ulStretchMode = m_ulStretchMode;
pNewDC->m_ulRop2Mode = m_ulRop2Mode;
pNewDC->m_dPixelHeight = m_dPixelHeight;
pNewDC->m_dPixelWidth = m_dPixelWidth;
pNewDC->m_ulTextAlign = m_ulTextAlign;
pNewDC->m_ulBgMode = m_ulBgMode;
pNewDC->m_ulMiterLimit = m_ulMiterLimit;
pNewDC->m_ulFillMode = m_ulFillMode;
pNewDC->m_ulStretchMode = m_ulStretchMode;
pNewDC->m_ulRop2Mode = m_ulRop2Mode;
pNewDC->m_dPixelHeight = m_dPixelHeight;
pNewDC->m_dPixelWidth = m_dPixelWidth;
pNewDC->m_oWindow.Copy(&m_oWindow);
pNewDC->m_oViewport.Copy(&m_oViewport);
pNewDC->m_oCurPos = m_oCurPos;
pNewDC->m_oClip = m_oClip;
pNewDC->m_oCurPos = m_oCurPos;
pNewDC->m_oClip = m_oClip;
pNewDC->m_unArcDirection = m_unArcDirection;
return pNewDC;
}
void CEmfDC::SetMapMode(unsigned int ulMapMode)
void CEmfDC::SetMapMode(unsigned int ulMapMode)
{
m_ulMapMode = ulMapMode;
......@@ -324,19 +327,19 @@ namespace MetaFile
}
}
}
unsigned int CEmfDC::GetMapMode()
unsigned int CEmfDC::GetMapMode()
{
return m_ulMapMode;
}
TEmfXForm* CEmfDC::GetTransform()
TEmfXForm* CEmfDC::GetTransform()
{
return &m_oTransform;
}
TEmfXForm* CEmfDC::GetInverseTransform()
TEmfXForm* CEmfDC::GetInverseTransform()
{
return &m_oInverseTransform;
}
void CEmfDC::MultiplyTransform(TEmfXForm& oForm, unsigned int ulMode)
void CEmfDC::MultiplyTransform(TEmfXForm& oForm, unsigned int ulMode)
{
m_oTransform.Multiply(oForm, ulMode);
......@@ -360,19 +363,19 @@ namespace MetaFile
m_oInverseTransform.Dx = pT->Dy * pT->M21 / dDet - pT->Dx * pT->M22 / dDet;
m_oInverseTransform.Dy = pT->Dx * pT->M12 / dDet - pT->Dy * pT->M11 / dDet;
}
void CEmfDC::SetTextColor(TEmfColor& oColor)
void CEmfDC::SetTextColor(TEmfColor& oColor)
{
m_oTextColor.Copy(&oColor);
}
TEmfColor& CEmfDC::GetTextColor()
TEmfColor& CEmfDC::GetTextColor()
{
return m_oTextColor;
}
void CEmfDC::SetBrush(CEmfLogBrushEx* pBrush)
void CEmfDC::SetBrush(CEmfLogBrushEx* pBrush)
{
m_pBrush = pBrush;
}
void CEmfDC::RemoveBrush(CEmfLogBrushEx* pBrush)
void CEmfDC::RemoveBrush(CEmfLogBrushEx* pBrush)
{
if (pBrush == m_pBrush)
m_pBrush = NULL;
......@@ -381,129 +384,129 @@ namespace MetaFile
{
return m_pBrush;
}
void CEmfDC::SetFont(CEmfLogFont* pFont)
void CEmfDC::SetFont(CEmfLogFont* pFont)
{
m_pFont = pFont;
}
void CEmfDC::RemoveFont(CEmfLogFont* pFont)
void CEmfDC::RemoveFont(CEmfLogFont* pFont)
{
if (pFont == m_pFont)
m_pFont = NULL;
}
CEmfLogFont* CEmfDC::GetFont()
CEmfLogFont* CEmfDC::GetFont()
{
return m_pFont;
}
void CEmfDC::SetTextAlign(unsigned int ulAlign)
void CEmfDC::SetTextAlign(unsigned int ulAlign)
{
m_ulTextAlign = ulAlign;
}
unsigned int CEmfDC::GetTextAlign()
unsigned int CEmfDC::GetTextAlign()
{
return m_ulTextAlign;
}
void CEmfDC::SetBgMode(unsigned int ulBgMode)
void CEmfDC::SetBgMode(unsigned int ulBgMode)
{
m_ulBgMode = ulBgMode;
}
unsigned int CEmfDC::GetBgMode()
unsigned int CEmfDC::GetBgMode()
{
return m_ulBgMode;
}
void CEmfDC::SetBgColor(TEmfColor& oColor)
void CEmfDC::SetBgColor(TEmfColor& oColor)
{
m_oBgColor.Copy(&oColor);
}
TEmfColor& CEmfDC::GetBgColor()
TEmfColor& CEmfDC::GetBgColor()
{
return m_oBgColor;
}
void CEmfDC::SetMiterLimit(unsigned int ulMiter)
void CEmfDC::SetMiterLimit(unsigned int ulMiter)
{
m_ulMiterLimit = ulMiter;
}
unsigned int CEmfDC::GetMiterLimit()
unsigned int CEmfDC::GetMiterLimit()
{
return m_ulMiterLimit;
}
void CEmfDC::SetFillMode(unsigned int ulFillMode)
void CEmfDC::SetFillMode(unsigned int ulFillMode)
{
m_ulFillMode = ulFillMode;
}
unsigned int CEmfDC::GetFillMode()
unsigned int CEmfDC::GetFillMode()
{
return m_ulFillMode;
}
void CEmfDC::SetPen(CEmfLogPen* pPen)
void CEmfDC::SetPen(CEmfLogPen* pPen)
{
m_pPen = pPen;
}
void CEmfDC::RemovePen(CEmfLogPen* pPen)
void CEmfDC::RemovePen(CEmfLogPen* pPen)
{
if (pPen == m_pPen)
m_pPen = NULL;
}
CEmfLogPen* CEmfDC::GetPen()
CEmfLogPen* CEmfDC::GetPen()
{
return m_pPen;
}
void CEmfDC::SetStretchMode(unsigned int& oMode)
void CEmfDC::SetStretchMode(unsigned int& oMode)
{
m_ulStretchMode = oMode;
}
unsigned int CEmfDC::GetStretchMode()
unsigned int CEmfDC::GetStretchMode()
{
return m_ulStretchMode;
}
double CEmfDC::GetPixelWidth()
double CEmfDC::GetPixelWidth()
{
return m_dPixelWidth;
}
double CEmfDC::GetPixelHeight()
double CEmfDC::GetPixelHeight()
{
return m_dPixelHeight;
}
void CEmfDC::SetPixelWidth(double dPixelW)
void CEmfDC::SetPixelWidth(double dPixelW)
{
m_dPixelWidth = dPixelW;
}
void CEmfDC::SetPixelHeight(double dPixelH)
void CEmfDC::SetPixelHeight(double dPixelH)
{
m_dPixelHeight = dPixelH;
}
void CEmfDC::SetWindowOrigin(TEmfPointL& oPoint)
void CEmfDC::SetWindowOrigin(TEmfPointL& oPoint)
{
m_oWindow.lX = oPoint.x;
m_oWindow.lY = oPoint.y;
UpdatePixelMetrics();
}
void CEmfDC::SetWindowExtents(TEmfSizeL& oPoint)
void CEmfDC::SetWindowExtents(TEmfSizeL& oPoint)
{
m_oWindow.ulW = oPoint.cx;
m_oWindow.ulH = oPoint.cy;
UpdatePixelMetrics();
}
TEmfWindow* CEmfDC::GetWindow()
TEmfWindow* CEmfDC::GetWindow()
{
return &m_oWindow;
}
void CEmfDC::SetViewportOrigin(TEmfPointL& oPoint)
void CEmfDC::SetViewportOrigin(TEmfPointL& oPoint)
{
m_oViewport.lX = oPoint.x;
m_oViewport.lY = oPoint.y;
UpdatePixelMetrics();
}
void CEmfDC::SetViewportExtents(TEmfSizeL& oPoint)
void CEmfDC::SetViewportExtents(TEmfSizeL& oPoint)
{
m_oViewport.ulW = oPoint.cx;
m_oViewport.ulH = oPoint.cy;
UpdatePixelMetrics();
}
TEmfWindow* CEmfDC::GetViewport()
TEmfWindow* CEmfDC::GetViewport()
{
return &m_oViewport;
}
bool CEmfDC::UpdatePixelMetrics()
bool CEmfDC::UpdatePixelMetrics()
{
unsigned int ulMapMode = m_ulMapMode;
if (MM_ISOTROPIC == ulMapMode)
......@@ -526,19 +529,19 @@ namespace MetaFile
return true;
}
void CEmfDC::SetRop2Mode(unsigned int& nMode)
void CEmfDC::SetRop2Mode(unsigned int& nMode)
{
m_ulRop2Mode = nMode;
}
unsigned int CEmfDC::GetRop2Mode()
unsigned int CEmfDC::GetRop2Mode()
{
return m_ulRop2Mode;
}
void CEmfDC::SetPalette(CEmfLogPalette* pPalette)
void CEmfDC::SetPalette(CEmfLogPalette* pPalette)
{
m_pPalette = pPalette;
}
void CEmfDC::RemovePalette(CEmfLogPalette* pPalette)
void CEmfDC::RemovePalette(CEmfLogPalette* pPalette)
{
if (m_pPalette == pPalette)
m_pPalette = NULL;
......@@ -547,25 +550,33 @@ namespace MetaFile
{
return m_pPalette;
}
void CEmfDC::SetCurPos(TEmfPointL& oPoint)
void CEmfDC::SetCurPos(TEmfPointL& oPoint)
{
SetCurPos(oPoint.x, oPoint.y);
}
void CEmfDC::SetCurPos(int lX, int lY)
void CEmfDC::SetCurPos(int lX, int lY)
{
m_oCurPos.x = lX;
m_oCurPos.y = lY;
}
TEmfPointL& CEmfDC::GetCurPos()
TEmfPointL& CEmfDC::GetCurPos()
{
return m_oCurPos;
}
CEmfClip* CEmfDC::GetClip()
CEmfClip* CEmfDC::GetClip()
{
return &m_oClip;
}
void CEmfDC::ClipToPath(CEmfPath* pPath, unsigned int unMode)
void CEmfDC::ClipToPath(CEmfPath* pPath, unsigned int unMode)
{
m_oClip.SetPath(pPath, unMode);
}
void CEmfDC::SetArcDirection(unsigned int unDirection)
{
m_unArcDirection = unDirection;
}
unsigned int CEmfDC::GetArcDirection()
{
return m_unArcDirection;
}
}
\ No newline at end of file
......@@ -54,7 +54,7 @@ namespace MetaFile
CEmfDC* Copy();
void SetMapMode(unsigned int ulMapMode);
unsigned int GetMapMode();
unsigned int GetMapMode();
TEmfXForm* GetTransform();
TEmfXForm* GetInverseTransform();
void MultiplyTransform(TEmfXForm& oForm, unsigned int ulMode);
......@@ -67,20 +67,20 @@ namespace MetaFile
void RemoveFont(CEmfLogFont* pFont);
CEmfLogFont* GetFont();
void SetTextAlign(unsigned int ulAlign);
unsigned int GetTextAlign();
unsigned int GetTextAlign();
void SetBgMode(unsigned int ulBgMode);
unsigned int GetBgMode();
unsigned int GetBgMode();
void SetBgColor(TEmfColor& oColor);
TEmfColor& GetBgColor();
void SetMiterLimit(unsigned int ulMiter);
unsigned int GetMiterLimit();
unsigned int GetMiterLimit();
void SetFillMode(unsigned int ulFillMode);
unsigned int GetFillMode();
unsigned int GetFillMode();
void SetPen(CEmfLogPen* pPen);
void RemovePen(CEmfLogPen* pPen);
CEmfLogPen* GetPen();
void SetStretchMode(unsigned int& oMode);
unsigned int GetStretchMode();
unsigned int GetStretchMode();
double GetPixelWidth();
double GetPixelHeight();
void SetWindowOrigin(TEmfPointL& oPoint);
......@@ -90,7 +90,7 @@ namespace MetaFile
void SetViewportExtents(TEmfSizeL& oPoint);
TEmfWindow* GetViewport();
void SetRop2Mode(unsigned int& nMode);
unsigned int GetRop2Mode();
unsigned int GetRop2Mode();
void SetPalette(CEmfLogPalette* pPalette);
void RemovePalette(CEmfLogPalette* pPalette);
CEmfLogPalette* GetPalette();
......@@ -99,6 +99,8 @@ namespace MetaFile
TEmfPointL& GetCurPos();
CEmfClip* GetClip();
void ClipToPath(CEmfPath* pPath, unsigned int unMode);
void SetArcDirection(unsigned int unDirection);
unsigned int GetArcDirection();
private:
......@@ -108,8 +110,6 @@ namespace MetaFile
private:
CEmfLogPen m_oDefaultPen;
CEmfLogBrushEx m_oDefaultBrush;
unsigned int m_ulMapMode;
CEmfLogBrushEx* m_pBrush;
CEmfLogPen* m_pPen;
......@@ -131,6 +131,7 @@ namespace MetaFile
TEmfWindow m_oViewport;
TEmfPointL m_oCurPos;
CEmfClip m_oClip;
unsigned int m_unArcDirection;
};
}
......
......@@ -675,11 +675,10 @@ namespace MetaFile
if (!(fuOptions & ETO_NO_RECT))
unSize += 16;
// .
if (fuOptions & ETO_SMALL_CHARS)
unSize += (cChars - 1);
unSize += cChars;
else
unSize += 2 * (cChars - 1);
unSize += 2 * cChars;
return unSize;
}
......
......@@ -160,7 +160,7 @@ namespace MetaFile
if (!pBgraData)
return;
memset(pBgraData, 0x00, nWidth * nHeight * 4);
memset(pBgraData, 0xff, nWidth * nHeight * 4);
CBgraFrame oFrame;
oFrame.put_Data(pBgraData);
oFrame.put_Width(nWidth);
......
......@@ -42,11 +42,11 @@ void ConvertFile(CMetaFile &oMetaFile, std::wstring wsFilePath)
oMetaFile.ConvertToRaster(wsDstFilePath.c_str(), 4, 1000);
}
}
void ConvertFolder(CMetaFile &oMetaFile, std::wstring wsFolderPath)
void ConvertFolder(CMetaFile &oMetaFile, std::wstring wsFolderPath, const int nType)
{
oMetaFile.Close();
std::vector<std::wstring> vFiles = GetAllFilesInFolder(wsFolderPath, L"wmf");
std::vector<std::wstring> vFiles = GetAllFilesInFolder(wsFolderPath, nType == c_lMetaEmf ? L"emf" : L"wmf");
for (int nIndex = 0; nIndex < vFiles.size(); nIndex++)
{
std::wstring wsFilePath = wsFolderPath;
......@@ -62,20 +62,14 @@ void ConvertFolder(CMetaFile &oMetaFile, std::wstring wsFolderPath)
}
}
#include "../../common/String.h"
void Test()
void main()
{
CApplicationFonts oFonts;
oFonts.Initialize();
CMetaFile oMetaFile(&oFonts);
//ConvertFile(oMetaFile, L"D://Test Files//fulltest.wmf");
ConvertFolder(oMetaFile, L"D://Test Files//Bugs//ALL//");
}
ConvertFolder(oMetaFile, L"D://Test Files//", c_lMetaEmf);
void main()
{
Test();
//_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
//_CrtDumpMemoryLeaks();
}
\ No newline at end of file
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