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)
{
......
......@@ -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);
......
This diff is collapsed.
......@@ -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