Commit 62f42732 authored by Elen.Subbotina's avatar Elen.Subbotina Committed by Alexander Trofimov

.....

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@61942 954022d7-b5bf-4e40-9824-e11837661b57
parent 05da13a9
This diff is collapsed.
#include "ArrowHead.h"
namespace Aggplus
{
CArrowHead::CArrowHead()
{
m_lType = 0;
m_bIsMoveTo = false;
m_dX1 = 0;
m_dY1 = 0;
m_dX2 = 1;
m_dY2 = 1;
}
CArrowHead::~CArrowHead()
{
}
void CArrowHead::SetType(LONG lType)
{
m_lType = lType;
switch (m_lType)
{
case Aggplus::LineCapSquareAnchor:
case Aggplus::LineCapRoundAnchor:
case Aggplus::LineCapDiamondAnchor:
case Aggplus::LineCapArrowAnchor:
break;
default:
m_lType = 0;
break;
}
}
bool CArrowHead::IsNeed()
{
return (0 != m_lType);
}
void CArrowHead::PathCommandMoveTo(double fX, double fY)
{
if (!IsNeed())
return;
m_bIsMoveTo = true;
m_oPath.MoveTo(fX, fY);
m_oPath.LineTo(fX, fY);
}
void CArrowHead::PathCommandLineTo(double fX, double fY)
{
if (!IsNeed())
return;
m_oPath.LineTo(fX, fY);
}
void CArrowHead::PathCommandLinesTo(double* pPoints, LONG lCount)
{
if (!IsNeed())
return;
if (!m_bIsMoveTo && (lCount >= 2))
{
PathCommandMoveTo(pPoints[0], pPoints[1]);
}
m_oPath.AddLines(pPoints, lCount);
}
void CArrowHead::PathCommandCurveTo(double fX1, double fY1, double fX2, double fY2, double fX3, double fY3)
{
if (!IsNeed())
return;
m_oPath.CurveTo(fX1, fY1, fX2, fY2, fX3, fY3);
}
void CArrowHead::PathCommandCurvesTo(double* pPoints, LONG lCount)
{
if (!IsNeed())
return;
if (!m_bIsMoveTo && (lCount >= 2))
{
PathCommandMoveTo(pPoints[0], pPoints[1]);
}
m_oPath.AddBeziers(pPoints, lCount);
}
void CArrowHead::PathCommandArcTo(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle)
{
if (!IsNeed())
return;
m_oPath.AddArc2(fX, fY, fWidth, fHeight, -fStartAngle, -fSweepAngle);
}
void CArrowHead::PathCommandClose()
{
if (!IsNeed())
return;
m_oPath.Reset();
}
void CArrowHead::PathCommandEnd()
{
if (!IsNeed())
return;
m_oPath.Reset();
m_bIsMoveTo = false;
}
void CArrowHead::PathCommandStart()
{
if (!IsNeed())
return;
m_oPath.StartFigure();
}
bool CArrowHead::DrawPath(LONG lType)
{
if (!IsNeed())
return false;
if (lType & 0x01)
{
m_oPath.Transform(&m_oTransform);
LONG lCount = (LONG)m_oPath.GetPointCount();
if (2 > lCount)
return false;
double* pPoints = new double[2 * lCount];
m_oPath.GetPathPoints(pPoints, lCount);
m_dX1 = pPoints[2 * lCount - 4];
m_dY1 = pPoints[2 * lCount - 3];
m_dX2 = pPoints[2 * lCount - 2];
m_dY2 = pPoints[2 * lCount - 1];
RELEASEARRAYOBJECTS(pPoints);
return true;
}
return false;
}
}
\ No newline at end of file
#ifndef _BUILD_ARROW_HEAD_H_
#define _BUILD_ARROW_HEAD_H_
#include "GraphicsPath.h"
namespace Aggplus
{
class CArrowHead
{
private:
LONG m_lType;
CMatrix m_oTransform;
bool m_bIsMoveTo;
CGraphicsPath m_oPath;
public:
double m_dX1;
double m_dY1;
double m_dX2;
double m_dY2;
public:
CArrowHead();
~CArrowHead();
public:
void SetType(LONG lType);
bool IsNeed();
void PathCommandMoveTo(double fX, double fY);
void PathCommandLineTo(double fX, double fY);
void PathCommandLinesTo(double* pPoints, LONG lCount);
void PathCommandCurveTo(double fX1, double fY1, double fX2, double fY2, double fX3, double fY3);
void PathCommandCurvesTo(double* pPoints, LONG lCount);
void PathCommandArcTo(double fX, double fY, double fWidth, double fHeight, double fStartAngle, double fSweepAngle);
void PathCommandClose();
void PathCommandEnd();
void PathCommandStart();
bool DrawPath(LONG lType);
};
}
#endif // _BUILD_ARROW_HEAD_H_
\ No newline at end of file
#ifndef _BUILD_BASETHREAD_H_
#define _BUILD_BASETHREAD_H_
#include "../common/Types.h"
#if defined(WIN32) || defined(_WIN32_WCE)
#include "windows.h"
#include "winbase.h"
#else
#include <pthread.h>
#include <signal.h>
#include "time.h"
#endif
namespace NSThreads
{
class CThreadDescriptor
{
public:
CThreadDescriptor(){}
virtual ~CThreadDescriptor(){}
};
static void Sleep(int nMilliseconds)
{
#if defined(WIN32) || defined(_WIN32_WCE)
::Sleep((DWORD)nMilliseconds);
#else
struct timespec tim, tim2;
tim.tv_sec = nMilliseconds / 1000;
tim.tv_nsec = (nMilliseconds % 1000) * 1000000;
::nanosleep(&tim , &tim2);
#endif
}
class CBaseThread
{
protected:
CThreadDescriptor* m_hThread;
INT m_bRunThread;
INT m_bSuspend;
int m_lError;
int m_lThreadPriority;
public:
CBaseThread()
{
m_hThread = NULL;
m_bRunThread = FALSE;
m_bSuspend = FALSE;
m_lError = 0;
m_lThreadPriority = 0;
}
virtual ~CBaseThread()
{
Stop();
}
public:
virtual void Start(int lPriority)
{
if (m_bRunThread)
return;
m_lError = 0;
m_bSuspend = FALSE;
m_hThread = new __native_thread();
m_bRunThread = TRUE;
#if defined(WIN32) || defined(_WIN32_WCE)
DWORD dwTemp;
((__native_thread*)m_hThread)->m_thread = CreateThread(NULL, 0, &__ThreadProc, (void*)this, 0, &dwTemp);
SetThreadPriority(((__native_thread*)m_hThread)->m_thread, lPriority);
#else
pthread_create(&((__native_thread*)m_hThread)->m_thread, 0, &__ThreadProc, (void*)this);
#endif
m_lThreadPriority = lPriority;
}
virtual void Suspend()
{
m_bSuspend = TRUE;
}
virtual void Resume()
{
m_bSuspend = FALSE;
}
virtual void Stop()
{
if (!m_bRunThread)
return;
m_bRunThread = FALSE;
Join();
RELEASEOBJECT(m_hThread);
}
inline INT IsSuspended() { return m_bSuspend; }
inline INT IsRunned() { return m_bRunThread; }
inline int GetError() { return m_lError; }
inline CThreadDescriptor* GetDescriptor() { return m_hThread; }
inline int GetPriority() { return m_lThreadPriority; }
virtual void CheckSuspend()
{
while (m_bSuspend && m_bRunThread)
NSThreads::Sleep(10);
}
protected:
virtual void Join()
{
if (NULL == m_hThread)
return;
#if defined(WIN32) || defined(_WIN32_WCE)
WaitForSingleObject(((__native_thread*)m_hThread)->m_thread, INFINITE);
#else
pthread_join(((__native_thread*)m_hThread)->m_thread, 0);
#endif
}
virtual DWORD ThreadProc() = 0;
private:
#if defined(WIN32) || defined(_WIN32_WCE)
static DWORD WINAPI __ThreadProc(void* pv)
{
CBaseThread* pThis = (CBaseThread*)pv;
return pThis->ThreadProc();
}
class __native_thread : public NSThreads::CThreadDescriptor
{
friend class CBaseThread;
private:
HANDLE m_thread;
public:
__native_thread() : CThreadDescriptor()
{
m_thread = NULL;
}
virtual ~__native_thread()
{
if (m_thread != NULL)
{
CloseHandle(m_thread);
m_thread = NULL;
}
}
};
#else
static void* __ThreadProc(void* pv)
{
int old_thread_type;
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &old_thread_type);
CBaseThread* pThis = (CBaseThread*)pv;
pThis->ThreadProc();
return NULL;
}
class __native_thread : public NSThreads::CThreadDescriptor
{
friend class CBaseThread;
private:
pthread_t m_thread;
public:
__native_thread() : CThreadDescriptor()
{
m_thread = NULL;
}
virtual ~__native_thread()
{
}
};
#endif
};
}
#endif // _BUILD_BASETHREAD_H_
This diff is collapsed.
#ifndef _BUILD_BRUSH_H_
#define _BUILD_BRUSH_H_
#include "AggPlusEnums.h"
#include "Color.h"
#include "Matrix.h"
#include "Image.h"
#include "structures.h"
#include "../common/Array.h"
namespace Aggplus
{
class CBrush
{
friend class CGraphics;
protected:
CBrush(BrushType bType);
public:
virtual ~CBrush();
virtual CBrush* Clone() const = 0;
BrushType GetType() const;
public:
BrushType m_bType;
};
class CBrushSolid : public CBrush
{
public:
CBrushSolid(CColor dwColor);
virtual ~CBrushSolid();
virtual CBrush *Clone() const;
void GetColor(CColor* color) const;
void SetColor(const CColor &color);
protected:
CColor m_dwColor;
};
class CBrushHatch : public CBrush
{
public:
CBrushHatch();
virtual ~CBrushHatch();
virtual CBrush *Clone() const;
inline CDoubleRect& GetBounds() { return Bounds; }
public:
std::wstring m_name;
CColor m_dwColor1;
CColor m_dwColor2;
CDoubleRect Bounds;
};
class CBrushLinearGradient : public CBrush
{
friend class CGraphics;
public:
CBrushLinearGradient( const PointF& p1, const PointF& p2, const CColor& c1, const CColor& c2 );
CBrushLinearGradient( const Point& p1, const Point& p2, const CColor& c1, const CColor& c2 );
CBrushLinearGradient( const RectF& rect, const CColor& c1, const CColor& c2, float angle, INT isAngleScalable );
CBrushLinearGradient( const Rect& rect, const CColor& c1, const CColor& c2, float angle, INT isAngleScalable );
CBrushLinearGradient( const RectF& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode );
CBrushLinearGradient( const Rect& rect, const CColor& c1, const CColor& c2, Aggplus::LinearGradientMode mode );
CBrushLinearGradient( const CBrushLinearGradient& out );
Status GetLinearColors( CColor* colors ) const;
Status GetRectangle( Rect *rect ) const;
Status GetRectangle( RectF *rect ) const;
Status GetTransform( CMatrix* matrix ) const;
Status MultiplyTransform( const CMatrix *matrix, MatrixOrder order = MatrixOrderPrepend);
Status ResetTransform();
Status RotateTransform( REAL angle, MatrixOrder order = MatrixOrderPrepend );
Status ScaleTransform( REAL sx, REAL sy, MatrixOrder order = MatrixOrderPrepend );
void SetWrapMode( WrapMode mode );
WrapMode GetWrapMode() const;
virtual CBrush *Clone() const;
Status SetInterpolationColors( const CColor *presetColors, const REAL *blendPositions, INT count );
Status GetInterpolationColors( CColor *presetColors, REAL *blendPositions, INT count ) const;
INT GetInterpolationColorsCount() const;
// additional methods
void GetSubColor( int nIndex, CColor* pColor, float* pPosition ) const;
void SetRelativeCoords( INT bRelative );
INT IsRelativeCoords() const;
INT IsAngleScalable() const;
INT IsRectable() const;
float GetAngle() const;
inline void SetBounds(const CDoubleRect& oRect) { Bounds = oRect; }
inline CDoubleRect& GetBounds() { return Bounds; }
protected:
CColor m_colors[2];
PointF m_points[2];
struct TSubColor
{
CColor color;
float position;
};
CArray<TSubColor> m_subcolors;
CMatrix m_matrix;
float m_angle; // угол поворота в градусах базовой линии p1 -> p2
CDoubleRect Bounds;
Aggplus::WrapMode m_wrap;
INT m_bAngleScalable; // масштабировать угол поворота относительно заданных точек b = arctan( width / height * tan(angle) );
INT m_bRectable; // в качестве направляющей используется диагональ прямоугольника
INT m_bRelativeCoords; // координаты точек считаются относительно рисуемого примитива
};
class CBrushTexture : public CBrush
{
friend class CGraphics;
protected:
CBrushTexture();
public:
CBrushTexture(const std::wstring& strName, WrapMode wrapMode = WrapModeTile);
CBrushTexture(CImage *pImage, WrapMode wrapMode = WrapModeTile);
virtual ~CBrushTexture();
virtual CBrush* Clone() const;
void TranslateTransform(double dX, double dY, MatrixOrder order = MatrixOrderPrepend);
void ScaleTransform(double dX, double dY, MatrixOrder order = MatrixOrderPrepend);
void RotateTransform(double angle, MatrixOrder order = MatrixOrderPrepend);
void GetTransform(CMatrix* matrix) const;
void SetTransform(const CMatrix* matrix);
void SetWrapMode(WrapMode wMode);
WrapMode GetWrapMode() const;
public:
void* PatternFinalize();
DWORD PatternGetWidth();
DWORD PatternGetHeight();
int PatternGetStride();
public:
CImage* m_pImage;
INT m_bReleaseImage;
WrapMode m_wrapMode;
CMatrix m_mtx;
INT m_bUsePattern;
CColor m_colors[2];
BYTE Alpha;
};
}
#endif // _BUILD_BRUSH_H_
\ No newline at end of file
This diff is collapsed.
#include "Clip.h"
namespace Aggplus
{
/////////////////////////////////////////////////////////////////////////////////////
CClipMask::CClipMask() : m_pixf(m_alpha_rbuf)
{
m_pMask = NULL;
m_bIsClip = false;
m_lWidth = 0;
m_lHeight = 0;
}
CClipMask::~CClipMask()
{
Destroy();
}
void CClipMask::Destroy()
{
if (NULL != m_pMask)
delete [] m_pMask;
}
void CClipMask::Reset()
{
m_bIsClip = false;
}
void CClipMask::Create(LONG width, LONG height)
{
Destroy();
m_pMask = new BYTE[width * height];
m_alpha_rbuf.attach(m_pMask, width, height, width);
m_lWidth = width;
m_lHeight = height;
m_pixf.attach(m_alpha_rbuf);
m_base_renderer.attach(m_pixf);
m_renderer.attach(m_base_renderer);
m_renderer.color(agg::gray8(0xFF, 0xFF));
}
void CClipMask::ResetClip()
{
}
void CClipMask::GenerateClip(CGraphicsPath* pPath, CMatrix* pMatrix)
{
if (NULL == pPath)
return;
memset(m_pMask, 0, m_lWidth * m_lHeight);
m_rasterizer.reset();
typedef agg::conv_transform<agg::path_storage> trans_type;
trans_type trans(pPath->m_agg_ps, pMatrix->m_agg_mtx);
typedef agg::conv_curve<trans_type> conv_crv_type;
conv_crv_type c_c_path(trans);
m_rasterizer.add_path(c_c_path);
agg::render_scanlines(m_rasterizer, m_sl, m_renderer);
m_bIsClip = true;
}
agg::rendering_buffer CClipMask::GetRenderingBuffer()
{
return m_alpha_rbuf;
}
BYTE* CClipMask::GetMask()
{
return m_pMask;
}
bool CClipMask::IsClip()
{
return m_bIsClip;
}
/////////////////////////////////////////////////////////////////////////////////////
CClip::CClip() : m_pixf(m_alpha_rbuf)
{
m_pMask = NULL;
m_bIsClip = false;
m_lWidth = 0;
m_lHeight = 0;
}
CClip::~CClip()
{
Destroy();
}
void CClip::Destroy()
{
if (NULL != m_pMask)
delete [] m_pMask;
}
void CClip::Reset()
{
m_bIsClip = false;
}
void CClip::Create(LONG width, LONG height)
{
}
void CClip::ResetClip()
{
}
void CClip::GenerateClip(CGraphicsPath* pPath, CMatrix* pMatrix)
{
if (NULL == pPath)
return;
m_rasterizer.reset();
typedef agg::conv_transform<agg::path_storage> trans_type;
trans_type trans(pPath->m_agg_ps, pMatrix->m_agg_mtx);
typedef agg::conv_curve<trans_type> conv_crv_type;
conv_crv_type c_c_path(trans);
m_rasterizer.add_path(c_c_path);
m_bIsClip = true;
}
agg::rendering_buffer CClip::GetRenderingBuffer()
{
return m_alpha_rbuf;
}
BYTE* CClip::GetMask()
{
return m_pMask;
}
bool CClip::IsClip()
{
return m_bIsClip;
}
/////////////////////////////////////////////////////////////////////////////////////
CClipMulti::CClipMulti()
{
m_bIsClip = false;
m_bIsClip2 = false;
}
CClipMulti::~CClipMulti()
{
}
void CClipMulti::Create(LONG width, LONG height)
{
m_rasterizer.clip_box(0, 0, width, height);
m_bIsClip = false;
m_bIsClip2 = false;
}
void CClipMulti::GenerateClip(CGraphicsPath* pPath, CMatrix* pMatrix)
{
if (NULL == pPath)
return;
m_rasterizer.reset();
typedef agg::conv_transform<agg::path_storage> trans_type;
trans_type trans(pPath->m_agg_ps, pMatrix->m_agg_mtx);
typedef agg::conv_curve<trans_type> conv_crv_type;
conv_crv_type c_c_path(trans);
m_rasterizer.add_path(c_c_path);
m_bIsClip = true;
m_bIsClip2 = false;
}
void CClipMulti::Combine(CGraphicsPath* pPath, CMatrix* pMatrix, agg::sbool_op_e op)
{
if (!m_bIsClip)
return GenerateClip(pPath, pMatrix);
if (!m_bIsClip2)
{
// смешивать надо с растерайзером
agg::rasterizer_scanline_aa<> rasterizer;
typedef agg::conv_transform<agg::path_storage> trans_type;
trans_type trans(pPath->m_agg_ps, pMatrix->m_agg_mtx);
typedef agg::conv_curve<trans_type> conv_crv_type;
conv_crv_type c_c_path(trans);
rasterizer.add_path(c_c_path);
rasterizer.filling_rule(pPath->m_bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
scanline_type sl1;
scanline_type sl2;
scanline_type sl;
agg::sbool_combine_shapes_aa(op, m_rasterizer, rasterizer, sl1, sl2, sl, m_storage1);
m_lCurStorage = 1;
}
else
{
// надо смешивать со стораджем
agg::rasterizer_scanline_aa<> rasterizer;
typedef agg::conv_transform<agg::path_storage> trans_type;
trans_type trans(pPath->m_agg_ps, pMatrix->m_agg_mtx);
typedef agg::conv_curve<trans_type> conv_crv_type;
conv_crv_type c_c_path(trans);
rasterizer.add_path(c_c_path);
rasterizer.filling_rule(pPath->m_bEvenOdd ? agg::fill_even_odd : agg::fill_non_zero);
scanline_type sl1;
scanline_type sl2;
scanline_type sl;
agg::sbool_combine_shapes_aa(op, rasterizer, (m_lCurStorage == 1) ? m_storage1 : m_storage2, sl1, sl2, sl,
(m_lCurStorage == 1) ? m_storage2 : m_storage1);
if (1 == m_lCurStorage)
{
//m_storage1.prepare();
m_lCurStorage = 2;
}
else
{
//m_storage2.prepare();
m_lCurStorage = 1;
}
}
m_bIsClip2 = true;
}
bool CClipMulti::IsClip()
{
return m_bIsClip;
}
bool CClipMulti::IsClip2()
{
return m_bIsClip2;
}
void CClipMulti::Reset()
{
m_rasterizer.reset();
//m_storage1.prepare();
//m_storage2.prepare();
m_bIsClip = false;
m_bIsClip2 = false;
}
}
\ No newline at end of file
#ifndef _BUILD_CLIP_H_
#define _BUILD_CLIP_H_
#include "GraphicsPath.h"
#include "../agg-2.4/include/agg_basics.h"
#include "../agg-2.4/include/agg_rendering_buffer.h"
#include "../agg-2.4/include/agg_rasterizer_scanline_aa.h"
#include "../agg-2.4/include/agg_scanline_storage_aa.h"
#include "../agg-2.4/include/agg_scanline_storage_bin.h"
#include "../agg-2.4/include/agg_pixfmt_rgb.h"
#include "../agg-2.4/include/agg_pixfmt_gray.h"
#include "../agg-2.4/include/agg_alpha_mask_u8.h"
#include "../agg-2.4/include/agg_scanline_u.h"
#include "../agg-2.4/include/agg_scanline_p.h"
#include "../agg-2.4/include/agg_scanline_bin.h"
#include "../agg-2.4/include/agg_scanline_boolean_algebra.h"
#include <string>
namespace Aggplus
{
class CClipMask
{
typedef agg::renderer_base<agg::pixfmt_gray8> ren_base;
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
friend class CGraphicsPath;
public:
BYTE* m_pMask;
LONG m_lWidth;
LONG m_lHeight;
agg::rendering_buffer m_alpha_rbuf;
agg::rasterizer_scanline_aa<> m_rasterizer;
agg::pixfmt_gray8 m_pixf;
ren_base m_base_renderer;
renderer m_renderer;
agg::scanline_p8 m_sl;
bool m_bIsClip;
public:
CClipMask();
~CClipMask();
void Destroy();
void Reset();
public:
void Create(LONG width, LONG height);
void ResetClip();
void GenerateClip(CGraphicsPath* pPath, CMatrix* pMatrix);
agg::rendering_buffer GetRenderingBuffer();
BYTE* GetMask();
bool IsClip();
};
class CClip
{
typedef agg::renderer_base<agg::pixfmt_gray8> ren_base;
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
friend class CGraphicsPath;
public:
BYTE* m_pMask;
LONG m_lWidth;
LONG m_lHeight;
agg::rendering_buffer m_alpha_rbuf;
agg::rasterizer_scanline_aa<> m_rasterizer;
agg::pixfmt_gray8 m_pixf;
ren_base m_base_renderer;
renderer m_renderer;
agg::scanline_p8 m_sl;
bool m_bIsClip;
public:
CClip();
~CClip();
void Destroy();
void Reset();
public:
void Create(LONG width, LONG height);
void ResetClip();
void GenerateClip(CGraphicsPath* pPath, CMatrix* pMatrix);
agg::rendering_buffer GetRenderingBuffer();
BYTE* GetMask();
bool IsClip();
};
class CClipMulti
{
typedef agg::scanline_p8 scanline_type;
public:
agg::rasterizer_scanline_aa<> m_rasterizer;
agg::scanline_storage_aa8 m_storage1;
agg::scanline_storage_aa8 m_storage2;
long m_lCurStorage;
bool m_bIsClip;
bool m_bIsClip2;
public:
CClipMulti();
~CClipMulti();
void Create(LONG width, LONG height);
void GenerateClip(CGraphicsPath* pPath, CMatrix* pMatrix);
void Combine(CGraphicsPath* pPath, CMatrix* pMatrix, agg::sbool_op_e op);
bool IsClip();
bool IsClip2();
void Reset();
};
}
#endif // _BUILD_CLIP_H_
\ No newline at end of file
#ifndef _BUILD_COLOR_H_
#define _BUILD_COLOR_H_
#include "AggPlusEnums.h"
#include "../agg-2.4/include/agg_color_rgba.h"
/*
#define GetRValue(rgb) (unsigned char(rgb))
#define GetGValue(rgb) (unsigned char(rgb) >> 8))
#define GetBValue(rgb) (unsigned char(rgb) >> 16))
*/
namespace Aggplus
{
class CColor
{
public:
CColor() { Argb = 0xFF000000; } //Black;
//Color values are not premultiplied.
CColor(BYTE r, BYTE g, BYTE b) { Argb = MakeARGB(255, r, g, b); }
CColor(BYTE a, LONG lColor, bool bSwapRGB = false)
{
if (!bSwapRGB)
Argb = ((a << AlphaShift) | lColor);
else
{
Argb = MakeARGB(a, (BYTE)(lColor >> BlueShift), (BYTE)(lColor >> GreenShift), (BYTE)(lColor >> RedShift));
}
}
CColor(BYTE a, BYTE r, BYTE g, BYTE b) { Argb = MakeARGB(a, r, g, b); }
CColor(ARGB argb) { Argb = argb; }
BYTE GetAlpha() const { return (BYTE) (Argb >> AlphaShift); }
BYTE GetA() const { return GetAlpha(); }
BYTE GetRed() const { return (BYTE) (Argb >> RedShift); }
BYTE GetR() const { return GetRed(); }
BYTE GetGreen() const { return (BYTE) (Argb >> GreenShift); }
BYTE GetG() const { return GetGreen(); }
BYTE GetBlue() const { return (BYTE) (Argb >> BlueShift); }
BYTE GetB() const { return GetBlue(); }
ARGB GetValue() const { return Argb; }
void SetValue(ARGB argb) { Argb = argb; }
public:
// Shift count and bit mask for A, R, G, B components
enum
{
AlphaShift = 24,
RedShift = 16,
GreenShift = 8,
BlueShift = 0
};
enum
{
AlphaMask = 0xff000000,
RedMask = 0x00ff0000,
GreenMask = 0x0000ff00,
BlueMask = 0x000000ff
};
// Assemble A, R, G, B values into a 32-bit integer
static ARGB MakeARGB(BYTE a, BYTE r, BYTE g, BYTE b)
{
return (((ARGB) (b) << BlueShift) |
((ARGB) (g) << GreenShift) |
((ARGB) (r) << RedShift) |
((ARGB) (a) << AlphaShift));
}
//AGG converter
inline agg::rgba8 GetAggColor() const { return(agg::rgba8(GetBlue(), GetGreen(), GetRed(), GetAlpha())); }
protected:
ARGB Argb;
};
}
#endif // _BUILD_COLOR_H_
#pragma once
typedef float REAL;
typedef int INT;
typedef unsigned int UINT, *PUINT;
typedef unsigned long ARGB;
typedef unsigned char BYTE;
typedef int INT;
typedef unsigned long DWORD;
typedef long LONG;
#define ADDREFINTERFACE(pinterface)\
{\
if (pinterface!=NULL)\
{\
pinterface->AddRef();\
}\
}
#define RELEASEINTERFACE(pinterface)\
{\
if (pinterface!=NULL)\
{\
pinterface->Release();\
pinterface=NULL;\
}\
}
#define QUERYINTERFACE(pinterface, pinterface_res, iid)\
{\
if (pinterface!=NULL)\
pinterface->QueryInterface(iid, (void**)&pinterface_res);\
else\
pinterface_res=NULL;\
}
#define RELEASEMEM(pobject)\
{\
if (pobject!=NULL)\
{\
free(pobject);\
pobject=NULL;\
}\
}
#define RELEASEOBJECT(pobject)\
{\
if (pobject!=NULL)\
{\
delete pobject;\
pobject=NULL;\
}\
}
#define RELEASEARRAYOBJECTS(pobject)\
{\
if (pobject!=NULL)\
{\
delete []pobject;\
pobject=NULL;\
}\
}
#define RELEASEHEAP(pmem)\
{\
if (pmem!=NULL)\
{\
HeapFree(GetProcessHeap(), 0, pmem);\
pmem=NULL;\
}\
}
#define RELEASEARRAY(parray)\
{\
if (parray!=NULL)\
{\
SafeArrayDestroy(parray);\
parray=NULL;\
}\
}
#define RELEASESYSSTRING(pstring)\
{\
if (pstring!=NULL)\
{\
SysFreeString(pstring);\
pstring=NULL;\
}\
}
#define RELEASEHANDLE(phandle)\
{\
if (phandle!=NULL)\
{\
CloseHandle(phandle);\
phandle=NULL;\
}\
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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