/binding/win32/gdiplusgraphics.d
http://github.com/wilkie/djehuty · D · 2335 lines · 1996 code · 291 blank · 48 comment · 22 complexity · a3dcf82dac6e4451f872aa9db2317a02 MD5 · raw file
Large files are truncated click here to view the full file
- /*
- * gdiplusgraphics.d
- *
- * This module implements GdiPlusGraphics.h for D. The original
- * copyright info is given below.
- *
- * Author: Dave Wilkinson
- * Originated: November 25th, 2009
- *
- */
- module binding.win32.gdiplusgraphics;
- import binding.win32.windef;
- import binding.win32.winbase;
- import binding.win32.winnt;
- import binding.win32.wingdi;
- import binding.win32.guiddef;
- import binding.win32.gdiplusbase;
- import binding.win32.gdiplustypes;
- import binding.win32.gdiplusenums;
- import binding.win32.gdipluspixelformats;
- import binding.win32.gdiplusgpstubs;
- import binding.win32.gdiplusmetaheader;
- import binding.win32.gdipluspixelformats;
- import binding.win32.gdipluscolor;
- import binding.win32.gdipluscolormatrix;
- import binding.win32.gdiplusflat;
- import binding.win32.gdiplusimaging;
- import binding.win32.gdiplusbitmap;
- import binding.win32.gdiplusimageattributes;
- import binding.win32.gdiplusmatrix;
- import binding.win32.gdiplusregion;
- import binding.win32.gdiplusbrush;
- import binding.win32.gdipluspen;
- import binding.win32.gdiplusfont;
- import binding.win32.gdipluspath;
- import binding.win32.gdiplusstringformat;
- import binding.win32.gdipluscachedbitmap;
- import binding.win32.gdipluseffects;
- import binding.win32.gdiplusmetafile;
- /**************************************************************************\
- *
- * Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
- *
- * Module Name:
- *
- * GdiplusGraphics.h
- *
- * Abstract:
- *
- * GDI+ Graphics Object
- *
- \**************************************************************************/
- extern(System):
- class Graphics : GdiplusBase {
- static Graphics FromHDC(in HDC hdc) {
- return new Graphics(hdc);
- }
- static Graphics FromHDC(in HDC hdc, in HANDLE hdevice) {
- return new Graphics(hdc, hdevice);
- }
- static Graphics FromHWND(in HWND hwnd, in BOOL icm = FALSE) {
- return new Graphics(hwnd, icm);
- }
- static Graphics FromImage(in Image image) {
- return new Graphics(image);
- }
- this(in HDC hdc) {
- GpGraphics *graphics = null;
- lastResult = GdipCreateFromHDC(hdc, &graphics);
- SetNativeGraphics(graphics);
- }
- this(in HDC hdc, in HANDLE hdevice) {
- GpGraphics *graphics = null;
- lastResult = GdipCreateFromHDC2(hdc, hdevice, &graphics);
- SetNativeGraphics(graphics);
- }
- this(in HWND hwnd, in BOOL icm) {
- GpGraphics *graphics = null;
- if (icm) {
- lastResult = GdipCreateFromHWNDICM(hwnd, &graphics);
- }
- else {
- lastResult = GdipCreateFromHWND(hwnd, &graphics);
- }
- SetNativeGraphics(graphics);
- }
- this(in Image image) {
- GpGraphics *graphics = null;
- if (image !is null) {
- lastResult = GdipGetImageGraphicsContext(
- image.nativeImage, &graphics);
- }
- SetNativeGraphics(graphics);
- }
- ~this() {
- GdipDeleteGraphics(nativeGraphics);
- }
- VOID Flush(in FlushIntention intention = FlushIntention.FlushIntentionFlush) {
- GdipFlush(nativeGraphics, intention);
- }
- //------------------------------------------------------------------------
- // GDI Interop methods
- //------------------------------------------------------------------------
- // Locks the graphics until ReleaseDC is called
- HDC GetHDC() {
- HDC hdc = null;
- SetStatus(GdipGetDC(nativeGraphics, &hdc));
- return hdc;
- }
- VOID ReleaseHDC(in HDC hdc) {
- SetStatus(GdipReleaseDC(nativeGraphics, hdc));
- }
- //------------------------------------------------------------------------
- // Rendering modes
- //------------------------------------------------------------------------
- Status SetRenderingOrigin(in INT x, in INT y) {
- return SetStatus(
- GdipSetRenderingOrigin(
- nativeGraphics, x, y
- )
- );
- }
- Status GetRenderingOrigin(ref INT x, ref INT y) {
- return SetStatus(
- GdipGetRenderingOrigin(
- nativeGraphics, &x, &y
- )
- );
- }
- Status SetCompositingMode(in CompositingMode compositingMode) {
- return SetStatus(GdipSetCompositingMode(nativeGraphics, compositingMode));
- }
- CompositingMode GetCompositingMode() {
- CompositingMode mode;
- SetStatus(GdipGetCompositingMode(nativeGraphics,
- &mode));
- return mode;
- }
- Status SetCompositingQuality(in CompositingQuality compositingQuality) {
- return SetStatus(GdipSetCompositingQuality(
- nativeGraphics,
- compositingQuality));
- }
- CompositingQuality GetCompositingQuality() {
- CompositingQuality quality;
- SetStatus(GdipGetCompositingQuality(
- nativeGraphics,
- &quality));
- return quality;
- }
- Status SetTextRenderingHint(in TextRenderingHint newMode) {
- return SetStatus(GdipSetTextRenderingHint(nativeGraphics,
- newMode));
- }
- TextRenderingHint GetTextRenderingHint() {
- TextRenderingHint hint;
- SetStatus(GdipGetTextRenderingHint(nativeGraphics,
- &hint));
- return hint;
- }
- Status SetTextContrast(in UINT contrast) {
- return SetStatus(GdipSetTextContrast(nativeGraphics, contrast));
- }
- UINT GetTextContrast() {
- UINT contrast;
- SetStatus(GdipGetTextContrast(nativeGraphics, &contrast));
- return contrast;
- }
- InterpolationMode GetInterpolationMode() {
- InterpolationMode mode = InterpolationMode.InterpolationModeInvalid;
- SetStatus(GdipGetInterpolationMode(nativeGraphics, &mode));
- return mode;
- }
- Status SetInterpolationMode(in InterpolationMode interpolationMode) {
- return SetStatus(GdipSetInterpolationMode(nativeGraphics, interpolationMode));
- }
- version(GDIPLUS6) {
- Status SetAbort(GdiplusAbort *pIAbort) {
- return SetStatus(GdipGraphicsSetAbort(
- nativeGraphics,
- pIAbort
- ));
- }
- }
- SmoothingMode GetSmoothingMode() {
- SmoothingMode smoothingMode = SmoothingMode.SmoothingModeInvalid;
- SetStatus(GdipGetSmoothingMode(nativeGraphics,
- &smoothingMode));
- return smoothingMode;
- }
- Status SetSmoothingMode(in SmoothingMode smoothingMode) {
- return SetStatus(GdipSetSmoothingMode(nativeGraphics,
- smoothingMode));
- }
- PixelOffsetMode GetPixelOffsetMode() {
- PixelOffsetMode pixelOffsetMode = PixelOffsetMode.PixelOffsetModeInvalid;
- SetStatus(GdipGetPixelOffsetMode(nativeGraphics,
- &pixelOffsetMode));
- return pixelOffsetMode;
- }
- Status SetPixelOffsetMode(in PixelOffsetMode pixelOffsetMode) {
- return SetStatus(GdipSetPixelOffsetMode(nativeGraphics,
- pixelOffsetMode));
- }
- //------------------------------------------------------------------------
- // Manipulate current world transform
- //------------------------------------------------------------------------
- Status SetTransform(in Matrix matrix) {
- return SetStatus(GdipSetWorldTransform(nativeGraphics,
- matrix.nativeMatrix));
- }
-
- Status ResetTransform() {
- return SetStatus(GdipResetWorldTransform(nativeGraphics));
- }
- Status MultiplyTransform(in Matrix matrix, in MatrixOrder order = MatrixOrder.MatrixOrderPrepend) {
- return SetStatus(GdipMultiplyWorldTransform(nativeGraphics,
- matrix.nativeMatrix,
- order));
- }
- Status TranslateTransform(in REAL dx, in REAL dy, in MatrixOrder order = MatrixOrder.MatrixOrderPrepend) {
- return SetStatus(GdipTranslateWorldTransform(nativeGraphics, dx, dy, order));
- }
- Status ScaleTransform(in REAL sx, in REAL sy, in MatrixOrder order = MatrixOrder.MatrixOrderPrepend) {
- return SetStatus(GdipScaleWorldTransform(nativeGraphics, sx, sy, order));
- }
- Status RotateTransform(in REAL angle, in MatrixOrder order = MatrixOrder.MatrixOrderPrepend) {
- return SetStatus(GdipRotateWorldTransform(nativeGraphics, angle, order));
- }
- Status GetTransform(Matrix* matrix) {
- return SetStatus(GdipGetWorldTransform(nativeGraphics, matrix.nativeMatrix));
- }
- Status SetPageUnit(in Unit unit) {
- return SetStatus(GdipSetPageUnit(nativeGraphics, unit));
- }
- Status SetPageScale(in REAL scale) {
- return SetStatus(GdipSetPageScale(nativeGraphics, scale));
- }
- Unit GetPageUnit() {
- Unit unit;
- SetStatus(GdipGetPageUnit(nativeGraphics, &unit));
- return unit;
- }
- REAL GetPageScale() {
- REAL scale;
- SetStatus(GdipGetPageScale(nativeGraphics, &scale));
- return scale;
- }
- REAL GetDpiX() {
- REAL dpi;
- SetStatus(GdipGetDpiX(nativeGraphics, &dpi));
- return dpi;
- }
- REAL GetDpiY() {
- REAL dpi;
- SetStatus(GdipGetDpiY(nativeGraphics, &dpi));
- return dpi;
- }
- Status TransformPoints(in CoordinateSpace destSpace, in CoordinateSpace srcSpace, PointF* pts, in INT count) {
- return SetStatus(GdipTransformPoints(nativeGraphics, destSpace, srcSpace, pts, count));
- }
- Status TransformPoints(in CoordinateSpace destSpace, in CoordinateSpace srcSpace, in Point* pts, in INT count) {
- return SetStatus(GdipTransformPointsI(nativeGraphics, destSpace, srcSpace, pts, count));
- }
- //------------------------------------------------------------------------
- // GetNearestColor (for <= 8bpp surfaces). Note: Alpha is ignored.
- //------------------------------------------------------------------------
-
- Status GetNearestColor(in Color color) {
- if (color is null) {
- return SetStatus(Status.InvalidParameter);
- }
- ARGB argb = color.GetValue();
- Status status = SetStatus(GdipGetNearestColor(nativeGraphics, &argb));
- color.SetValue(argb);
- return status;
- }
- Status DrawLine(in Pen pen, in REAL x1, in REAL y1, in REAL x2, in REAL y2) {
- return SetStatus(GdipDrawLine(nativeGraphics,
- pen.nativePen, x1, y1, x2,
- y2));
- }
- Status DrawLine(in Pen pen, in PointF pt1, in PointF pt2) {
- return DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y);
- }
- Status DrawLines(in Pen pen,
- in PointF* points,
- in INT count)
- {
- return SetStatus(GdipDrawLines(nativeGraphics,
- pen.nativePen,
- points, count));
- }
- Status DrawLine(in Pen pen,
- in INT x1,
- in INT y1,
- in INT x2,
- in INT y2)
- {
- return SetStatus(GdipDrawLineI(nativeGraphics,
- pen.nativePen,
- x1,
- y1,
- x2,
- y2));
- }
- Status DrawLine(in Pen pen,
- in Point pt1,
- in Point pt2)
- {
- return DrawLine(pen,
- pt1.X,
- pt1.Y,
- pt2.X,
- pt2.Y);
- }
- Status DrawLines(in Pen pen,
- in Point* points,
- in INT count)
- {
- return SetStatus(GdipDrawLinesI(nativeGraphics,
- pen.nativePen,
- points,
- count));
- }
- Status DrawArc(in Pen pen,
- in REAL x,
- in REAL y,
- in REAL width,
- in REAL height,
- in REAL startAngle,
- in REAL sweepAngle)
- {
- return SetStatus(GdipDrawArc(nativeGraphics,
- pen.nativePen,
- x,
- y,
- width,
- height,
- startAngle,
- sweepAngle));
- }
- Status DrawArc(in Pen pen,
- in RectF rect,
- in REAL startAngle,
- in REAL sweepAngle)
- {
- return DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height,
- startAngle, sweepAngle);
- }
- Status DrawArc(in Pen pen,
- in INT x,
- in INT y,
- in INT width,
- in INT height,
- in REAL startAngle,
- in REAL sweepAngle)
- {
- return SetStatus(GdipDrawArcI(nativeGraphics,
- pen.nativePen,
- x,
- y,
- width,
- height,
- startAngle,
- sweepAngle));
- }
- Status DrawArc(in Pen pen,
- in Rect rect,
- in REAL startAngle,
- in REAL sweepAngle)
- {
- return DrawArc(pen,
- rect.X,
- rect.Y,
- rect.Width,
- rect.Height,
- startAngle,
- sweepAngle);
- }
- Status DrawBezier(in Pen pen,
- in REAL x1,
- in REAL y1,
- in REAL x2,
- in REAL y2,
- in REAL x3,
- in REAL y3,
- in REAL x4,
- in REAL y4)
- {
- return SetStatus(GdipDrawBezier(nativeGraphics,
- pen.nativePen, x1, y1,
- x2, y2, x3, y3, x4, y4));
- }
- Status DrawBezier(in Pen pen,
- in PointF pt1,
- in PointF pt2,
- in PointF pt3,
- in PointF pt4)
- {
- return DrawBezier(pen,
- pt1.X,
- pt1.Y,
- pt2.X,
- pt2.Y,
- pt3.X,
- pt3.Y,
- pt4.X,
- pt4.Y);
- }
- Status DrawBeziers(in Pen pen,
- in PointF* points,
- in INT count)
- {
- return SetStatus(GdipDrawBeziers(nativeGraphics,
- pen.nativePen,
- points,
- count));
- }
- Status DrawBezier(in Pen pen,
- in INT x1,
- in INT y1,
- in INT x2,
- in INT y2,
- in INT x3,
- in INT y3,
- in INT x4,
- in INT y4)
- {
- return SetStatus(GdipDrawBezierI(nativeGraphics,
- pen.nativePen,
- x1,
- y1,
- x2,
- y2,
- x3,
- y3,
- x4,
- y4));
- }
- Status DrawBezier(in Pen pen,
- in Point pt1,
- in Point pt2,
- in Point pt3,
- in Point pt4)
- {
- return DrawBezier(pen,
- pt1.X,
- pt1.Y,
- pt2.X,
- pt2.Y,
- pt3.X,
- pt3.Y,
- pt4.X,
- pt4.Y);
- }
- Status DrawBeziers(in Pen pen,
- in Point* points,
- in INT count)
- {
- return SetStatus(GdipDrawBeziersI(nativeGraphics,
- pen.nativePen,
- points,
- count));
- }
- Status DrawRectangle(in Pen pen,
- in RectF rect)
- {
- return DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
- }
- Status DrawRectangle(in Pen pen,
- in REAL x,
- in REAL y,
- in REAL width,
- in REAL height)
- {
- return SetStatus(GdipDrawRectangle(nativeGraphics,
- pen.nativePen, x, y,
- width, height));
- }
- Status DrawRectangles(in Pen pen,
- in RectF* rects,
- in INT count)
- {
- return SetStatus(GdipDrawRectangles(nativeGraphics,
- pen.nativePen,
- rects, count));
- }
- Status DrawRectangle(in Pen pen,
- in Rect rect)
- {
- return DrawRectangle(pen,
- rect.X,
- rect.Y,
- rect.Width,
- rect.Height);
- }
- Status DrawRectangle(in Pen pen,
- in INT x,
- in INT y,
- in INT width,
- in INT height)
- {
- return SetStatus(GdipDrawRectangleI(nativeGraphics,
- pen.nativePen,
- x,
- y,
- width,
- height));
- }
- Status DrawRectangles(in Pen pen,
- in Rect* rects,
- in INT count)
- {
- return SetStatus(GdipDrawRectanglesI(nativeGraphics,
- pen.nativePen,
- rects,
- count));
- }
- Status DrawEllipse(in Pen pen,
- in RectF rect)
- {
- return DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height);
- }
- Status DrawEllipse(in Pen pen,
- in REAL x,
- in REAL y,
- in REAL width,
- in REAL height)
- {
- return SetStatus(GdipDrawEllipse(nativeGraphics,
- pen.nativePen,
- x,
- y,
- width,
- height));
- }
- Status DrawEllipse(in Pen pen,
- in Rect rect)
- {
- return DrawEllipse(pen,
- rect.X,
- rect.Y,
- rect.Width,
- rect.Height);
- }
- Status DrawEllipse(in Pen pen,
- in INT x,
- in INT y,
- in INT width,
- in INT height)
- {
- return SetStatus(GdipDrawEllipseI(nativeGraphics,
- pen.nativePen,
- x,
- y,
- width,
- height));
- }
- Status DrawPie(in Pen pen,
- in RectF rect,
- in REAL startAngle,
- in REAL sweepAngle)
- {
- return DrawPie(pen,
- rect.X,
- rect.Y,
- rect.Width,
- rect.Height,
- startAngle,
- sweepAngle);
- }
- Status DrawPie(in Pen pen,
- in REAL x,
- in REAL y,
- in REAL width,
- in REAL height,
- in REAL startAngle,
- in REAL sweepAngle)
- {
- return SetStatus(GdipDrawPie(nativeGraphics,
- pen.nativePen,
- x,
- y,
- width,
- height,
- startAngle,
- sweepAngle));
- }
- Status DrawPie(in Pen pen,
- in Rect rect,
- in REAL startAngle,
- in REAL sweepAngle)
- {
- return DrawPie(pen,
- rect.X,
- rect.Y,
- rect.Width,
- rect.Height,
- startAngle,
- sweepAngle);
- }
- Status DrawPie(in Pen pen,
- in INT x,
- in INT y,
- in INT width,
- in INT height,
- in REAL startAngle,
- in REAL sweepAngle)
- {
- return SetStatus(GdipDrawPieI(nativeGraphics,
- pen.nativePen,
- x,
- y,
- width,
- height,
- startAngle,
- sweepAngle));
- }
- Status DrawPolygon(in Pen pen,
- in PointF* points,
- in INT count)
- {
- return SetStatus(GdipDrawPolygon(nativeGraphics,
- pen.nativePen,
- points,
- count));
- }
- Status DrawPolygon(in Pen pen,
- in Point* points,
- in INT count)
- {
- return SetStatus(GdipDrawPolygonI(nativeGraphics,
- pen.nativePen,
- points,
- count));
- }
- Status DrawPath(in Pen pen,
- in GraphicsPath* path)
- {
- return SetStatus(GdipDrawPath(nativeGraphics,
- pen ? pen.nativePen : null,
- path ? path.nativePath : null));
- }
- Status DrawCurve(in Pen pen,
- in PointF* points,
- in INT count)
- {
- return SetStatus(GdipDrawCurve(nativeGraphics,
- pen.nativePen, points,
- count));
- }
- Status DrawCurve(in Pen pen,
- in PointF* points,
- in INT count,
- in REAL tension)
- {
- return SetStatus(GdipDrawCurve2(nativeGraphics,
- pen.nativePen, points,
- count, tension));
- }
- Status DrawCurve(in Pen pen,
- in PointF* points,
- in INT count,
- in INT offset,
- in INT numberOfSegments,
- in REAL tension = 0.5f)
- {
- return SetStatus(GdipDrawCurve3(nativeGraphics,
- pen.nativePen, points,
- count, offset,
- numberOfSegments, tension));
- }
- Status DrawCurve(in Pen pen,
- in Point* points,
- in INT count)
- {
- return SetStatus(GdipDrawCurveI(nativeGraphics,
- pen.nativePen,
- points,
- count));
- }
- Status DrawCurve(in Pen pen,
- in Point* points,
- in INT count,
- in REAL tension)
- {
- return SetStatus(GdipDrawCurve2I(nativeGraphics,
- pen.nativePen,
- points,
- count,
- tension));
- }
- Status DrawCurve(in Pen pen,
- in Point* points,
- in INT count,
- in INT offset,
- in INT numberOfSegments,
- in REAL tension = 0.5f)
- {
- return SetStatus(GdipDrawCurve3I(nativeGraphics,
- pen.nativePen,
- points,
- count,
- offset,
- numberOfSegments,
- tension));
- }
- Status DrawClosedCurve(in Pen pen,
- in PointF* points,
- in INT count)
- {
- return SetStatus(GdipDrawClosedCurve(nativeGraphics,
- pen.nativePen,
- points, count));
- }
- Status DrawClosedCurve(in Pen *pen,
- in PointF* points,
- in INT count,
- in REAL tension)
- {
- return SetStatus(GdipDrawClosedCurve2(nativeGraphics,
- pen.nativePen,
- points, count,
- tension));
- }
- Status DrawClosedCurve(in Pen pen,
- in Point* points,
- in INT count)
- {
- return SetStatus(GdipDrawClosedCurveI(nativeGraphics,
- pen.nativePen,
- points,
- count));
- }
- Status DrawClosedCurve(in Pen *pen,
- in Point* points,
- in INT count,
- in REAL tension)
- {
- return SetStatus(GdipDrawClosedCurve2I(nativeGraphics,
- pen.nativePen,
- points,
- count,
- tension));
- }
- Status Clear(in Color color)
- {
- return SetStatus(GdipGraphicsClear(
- nativeGraphics,
- color.GetValue()));
- }
- Status FillRectangle(in Brush* brush,
- in RectF rect)
- {
- return FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height);
- }
- Status FillRectangle(in Brush* brush,
- in REAL x,
- in REAL y,
- in REAL width,
- in REAL height)
- {
- return SetStatus(GdipFillRectangle(nativeGraphics, brush.nativeBrush, x, y, width, height));
- }
- Status FillRectangles(in Brush* brush,
- in RectF* rects,
- in INT count)
- {
- return SetStatus(GdipFillRectangles(nativeGraphics,
- brush.nativeBrush,
- rects, count));
- }
- Status FillRectangle(in Brush* brush,
- in Rect rect)
- {
- return FillRectangle(brush,
- rect.X,
- rect.Y,
- rect.Width,
- rect.Height);
- }
- Status FillRectangle(in Brush* brush,
- in INT x,
- in INT y,
- in INT width,
- in INT height)
- {
- return SetStatus(GdipFillRectangleI(nativeGraphics,
- brush.nativeBrush,
- x,
- y,
- width,
- height));
- }
- Status FillRectangles(in Brush* brush,
- in Rect* rects,
- in INT count)
- {
- return SetStatus(GdipFillRectanglesI(nativeGraphics,
- brush.nativeBrush,
- rects,
- count));
- }
- Status FillPolygon(in Brush* brush,
- in PointF* points,
- in INT count)
- {
- return FillPolygon(brush, points, count, FillMode.FillModeAlternate);
- }
- Status FillPolygon(in Brush* brush,
- in PointF* points,
- in INT count,
- in FillMode fillMode)
- {
- return SetStatus(GdipFillPolygon(nativeGraphics,
- brush.nativeBrush,
- points, count, fillMode));
- }
- Status FillPolygon(in Brush* brush,
- in Point* points,
- in INT count)
- {
- return FillPolygon(brush, points, count, FillMode.FillModeAlternate);
- }
- Status FillPolygon(in Brush* brush,
- in Point* points,
- in INT count,
- in FillMode fillMode)
- {
- return SetStatus(GdipFillPolygonI(nativeGraphics,
- brush.nativeBrush,
- points, count,
- fillMode));
- }
- Status FillEllipse(in Brush* brush,
- in RectF rect)
- {
- return FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height);
- }
- Status FillEllipse(in Brush* brush,
- in REAL x,
- in REAL y,
- in REAL width,
- in REAL height)
- {
- return SetStatus(GdipFillEllipse(nativeGraphics,
- brush.nativeBrush, x, y,
- width, height));
- }
- Status FillEllipse(in Brush* brush,
- in Rect rect)
- {
- return FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height);
- }
- Status FillEllipse(in Brush* brush,
- in INT x,
- in INT y,
- in INT width,
- in INT height)
- {
- return SetStatus(GdipFillEllipseI(nativeGraphics,
- brush.nativeBrush,
- x,
- y,
- width,
- height));
- }
- Status FillPie(in Brush* brush,
- in RectF rect,
- in REAL startAngle,
- in REAL sweepAngle)
- {
- return FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height,
- startAngle, sweepAngle);
- }
- Status FillPie(in Brush* brush,
- in REAL x,
- in REAL y,
- in REAL width,
- in REAL height,
- in REAL startAngle,
- in REAL sweepAngle)
- {
- return SetStatus(GdipFillPie(nativeGraphics,
- brush.nativeBrush, x, y,
- width, height, startAngle,
- sweepAngle));
- }
- Status FillPie(in Brush* brush,
- in Rect rect,
- in REAL startAngle,
- in REAL sweepAngle)
- {
- return FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height,
- startAngle, sweepAngle);
- }
- Status FillPie(in Brush* brush,
- in INT x,
- in INT y,
- in INT width,
- in INT height,
- in REAL startAngle,
- in REAL sweepAngle)
- {
- return SetStatus(GdipFillPieI(nativeGraphics,
- brush.nativeBrush,
- x,
- y,
- width,
- height,
- startAngle,
- sweepAngle));
- }
- Status FillPath(in Brush* brush,
- in GraphicsPath* path)
- {
- return SetStatus(GdipFillPath(nativeGraphics,
- brush.nativeBrush,
- path.nativePath));
- }
- Status FillClosedCurve(in Brush* brush,
- in PointF* points,
- in INT count)
- {
- return SetStatus(GdipFillClosedCurve(nativeGraphics,
- brush.nativeBrush,
- points, count));
- }
- Status FillClosedCurve(in Brush* brush,
- in PointF* points,
- in INT count,
- in FillMode fillMode,
- in REAL tension = 0.5f)
- {
- return SetStatus(GdipFillClosedCurve2(nativeGraphics,
- brush.nativeBrush,
- points, count,
- tension, fillMode));
- }
- Status FillClosedCurve(in Brush* brush,
- in Point* points,
- in INT count)
- {
- return SetStatus(GdipFillClosedCurveI(nativeGraphics,
- brush.nativeBrush,
- points,
- count));
- }
- Status FillClosedCurve(in Brush* brush,
- in Point* points,
- in INT count,
- in FillMode fillMode,
- in REAL tension = 0.5f)
- {
- return SetStatus(GdipFillClosedCurve2I(nativeGraphics,
- brush.nativeBrush,
- points, count,
- tension, fillMode));
- }
- Status FillRegion(in Brush* brush,
- in Region* region)
- {
- return SetStatus(GdipFillRegion(nativeGraphics,
- brush.nativeBrush,
- region.nativeRegion));
- }
- Status DrawString(in WCHAR* string, in INT length, in Font font,
- in RectF layoutRect, in StringFormat stringFormat, in Brush brush) {
- return SetStatus(GdipDrawString(
- nativeGraphics,
- string,
- length,
- font ? font.nativeFont : null,
- &layoutRect,
- stringFormat ? stringFormat.nativeFormat : null,
- brush ? brush.nativeBrush : null
- ));
- }
- Status
- DrawString(
- WCHAR *string,
- INT length,
- Font font,
- PointF origin,
- Brush brush
- )
- {
- RectF rect;
- rect.init(origin.X, origin.Y, 0.0f, 0.0f);
- return SetStatus(GdipDrawString(
- nativeGraphics,
- string,
- length,
- font ? font.nativeFont : null,
- &rect,
- null,
- brush ? brush.nativeBrush : null
- ));
- }
- Status
- DrawString(
- WCHAR *string,
- INT length,
- Font font,
- PointF origin,
- StringFormat stringFormat,
- Brush brush
- )
- {
- RectF rect;
- rect.init(origin.X, origin.Y, 0.0f, 0.0f);
- return SetStatus(GdipDrawString(
- nativeGraphics,
- string,
- length,
- font ? font.nativeFont : null,
- &rect,
- stringFormat ? stringFormat.nativeFormat : null,
- brush ? brush.nativeBrush : null
- ));
- }
- Status
- MeasureString(
- in WCHAR *string,
- in INT length,
- in Font font,
- in RectF layoutRect,
- in StringFormat stringFormat,
- RectF *boundingBox,
- INT *codepointsFitted = null,
- INT *linesFilled = null
- ) {
- return SetStatus(GdipMeasureString(
- nativeGraphics,
- string,
- length,
- font ? font.nativeFont : null,
- &layoutRect,
- stringFormat ? stringFormat.nativeFormat : null,
- boundingBox,
- codepointsFitted,
- linesFilled
- ));
- }
- Status
- MeasureString(
- in WCHAR *string,
- in INT length,
- in Font font,
- in SizeF *layoutRectSize,
- in StringFormat stringFormat,
- SizeF *size,
- INT *codepointsFitted = null,
- INT *linesFilled = null
- )
- {
- RectF layoutRect;
- layoutRect.init(0, 0, layoutRectSize.Width, layoutRectSize.Height);
- RectF boundingBox;
- Status status;
- if (size is null) {
- return SetStatus(Status.InvalidParameter);
- }
- status = SetStatus(GdipMeasureString(
- nativeGraphics,
- string,
- length,
- font ? font.nativeFont : null,
- &layoutRect,
- stringFormat ? stringFormat.nativeFormat : null,
- size ? &boundingBox : null,
- codepointsFitted,
- linesFilled
- ));
- if (size && status == Status.Ok)
- {
- size.Width = boundingBox.Width;
- size.Height = boundingBox.Height;
- }
- return status;
- }
- Status
- MeasureString(
- in WCHAR *string,
- in INT length,
- in Font font,
- in PointF origin,
- in StringFormat stringFormat,
- RectF *boundingBox
- )
- {
- RectF rect;
- rect.init(origin.X, origin.Y, 0.0f, 0.0f);
- return SetStatus(GdipMeasureString(
- nativeGraphics,
- string,
- length,
- font ? font.nativeFont : null,
- &rect,
- stringFormat ? stringFormat.nativeFormat : null,
- boundingBox,
- null,
- null
- ));
- }
- Status
- MeasureString(
- in WCHAR *string,
- in INT length,
- in Font font,
- in RectF layoutRect,
- RectF *boundingBox
- )
- {
- return SetStatus(GdipMeasureString(
- nativeGraphics,
- string,
- length,
- font ? font.nativeFont : null,
- &layoutRect,
- null,
- boundingBox,
- null,
- null
- ));
- }
- Status
- MeasureString(
- in WCHAR *string,
- in INT length,
- in Font font,
- in PointF origin,
- RectF *boundingBox
- )
- {
- RectF rect;
- rect.init(origin.X, origin.Y, 0.0f, 0.0f);
- return SetStatus(GdipMeasureString(
- nativeGraphics,
- string,
- length,
- font ? font.nativeFont : null,
- &rect,
- null,
- boundingBox,
- null,
- null
- ));
- }
- Status
- MeasureCharacterRanges(
- in WCHAR *string,
- in INT length,
- in Font font,
- in RectF layoutRect,
- in StringFormat stringFormat,
- in INT regionCount,
- Region *regions
- )
- {
- if (!regions || regionCount <= 0)
- {
- return Status.InvalidParameter;
- }
- GpRegion*[] nativeRegions = new GpRegion* [regionCount];
- if (!nativeRegions) {
- return Status.OutOfMemory;
- }
- for (INT i = 0; i < regionCount; i++) {
- nativeRegions[i] = regions[i].nativeRegion;
- }
- Status status = SetStatus(GdipMeasureCharacterRanges(
- nativeGraphics,
- string,
- length,
- font ? font.nativeFont : null,
- layoutRect,
- stringFormat ? stringFormat.nativeFormat : null,
- regionCount,
- nativeRegions.ptr
- ));
- return status;
- }
- Status DrawDriverString(
- in UINT16 *text,
- in INT length,
- in Font font,
- in Brush brush,
- in PointF *positions,
- in INT flags,
- in Matrix matrix
- )
- {
- return SetStatus(GdipDrawDriverString(
- nativeGraphics,
- text,
- length,
- font ? font.nativeFont : null,
- brush ? brush.nativeBrush : null,
- positions,
- flags,
- matrix ? matrix.nativeMatrix : null
- ));
- }
- Status MeasureDriverString(
- in UINT16 *text,
- in INT length,
- in Font font,
- in PointF *positions,
- in INT flags,
- in Matrix matrix,
- RectF *boundingBox
- )
- {
- return SetStatus(GdipMeasureDriverString(
- nativeGraphics,
- text,
- length,
- font ? font.nativeFont : null,
- positions,
- flags,
- matrix ? matrix.nativeMatrix : null,
- boundingBox
- ));
- }
- // Draw a cached bitmap on this graphics destination offset by
- // x, y. Note this will fail with WrongState if the CachedBitmap
- // native format differs from this Graphics.
- Status DrawCachedBitmap(in CachedBitmap cb,
- in INT x,
- in INT y)
- {
- return SetStatus(GdipDrawCachedBitmap(
- nativeGraphics,
- cb.nativeCachedBitmap,
- x, y
- ));
- }
- Status DrawImage(in Image image,
- in PointF point)
- {
- return DrawImage(image, point.X, point.Y);
- }
- Status DrawImage(in Image image,
- in REAL x,
- in REAL y)
- {
- return SetStatus(GdipDrawImage(nativeGraphics,
- image ? image.nativeImage
- : null,
- x,
- y));
- }
- Status DrawImage(in Image image, in RectF rect) {
- return DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
- }
- Status DrawImage(in Image image,
- in REAL x,
- in REAL y,
- in REAL width,
- in REAL height)
- {
- return SetStatus(GdipDrawImageRect(nativeGraphics,
- image ? image.nativeImage
- : null,
- x,
- y,
- width,
- height));
- }
- Status DrawImage(in Image image,
- in Point point)
- {
- return DrawImage(image, point.X, point.Y);
- }
- Status DrawImage(in Image image,
- in INT x,
- in INT y)
- {
- return SetStatus(GdipDrawImageI(nativeGraphics,
- image ? image.nativeImage
- : null,
- x,
- y));
- }
- Status DrawImage(in Image image,
- in Rect rect)
- {
- return DrawImage(image,
- rect.X,
- rect.Y,
- rect.Width,
- rect.Height);
- }
- Status DrawImage(in Image image,
- in INT x,
- in INT y,
- in INT width,
- in INT height) {
- return SetStatus(GdipDrawImageRectI(nativeGraphics,
- image ? image.nativeImage
- : null,
- x,
- y,
- width,
- height));
- }
-
- Status DrawImage(in Image image,
- in PointF* destPoints,
- in INT count)
- {
- if (count != 3 && count != 4)
- return SetStatus(Status.InvalidParameter);
- return SetStatus(GdipDrawImagePoints(nativeGraphics,
- image ? image.nativeImage
- : null,
- destPoints, count));
- }
- Status DrawImage(in Image image,
- in Point* destPoints,
- in INT count)
- {
- if (count != 3 && count != 4)
- return SetStatus(Status.InvalidParameter);
- return SetStatus(GdipDrawImagePointsI(nativeGraphics,
- image ? image.nativeImage
- : null,
- destPoints,
- count));
- }
- Status DrawImage(in Image image,
- in REAL x,
- in REAL y,
- in REAL srcx,
- in REAL srcy,
- in REAL srcwidth,
- in REAL srcheight,
- in Unit srcUnit)
- {
- return SetStatus(GdipDrawImagePointRect(nativeGraphics,…