📄 gdiplusbrush.h
字号:
/**************************************************************************\
*
* Copyright (c) 1998-2000, Microsoft Corp. All Rights Reserved.
*
* Module Name:
*
* GdiplusBrush.h
*
* Abstract:
*
* Brush API related declarations
*
\**************************************************************************/
#ifndef _GDIPLUSBRUSH_H
#define _GDIPLUSBRUSH_H
//--------------------------------------------------------------------------
// Abstract base class for various brush types
//--------------------------------------------------------------------------
class GraphicsPath;
class Brush : public GdiplusBase
{
public:
friend class Pen;
friend class Graphics;
virtual ~Brush()
{
DllExports::GdipDeleteBrush(nativeBrush);
}
virtual Brush* Clone() const
{
GpBrush *brush = NULL;
SetStatus(DllExports::GdipCloneBrush(nativeBrush, &brush));
Brush *newBrush = new Brush(brush, lastResult);
if (newBrush == NULL)
{
DllExports::GdipDeleteBrush(brush);
}
return newBrush;
}
BrushType GetType() const
{
BrushType type = static_cast<BrushType>(-1);
SetStatus(DllExports::GdipGetBrushType(nativeBrush, &type));
return type;
}
Status GetLastStatus() const
{
Status lastStatus = lastResult;
lastResult = Ok;
return lastStatus;
}
protected:
Brush()
{
SetStatus(NotImplemented);
}
#ifdef DCR_USE_NEW_250932
private:
Brush(const Brush& brush);
Brush& operator=(const Brush& brush);
protected:
#else
Brush(const Brush& brush)
{
brush;
SetStatus(NotImplemented);
}
Brush& operator=(const Brush& brush)
{
brush;
SetStatus(NotImplemented);
return *this;
}
#endif
Brush(GpBrush* nativeBrush, Status status)
{
lastResult = status;
SetNativeBrush(nativeBrush);
}
VOID SetNativeBrush(GpBrush* nativeBrush)
{
this->nativeBrush = nativeBrush;
}
Status SetStatus(Status status) const
{
if (status != Ok)
return (lastResult = status);
else
return status;
}
GpBrush* nativeBrush;
mutable Status lastResult;
};
//--------------------------------------------------------------------------
// Represent solid fill brush object
//--------------------------------------------------------------------------
class SolidBrush : public Brush
{
public:
friend class Pen;
SolidBrush(IN const Color& color)
{
GpSolidFill *brush = NULL;
lastResult = DllExports::GdipCreateSolidFill(color.GetValue(), &brush);
SetNativeBrush(brush);
}
Status GetColor(OUT Color* color) const
{
ARGB argb;
if (color == NULL)
{
return SetStatus(InvalidParameter);
}
SetStatus(DllExports::GdipGetSolidFillColor((GpSolidFill*)nativeBrush,
&argb));
*color = Color(argb);
return lastResult;
}
Status SetColor(IN const Color& color)
{
return SetStatus(DllExports::GdipSetSolidFillColor((GpSolidFill*)nativeBrush,
color.GetValue()));
}
#ifdef DCR_USE_NEW_250932
private:
SolidBrush(const SolidBrush &);
SolidBrush& operator=(const SolidBrush &);
#endif
protected:
SolidBrush()
{
}
};
class TextureBrush : public Brush
{
public:
friend class Pen;
TextureBrush(IN Image* image,
IN WrapMode wrapMode = WrapModeTile)
{
GpTexture *texture = NULL;
lastResult = DllExports::GdipCreateTexture(
image->nativeImage,
wrapMode, &texture);
SetNativeBrush(texture);
}
// When creating a texture brush from a metafile image, the dstRect
// is used to specify the size that the metafile image should be
// rendered at in the device units of the destination graphics.
// It is NOT used to crop the metafile image, so only the width
// and height values matter for metafiles.
TextureBrush(IN Image* image,
IN WrapMode wrapMode,
IN const RectF &dstRect)
{
GpTexture *texture = NULL;
lastResult = DllExports::GdipCreateTexture2(
image->nativeImage,
wrapMode,
dstRect.X,
dstRect.Y,
dstRect.Width,
dstRect.Height,
&texture);
SetNativeBrush(texture);
}
// When creating a texture brush from a metafile image, the dstRect
// is used to specify the size that the metafile image should be
// rendered at in the device units of the destination graphics.
// It is NOT used to crop the metafile image, so only the width
// and height values matter for metafiles.
TextureBrush(IN Image *image,
IN const RectF &dstRect,
IN const ImageAttributes *imageAttributes = NULL)
{
GpTexture *texture = NULL;
lastResult = DllExports::GdipCreateTextureIA(
image->nativeImage,
(imageAttributes)?imageAttributes->nativeImageAttr:NULL,
dstRect.X,
dstRect.Y,
dstRect.Width,
dstRect.Height,
&texture
);
SetNativeBrush(texture);
}
#ifdef DCR_USE_NEW_145138
TextureBrush(IN Image *image,
IN const Rect &dstRect,
IN const ImageAttributes *imageAttributes = NULL)
{
GpTexture *texture = NULL;
lastResult = DllExports::GdipCreateTextureIAI(
image->nativeImage,
(imageAttributes)?imageAttributes->nativeImageAttr:NULL,
dstRect.X,
dstRect.Y,
dstRect.Width,
dstRect.Height,
&texture
);
SetNativeBrush(texture);
}
#endif
// When creating a texture brush from a metafile image, the dstRect
// is used to specify the size that the metafile image should be
// rendered at in the device units of the destination graphics.
// It is NOT used to crop the metafile image, so only the width
// and height values matter for metafiles.
TextureBrush(
IN Image* image,
IN WrapMode wrapMode,
#ifdef DCR_USE_NEW_145138
const IN Rect &dstRect
#else
IN Rect &dstRect
#endif
)
{
GpTexture *texture = NULL;
lastResult = DllExports::GdipCreateTexture2I(
image->nativeImage,
wrapMode,
dstRect.X,
dstRect.Y,
dstRect.Width,
dstRect.Height,
&texture);
SetNativeBrush(texture);
}
// When creating a texture brush from a metafile image, the dstRect
// is used to specify the size that the metafile image should be
// rendered at in the device units of the destination graphics.
// It is NOT used to crop the metafile image, so only the width
// and height values matter for metafiles.
TextureBrush(IN Image* image,
IN WrapMode wrapMode,
IN REAL dstX,
IN REAL dstY,
IN REAL dstWidth,
IN REAL dstHeight)
{
GpTexture *texture = NULL;
lastResult = DllExports::GdipCreateTexture2(
image->nativeImage,
wrapMode,
dstX,
dstY,
dstWidth,
dstHeight,
&texture);
SetNativeBrush(texture);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -