Brush Class

The Brush class is an abstract base class that defines objects used to fill interiors of graphics shapes. It provides common functionality for derived brush types in GDI+.

Inheritance

Object → Brush

Derived Classes

#include <gdiplus.h>
using namespace Gdiplus;

class Brush : public Image
{
protected:
    Brush();
public:
    virtual ~Brush();
    virtual Brush* Clone() const = 0;
    // ... other members
};
MemberDescription
Clone()Creates an exact copy of the brush.
GetLastStatus()Retrieves the status of the last operation.
SetTransform(const Matrix*)Sets a transformation matrix for the brush.
GetTransform(Matrix*)Gets the current transformation matrix.
ResetTransform()Resets the brush's transformation to the identity.
#include <windows.h>
#include <gdiplus.h>
using namespace Gdiplus;

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int nCmdShow)
{
    GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR gdiplusToken;
    GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr);

    {
        Bitmap bitmap(300, 200, PixelFormat32bppARGB);
        Graphics graphics(&bitmap);
        SolidBrush solidBrush(Color(255, 30, 144, 255)); // DeepSkyBlue
        graphics.FillRectangle(&solidBrush, 10, 10, 280, 180);
        bitmap.Save(L"brush_demo.png", &ImageFormatPNG);
    }

    GdiplusShutdown(gdiplusToken);
    return 0;
}