Ignore:
Timestamp:
Dec 17, 2006, 12:36:30 PM (18 years ago)
Author:
イグトランス (egtra)
Message:

Graphics クラスの追加とそれに伴う修正

Location:
Include/Classes/System/Drawing
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Include/Classes/System/Drawing/Graphics.ab

    r11 r33  
     1' Classes/System/Drawing/Graphics.ab
     2
     3#ifndef __SYSTEM_DRAWING_GRAPHICS_AB__
     4#define __SYSTEM_DRAWING_GRAPHICS_AB__
     5
     6#include <GdiPlusGpStabus.ab>
     7#include <GdiPlusFlat.ab>
     8#include <Classes/System/Drawing/Graphics/misc.ab>
     9#include <Classes/System/Drawing/Graphics/Rectangle.ab>
     10#include <Classes/System/Drawing/Graphics/RectangleF.ab>
     11#include <Classes/System/Drawing/Graphics/Point.ab>
     12#include <Classes/System/Drawing/Graphics/PointF.ab>
     13#include <Classes/System/Drawing/Graphics/SizeF.ab>
     14#include <Classes/System/Drawing/Graphics/Brush.ab>
     15#include <Classes/System/Drawing/Graphics/Pen.ab>
     16#include <Classes/System/Drawing/Graphics/Region.ab>
     17#include <Classes/System/Drawing/Graphics/StringFormat.ab>
     18#include <Classes/System/Drawing/Graphics/Image.ab>
     19#include <Classes/System/Drawing/Graphics/Drawing2D/misc.ab>
     20#include <Classes/System/Drawing/Graphics/Drawing2D/Matrix.ab>
     21
     22Class Graphics
     23Public
     24    '=========================================================================
     25    ' Properties
     26    '=========================================================================
     27    Const Function Clip() As Region
     28        Dim r As Regino
     29        GetClip(r)
     30        Return r
     31    End Function
     32
     33    Sub Clip(ByRef region As /*Const*/ Region)
     34        SetClip(region, CombineMode.Replace)
     35    End Sub
     36
     37    Const Function ClipBounds() As RectangleF
     38        Dim rc As RectangleF
     39        GetClipBounds(rc)
     40        Return rc
     41    End Function
     42
     43    Sub ClipBounds(rc As RectangleF)
     44        SetClipBounds(rc)
     45    End Sub
     46
     47    Function CompositingMode() As CompositingMode
     48        Return GetCompositingMode()
     49    End Function
     50
     51    Sub CompositingMode(mode As CompositingMode)
     52        SetCompositingMode(mode)
     53    End Sub
     54
     55    Function CompositingQuality() As CompositingQuality
     56        Return GetCompositingQuality()
     57    End Function
     58
     59    Sub CompositingQuality(cq As CompositingQuality)
     60        SetCompositingQuality(cq)
     61    End Sub
     62
     63    Const Function DpiX() As Single
     64        Dim dpi As Single
     65        SetStatus(GdipGetDpiX(nativeGraphics, dpi))
     66        Return dpi
     67    End Function
     68
     69    Const Function DpiY() As Single
     70        Dim dpi As Single
     71        SetStatus(GdipGetDpiY(nativeGraphics, dpi))
     72        Return dpi
     73    End Function
     74
     75    Const Function InterpolationMode() As InterpolationMode
     76        Return GetInterpolationMode()
     77    End Function
     78
     79    Sub InterpolationMode(im As InterpolationMode)
     80        SetInterpolationMode(im)
     81    End Sub
     82
     83    Const Function IsClipEmpty() As BOOL
     84        Dim b = FALSE As BOOL
     85        SetStatus(GdipIsClipEmpty(nativeGraphics, b))
     86        Return b
     87    End Function
     88
     89    Const Function IsVisibleClipEmpty() As BOOL
     90        Dim b = FALSE As BOOL
     91        SetStatus(GdipIsVisibleClipEmpty(nativeGraphics, b))
     92        Return b
     93    End Function
     94
     95    Function PageScale(scale As Single) As Status
     96        Return SetStatus(GdipSetPageScale(nativeGraphics, scale))
     97    End Function
     98
     99    Const Function PageScale() As Single
     100        Dim scale As Single
     101        SetStatus(GdipGetPageScale(nativeGraphics, scale))
     102        Return scale
     103    End Function
     104
     105    Const Function PageUnit() As GraphicsUnit
     106        Dim unit As GraphicsUnit
     107        SetStatus(GdipGetPageUnit(nativeGraphics, unit))
     108        Return unit
     109    End Function
     110
     111    Function PageUnit(unit As GraphicsUnit) As Status
     112        Return SetStatus(GdipSetPageUnit(nativeGraphics, unit))
     113    End Function
     114
     115    Function PixelOffsetMode() As PixelOffsetMode
     116        Return GetPixelOffsetMode()
     117    End Function
     118
     119    Sub PixelOffsetMode(mode  As PixelOffsetMode)
     120        SetPixelOffsetMode(mode)
     121    End Sub
     122
     123    Function RenderingOrigin() As Point
     124        Dim pt As Point
     125        GetRenderingOrigin(pt.X, pt.Y)
     126        Return pt
     127    End Function
     128
     129    Sub RenderingOrigin(pt As Point)
     130        SetRenderingOrigin(pt.X, pt.Y)
     131    End Sub
     132
     133    Function SmoothingMode() As SmoothingMode
     134        Return GetSmoothingMode()
     135    End Function
     136
     137    Sub SmoothingMode(mode As SmoothingMode)
     138        SetSmoothingMode(mode)
     139    End Sub
     140
     141    Function TextContrast() As DWord
     142        Return GetTextContrast()
     143    End Function
     144
     145    Sub TextContrast(contrast As DWord)
     146        SetTextContrast(contrast)
     147    End Sub
     148
     149    Function TextRenderingHint() As TextRenderingHint
     150        Return GetTextRenderingHint()
     151    End Function
     152
     153    Sub TextRenderingHint(mode As TextRenderingHint)
     154        SetTextRenderingHint(mode)
     155    End Sub
     156
     157    Function Transform() As Matrix
     158        Dim matrix As Matrix
     159        GetTransform(matrix)
     160        Return matrix
     161    End Function
     162
     163    Sub Transform(ByRef matrix As Matrix)
     164        SetTransform(matirx)
     165    End Sub
     166
     167    Function VisibleClipBounds() As RectangleF
     168        Dim rc As RectangleF
     169        GetVisibleClipBounds(rc)
     170        Return rc
     171    End Function
     172
     173    '=========================================================================
     174    ' Methods
     175    '=========================================================================
     176    Static Function FromHDC(hdc As HDC) As *Graphics
     177        Return New Graphics(hdc)
     178    End Function
     179
     180    Static Function FromHDC(hdc As HDC, hdevice As HANDLE) As *Graphics
     181        Return New Graphics(hdc, hdevice)
     182    End Function
     183
     184    Static Function FromHWND(hwnd As HWND) As *Graphics
     185        Return New Graphics(hwnd, FALSE)
     186    End Function
     187
     188    Static Function FromHWND(hwnd As DWord, icm As BOOL) As *Graphics
     189        Return New Graphics(hwnd, icm)
     190    End Function
     191
     192    Static Function FromImage(image As *Image) As *Graphics
     193        Return New Graphics(image)
     194    End Function
     195
     196    Sub Graphics(hdc As HDC)
     197        Dim graphics = 0 As *GpGraphics
     198        lastResult = GdipCreateFromHDC(hdc, graphics)
     199        SetNativeGraphics(graphics)
     200    End Sub
     201
     202    Sub Graphics(hdc As HDC, hdevice As HANDLE)
     203        Dim graphics = 0 As *GpGraphics
     204        lastResult = GdipCreateFromHDC2(hdc, hdevice, graphics)
     205        SetNativeGraphics(graphics)
     206    End Sub
     207
     208    Sub Graphics(hwnd As HWND)
     209        Dim graphics = 0 As *GpGraphics
     210        lastResult = GdipCreateFromHWND(hwnd, graphics)
     211        SetNativeGraphics(graphics)
     212    End Sub
     213
     214    Sub Graphics(hwnd As HWND, icm As BOOL)
     215        Dim graphics = 0 As *GpGraphics
     216        If icm <> FALSE Then
     217            lastResult = GdipCreateFromHWNDICM(hwnd, graphics)
     218        Else
     219            lastResult = GdipCreateFromHWND(hwnd, graphics)
     220        End If
     221        SetNativeGraphics(graphics)
     222    End Sub
     223
     224    Sub Graphics(image As *Image)
     225        Dim graphics = 0 As *GpGraphics
     226        If (image != 0)
     227            lastResult = GdipGetImageGraphicsContext(image->nativeImage, graphics)
     228        End If
     229        SetNativeGraphics(graphics)
     230    End Sub
     231
     232    Sub ~Graphics()
     233        GdipDeleteGraphics(nativeGraphics)
     234    End Sub
     235
     236    Sub Flush()
     237        GdipFlush(nativeGraphics, FlushIntention.Flush)
     238    End Sub
     239
     240    Sub Flush(intention As FlushIntention)
     241        GdipFlush(nativeGraphics, intention)
     242    End Sub
     243
     244    '------------------------------------------------------------------------
     245    ' GDI Interop methods
     246    '------------------------------------------------------------------------
     247
     248    ' Locks the graphics until ReleaseDC is called
     249
     250    Function GetHDC() As HDC
     251        Dim hdc = 0 As HDC
     252        SetStatus(GdipGetDC(nativeGraphics, hdc))
     253        Return hdc
     254    End Function
     255
     256    Sub ReleaseHDC(hdc As HDC)
     257        SetStatus(GdipReleaseDC(nativeGraphics, hdc))
     258    End Sub
     259
     260    '------------------------------------------------------------------------
     261    ' Rendering modes
     262    '------------------------------------------------------------------------
     263
     264    Function SetRenderingOrigin(x As Long, y As Long) As Status
     265        Return SetStatus(GdipSetRenderingOrigin(nativeGraphics, x, y))
     266    End Function
     267
     268    Const Function GetRenderingOrigin(ByRef x As Long, ByRef y As Long) As Status
     269        Return SetStatus(GdipGetRenderingOrigin(nativeGraphics, x, y))
     270    End Function
     271
     272    Function SetCompositingMode(compositingMode As CompositingMode) As Status
     273        Return SetStatus(GdipSetCompositingMode(nativeGraphics, compositingMode))
     274    End Function
     275
     276    Const Function GetCompositingMode() As CompositingMode
     277        Dim mode As CompositingMode
     278        SetStatus(GdipGetCompositingMode(nativeGraphics, mode))
     279        Return mode
     280    End Function
     281
     282    Function SetCompositingQuality(compositingQuality As CompositingQuality)
     283        Return SetStatus(GdipSetCompositingQuality(nativeGraphics, compositingQuality))
     284    End Function
     285
     286    Const Function GetCompositingQuality() As CompositingQuality
     287        Dim quality As CompositingQuality
     288        SetStatus(GdipGetCompositingQuality(nativeGraphics, quality))
     289        Return quality
     290    End Function
     291
     292    Function SetTextRenderingHint(newMode As TextRenderingHint) As Status
     293        Return SetStatus(GdipSetTextRenderingHint(nativeGraphics, newMode))
     294    End Function
     295
     296    Const Function GetTextRenderingHint() As TextRenderingHint
     297        Dim hint As TextRenderingHint
     298        SetStatus(GdipGetTextRenderingHint(nativeGraphics, hint))
     299        Return hint
     300    End Function
     301
     302    Function SetTextContrast(contrast As DWord) As Status
     303        Return SetStatus(GdipSetTextContrast(nativeGraphics, contrast))
     304    End Function
     305
     306    Const Function GetTextContrast() As DWord
     307        Dim contrast As DWord
     308        SetStatus(GdipGetTextContrast(nativeGraphics, contrast))
     309        Return contrast
     310    End Function
     311
     312    Const Function GetInterpolationMode() As InterpolationMode
     313        Dim mode = InterpolationMode.Invalid As InterpolationMode
     314        SetStatus(GdipGetInterpolationMode(nativeGraphics, mode))
     315        Return mode
     316    End Function
     317
     318    Function SetInterpolationMode(interpolationMode As InterpolationMode) As Status
     319        Return SetStatus(GdipSetInterpolationMode(nativeGraphics, interpolationMode))
     320    End Function
     321
     322    Const Function GetSmoothingMode() As SmoothingMode
     323        Dim smoothingMode = SmoothingMode.Invalid As SmoothingMode
     324        SetStatus(GdipGetSmoothingMode(nativeGraphics, smoothingMode))
     325        Return smoothingMode
     326    End Function
     327
     328    Function SetSmoothingMode(smoothingMode As SmoothingMode) As Status
     329        Return SetStatus(GdipSetSmoothingMode(nativeGraphics, smoothingMode))
     330    End Function
     331
     332    Const Function GetPixelOffsetMode() As PixelOffsetMode
     333        Dim pixelOffsetMode = PixelOffsetMode.Invalid As PixelOffsetMode
     334        SetStatus(GdipGetPixelOffsetMode(nativeGraphics, pixelOffsetMode))
     335        Return pixelOffsetMode
     336    End Function
     337
     338    Function SetPixelOffsetMode(pixelOffsetMode As PixelOffsetMode) As Status
     339        Return SetStatus(GdipSetPixelOffsetMode(nativeGraphics, pixelOffsetMode))
     340    End Function
     341
     342    '------------------------------------------------------------------------
     343    ' Manipulate current world transform
     344    '------------------------------------------------------------------------
     345
     346    Function SetTransform(ByRef matrix As /*Const*/ *Matrix) As Status
     347        Return SetStatus(GdipSetWorldTransform(nativeGraphics, matrix->nativeMatrix))
     348    End Function
     349
     350    Function ResetTransform() As Status
     351        Return SetStatus(GdipResetWorldTransform(nativeGraphics))
     352    End Function
     353
     354    Function MultiplyTransform(ByRef matrix As /*Const*/ Matrix) As Status
     355        Return SetStatus(GdipMultiplyWorldTransform(nativeGraphics, matrix->nativeMatrix, MatrixOrder.Prepend))
     356    End Function
     357
     358    Function MultiplyTransform(ByRef matrix As /*Const*/ Matrix, order As MatrixOrder) As Status
     359        Return SetStatus(GdipMultiplyWorldTransform(nativeGraphics, matrix->nativeMatrix, order))
     360    End Function
     361
     362    Function TranslateTransform(dx As Single, dy As Single) As Status
     363        Return SetStatus(GdipTranslateWorldTransform(nativeGraphics, dx, dy, MatrixOrder.Prepend))
     364    End Function
     365
     366    Function TranslateTransform(dx As Single, dy As Single, order As MatrixOrder) As Status
     367        Return SetStatus(GdipTranslateWorldTransform(nativeGraphics, dx, dy, order))
     368    End Function
     369
     370    Function ScaleTransform(sx As Single, sy As Single) As Status
     371        Return SetStatus(GdipScaleWorldTransform(nativeGraphics, sx, sy, MatrixOrder.Prepend))
     372    End Function
     373
     374    Function ScaleTransform(sx As Single, sy As Single, order As MatrixOrder) As Status
     375        Return SetStatus(GdipScaleWorldTransform(nativeGraphics, sx, sy, order))
     376    End Function
     377
     378    Function RotateTransform(angle As Single) As Status
     379        Return SetStatus(GdipRotateWorldTransform(nativeGraphics, angle, MatrixOrder.Prepend))
     380    End Function
     381
     382    Function RotateTransform(angle As Single, order As MatrixOrder) As Status
     383        Return SetStatus(GdipRotateWorldTransform(nativeGraphics, angle, order))
     384    End Function
     385
     386    Const Function GetTransform(ByRef matrix As Matrix) As Status
     387        Return SetStatus(GdipGetWorldTransform(nativeGraphics, matrix->nativeMatrix))
     388    End Function
     389
     390    Const Function TransformPoints(destSpace As CoordinateSpace, srcSpace As CoordinateSpace, pts As PointF, count As Long) As Status
     391        Return SetStatus(GdipTransformPoints(nativeGraphics, destSpace, srcSpace, pts, count))
     392    End Function
     393
     394    Const Function TransformPoints(destSpace As CoordinateSpace, srcSpace As CoordinateSpace, pts As Point, count As Long) As Status
     395        Return SetStatus(GdipTransformPointsI(nativeGraphics, destSpace, srcSpace, pts, count))
     396    End Function
     397
     398    '------------------------------------------------------------------------
     399    ' GetNearestColor (for <= 8bpp surfaces).   Note: Alpha is ignored.
     400    '------------------------------------------------------------------------
     401
     402    Const Function GetNearestColor(ByRef color As Color) As Status
     403        Dim argb = color->Value
     404        Dim status = SetStatus(GdipGetNearestColor(nativeGraphics, argb))
     405        color->Value = argb
     406        Return status
     407    End Function
     408
     409    Function DrawLine(ByRef pen As /*Const*/ Pen, x1 As Single, y1 As Single, x2 As Single, y2 As Single) As Status
     410        Return SetStatus(GdipDrawLine(nativeGraphics, pen->nativePen, x1, y1, x2, y2))
     411    End Function
     412
     413    Function DrawLine(ByRef pen As /*Const*/ Pen, ByRef pt1 As /*Const*/ PointF, ByRef pt2 As /*Const*/ PointF) As Status
     414        Return DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y)
     415    End Function
     416
     417    Function DrawLines(ByRef pen As /*Const*/ Pen, points As /*Const*/ *PointF, count As Long) As Status
     418        Return SetStatus(GdipDrawLines(nativeGraphics, pen->nativePen, points, count))
     419    End Function
     420
     421    Function DrawLine(ByRef pen As /*Const*/ Pen, x1 As Long, y1 As Long, x2 As Long, y2 As Long) As Status
     422        Return SetStatus(GdipDrawLineI(nativeGraphics, pen->nativePen, x1, y1, x2, y2))
     423    End Function
     424
     425    Function DrawLine(ByRef pen As /*Const*/ Pen, ByRef pt1 As /*Const*/ Point, ByRef pt2 As /*Const*/ Point) As Status
     426        Return DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y)
     427    End Function
     428
     429    Function DrawLines(ByRef pen As /*Const*/ Pen, points As /*Const*/ *Point, count As Long) As Status
     430        Return SetStatus(GdipDrawLinesI(nativeGraphics, pen->nativePen, points, count))
     431    End Function
     432
     433    Function DrawArc(ByRef pen As /*Const*/ Pen, x As Single, y As Single, width As Single, height As Single, startAngle As Single, sweepAngle As Single) As Status
     434        Return SetStatus(GdipDrawArc(nativeGraphics, pen->nativePen, x, y, width, height, startAngle, sweepAngle))
     435    End Function
     436
     437    Function DrawArc(ByRef pen As /*Const*/ Pen, ByRef rect As /*Const*/ RectangleF, startAngle As Single, sweepAngle As Single) As Status
     438        Return DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
     439    End Function
     440
     441    Function DrawArc(ByRef pen As /*Const*/ Pen, x As Long, y As Long, width As Long, height As Long, startAngle As Single, sweepAngle As Single) As Status
     442        Return SetStatus(GdipDrawArcI(nativeGraphics, pen->nativePen, x, y, width, height, startAngle, sweepAngle))
     443    End Function
     444
     445    Function DrawArc(ByRef pen As /*Const*/ Pen, ByRef rect As /*Const*/ RectangleF, startAngle As Single, sweepAngle As Single) As Status
     446        Return DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
     447    End Function
     448
     449    Function DrawBezier(ByRef pen As /*Const*/ Pen, x1 As Single, y1 As Single, x2 As Single, y2 As Single, x3 As Single, y3 As Single, x4 As Single, y4 As Single) As Status
     450        Return SetStatus(GdipDrawBezier(nativeGraphics, pen->nativePen, x1, y1,x2, y2, x3, y3, x4, y4))
     451    End Function
     452
     453    Function DrawBezier(ByRef pen As /*Const*/ Pen, ByRef pt1 As /*Const*/ PointF, ByRef pt2 As /*Const*/ PointF, ByRef pt3 As /*Const*/ PointF, ByRef pt4 As /*Const*/ PointF) As Status
     454        Return DrawBezier(pen, pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y)
     455    End Function
     456
     457    Function DrawBeziers(ByRef pen As /*Const*/ Pen, points As /*Const*/ *PointF, count As Long) As Status
     458        Return SetStatus(GdipDrawBeziers(nativeGraphics, pen->nativePen, points, count))
     459    End Function
     460
     461    Function DrawBezier(ByRef pen As /*Const*/ Pen, x1 As Long, y1 As Long, x2 As Long, y2 As Long, x3 As Long, y3 As Long, x4 As Long, y4 As Long) As Status
     462        Return SetStatus(GdipDrawBezierI(nativeGraphics, pen->nativePen, x1, y1, x2, y2, x3, y3, x4, y4))
     463    End Function
     464
     465    Function DrawBezier(ByRef pen As /*Const*/ Pen, ByRef pt1 As /*Const*/ Point, ByRef pt2 As /*Const*/ Point, ByRef pt3 As /*Const*/ Point, ByRef pt4 As /*Const*/ Point) As Status
     466        Return DrawBezier(pen pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y)
     467    End Function
     468
     469    Function DrawBeziers(ByRef pen As /*Const*/ Pen, points As /*Const*/ *Point count As Long) As Status
     470        Return SetStatus(GdipDrawBeziersI(nativeGraphics, pen->nativePen, points, count))
     471    End Function
     472
     473    Function DrawRectangle(ByRef pen As /*Const*/ Pen, ByRef rect As /*Const*/ RectangleF) As Status
     474        Return DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height)
     475    End Function
     476
     477    Function DrawRectangle(ByRef pen As /*Const*/ Pen, x As Single, y As Single, width As Single, height As Single) As Status
     478        Return SetStatus(GdipDrawRectangle(nativeGraphics, pen->nativePen, x, y, width, height))
     479    End Function
     480
     481    Function DrawRectangles(ByRef pen As /*Const*/ Pen, rects As /*Const*/ *RectangleF, count As Long) As Status
     482        Return SetStatus(GdipDrawRectangles(nativeGraphics, pen->nativePen, rects, count))
     483    End Function
     484
     485    Function DrawRectangle(ByRef pen As /*Const*/ Pen, ByRef rect As /*Const*/ Rectangle) As Status
     486        Return DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height)
     487    End Function
     488
     489    Function DrawRectangle(ByRef pen As /*Const*/ Pen, x As Long, y As Long, width As Long, height As Long) As Status
     490        Return SetStatus(GdipDrawRectangleI(nativeGraphics, pen->nativePen, x, y, width, height))
     491    End Function
     492
     493    Function DrawRectangles(ByRef pen As /*Const*/ Pen, rects As /*Const*/ *Rectangle,  count As Long) As Status
     494        Return SetStatus(GdipDrawRectanglesI(nativeGraphics, pen->nativePen, rects, count))
     495    End Function
     496
     497    Function DrawEllipse(ByRef pen As /*Const*/ Pen, ByRef rect As /*Const*/ RectangleF) As Status
     498        Return DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height)
     499    End Function
     500
     501    Function DrawEllipse(ByRef pen As /*Const*/ Pen, x As Single, y As Single, width As Single, height As Single) As Status
     502        Return SetStatus(GdipDrawEllipse(nativeGraphics, pen->nativePen, x, y, width, height))
     503    End Function
     504
     505    Function DrawEllipse(ByRef pen As /*Const*/ Pen, ByRef rect As /*Const*/ Rectangle) As Status
     506        Return DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height)
     507    End Function
     508
     509    Function DrawEllipse(ByRef pen As /*Const*/ Pen, x As Long, y As Long, width As Long, height As Long) As Status
     510        Return SetStatus(GdipDrawEllipseI(nativeGraphics, pen->nativePen, x, y, width, height))
     511    End Function
     512
     513    Function DrawPie(ByRef pen As /*Const*/ Pen, ByRef rect As /*Const*/ RectangleF, startAngle As Single, sweepAngle As Single) As Status
     514        Return DrawPie(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
     515    End Function
     516
     517    Function DrawPie(ByRef pen As /*Const*/ Pen, x As Single, y As Single, width As Single, height As Single, startAngle As Single, sweepAngle As Single) As Status
     518        Return SetStatus(GdipDrawPie(nativeGraphics, pen->nativePen, x, y, width, height, startAngle, sweepAngle))
     519    End Function
     520
     521    Function DrawPie(ByRef pen As /*Const*/ Pen, ByRef rect As /*Const*/ Rectangle, startAngle As Single, sweepAngle As Single) As Status
     522        Return DrawPie(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
     523    End Function
     524
     525    Function DrawPie(ByRef pen As /*Const*/ Pen, x As Long, y As Long, width As Long, height As Long, startAngle As Single, sweepAngle As Single) As Status
     526        Return SetStatus(GdipDrawPieI(nativeGraphics, pen->nativePen, x, y, width, height, startAngle, sweepAngle))
     527    End Function
     528
     529    Function DrawPolygon(ByRef pen As /*Const*/ Pen, points As /*Const*/ *PointF, count As Long) As Status
     530        Return SetStatus(GdipDrawPolygon(nativeGraphics, pen->nativePen, points, count))
     531    End Function
     532
     533    Function DrawPolygon(ByRef pen As /*Const*/ Pen, points As /*Const*/ *Point, count As Long) As Status
     534        Return SetStatus(GdipDrawPolygonI(nativeGraphics, pen->nativePen, points, count))
     535    End Function
     536
     537    Function DrawPath(ByRef pen As /*Const*/ Pen, ByRef path As /*Const*/ GraphicsPath) As Status
     538        Return SetStatus(GdipDrawPath(nativeGraphics, pen->nativePen, path->nativePath))
     539'       Return SetStatus(GdipDrawPath(nativeGraphics, pen ? pen->nativePen : NULL, path ? path->nativePath : NULL))
     540    End Function
     541
     542    Function DrawCurve(ByRef pen As /*Const*/ Pen, points As /*Const*/ *PointF, count As Long) As Status
     543        Return SetStatus(GdipDrawCurve(nativeGraphics, pen->nativePen, points, count))
     544    End Function
     545
     546    Function DrawCurve(ByRef pen As /*Const*/ Pen, points As /*Const*/ *PointF, count As Long, tension As Single) As Status
     547        Return SetStatus(GdipDrawCurve2(nativeGraphics, pen->nativePen, points,count, tension))
     548    End Function
     549
     550    Function DrawCurve(ByRef pen As /*Const*/ Pen, points As /*Const*/ *PointF, count As Long, offset As Long, numberOfSegments As Long) As Status
     551        Return SetStatus(GdipDrawCurve3(nativeGraphics, pen->nativePen, points, count, offset,numberOfSegments, 0.5))
     552    End Function
     553
     554    Function DrawCurve(ByRef pen As /*Const*/ Pen, points As /*Const*/ *PointF, count As Long, offset As Long, numberOfSegments As Long, tension As Single) As Status
     555        Return SetStatus(GdipDrawCurve3(nativeGraphics, pen->nativePen, points, count, offset,numberOfSegments, tension))
     556    End Function
     557
     558    Function DrawCurve(ByRef pen As /*Const*/ Pen, points As /*Const*/ *Point, count As Long) As Status
     559        Return SetStatus(GdipDrawCurveI(nativeGraphics, pen->nativePen, points, count))
     560    End Function
     561
     562    Function DrawCurve(ByRef pen As /*Const*/ Pen, points As /*Const*/ *Point, count As Long, tension As Single) As Status
     563        Return SetStatus(GdipDrawCurve2I(nativeGraphics, pen->nativePen, points, count, tension))
     564    End Function
     565
     566    Function DrawCurve(ByRef pen As /*Const*/ Pen, points As /*Const*/ *Point, count As Long, offset As Long, numberOfSegments As Long) As Status
     567        Return SetStatus(GdipDrawCurve3I(nativeGraphics, pen->nativePen, points, count, offset, numberOfSegments, 0.5))
     568    End Function
     569
     570    Function DrawCurve(ByRef pen As /*Const*/ Pen, points As /*Const*/ *Point, count As Long, offset As Long, numberOfSegments As Long, tension As Single) As Status
     571        Return SetStatus(GdipDrawCurve3I(nativeGraphics, pen->nativePen, points, count, offset, numberOfSegments, tension))
     572    End Function
     573
     574    Function DrawClosedCurve(ByRef pen As /*Const*/ Pen, points As /*Const*/ *PointF, count As Long) As Status
     575        Return SetStatus(GdipDrawClosedCurve(nativeGraphics, pen->nativePen, points, count))
     576    End Function
     577
     578    Function DrawClosedCurve(ByRef pen As /*Const*/ Pen, points As /*Const*/ *PointF, count As Long, tension As Single) As Status
     579        Return SetStatus(GdipDrawClosedCurve2(nativeGraphics, pen->nativePen, points, count, tension))
     580    End Function
     581
     582    Function DrawClosedCurve(ByRef pen As /*Const*/ Pen, points As /*Const*/ *Point, count As Long) As Status
     583        Return SetStatus(GdipDrawClosedCurveI(nativeGraphics, pen->nativePen, points, count))
     584    End Function
     585
     586    Function DrawClosedCurve(ByRef pen As /*Const*/ Pen, points As /*Const*/ *Point, count As Long, tension As Single) As Status
     587        Return SetStatus(GdipDrawClosedCurve2I(nativeGraphics, pen->nativePen, points, count, tension))
     588    End Function
     589
     590    Function Clear(ByRef color As /*Const*/ Color) As Status
     591        Return SetStatus(GdipGraphicsClear(nativeGraphics, color.Value))
     592    End Function
     593
     594    Function FillRectangle(ByRef brush As /*Const*/ Brush, ByRef rect As /*Const*/ RectangleF) As Status
     595        Return FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height)
     596    End Function
     597
     598    Function FillRectangle(ByRef brush As /*Const*/ Brush, x As Single, y As Single, width As Single, height As Single) As Status
     599        Return SetStatus(GdipFillRectangle(nativeGraphics, brush->nativeBrush, x, y, width, height))
     600    End Function
     601
     602    Function FillRectangles(ByRef brush As /*Const*/ Brush, rects As /*Const*/ *RectangleF, count As Long) As Status
     603        Return SetStatus(GdipFillRectangles(nativeGraphics,brush->nativeBrush,rects, count))
     604    End Function
     605
     606    Function FillRectangle(ByRef brush As /*Const*/ Brush, ByRef rect As /*Const*/ Rectangle) As Status
     607        Return FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height)
     608    End Function
     609
     610    Function FillRectangle(ByRef brush As /*Const*/ Brush, x As Long, y As Long, width As Long, height As Long) As Status
     611        Return SetStatus(GdipFillRectangleI(nativeGraphics, brush->nativeBrush, x, y, width, height))
     612    End Function
     613
     614    Function FillRectangles(ByRef brush As /*Const*/ Brush, rects As /*Const*/ *Rectangle, count As Long) As Status
     615        Return SetStatus(GdipFillRectanglesI(nativeGraphics, brush->nativeBrush, rects, count))
     616    End Function
     617
     618    Function FillPolygon(ByRef brush As /*Const*/ Brush, points As /*Const*/ *PointF, count As Long) As Status
     619        Return FillPolygon(brush, points, count, FillModeAlternate)
     620    End Function
     621
     622    Function FillPolygon(ByRef brush As /*Const*/ Brush, points As /*Const*/ *PointF, count As Long, fillMode As FillMode) As Status
     623        Return SetStatus(GdipFillPolygon(nativeGraphics, brush->nativeBrush, points, count, fillMode))
     624    End Function
     625
     626    Function FillPolygon(ByRef brush As /*Const*/ Brush, points As /*Const*/ *Point, count As Long) As Status
     627        Return FillPolygon(brush, points, count, FillModeAlternate)
     628    End Function
     629
     630    Function FillPolygon(ByRef brush As /*Const*/ Brush, points As /*Const*/ *Point, count As Long, fillMode As FillMode) As Status
     631        Return SetStatus(GdipFillPolygonI(nativeGraphics, brush->nativeBrush, points, count, fillMode))
     632    End Function
     633
     634    Function FillEllipse(ByRef brush As /*Const*/ Brush, ByRef rect As /*Const*/ RectangleF) As Status
     635        Return FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height)
     636    End Function
     637
     638    Function FillEllipse(ByRef brush As /*Const*/ Brush, x As Single, y As Single, width As Single, height As Single) As Status
     639        Return SetStatus(GdipFillEllipse(nativeGraphics, brush->nativeBrush, x, y, width, height))
     640    End Function
     641
     642    Function FillEllipse(ByRef brush As /*Const*/ Brush, ByRef rect As /*Const*/ Rectangle) As Status
     643        Return FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height)
     644    End Function
     645
     646    Function FillEllipse(ByRef brush As /*Const*/ Brush, x As Long, y As Long, width As Long, height As Long) As Status
     647        Return SetStatus(GdipFillEllipseI(nativeGraphics, brush->nativeBrush, x, y, width, height))
     648    End Function
     649
     650    Function FillPie(ByRef brush As /*Const*/ Brush, ByRef rect As /*Const*/ RectangleF, startAngle As Single, sweepAngle As Single) As Status
     651        Return FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
     652    End Function
     653
     654    Function FillPie(ByRef brush As /*Const*/ Brush, x As Single, y As Single, width As Single, height As Single, startAngle As Single, sweepAngle As Single) As Status
     655        Return SetStatus(GdipFillPie(nativeGraphics, brush->nativeBrush, x, y, width, height, startAngle, sweepAngle))
     656    End Function
     657
     658    Function FillPie(ByRef brush As /*Const*/ Brush, ByRef rect As /*Const*/ Rectangle, startAngle As Single, sweepAngle As Single) As Status
     659        Return FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
     660    End Function
     661
     662    Function FillPie(ByRef brush As /*Const*/ Brush, x As Long, y As Long, width As Long, height As Long, startAngle As Single, sweepAngle As Single) As Status
     663        Return SetStatus(GdipFillPieI(nativeGraphics, brush->nativeBrush, x, y, width, height, startAngle, sweepAngle))
     664    End Function
     665
     666    Function FillPath(ByRef brush As /*Const*/ Brush, ByRef path As /*Const*/ GraphicsPath) As Status
     667        Return SetStatus(GdipFillPath(nativeGraphics, brush->nativeBrush, path->nativePath))
     668    End Function
     669
     670    Function FillClosedCurve(ByRef brush As /*Const*/ Brush, points As /*Const*/ *PointF, count As Long) As Status
     671        Return SetStatus(GdipFillClosedCurve(nativeGraphics, brush->nativeBrush, points, count))
     672    End Function
     673
     674    Function FillClosedCurve(ByRef brush As /*Const*/ Brush, points As /*Const*/ *PointF, count As Long, fillMode As FillMode) As Status
     675        Return SetStatus(GdipFillClosedCurve2(nativeGraphics, brush->nativeBrush, points, count, 0.5, fillMode))
     676    End Function
     677
     678    Function FillClosedCurve(ByRef brush As /*Const*/ Brush, points As /*Const*/ *PointF, count As Long, fillMode As FillMode, tension As Single) As Status
     679        Return SetStatus(GdipFillClosedCurve2(nativeGraphics, brush->nativeBrush, points, count, tension, fillMode))
     680    End Function
     681
     682    Function FillClosedCurve(ByRef brush As /*Const*/ Brush, points As /*Const*/ *Point, count As Long) As Status
     683        Return SetStatus(GdipFillClosedCurveI(nativeGraphics, brush->nativeBrush, points, count))
     684    End Function
     685
     686    Function FillClosedCurve(ByRef brush As /*Const*/ Brush, points As /*Const*/ *Point, count As Long, fillMode As FillMode) As Status
     687        Return SetStatus(GdipFillClosedCurve2I(nativeGraphics, brush->nativeBrush, points, count, 0.5, fillMode))
     688    End Function
     689
     690    Function FillClosedCurve(ByRef brush As /*Const*/ Brush, points As /*Const*/ *Point, count As Long, fillMode As FillMode, tension As Single) As Status
     691        Return SetStatus(GdipFillClosedCurve2I(nativeGraphics, brush->nativeBrush, points, count, tension, fillMode))
     692    End Function
     693
     694    Function FillRegion(ByRef brush As /*Const*/ Brush, ByRef region As /*Const*/ Region) As Status
     695        Return SetStatus(GdipFillRegion(nativeGraphics, brush->nativeBrush, region->nativeRegion))
     696    End Function
     697
     698    Function DrawString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font, ByRef layoutRect As /*Const*/ RectangleF) As Status
     699        Dim nativeFont As *GpFont
     700        If VarPtr(font) <> 0 Then
     701            nativeFont = font.nativeFormat
     702        Else
     703            nativeFont = 0
     704        End If
     705        Return SetStatus(GdipDrawString( nativeGraphics, str, length, nativeFont, layoutRect, 0, 0))
     706    End Function
     707
     708    Function DrawString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font, ByRef layoutRect As /*Const*/ RectangleF,
     709        ByRef stringFormat As /*Const*/ StringFormat, ByRef brush As /*Const*/ Brush) As Status
     710
     711        Dim nativeFont As *GpFont
     712        If VarPtr(font) <> 0 Then
     713            nativeFont = font.nativeFormat
     714        Else
     715            nativeFont = 0
     716        End If
     717        Dim nativeFormat As *GpStringFormat
     718        If VarPtr(layoutRect) <> 0 Then
     719            nativeFormat = layoutRect.nativeFormat
     720        Else
     721            nativeFormat = 0
     722        End If
     723        Return SetStatus(GdipDrawString( nativeGraphics, str, length, nativeFont, layoutRect, nativeFormat, 0))
     724    End Function
     725
     726    Function DrawString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font, ByRef layoutRect As /*Const*/ RectangleF,
     727        ByRef stringFormat As /*Const*/ StringFormat, ByRef brush As /*Const*/ Brush) As Status
     728
     729        Dim nativeFont As *GpFont
     730        If VarPtr(font) <> 0 Then
     731            nativeFont = font.nativeFormat
     732        Else
     733            nativeFont = 0
     734        End If
     735        Dim nativeFormat As *GpStringFormat
     736        If VarPtr(stringFormat) <> 0 Then
     737            nativeFormat = stringFormat.nativeFormat
     738        Else
     739            nativeFormat = 0
     740        End If
     741        Dim nativeBrush As *GpBrush
     742        If VarPtr(brush) <> 0 Then
     743            nativeBrush = brush.nativeFormat
     744        Else
     745            nativeBrush = 0
     746        End If
     747        Return SetStatus(GdipDrawString(nativeGraphics, str, length, nativeFont, layoutRect, nativeFormat, nativeBrush))
     748    End Function
     749
     750    Function DrawString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font, ByRef origin As /*Const*/ PointF) As Status
     751        Dim rect As RectangleF(origin.X, origin.Y, 0.0, 0.0)
     752        Dim nativeFont As *GpFont
     753        If VarPtr(font) <> 0 Then
     754            nativeFont = font.nativeFormat
     755        Else
     756            nativeFont = 0
     757        End If
     758        Return SetStatus(GdipDrawString(nativeGraphics, str, length, nativeFont, rect, 0, 0))
     759    End Function
     760
     761    Function DrawString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font, ByRef origin As /*Const*/ PointF,
     762        ByRef brush As /*Const*/ Brush) As Status
     763
     764        Dim rect As RectangleF(origin.X, origin.Y, 0.0, 0.0)
     765        Dim nativeFont As *GpFont
     766        If VarPtr(font) <> 0 Then
     767            nativeFont = font.nativeFormat
     768        Else
     769            nativeFont = 0
     770        End If
     771        Dim nativeBrush As *GpBrush
     772        If VarPtr(brush) <> 0 Then
     773            nativeBrush = brush.nativeFormat
     774        Else
     775            nativeBrush = 0
     776        End If
     777        Return SetStatus(GdipDrawString(nativeGraphics, str, length, nativeFont, rect, 0, nativeBrush))
     778    End Function
     779
     780    Function DrawString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font, ByRef origin As /*Const*/ PointF) As Status
     781        Dim rect As RectangleF(origin.X, origin.Y, 0.0, 0.0)
     782        Dim nativeFont As *GpFont
     783        If VarPtr(font) <> 0 Then
     784            nativeFont = font.nativeFormat
     785        Else
     786            nativeFont = 0
     787        End If
     788        Return SetStatus(GdipDrawString(nativeGraphics, str, length, nativeFont, rect, 0, 0))
     789    End Function
     790
     791    Function DrawString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font, ByRef origin As /*Const*/ PointF,
     792        ByRef stringFormat As /*Const*/ StringFormat) As Status
     793
     794        Dim rect As RectangleF(origin.X, origin.Y, 0.0, 0.0)
     795        Dim nativeFont As *GpFont
     796        If VarPtr(font) <> 0 Then
     797            nativeFont = font.nativeFormat
     798        Else
     799            nativeFont = 0
     800        End If
     801        Dim nativeFormat As *GpStringFormat
     802        If VarPtr(stringFormat) <> 0 Then
     803            nativeFormat = stringFormat.nativeFormat
     804        Else
     805            nativeFormat = 0
     806        End If
     807        Return SetStatus(GdipDrawString(nativeGraphics, str, length, nativeFont, rect, nativeFormat, 0))
     808    End Function
     809
     810    Function DrawString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font, ByRef origin As /*Const*/ PointF,
     811        ByRef stringFormat As /*Const*/ StringFormat, ByRef brush As /*Const*/ Brush) As Status
     812
     813        Dim rect As RectangleF(origin.X, origin.Y, 0.0, 0.0)
     814        Dim nativeFont As *GpFont
     815        If VarPtr(font) <> 0 Then
     816            nativeFont = font.nativeFormat
     817        Else
     818            nativeFont = 0
     819        End If
     820        Dim nativeFormat As *GpStringFormat
     821        If VarPtr(stringFormat) <> 0 Then
     822            nativeFormat = stringFormat.nativeFormat
     823        Else
     824            nativeFormat = 0
     825        End If
     826        If VarPtr(brush) <> 0 Then
     827            nativeBrush = brush.nativeFormat
     828        Else
     829            nativeBrush = 0
     830        End If
     831        Return SetStatus(GdipDrawString( nativeGraphics, str, length, nativeFont, rect, nativeFormat, nativeBrush))
     832    End Function
     833
     834    Const Function MeasureString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font, ByRef layoutRect As /*Const*/ RectangleF,
     835        ByRef stringFormat As /*Const*/ StringFormat, ByRef boundingBox As RectangleF) As Status
     836
     837        Return MeasureString(str, length, font, layoutRect, stringFormat, boundingBox, ByVal 0, ByVal 0)
     838    End Function
     839
     840    Const Function MeasureString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font, ByRef layoutRect As /*Const*/ RectangleF,
     841        ByRef stringFormat As /*Const*/ StringFormat, ByRef boundingBox As RectangleF,
     842        ByRef codepointsFitted As Long) As Status
     843
     844        Return MeasureString(str, length, font, layoutRect, stringFormat, boundingBox, codepointsFitted, ByVal 0)
     845    End Function
     846
     847    Const Function MeasureString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font, ByRef layoutRect As /*Const*/ RectangleF,
     848        ByRef stringFormat As /*Const*/ StringFormat, ByRef boundingBox As RectangleF,
     849        ByRef codepointsFitted As Long, ByRef linesFilled As Long) As Status
     850
     851        Dim nativeFont As *GpFont
     852        If VarPtr(font) <> 0 Then
     853            nativeFont = font.nativeFormat
     854        Else
     855            nativeFont = 0
     856        End If
     857        Dim nativeFormat As *GpStringFormat
     858        If VarPtr(stringFormat) <> 0 Then
     859            nativeFormat = stringFormat.nativeFormat
     860        Else
     861            nativeFormat = 0
     862        End If
     863        Return SetStatus(GdipMeasureString(nativeGraphics, str, length, nativeFont, layoutRect, nativeFormat,
     864            boundingBox, codepointsFitted, linesFilled))
     865    End Function
     866
     867    Const Function MeasureString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font,
     868        ByRef layoutRectSize As /*Const*/ SizeF, ByRef stringFormat As /*Const*/ StringFormat,
     869        ByRef size As SizeF) As Status
     870
     871            Return MeasureString, str, length, font, layoutRectSize, stringFormat, size, ByVal 0, ByVal 0)
     872    End Function
     873
     874    Const Function MeasureString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font,
     875        ByRef layoutRectSize As /*Const*/ SizeF, ByRef stringFormat As /*Const*/ StringFormat,
     876        ByRef size As SizeF, ByRef codepointsFitted As Long) As Status
     877
     878            Return MeasureString, str, length, font, layoutRectSize, stringFormat, size, codepointsFitted, ByVal 0)
     879    End Function
     880
     881    Const Function MeasureString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font,
     882        ByRef layoutRectSize As /*Const*/ SizeF, ByRef stringFormat As /*Const*/ StringFormat,
     883        ByRef size As SizeF, ByRef codepointsFitted As Long, ByRef linesFilled As Long) As Status
     884
     885        Dim layoutRect As RectangleF(0, 0, layoutRectSize.Width, layoutRectSize.Height)
     886        Dim boundingBox As RectangleF, pBoundingBox As *RectangleF
     887        If VarPtr(size) <> 0 Then
     888            pBoundingBox = VarPtr(boundingBox)
     889        Else
     890            pBoundingBox = 0
     891        End If
     892
     893        Dim nativeFont As *GpFont
     894        If VarPtr(font) <> 0 Then
     895            nativeFont = font.nativeFormat
     896        Else
     897            nativeFont = 0
     898        End If
     899        Dim nativeFormat As *GpStringFormat
     900        If VarPtr(stringFormat) <> 0 Then
     901            nativeFormat = stringFormat.nativeFormat
     902        Else
     903            nativeFormat = 0
     904        End If
     905        Dim status = SetStatus(GdipMeasureString(nativeGraphics, str, length,
     906            nativeFont, layoutRect, nativeFormat, pBoundingBox, codepointsFitted, linesFilled))
     907
     908        If VarPtr(size) <> 0 And status = Ok Then
     909            size.Width  = boundingBox.Width
     910            size.Height = boundingBox.Height
     911        End Function
     912
     913        Return status
     914    End Function
     915
     916    Const Function MeasureString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font,
     917        ByRef origin As /*Const*/ PointF, ByRef stringFormat As /*Const*/ StringFormat,
     918        ByRef boundingBox As RectangleF) As Status
     919
     920        Dim rect As RectangleF(origin.X, origin.Y, 0.0f, 0.0f)
     921        Dim nativeFont As *GpFont
     922        If VarPtr(font) <> 0 Then
     923            nativeFont = font.nativeFormat
     924        Else
     925            nativeFont = 0
     926        End If
     927        Dim nativeFormat As *GpStringFormat
     928        If VarPtr(stringFormat) <> 0 Then
     929            nativeFormat = stringFormat.nativeFormat
     930        Else
     931            nativeFormat = 0
     932        End If
     933
     934        Return SetStatus(GdipMeasureString(nativeGraphics, str, length, nativeFont, rect, nativeFormat, boundingBox, 0, 0))
     935    End Function
     936
     937    Const Function MeasureString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font,
     938        ByRef layoutRect As /*Const*/ RectangleF, ByRef boundingBox As RectangleF) As Status
     939
     940        Dim nativeFont As *GpFont
     941        If VarPtr(font) <> 0 Then
     942            nativeFont = font.nativeFormat
     943        Else
     944            nativeFont = 0
     945        End If
     946
     947        Return SetStatus(GdipMeasureString(nativeGraphics, str, length, nativeFont, layoutRect, 0, boundingBox, 0, 0))
     948    End Function
     949
     950    Const Function MeasureString(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font,
     951        ByRef origin As /*Const*/ PointF, ByRef boundingBox As RectangleF) As Status
     952        Dim rect As RectangleF(origin.X, origin.Y, 0.0, 0.0)
     953
     954        Dim nativeFont As *GpFont
     955        If VarPtr(font) <> 0 Then
     956            nativeFont = font.nativeFormat
     957        Else
     958            nativeFont = 0
     959        End If
     960        Return SetStatus(GdipMeasureString(nativeGraphics, str, length, nativeFont, rect, 0, boundingBox, 0, 0))
     961    End Function
     962
     963    Const Function MeasureCharacterRanges(str As PCWSTR, length As Long, ByRef font As /*Const*/ Font,
     964        ByRef layoutRect As /*Const*/ RectangleF, ByRef stringFormat As /*Const*/ StringFormat,
     965        regionCount As Long, regions As *Region) As Status
     966        If regions = 0 Or regionCount <= 0 Then
     967            Return InvalidParameter
     968        End If
     969
     970        Dim nativeRegions = _System_malloc(regionCount * SizeOf (GpRegion*)) As **GpRegion
     971
     972        If nativeRegions = 0 Then
     973            Return OutOfMemory
     974        End If
     975
     976        Dim i As Long
     977        For i = 0 To regionCount
     978            nativeRegions[i] = regions[i].nativeRegion
     979        Next
     980
     981        Dim nativeFont As *GpFont
     982        If VarPtr(font) <> 0 Then
     983            nativeFont = font.nativeFormat
     984        Else
     985            nativeFont = 0
     986        End If
     987        Dim nativeFormat As *GpStringFormat
     988        If VarPtr(stringFormat) <> 0 Then
     989            nativeFormat = stringFormat.nativeFormat
     990        Else
     991            nativeFormat = 0
     992        End If
     993
     994        Dim status = SetStatus(GdipMeasureCharacterRanges(nativeGraphics,
     995            str, length, nativeFont, layoutRect, nativeFormat,regionCount, nativeRegions))
     996        _System_free(nativeRegions)
     997        Return status
     998    End Function
     999
     1000    Function DrawDriverString(text As /*Const*/ Word, length As Long, ByRef font As /*Const*/ Font,
     1001        ByRef brush As /*Const*/ Brush, positions As /*Const*/ *PointF, flags As Long) As Status
     1002
     1003        Return DrawDriverString(text, length, font, brush, positions, flags, ByVal 0)
     1004    End Function
     1005
     1006    Function DrawDriverString(text As /*Const*/ Word, length As Long, ByRef font As /*Const*/ Font,
     1007        ByRef brush As /*Const*/ Brush, positions As /*Const*/ *PointF, flags As Long, ByRef matrix As /*Const*/ Matrix) As Status
     1008
     1009        Dim nativeFont As *GpFont
     1010        If VarPtr(font) <> 0 Then
     1011            nativeFont = font.nativeFormat
     1012        Else
     1013            nativeFont = 0
     1014        End If
     1015        Dim nativeBrush As *GpBrush
     1016        If VarPtr(brush) <> 0 Then
     1017            nativeBrush = brush.nativeBrush
     1018        Else
     1019            nativeBrush = 0
     1020        End If
     1021        Dim nativeMatrix As *GpMatrix
     1022        If VarPtr(matrix) <> 0 Then
     1023            nativeMatrix = matrix.nativeMatrix
     1024        Else
     1025            nativeMatrix = 0
     1026        End If
     1027        Return SetStatus(GdipDrawDriverString(nativeGraphics, text, length, nativeFont, nativeBrush, positions, flags, nativeMatrix))
     1028    End Function
     1029
     1030    Const Function MeasureDriverString(text As /*Const*/ Word, length As Long, ByRef font As /*Const*/ Font,
     1031        positions As /*Const*/ *PointF, flags As Long, ByRef matrix As /*Const*/ Matrix, ByRef boundingBox As RectangleF) As Status
     1032
     1033        Dim nativeFont As *GpFont
     1034        If VarPtr(font) <> 0 Then
     1035            nativeFont = font.nativeFormat
     1036        Else
     1037            nativeFont = 0
     1038        End If
     1039        Dim nativeMatrix As *GpMatrix
     1040        If VarPtr(matrix) <> 0 Then
     1041            nativeMatrix = matrix.nativeMatrix
     1042        Else
     1043            nativeMatrix = 0
     1044        End If
     1045        Return SetStatus(GdipMeasureDriverString(nativeGraphics, text, length, nativeFont, positions, flags, nativeMatrix, boundingBox))
     1046    End Function
     1047
     1048    ' Draw a cached bitmap on this graphics destination offset by
     1049    ' x, y. Note this will fail with WrongState if the CachedBitmap
     1050    ' native format differs from this Graphics.
     1051
     1052    Function DrawCachedBitmap(ByRef cb As CachedBitma, x As Long, y As Long) As Status
     1053        Return SetStatus(GdipDrawCachedBitmap(nativeGraphics, cb->nativeCachedBitmap, x, y))
     1054    End Function
     1055
     1056    Function DrawImage(ByRef image As Image, ByRef point As /*Const*/ PointF) As Status
     1057        Return DrawImage(image, point.X, point.Y)
     1058    End Function
     1059
     1060    Function DrawImage(ByRef image As Image, x As Single, y As Single) As Status
     1061        Dim nativeImage As *GpImage
     1062        If VarPtr(image) <> 0 Then
     1063            nativeImage = image.nativeImage
     1064        Else
     1065            nativeImage = 0
     1066        End If
     1067        Return SetStatus(GdipDrawImage(nativeGraphics, nativeImage, x, y))
     1068    End Function
     1069
     1070    Function DrawImage(ByRef image As Image, ByRef rect As /*Const*/ RectangleF) As Status
     1071        Return DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height)
     1072    End Function
     1073
     1074    Function DrawImage(ByRef image As Image, x As Single, y As Single, width As Single, height As Single) As Status
     1075        Dim nativeImage As *GpImage
     1076        If VarPtr(image) <> 0 Then
     1077            nativeImage = image.nativeImage
     1078        Else
     1079            nativeImage = 0
     1080        End If
     1081        Return SetStatus(GdipDrawImageRect(nativeGraphics, nativeImage, x, y, width, height))
     1082    End Function
     1083
     1084    Function DrawImage(ByRef image As Image, ByRef point As /*Const*/ Point) As Status
     1085        Return DrawImage(image, point.X, point.Y) As Status
     1086    End Function
     1087
     1088    Function DrawImage(ByRef image As Image, x As Long, y As Long) As Status
     1089        Dim nativeImage As *GpImage
     1090        If VarPtr(image) <> 0 Then
     1091            nativeImage = image.nativeImage
     1092        Else
     1093            nativeImage = 0
     1094        End If
     1095        Return SetStatus(GdipDrawImageI(nativeGraphics, nativeImage, x, y))
     1096    End Function
     1097
     1098    Function DrawImage(ByRef image As Image, ByRef rect As /*Const*/ Rectangle) As Status
     1099        Return DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height)
     1100    End Function
     1101
     1102    Function DrawImage(ByRef image As Image, x As Long, y As Long, width As Long, height As Long) As Status
     1103        Dim nativeImage As *GpImage
     1104        If VarPtr(image) <> 0 Then
     1105            nativeImage = image.nativeImage
     1106        Else
     1107            nativeImage = 0
     1108        End If
     1109        Return SetStatus(GdipDrawImageRectI(nativeGraphics, nativeImage, x, y, width, height))
     1110    End Function
     1111
     1112    ' Affine Draw Image
     1113    ' destPoints.length = 3: rect => parallelogram
     1114    '      destPoints[0] <=> top-left corner of the source rectangle
     1115    '      destPoints[1] <=> top-right corner
     1116    '      destPoints[2] <=> bottom-left corner
     1117    ' destPoints.length = 4: rect => quad
     1118    '      destPoints[3] <=> bottom-right corner
     1119
     1120    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ PointF, count As Long) As Status
     1121        If count <> 3 And count <> 4 Then
     1122            Return SetStatus(InvalidParameter)
     1123        End If
     1124
     1125        Dim nativeImage As *GpImage
     1126        If VarPtr(image) <> 0 Then
     1127            nativeImage = image.nativeImage
     1128        Else
     1129            nativeImage = 0
     1130        End If
     1131        Return SetStatus(GdipDrawImagePoints(nativeGraphics, nativeImage, destPoints, count))
     1132    End Function
     1133
     1134    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ Point, count As Long) As Status
     1135        If count <> 3 And count <> 4 Then
     1136            Return SetStatus(InvalidParameter)
     1137        End If
     1138
     1139        Dim nativeImage As *GpImage
     1140        If VarPtr(image) <> 0 Then
     1141            nativeImage = image.nativeImage
     1142        Else
     1143            nativeImage = 0
     1144        End If
     1145        Return SetStatus(GdipDrawImagePointsI(nativeGraphics, nativeImage, destPoints, count))
     1146    End Function
     1147
     1148    Function DrawImage(ByRef image As Image, x As Single, y As Single,
     1149        srcx As Single, srcy As Single, srcwidth As Single, srcheight As Single, srcUnit As GraphicsUnit) As Status
     1150
     1151        Dim nativeImage As *GpImage
     1152        If VarPtr(image) <> 0 Then
     1153            nativeImage = image.nativeImage
     1154        Else
     1155            nativeImage = 0
     1156        End If
     1157        Return SetStatus(GdipDrawImagePointRect(nativeGraphics, nativeImage, x, y, srcx, srcy, srcwidth, srcheight, srcUnit))
     1158    End Function
     1159
     1160    Function DrawImage(ByRef image As Image, ByRef destRect As /*Const*/ RectangleF,
     1161        srcx As Single, srcy As Single, srcwidth As Single, srcheight As Single, srcUnit As GraphicsUnit) As Status
     1162
     1163        Return DrawImage(image, destRect, srcx, srcy, srcwidth, srcheight, srcUnit, 0, 0, 0)
     1164    End Function
     1165
     1166    Function DrawImage(ByRef image As Image, ByRef destRect As /*Const*/ RectangleF,
     1167        srcx As Single, srcy As Single, srcwidth As Single, srcheight As Single, srcUnit As GraphicsUnit,
     1168        ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1169
     1170        Return DrawImage(image, destRect, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, 0, 0)
     1171    End Function
     1172
     1173    Function DrawImage(ByRef image As Image, ByRef destRect As /*Const*/ RectangleF,
     1174        srcx As Single, srcy As Single, srcwidth As Single, srcheight As Single, srcUnit As GraphicsUnit,
     1175        ByRef imageAttributes As /*Const*/ ImageAttributes,
     1176        callback As DrawImageAbort) As Status
     1177
     1178        Return DrawImage(image, destRect, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, 0)
     1179    End Function
     1180
     1181    Function DrawImage(ByRef image As Image, ByRef destRect As /*Const*/ RectangleF,
     1182        srcx As Single, srcy As Single, srcwidth As Single, srcheight As Single, srcUnit As GraphicsUnit,
     1183        ByRef imageAttributes As /*Const*/ ImageAttributes, callback As DrawImageAbort, callbackData As VoidPtr) As Status
     1184
     1185        Dim nativeImage As *GpImage
     1186        If VarPtr(image) <> 0 Then
     1187            nativeImage = image.nativeImage
     1188        Else
     1189            nativeImage = 0
     1190        End If
     1191        Dim nativeImageAttr As *GpImageAttributes
     1192        If VarPtr(imageAttributes) <> 0 Then
     1193            nativeImageAttr = image.nativeImageAttr
     1194        Else
     1195            nativeImageAttr = 0
     1196        End If
     1197
     1198        Return SetStatus(GdipDrawImageRectRect(nativeGraphics, nativeImageAttr,
     1199            destRect.X, destRect.Y, destRect.Width, destRect.Height, srcx, srcy, srcwidth, srcheight,
     1200            srcUnit, nativeImageAttr, callback, callbackData))
     1201    End Function
     1202
     1203    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ PointF, count As Long,
     1204        srcx As Single, srcy As Single, srcwidth As Single, srcheight As Single, srcUnit As GraphicsUnit) As Status
     1205
     1206        Return DrawImage(image, destPoints, count, srcx, srcy, srcwidth, srcheight, srcUnit, 0, 0, 0)
     1207    End Function
     1208
     1209    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ PointF, count As Long,
     1210        srcx As Single, srcy As Single, srcwidth As Single, srcheight As Single, srcUnit As GraphicsUnit,
     1211        ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1212
     1213        Return DrawImage(image, destPoints, count, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, 0, 0)
     1214    End Function
     1215
     1216    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ PointF, count As Long,
     1217        srcx As Single, srcy As Single, srcwidth As Single, srcheight As Single, srcUnit As GraphicsUnit,
     1218        ByRef imageAttributes As /*Const*/ ImageAttributes,
     1219        callback As DrawImageAbort) As Status
     1220
     1221        Return DrawImage(image, destPoints, count, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, 0)
     1222    End Function
     1223
     1224    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ PointF, count As Long,
     1225        srcx As Single, srcy As Single, srcwidth As Single, srcheight As Single, srcUnit As GraphicsUnit,
     1226        ByRef imageAttributes As /*Const*/ ImageAttributes, callback As DrawImageAbort, callbackData As VoidPtr) As Status
     1227
     1228        Dim nativeImage As *GpImage
     1229        If VarPtr(image) <> 0 Then
     1230            nativeImage = image.nativeImage
     1231        Else
     1232            nativeImage = 0
     1233        End If
     1234        Dim nativeImageAttr As *GpImageAttributes
     1235        If VarPtr(imageAttributes) <> 0 Then
     1236            nativeImageAttr = image.nativeImageAttr
     1237        Else
     1238            nativeImageAttr = 0
     1239        End If
     1240
     1241        Return SetStatus(GdipDrawImagePointsRect(nativeGraphics, nativeImage, destPoints, count,
     1242            srcx, srcy, srcwidth, srcheight, srcUnit, nativeImageAttr, callback, callbackData))
     1243    End Function
     1244
     1245    Function DrawImage(ByRef image As Image, x As Long, y As Long,
     1246        srcx As Long, srcy As Long, srcwidth As Long, srcheight As Long, srcUnit As GraphicsUnit) As Status
     1247
     1248        Dim nativeImage As *GpImage
     1249        If VarPtr(image) <> 0 Then
     1250            nativeImage = image.nativeImage
     1251        Else
     1252            nativeImage = 0
     1253        End If
     1254        Return SetStatus(GdipDrawImagePointRectI(nativeGraphics, nativeImage, x, y, srcx, srcy, srcwidth, srcheight, srcUnit))
     1255    End Function
     1256
     1257    Function DrawImage(ByRef image As Image, ByRef destRect As /*Const*/ Rectangle,
     1258        srcx As Single, srcy As Single, srcwidth As Single, srcheight As Single, srcUnit As GraphicsUnit) As Status
     1259
     1260        Return DrawImage(image, destRect, srcx, srcy, srcwidth, srcheight, srcUnit, 0, 0, 0)
     1261    End Function
     1262
     1263    Function DrawImage(ByRef image As Image, ByRef destRect As /*Const*/ Rectangle,
     1264        srcx As Single, srcy As Single, srcwidth As Single, srcheight As Single, srcUnit As GraphicsUnit,
     1265        ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1266
     1267        Return DrawImage(image, destRect, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, 0, 0)
     1268    End Function
     1269
     1270    Function DrawImage(ByRef image As Image, ByRef destRect As /*Const*/ Rectangle,
     1271        srcx As Single, srcy As Single, srcwidth As Single, srcheight As Single, srcUnit As GraphicsUnit,
     1272        ByRef imageAttributes As /*Const*/ ImageAttributes, callback As DrawImageAbort) As Status
     1273
     1274        Return DrawImage(image, destRect, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, 0)
     1275    End Function
     1276
     1277    Function DrawImage(ByRef image As Image, ByRef destRect As /*Const*/ Rectangle,
     1278        srcx As Long, srcy As Long, srcwidth As Long, srcheight As Long, srcUnit As GraphicsUnit,
     1279        ByRef imageAttributes As /*Const*/ ImageAttributes, callback As DrawImageAbort, callbackData As VoidPtr) As Status
     1280
     1281        Dim nativeImage As *GpImage
     1282        If VarPtr(image) <> 0 Then
     1283            nativeImage = image.nativeImage
     1284        Else
     1285            nativeImage = 0
     1286        End If
     1287        Dim nativeImageAttr As *GpImageAttributes
     1288        If VarPtr(imageAttributes) <> 0 Then
     1289            nativeImageAttr = image.nativeImageAttr
     1290        Else
     1291            nativeImageAttr = 0
     1292        End If
     1293
     1294        Return SetStatus(GdipDrawImageRectRectI(nativeGraphics, nativeImage,
     1295            destRect.X, destRect.Y, destRect.Width, destRect.Height,
     1296            srcx, srcy, srcwidth, srcheight, srcUnit, nativeImageAttr, callback, callbackData))
     1297    End Function
     1298
     1299    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ Point, count As Long,
     1300        srcx As Long, srcy As Long, srcwidth As Long, srcheight As Long, srcUnit As GraphicsUnit) As Status
     1301
     1302        Return DrawImage(image, destPoints, count, srcx, srcy, srcwidth, srcheight, srcUnit, 0, 0, 0)
     1303    End Function
     1304
     1305    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ Point, count As Long,
     1306        srcx As Long, srcy As Long, srcwidth As Long, srcheight As Long, srcUnit As GraphicsUnit,
     1307        ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1308
     1309        Return DrawImage(image, destPoints, count, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, 0, 0)
     1310    End Function
     1311
     1312    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ Point, count As Long,
     1313        srcx As Long, srcy As Long, srcwidth As Long, srcheight As Long, srcUnit As GraphicsUnit,
     1314        ByRef imageAttributes As /*Const*/ ImageAttributes,
     1315        DrawImageAbort callback As DrawImageAbort) As Status
     1316
     1317        Return DrawImage(image, destPoints, count, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, 0)
     1318    End Function
     1319
     1320    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ Point, count As Long,
     1321        srcx As Long, srcy As Long, srcwidth As Long, srcheight As Long, srcUnit As GraphicsUnit,
     1322        ByRef imageAttributes As /*Const*/ ImageAttributes, callback As DrawImageAbort, callbackData As VoidPtr) As Status
     1323
     1324        Dim nativeImage As *GpImage
     1325        If VarPtr(image) <> 0 Then
     1326            nativeImage = image.nativeImage
     1327        Else
     1328            nativeImage = 0
     1329        End If
     1330        Dim nativeImageAttr As *GpImageAttributes
     1331        If VarPtr(imageAttributes) <> 0 Then
     1332            nativeImageAttr = image.nativeImageAttr
     1333        Else
     1334            nativeImageAttr = 0
     1335        End If
     1336
     1337        Return SetStatus(GdipDrawImagePointsRectI(nativeGraphics, nativeImage, destPoints, count,
     1338            srcx, srcy, srcwidth, srcheight, srcUnit, nativeImageAttr, callback, callbackData))
     1339    End Function
     1340
     1341    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ *Point, count As Long, ByRef srcRect As Rectangle, srcUnit As GraphicsUnit) As Status
     1342        Return DrawImage(image, destPoints, count, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit)
     1343    End Function
     1344
     1345    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ *PointF, count As Long, ByRef srcRect As RectangleF, srcUnit As GraphicsUnit) As Status
     1346        Return DrawImage(image, destPoints, count, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit)
     1347    End Function
     1348
     1349    Function DrawImage(ByRef image As Image, x As Long, y As Long, ByRef srcRect As Rectangle, srcUnit As GraphicsUnit) As Status
     1350        Return DrawImage(image, x, y, count, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit)
     1351    End Function
     1352
     1353    Function DrawImage(ByRef image As Image, x As Single, y As Single, ByRef srcRect As RectangleF, srcUnit As GraphicsUnit) As Status
     1354        Return DrawImage(image, x, y, count, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit)
     1355    End Function
     1356
     1357    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ *Point, count As Long, ByRef srcRect As Rectangle, srcUnit As GraphicsUnit, ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1358        Return DrawImage(image, destPoints, count, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit, imageAttributes)
     1359    End Function
     1360
     1361    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ *PointF, count As Long, ByRef srcRect As RectangleF, srcUnit As GraphicsUnit, ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1362        Return DrawImage(image, destPoints, count, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit, imageAttributes)
     1363    End Function
     1364
     1365    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ *Point, count As Long, ByRef srcRect As Rectangle, srcUnit As GraphicsUnit, ByRef imageAttributes As /*Const*/ ImageAttributes, callback As DrawImageAbort) As Status
     1366        Return DrawImage(image, destPoints, count, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit, imageAttributes, callback)
     1367    End Function
     1368
     1369    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ *PointF, count As Long, ByRef srcRect As RectangleF, srcUnit As GraphicsUnit, ByRef imageAttributes As /*Const*/ ImageAttributes, callback As DrawImageAbort) As Status
     1370        Return DrawImage(image, destPoints, count, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit, imageAttributes, callback)
     1371    End Function
     1372
     1373    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ *Point, count As Long, ByRef srcRect As Rectangle, srcUnit As GraphicsUnit, ByRef imageAttributes As /*Const*/ ImageAttributes, callback As DrawImageAbort, callbackData As VoidPtr) As Status
     1374        Return DrawImage(image, destPoints, count, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit, imageAttributes, callback, callbackData)
     1375    End Function
     1376
     1377    Function DrawImage(ByRef image As Image, destPoints As /*Const*/ *PointF, count As Long, ByRef srcRect As RectangleF, srcUnit As GraphicsUnit, ByRef imageAttributes As /*Const*/ ImageAttributes, callback As DrawImageAbort, callbackData As VoidPtr) As Status
     1378        Return DrawImage(image, destPoints, count, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, srcUnit, imageAttributes, callback, callbackData)
     1379    End Function
     1380
     1381    ' The following methods are for playing an EMF+ to a graphics
     1382    ' via the enumeration interface.  Each record of the EMF+ is
     1383    ' sent to the callback (along with the callbackData).   Then
     1384    ' the callback can invoke the Metafile::PlayRecord method
     1385    ' to play the particular record.
     1386
     1387    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, ByRef destPoint As /*Const*/ PointF,
     1388        callback As EnumerateMetafileProc) As Status
     1389
     1390        Return EnumerateMetafile(metafile, destPoint, callback, 0, 0)
     1391    End Function
     1392
     1393    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, ByRef destPoint As /*Const*/ PointF,
     1394        callback As EnumerateMetafileProc, callbackData As VoidPtr) As Status
     1395
     1396        Return EnumerateMetafile(metafile, destPoint, callback, callbackData, 0)
     1397    End Function
     1398
     1399    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, ByRef destPoint As /*Const*/ PointF,
     1400        callback As EnumerateMetafileProc, callbackData As VoidPtr, ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1401
     1402        Dim nativeImage As /*Const*/ *GpMetafile
     1403        If VarPtr(metafile) <> 0 Then
     1404            nativeImage = metafile.nativeImage
     1405        Else
     1406            nativeImage = 0
     1407        End If
     1408        Dim nativeImageAttr As *GpImageAttributes
     1409        If VarPtr(imageAttributes) <> 0 Then
     1410            nativeImageAttr = image.nativeImageAttr
     1411        Else
     1412            nativeImageAttr = 0
     1413        End If
     1414
     1415        Return SetStatus(GdipEnumerateMetafileDestPoint(nativeGraphics,
     1416            nativeImage, destPoint, callback, callbackData,nativeImageAttr))
     1417    End Function
     1418
     1419    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, ByRef destPoint As /*Const*/ Point,
     1420        callback As EnumerateMetafileProc) As Status
     1421
     1422        Return EnumerateMetafile(metafile, destPoint, callback, 0, 0)
     1423    End Function
     1424
     1425    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, ByRef destPoint As /*Const*/ Point,
     1426        callback As EnumerateMetafileProc, callbackData As VoidPtr) As Status
     1427
     1428        Return EnumerateMetafile(metafile, destPoint, callback, callbackData, 0)
     1429    End Function
     1430
     1431    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, ByRef destPoint As /*Const*/ Point,
     1432        callback As EnumerateMetafileProc, callbackData As VoidPtr, ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1433
     1434        Dim nativeImage As /*Const*/ *GpMetafile
     1435        If VarPtr(metafile) <> 0 Then
     1436            nativeImage = metafile.nativeImage
     1437        Else
     1438            nativeImage = 0
     1439        End If
     1440        Dim nativeImageAttr As *GpImageAttributes
     1441        If VarPtr(imageAttributes) <> 0 Then
     1442            nativeImageAttr = image.nativeImageAttr
     1443        Else
     1444            nativeImageAttr = 0
     1445        End If
     1446
     1447        Return SetStatus(GdipEnumerateMetafileDestPointI(nativeGraphics,
     1448            nativeImage, destPoint, callback, callbackData,nativeImageAttr))
     1449    End Function
     1450
     1451    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, ByRef destRect As /*Const*/ RectangleF,
     1452        callback As EnumerateMetafileProc) As Status
     1453
     1454        Return EnumerateMetafile(metafile, destRect, callback, 0, 0)
     1455    End Function
     1456
     1457    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, ByRef destRect As /*Const*/ RectangleF,
     1458        callback As EnumerateMetafileProc, callbackData As VoidPtr) As Status
     1459
     1460        Return EnumerateMetafile(metafile, destRect, callback, callbackData, 0)
     1461    End Function
     1462
     1463    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, ByRef destRect As /*Const*/ RectangleF,
     1464        callback As EnumerateMetafileProc, callbackData As VoidPtr, ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1465
     1466        Dim nativeImage As /*Const*/ *GpMetafile
     1467        If VarPtr(metafile) <> 0 Then
     1468            nativeImage = metafile.nativeImage
     1469        Else
     1470            nativeImage = 0
     1471        End If
     1472        Dim nativeImageAttr As *GpImageAttributes
     1473        If VarPtr(imageAttributes) <> 0 Then
     1474            nativeImageAttr = image.nativeImageAttr
     1475        Else
     1476            nativeImageAttr = 0
     1477        End If
     1478
     1479        Return SetStatus(GdipEnumerateMetafileDestRect(nativeGraphics,
     1480            nativeImage, destRect, callback, callbackData, nativeImageAttr))
     1481    End Function
     1482
     1483    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, ByRef destRect As /*Const*/ Rectangle,
     1484        callback As EnumerateMetafileProc) As Status
     1485
     1486        Return EnumerateMetafile(metafile, destRect, callback, 0, 0)
     1487    End Function
     1488
     1489    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, ByRef destRect As /*Const*/ Rectangle,
     1490        callback As EnumerateMetafileProc, callbackData As VoidPtr) As Status
     1491
     1492        Return EnumerateMetafile(metafile, destRect, callback, callbackData, 0)
     1493    End Function
     1494
     1495    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, ByRef destRect As /*Const*/ Rectangle,
     1496        callback As EnumerateMetafileProc, callbackData As VoidPtr, ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1497
     1498        Dim nativeImage As /*Const*/ *GpMetafile
     1499        If VarPtr(metafile) <> 0 Then
     1500            nativeImage = metafile.nativeImage
     1501        Else
     1502            nativeImage = 0
     1503        End If
     1504        Dim nativeImageAttr As *GpImageAttributes
     1505        If VarPtr(imageAttributes) <> 0 Then
     1506            nativeImageAttr = image.nativeImageAttr
     1507        Else
     1508            nativeImageAttr = 0
     1509        End If
     1510
     1511        Return SetStatus(GdipEnumerateMetafileDestRectI(nativeGraphics,
     1512            nativeImage, destRect, callback, callbackData, nativeImageAttr))
     1513    End Function
     1514
     1515    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, destPoints As /*Const*/ *PointF, count As Long,
     1516        callback As EnumerateMetafileProc) As Status
     1517
     1518        Return EnumerateMetafile(metafile, destPoints, count, callback, 0, 0)
     1519    End Function
     1520
     1521    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, destPoints As /*Const*/ *PointF, count As Long,
     1522        callback As EnumerateMetafileProc, callbackData As VoidPtr) As Status
     1523
     1524        Return EnumerateMetafile(metafile, destPoints, count, callback, callbackData, 0)
     1525    End Function
     1526
     1527    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, destPoints As /*Const*/ *PointF, count As Long,
     1528        callback As EnumerateMetafileProc, callbackData As VoidPtr, ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1529
     1530        Dim nativeImage As /*Const*/ *GpMetafile
     1531        If VarPtr(metafile) <> 0 Then
     1532            nativeImage = metafile.nativeImage
     1533        Else
     1534            nativeImage = 0
     1535        End If
     1536        Dim nativeImageAttr As *GpImageAttributes
     1537        If VarPtr(imageAttributes) <> 0 Then
     1538            nativeImageAttr = image.nativeImageAttr
     1539        Else
     1540            nativeImageAttr = 0
     1541        End If
     1542
     1543        Return SetStatus(GdipEnumerateMetafileDestPoints(nativeGraphics,
     1544            nativeImage,destPoints, count, callback, callbackData, nativeImageAttr))
     1545    End Function
     1546
     1547    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, destPoints As /*Const*/ *Point, count As Long,
     1548        callback As EnumerateMetafileProc) As Status
     1549
     1550        Return EnumerateMetafile(metafile, destPoints, count, callback, 0, 0)
     1551    End Function
     1552
     1553    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, destPoints As /*Const*/ *Point, count As Long,
     1554        callback As EnumerateMetafileProc, callbackData As VoidPtr) As Status
     1555
     1556        Return EnumerateMetafile(metafile, destPoints, count, callback, callbackData, 0)
     1557    End Function
     1558
     1559    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile, destPoints As /*Const*/ *Point, count As Long,
     1560        callback As EnumerateMetafileProc, callbackData As VoidPtr, ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1561
     1562        Dim nativeImage As /*Const*/ *GpMetafile
     1563        If VarPtr(metafile) <> 0 Then
     1564            nativeImage = metafile.nativeImage
     1565        Else
     1566            nativeImage = 0
     1567        End If
     1568        Dim nativeImageAttr As *GpImageAttributes
     1569        If VarPtr(imageAttributes) <> 0 Then
     1570            nativeImageAttr = image.nativeImageAttr
     1571        Else
     1572            nativeImageAttr = 0
     1573        End If
     1574
     1575        Return SetStatus(GdipEnumerateMetafileDestPointsI(nativeGraphics,
     1576            nativeImage,destPoints, count, callback, callbackData, nativeImageAttr))
     1577    End Function
     1578
     1579    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1580        ByRef destPoint As /*Const*/ PointF, ByRef srcRect As /*Const*/ RectangleF, srcUnit As GraphicsUnit,
     1581        callback As EnumerateMetafileProc) As Status
     1582
     1583        Return EnumerateMetafile(metafile, destPoint, count, srcUnit, callback, 0, 0)
     1584    End Function
     1585
     1586    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1587        ByRef destPoint As /*Const*/ PointF, ByRef srcRect As /*Const*/ RectangleF, srcUnit As GraphicsUnit,
     1588        callback As EnumerateMetafileProc, callbackData As VoidPtr) As Status
     1589
     1590        Return EnumerateMetafile(metafile, destPoint, srcRect, srcUnit, callback, callbackData, 0)
     1591    End Function
     1592
     1593    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1594        ByRef destPoint As /*Const*/ PointF, ByRef srcRect As /*Const*/ RectangleF, srcUnit As GraphicsUnit,
     1595        callback As EnumerateMetafileProc, callbackData As VoidPtr, ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1596
     1597        Dim nativeImage As /*Const*/ *GpMetafile
     1598        If VarPtr(metafile) <> 0 Then
     1599            nativeImage = metafile.nativeImage
     1600        Else
     1601            nativeImage = 0
     1602        End If
     1603        Dim nativeImageAttr As *GpImageAttributes
     1604        If VarPtr(imageAttributes) <> 0 Then
     1605            nativeImageAttr = image.nativeImageAttr
     1606        Else
     1607            nativeImageAttr = 0
     1608        End If
     1609
     1610        Return SetStatus(GdipEnumerateMetafileSrcRectDestPoint(nativeGraphics,
     1611            nativeImage, destPoint, srcRect, srcUnit, callback, callbackData, nativeImageAttr)
     1612    End Function
     1613
     1614    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1615        ByRef destPoint As /*Const*/ Point, ByRef srcRect As /*Const*/ Rectangle, srcUnit As GraphicsUnit,
     1616        callback As EnumerateMetafileProc) As Status
     1617
     1618        Return EnumerateMetafile(metafile, destPoint, count, srcUnit, callback, 0, 0)
     1619    End Function
     1620
     1621    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1622        ByRef destPoint As /*Const*/ Point, ByRef srcRect As /*Const*/ Rectangle, srcUnit As GraphicsUnit,
     1623        callback As EnumerateMetafileProc, callbackData As VoidPtr) As Status
     1624
     1625        Return EnumerateMetafile(metafile, destPoint, srcRect, srcUnit, callback, callbackData, 0)
     1626    End Function
     1627
     1628    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1629        ByRef destPoint As /*Const*/ Point, ByRef srcRect As /*Const*/ Rectangle, srcUnit As GraphicsUnit,
     1630        callback As EnumerateMetafileProc, callbackData As VoidPtr, ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1631
     1632        Dim nativeImage As /*Const*/ *GpMetafile
     1633        If VarPtr(metafile) <> 0 Then
     1634            nativeImage = metafile.nativeImage
     1635        Else
     1636            nativeImage = 0
     1637        End If
     1638        Dim nativeImageAttr As *GpImageAttributes
     1639        If VarPtr(imageAttributes) <> 0 Then
     1640            nativeImageAttr = image.nativeImageAttr
     1641        Else
     1642            nativeImageAttr = 0
     1643        End If
     1644
     1645        Return SetStatus(GdipEnumerateMetafileSrcRectDestPointI(nativeGraphics,
     1646            nativeImage, destPoint, srcRect, srcUnit, callback, callbackData, nativeImageAttr)
     1647    End Function
     1648
     1649    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1650        ByRef destRect As /*Const*/ RectangleF, ByRef srcRect As /*Const*/ RectangleF, srcUnit As GraphicsUnit,
     1651        callback As EnumerateMetafileProc) As Status
     1652
     1653        Return EnumerateMetafile(metafile, destRect, count, srcUnit, callback, 0, 0)
     1654    End Function
     1655
     1656    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1657        ByRef destRect As /*Const*/ RectangleF, ByRef srcRect As /*Const*/ RectangleF, srcUnit As GraphicsUnit,
     1658        callback As EnumerateMetafileProc, callbackData As VoidPtr) As Status
     1659
     1660        Return EnumerateMetafile(metafile, destRect, srcRect, srcUnit, callback, callbackData, 0)
     1661    End Function
     1662
     1663    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1664        ByRef destRect As /*Const*/ RectangleF, ByRef srcRect As /*Const*/ RectangleF, srcUnit As GraphicsUnit,
     1665        callback As EnumerateMetafileProc, callbackData As VoidPtr, ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1666
     1667        Dim nativeImage As /*Const*/ *GpMetafile
     1668        If VarPtr(metafile) <> 0 Then
     1669            nativeImage = metafile.nativeImage
     1670        Else
     1671            nativeImage = 0
     1672        End If
     1673        Dim nativeImageAttr As *GpImageAttributes
     1674        If VarPtr(imageAttributes) <> 0 Then
     1675            nativeImageAttr = image.nativeImageAttr
     1676        Else
     1677            nativeImageAttr = 0
     1678        End If
     1679
     1680        Return SetStatus(GdipEnumerateMetafileSrcRectDestRect(nativeGraphics,
     1681            nativeImage, destRect, srcRect, srcUnit, callback, callbackData, nativeImageAttr))
     1682    End Function
     1683
     1684    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1685        ByRef destRect As /*Const*/ Rectangle, ByRef srcRect As /*Const*/ Rectangle, srcUnit As GraphicsUnit,
     1686        callback As EnumerateMetafileProc) As Status
     1687
     1688        Return EnumerateMetafile(metafile, destRect, srcRect, srcUnit, callback, 0, 0)
     1689    End Function
     1690
     1691    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1692        ByRef destRect As /*Const*/ Rectangle, ByRef srcRect As /*Const*/ Rectangle, srcUnit As GraphicsUnit,
     1693        callback As EnumerateMetafileProc, callbackData As VoidPtr) As Status
     1694
     1695        Return EnumerateMetafile(metafile, destRect, srcRect, srcUnit, callback, callbackData, 0)
     1696    End Function
     1697
     1698    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1699        ByRef destRect As /*Const*/ Rectangle, ByRef srcRect As /*Const*/ Rectangle, srcUnit As GraphicsUnit,
     1700        callback As EnumerateMetafileProc, callbackData As VoidPtr, ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1701
     1702        Dim nativeImage As /*Const*/ *GpMetafile
     1703        If VarPtr(metafile) <> 0 Then
     1704            nativeImage = metafile.nativeImage
     1705        Else
     1706            nativeImage = 0
     1707        End If
     1708        Dim nativeImageAttr As *GpImageAttributes
     1709        If VarPtr(imageAttributes) <> 0 Then
     1710            nativeImageAttr = image.nativeImageAttr
     1711        Else
     1712            nativeImageAttr = 0
     1713        End If
     1714
     1715        Return SetStatus(GdipEnumerateMetafileSrcRectDestRectI(nativeGraphics,
     1716            nativeImage, destRect, srcRect, srcUnit, callback, callbackData, nativeImageAttr))
     1717    End Function
     1718
     1719    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1720        destPoints As /*Const*/ *PointF, count As Long, ByRef srcRect As /*Const*/ RectangleF, srcUnit As GraphicsUnit,
     1721        callback As EnumerateMetafileProc) As Status
     1722
     1723        Return EnumerateMetafile(metafile, destPoints, count, srcRect, srcUnit, callback, 0, 0)
     1724    End Function
     1725
     1726    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1727        destPoints As /*Const*/ *PointF, count As Long, ByRef srcRect As /*Const*/ RectangleF, srcUnit As GraphicsUnit,
     1728        callback As EnumerateMetafileProc, callbackData As VoidPtr) As Status
     1729
     1730        Return EnumerateMetafile(metafile, destPoints, count, srcRect, srcUnit, callback, callbackData, 0)
     1731    End Function
     1732
     1733    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1734        destPoints As /*Const*/ *PointF, count As Long, ByRef srcRect As /*Const*/ RectangleF, srcUnit As GraphicsUnit,
     1735        callback As EnumerateMetafileProc, callbackData As VoidPtr, ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1736
     1737        Dim nativeImage As /*Const*/ *GpMetafile
     1738        If VarPtr(metafile) <> 0 Then
     1739            nativeImage = metafile.nativeImage
     1740        Else
     1741            nativeImage = 0
     1742        End If
     1743        Dim nativeImageAttr As *GpImageAttributes
     1744        If VarPtr(imageAttributes) <> 0 Then
     1745            nativeImageAttr = image.nativeImageAttr
     1746        Else
     1747            nativeImageAttr = 0
     1748        End If
     1749
     1750        Return SetStatus(GdipEnumerateMetafileSrcRectDestPoints(nativeGraphics,
     1751            nativeImage, destPoints, count, srcRect, srcUnit, callback, callbackData, nativeImageAttr)
     1752    End Function
     1753
     1754    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1755        destPoints As /*Const*/ *Point, count As Long, ByRef srcRect As /*Const*/ Rectangle, srcUnit As GraphicsUnit,
     1756        callback As EnumerateMetafileProc) As Status
     1757
     1758        Return EnumerateMetafile(metafile, destPoints, count, srcRect, srcUnit, callback, 0, 0)
     1759    End Function
     1760
     1761    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1762        destPoints As /*Const*/ *Point, count As Long, ByRef srcRect As /*Const*/ Rectangle, srcUnit As GraphicsUnit,
     1763        callback As EnumerateMetafileProc, callbackData As VoidPtr) As Status
     1764
     1765        Return EnumerateMetafile(metafile, destPoints, count, srcRect, srcUnit, callback, callbackData, 0)
     1766    End Function
     1767
     1768    Function EnumerateMetafile(ByRef metafile As /*Const*/ Metafile,
     1769        destPoints As /*Const*/ *Point, count As Long, ByRef srcRect As /*Const*/ Rectangle, srcUnit As GraphicsUnit,
     1770        callback As EnumerateMetafileProc, callbackData As VoidPtr, ByRef imageAttributes As /*Const*/ ImageAttributes) As Status
     1771
     1772        Dim nativeImage As /*Const*/ *GpMetafile
     1773        If VarPtr(metafile) <> 0 Then
     1774            nativeImage = metafile.nativeImage
     1775        Else
     1776            nativeImage = 0
     1777        End If
     1778        Dim nativeImageAttr As *GpImageAttributes
     1779        If VarPtr(imageAttributes) <> 0 Then
     1780            nativeImageAttr = image.nativeImageAttr
     1781        Else
     1782            nativeImageAttr = 0
     1783        End If
     1784
     1785        Return SetStatus(GdipEnumerateMetafileSrcRectDestPointsI(nativeGraphics,
     1786            nativeImage, destPoints, count, srcRect, srcUnit, callback, callbackData, nativeImageAttr)
     1787    End Function
     1788
     1789    Function SetClip(ByRef g As /*Const*/ Graphics) As Status
     1790        Return SetClip(g, CombineMode.Replace)
     1791    End Function
     1792
     1793    Function SetClip(ByRef rc As /*Const*/ RectangleF) As Status
     1794        Return SetStatus(GdipSetClipRect(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, CombineMode.Replace))
     1795    End Function
     1796
     1797    Function SetClip(ByRef rc As /*Const*/ Rectangle) As Status
     1798        Return SetStatus(GdipSetClipRectI(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, CombineMode.Replace))
     1799    End Function
     1800
     1801    Function SetClip(ByRef path As /*Const*/ GraphicsPath) As Status
     1802        Return SetStatus(GdipSetClipPath(nativeGraphics, path->nativePath, CombineMode.Replace))
     1803    End Function
     1804
     1805    Function SetClip(ByRef region As /*Const*/ Region) As Status
     1806        Return SetStatus(GdipSetClipRegion(nativeGraphics, region->nativeRegion, CombineMode.Replace))
     1807    End Function
     1808
     1809    Function SetClip(ByRef g As /*Const*/ Graphics, combineMode As CombineMode) As Status
     1810        Return SetStatus(GdipSetClipGraphics(nativeGraphics, g->nativeGraphics, combineMode))
     1811    End Function
     1812
     1813    Function SetClip(ByRef rc As /*Const*/ RectangleF, combineMode As CombineMode) As Status
     1814        Return SetStatus(GdipSetClipRect(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, combineMode))
     1815    End Function
     1816
     1817    Function SetClip(ByRef rc As /*Const*/ Rectangle, combineMode As CombineMode) As Status
     1818        Return SetStatus(GdipSetClipRectI(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, combineMode))
     1819    End Function
     1820
     1821    Function SetClip(ByRef path As /*Const*/ GraphicsPath, combineMode As CombineMode) As Status
     1822        Return SetStatus(GdipSetClipPath(nativeGraphics, path->nativePath, combineMode))
     1823    End Function
     1824
     1825    Function SetClip(ByRef region As /*Const*/ Region, combineMode As CombineMode) As Status
     1826        Return SetStatus(GdipSetClipRegion(nativeGraphics, region->nativeRegion, combineMode))
     1827    End Function
     1828
     1829    ' This is different than the other SetClip methods because it assumes
     1830    ' that the HRGN is already in device units, so it doesn't transform
     1831    ' the coordinates in the HRGN.
     1832
     1833    Function SetClip(hrgn As HRGN, combineMode As CombineMode /* = CombineModeReplace*/) As Status
     1834        Return SetStatus(GdipSetClipHrgn(nativeGraphics, hrgn, combineMode))
     1835    End Function
     1836
     1837    Function IntersectClip(ByRef rc As /*Const*/ RectangleF) As Status
     1838        Return SetStatus(GdipSetClipRect(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, CombineMode.Intersect))
     1839    End Function
     1840
     1841    Function IntersectClip(ByRef rc As /*Const*/ Rectangle) As Status
     1842        Return SetStatus(GdipSetClipRectI(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, CombineMode.Intersect))
     1843    End Function
     1844
     1845    Function IntersectClip(ByRef region As /*Const*/ Region) As Status
     1846        Return SetStatus(GdipSetClipRegion(nativeGraphics, region->nativeRegion, CombineMode.Intersect))
     1847    End Function
     1848
     1849    Function ExcludeClip(ByRef rc As /*Const*/ RectangleF) As Status
     1850        Return SetStatus(GdipSetClipRect(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, CombineMode.Exclude))
     1851    End Function
     1852
     1853    Function ExcludeClip(ByRef rc As /*Const*/ Rectangle) As Status
     1854        Return SetStatus(GdipSetClipRectI(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, CombineMode.Exclude))
     1855    End Function
     1856
     1857    Function ExcludeClip(ByRef region As /*Const*/ Region) As Status
     1858        Return SetStatus(GdipSetClipRegion(nativeGraphics, region->nativeRegion, CombineMode.Exclude))
     1859    End Function
     1860
     1861    Function ResetClip() As Status
     1862        Return SetStatus(GdipResetClip(nativeGraphics))
     1863    End Function
     1864
     1865    Function TranslateClip(dx As Single, dy As Single) As Status
     1866        Return SetStatus(GdipTranslateClip(nativeGraphics, dx, dy))
     1867    End Function
     1868
     1869    Function TranslateClip(dx As Long, dy As Long) As Status
     1870        Return SetStatus(GdipTranslateClipI(nativeGraphics, dx, dy))
     1871    End Function
     1872
     1873    Const Function GetClip(ByRef region As Region) As Status
     1874        Return SetStatus(GdipGetClip(nativeGraphics, region->nativeRegion))
     1875    End Function
     1876
     1877    Const Function GetClipBounds(ByRef rc As RectangleF) As Status
     1878        Return SetStatus(GdipGetClipBounds(nativeGraphics, rc))
     1879    End Function
     1880
     1881    Const Function GetClipBounds(ByRef rc As Rectangle) As Status
     1882        Return SetStatus(GdipGetClipBoundsI(nativeGraphics, rc))
     1883    End Function
     1884
     1885    Const Function GetVisibleClipBounds(ByRef rc As RectangleF) As Status
     1886        Return SetStatus(GdipGetVisibleClipBounds(nativeGraphics, rc))
     1887    End Function
     1888
     1889    Const Function GetVisibleClipBounds(ByRef rc As Rectangle) As Status
     1890        Return SetStatus(GdipGetVisibleClipBoundsI(nativeGraphics, rc))
     1891    End Function
     1892
     1893    Const Function IsVisible(x As Long, y As Long) As BOOL
     1894        Dim b = FALSE As BOOL
     1895        SetStatus(GdipIsVisiblePointI(nativeGraphics, x, y, b))
     1896        Return b
     1897    End Function
     1898
     1899    Const Function IsVisible(ByRef pt As /*Const*/ Point) As BOOL
     1900        Return IsVisible(pt.X, pt.Y)
     1901    End Function
     1902
     1903    Const Function IsVisible(x As Long, y As Long, width As Long, height As Long) As BOOL
     1904        Dim b = FALSE As BOOL
     1905        SetStatus(GdipIsVisibleRectI(nativeGraphics, x, y, width, height, b))
     1906        Return b
     1907    End Function
     1908
     1909    Const Function IsVisible(ByRef rc As /*Const*/ Rectangle) As BOOL
     1910        Return IsVisible(rc.X, rc.Y, rc.Width, rc.Height)
     1911    End Function
     1912
     1913    Const Function IsVisible(x As Single, y As Single) As BOOL
     1914        Dim b = FALSE As BOOL
     1915        SetStatus(GdipIsVisiblePoint(nativeGraphics, x, y, b))
     1916        Return b
     1917    End Function
     1918
     1919    Const Function IsVisible(ByRef point As /*Const*/ PointF) As BOOL
     1920        Return IsVisible(pt.X, pt.Y)
     1921    End Function
     1922
     1923    Const Function IsVisible(x As Single, y As Single, width As Single, height As Single) As BOOL
     1924        Dim b = FALSE As BOOL
     1925        SetStatus(GdipIsVisibleRect(nativeGraphics, x, y, width, height, b))
     1926        Return b
     1927    End Function
     1928
     1929    Const Function IsVisible(ByRef rect As /*Const*/ RectangleF) As BOOL
     1930        Return IsVisible(rc.X, rc.Y, rc.Width, rc.Height)
     1931    End Function
     1932
     1933    Const Function Save() As GraphicsState
     1934        Dim gstate As GraphicsState
     1935        SetStatus(GdipSaveGraphics(nativeGraphics, state))
     1936        Return gstate
     1937    End Function
     1938
     1939    Function Restore(gstate As GraphicsState)
     1940        Return SetStatus(GdipRestoreGraphics(nativeGraphics, gstate))
     1941    End Function
     1942
     1943    Function BeginContainer(ByRef dstrect As /*Const*/ RectangleF, ByRef srcrect As /*Const*/ RectangleF, unit As GraphicsUnit) As GraphicsContainer
     1944        Dim state As GraphicsContainer
     1945        SetStatus(GdipBeginContainer(nativeGraphics, dstrect, srcrect, unit, state))
     1946        Return state
     1947    End Function
     1948
     1949    Function BeginContainer(ByRef dstrect As /*Const*/ Rectangle, ByRef srcrect As /*Const*/ Rectangle, unit As GraphicsUnit) As GraphicsContainer
     1950        Dim state As GraphicsContainer
     1951        SetStatus(GdipBeginContainerI(nativeGraphics, dstrect, srcrect, unit, state))
     1952        Return state
     1953    End Function
     1954
     1955    Function BeginContainer() As GraphicsContainer
     1956        Dim state As GraphicsContainer
     1957        SetStatus(GdipBeginContainer2(nativeGraphics, state))
     1958        Return state
     1959    End Function
     1960
     1961    Function EndContainer(state As GraphicsContainer) As Status
     1962        Return SetStatus(GdipEndContainer(nativeGraphics, state))
     1963    End Function
     1964
     1965    ' Only valid when recording metafiles.
     1966
     1967    Function AddMetafileComment(data As /*Const*/ *Byte, sizeData As DWord)
     1968        Return SetStatus(GdipComment(nativeGraphics, sizeData, data))
     1969    End Function
     1970
     1971    Static Function GetHalftonePalette() As HPALETTE
     1972        Return GdipCreateHalftonePalette()
     1973    End Function
     1974
     1975    Const Function GetLastStatus() As Status
     1976        Dim lastStatus = lastResult
     1977        lastResult = Status.Ok
     1978        Return lastStatus
     1979    End Function
     1980
     1981Private
     1982    Sub Graphics(ByRef gr As Graphics)
     1983        Debug
     1984    End Sub
     1985    Sub Operator =(ByRef gr As Graphics)
     1986        Debug
     1987    End Sub
     1988
     1989Protected
     1990    Sub Graphics(graphics As *GpGraphics)
     1991        lastResult = Ok
     1992        SetNativeGraphics(graphics)
     1993    End Sub
     1994
     1995    Sub SetNativeGraphics(graphics As *GpGraphics)
     1996        This.nativeGraphics = graphics
     1997    End Sub
     1998
     1999    Const Function SetStatus(status As Status) As Status
     2000        If status <> Status.Ok Then
     2001            lastResult = status
     2002        End If
     2003        Return status
     2004    End Function
     2005
     2006    Const Function GetNativeGraphics() As *GpGraphics
     2007        Return This.nativeGraphics
     2008    End Function
     2009
     2010    Function GetNativePen(const Pen* pen) As *GpPen
     2011        Return pen->nativePen
     2012    End Function
     2013
     2014Protected
     2015    nativeGraphics As *GpGraphics
     2016    lastResult As /*Mutable*/ Status
     2017End Class
     2018
     2019#endif
  • Include/Classes/System/Drawing/misc.ab

    r11 r33  
    2626End Enum
    2727
     28Const Enum GraphicsUnit
     29    World       ' 0
     30    Display     ' 1
     31    Pixel       ' 2
     32    Point       ' 3
     33    Inch        ' 4
     34    Document    ' 5
     35    Millimeter  ' 6
     36End Enum
     37
    2838#endif '__SYSTEM_DRAWING_MISC_AB__
Note: See TracChangeset for help on using the changeset viewer.