Ignore:
Timestamp:
Mar 31, 2009, 2:09:07 PM (15 years ago)
Author:
イグトランス (egtra)
Message:

GDI+をコンパイルできるように修正。FontFamily, Penの追加。サンプルとして、Step 32のGDI+版を制作。
(#56)

Location:
trunk/ab5.0/ablib/src/Classes/System/Drawing
Files:
2 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/CharacterRange.ab

    r635 r698  
    44Namespace Drawing
    55
    6 Class CharacterRange
    7 Public
    8     Sub CharacterRange(f As Long, l As Long)
    9         first = f
    10         length = l
    11     End Sub
    12 
    13     Sub CharacterRange()
    14         First = 0
    15         Length = 0
    16     End Sub
    17 
    18     Function First() As Long
    19         Return first
    20     End Function
    21 
    22     Sub First(f As Long)
    23         first = f
    24     End Sub
    25 
    26     Function Length() As Long
    27         Return length
    28     End Function
    29 
    30     Sub Length(l As Long)
    31         length = l
    32     End Sub
    33 
    34     Function Operator ==(c As CharacterRange) As Boolean
    35         Return Equals(c)
    36     End Function
    37 
    38     Function Operator <>(c As CharacterRange) As Boolean
    39         Return Not Equals(c)
    40     End Function
    41 
    42     Function Equals(c As CharacterRange) As Boolean
    43         Return first = c.first And length = c.length
    44     End Function
    45 
    46     Override Function GetHashCode() As Long
    47         Return first Xor length
    48     End Function
    49 
    50 Private
    51     first As Long
    52     length As Long
    53 End Class
     6Type CharacterRange
     7    First As Long
     8    Length As Long
     9End Type
    5410
    5511End Namespace
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/Color.ab

    r635 r698  
    44Namespace Drawing
    55
    6 Class Color
    7 Public
    8     Sub Color()
    9         argb = MakeARGB(255, 0, 0, 0) ' Black
    10     End Sub
    11 
    12     Sub Color(ByRef c As Color)
    13         argb = c.argb
    14     End Sub
    15 
    16     Sub Color(r As Byte, g As Byte, b As Byte)
    17         argb = MakeARGB(255, r, g, b)
    18     End Sub
    19 
    20     Sub Color(a As Byte, r As Byte, g As Byte, b As Byte)
    21         argb = MakeARGB(a, r, g, b)
    22     End Sub
    23 
    24     Sub Color(newArgb As System.Drawing.Imaging.ARGB)
    25         argb = newArgb
    26     End Sub
    27 
    28     Function Operator ==(c As Color) As Boolean
    29         Return Equals(c)
    30     End Function
    31 
    32     Function Operator <>(c As Color) As Boolean
    33         Return Not Equals(c)
    34     End Function
    35 
    36     Function A() As Byte
    37         A = (argb >> System.Drawing.Imaging.ALPHA_SHIFT) As Byte
    38     End Function
    39 
    40     Function R() As Byte
    41         R = (argb >> System.Drawing.Imaging.RED_SHIFT) As Byte
    42     End Function
    43 
    44     Function G() As Byte
    45         G = (argb >> System.Drawing.Imaging.GREEN_SHIFT) As Byte
    46     End Function
    47 
    48     Function B() As Byte
    49         B = (argb >> System.Drawing.Imaging.BLUE_SHIFT) As Byte
    50     End Function
    51 
    52     Function Value() As System.Drawing.Imaging.ARGB
    53         Value = argb
    54     End Function
    55 
    56     Sub Value(value As System.Drawing.Imaging.ARGB)
    57         argb = value
    58     End Sub
    59 
    60     Sub SetFromCOLORREF(rgb As COLORREF)
    61         If (rgb And &hff000000) = &h01000000 Then
    62             Exit Sub ' パレットインデックス指定は無効
    63         Else
    64             argb = MakeARGB(255, GetRValue(rgb) As Byte, GetGValue(rgb) As Byte, GetBValue(rgb) As Byte)
    65         End If
    66     End Sub
    67 
    68     Function ToCOLORREF() As COLORREF
    69         ToCOLORREF = RGB(R, G, B)
    70     End Function
    71 /*
    72     Function ToArgb() As ARGB
    73         ToArgb = argb
    74     End Function
    75 */
    76     Static Function FromArgb(argb As System.Drawing.Imaging.ARGB) As Color
    77         Return New Color(argb)
    78     End Function
    79 
    80     Static Function FromArgb(a As Byte, base As Color) As Color
    81         Return New Color(a, base.R, base.G, base.B)
    82     End Function
    83 
    84     Static Function FromArgb(r As Byte, g As Byte, b As Byte) As Color
    85         Return New Color(r, g, b)
    86     End Function
    87 
    88     Static Function FromArgb(a As Byte, r As Byte, g As Byte, b As Byte) As Color
    89         Return New Color(a, r, g, b)
    90     End Function
    91 
    92     Override Function GetHashCode() As Long
    93         Return argb As Long
    94     End Function
    95 
    96     Function Equals(c As Color) As Boolean
    97         Return argb = c.argb
    98     End Function
    99 
    100     ' HSBを求める式はhttp://ofo.jp/osakana/cgtips/hsb.phtmlを参考にしました。
    101     Function GetHue() As Single
    102         Dim max As Long, min As Long, d As Long
    103         Dim r = R
    104         Dim g = G
    105         Dim b = B
    106         max = System.Math.Max(System.Math.Max(r, g), b)
    107         min = System.Math.Min(System.Math.Min(r, g), b)
    108         d = max - min
    109         If g = max Then
    110             Return ((b - r) As Double / d * 60.0 + 120.0) As Single
    111         ElseIf b = max Then
    112             Return ((r - g) As Double / d * 60 + 240) As Single
    113         ElseIf g < b Then
    114             Return ((g - b) As Double / d * 60 + 360) As Single
    115         Else
    116             Return ((g - b) As Double / d * 60) As Single
    117         EndIf
    118     End Function
    119 
    120     Function GetSaturation() As Single
    121         Dim r = R
    122         Dim g = G
    123         Dim b = B
    124         Dim max = System.Math.Max(System.Math.Max(r, g), b) As Long
    125         Dim min = System.Math.Min(System.Math.Min(r, g), b) As Long
    126         Return ( (max - min) / max ) As Single
    127     End Function
    128 
    129     Function GetBrightness() As Single
    130         Dim r = R
    131         Dim g = G
    132         Dim b = B
    133         Dim max = System.Math.Max(System.Math.Max(r, g), b)
    134         Return ( max * (1 / 255) ) As Single
    135     End Function
    136 
    137 /*
    138     ' Common color constants
    139     Const Enum
    140         AliceBlue            = &hFFF0F8FF
    141         AntiqueWhite         = &hFFFAEBD7
    142         Aqua                 = &hFF00FFFF
    143         Aquamarine           = &hFF7FFFD4
    144         Azure                = &hFFF0FFFF
    145         Beige                = &hFFF5F5DC
    146         Bisque               = &hFFFFE4C4
    147         Black                = &hFF000000
    148         BlanchedAlmond       = &hFFFFEBCD
    149         Blue                 = &hFF0000FF
    150         BlueViolet           = &hFF8A2BE2
    151         Brown                = &hFFA52A2A
    152         BurlyWood            = &hFFDEB887
    153         CadetBlue            = &hFF5F9EA0
    154         Chartreuse           = &hFF7FFF00
    155         Chocolate            = &hFFD2691E
    156         Coral                = &hFFFF7F50
    157         CornflowerBlue       = &hFF6495ED
    158         Cornsilk             = &hFFFFF8DC
    159         Crimson              = &hFFDC143C
    160         Cyan                 = &hFF00FFFF
    161         DarkBlue             = &hFF00008B
    162         DarkCyan             = &hFF008B8B
    163         DarkGoldenrod        = &hFFB8860B
    164         DarkGray             = &hFFA9A9A9
    165         DarkGreen            = &hFF006400
    166         DarkKhaki            = &hFFBDB76B
    167         DarkMagenta          = &hFF8B008B
    168         DarkOliveGreen       = &hFF556B2F
    169         DarkOrange           = &hFFFF8C00
    170         DarkOrchid           = &hFF9932CC
    171         DarkRed              = &hFF8B0000
    172         DarkSalmon           = &hFFE9967A
    173         DarkSeaGreen         = &hFF8FBC8B
    174         DarkSlateBlue        = &hFF483D8B
    175         DarkSlateGray        = &hFF2F4F4F
    176         DarkTurquoise        = &hFF00CED1
    177         DarkViolet           = &hFF9400D3
    178         DeepPink             = &hFFFF1493
    179         DeepSkyBlue          = &hFF00BFFF
    180         DimGray              = &hFF696969
    181         DodgerBlue           = &hFF1E90FF
    182         Firebrick            = &hFFB22222
    183         FloralWhite          = &hFFFFFAF0
    184         ForestGreen          = &hFF228B22
    185         Fuchsia              = &hFFFF00FF
    186         Gainsboro            = &hFFDCDCDC
    187         GhostWhite           = &hFFF8F8FF
    188         Gold                 = &hFFFFD700
    189         Goldenrod            = &hFFDAA520
    190         Gray                 = &hFF808080
    191         Green                = &hFF008000
    192         GreenYellow          = &hFFADFF2F
    193         Honeydew             = &hFFF0FFF0
    194         HotPink              = &hFFFF69B4
    195         IndianRed            = &hFFCD5C5C
    196         Indigo               = &hFF4B0082
    197         Ivory                = &hFFFFFFF0
    198         Khaki                = &hFFF0E68C
    199         Lavender             = &hFFE6E6FA
    200         LavenderBlush        = &hFFFFF0F5
    201         LawnGreen            = &hFF7CFC00
    202         LemonChiffon         = &hFFFFFACD
    203         LightBlue            = &hFFADD8E6
    204         LightCoral           = &hFFF08080
    205         LightCyan            = &hFFE0FFFF
    206         LightGoldenrodYellow = &hFFFAFAD2
    207         LightGray            = &hFFD3D3D3
    208         LightGreen           = &hFF90EE90
    209         LightPink            = &hFFFFB6C1
    210         LightSalmon          = &hFFFFA07A
    211         LightSeaGreen        = &hFF20B2AA
    212         LightSkyBlue         = &hFF87CEFA
    213         LightSlateGray       = &hFF778899
    214         LightSteelBlue       = &hFFB0C4DE
    215         LightYellow          = &hFFFFFFE0
    216         Lime                 = &hFF00FF00
    217         LimeGreen            = &hFF32CD32
    218         Linen                = &hFFFAF0E6
    219         Magenta              = &hFFFF00FF
    220         Maroon               = &hFF800000
    221         MediumAquamarine     = &hFF66CDAA
    222         MediumBlue           = &hFF0000CD
    223         MediumOrchid         = &hFFBA55D3
    224         MediumPurple         = &hFF9370DB
    225         MediumSeaGreen       = &hFF3CB371
    226         MediumSlateBlue      = &hFF7B68EE
    227         MediumSpringGreen    = &hFF00FA9A
    228         MediumTurquoise      = &hFF48D1CC
    229         MediumVioletRed      = &hFFC71585
    230         MidnightBlue         = &hFF191970
    231         MintCream            = &hFFF5FFFA
    232         MistyRose            = &hFFFFE4E1
    233         Moccasin             = &hFFFFE4B5
    234         NavajoWhite          = &hFFFFDEAD
    235         Navy                 = &hFF000080
    236         OldLace              = &hFFFDF5E6
    237         Olive                = &hFF808000
    238         OliveDrab            = &hFF6B8E23
    239         Orange               = &hFFFFA500
    240         OrangeRed            = &hFFFF4500
    241         Orchid               = &hFFDA70D6
    242         PaleGoldenrod        = &hFFEEE8AA
    243         PaleGreen            = &hFF98FB98
    244         PaleTurquoise        = &hFFAFEEEE
    245         PaleVioletRed        = &hFFDB7093
    246         PapayaWhip           = &hFFFFEFD5
    247         PeachPuff            = &hFFFFDAB9
    248         Peru                 = &hFFCD853F
    249         Pink                 = &hFFFFC0CB
    250         Plum                 = &hFFDDA0DD
    251         PowderBlue           = &hFFB0E0E6
    252         Purple               = &hFF800080
    253         Red                  = &hFFFF0000
    254         RosyBrown            = &hFFBC8F8F
    255         RoyalBlue            = &hFF4169E1
    256         SaddleBrown          = &hFF8B4513
    257         Salmon               = &hFFFA8072
    258         SandyBrown           = &hFFF4A460
    259         SeaGreen             = &hFF2E8B57
    260         SeaShell             = &hFFFFF5EE
    261         Sienna               = &hFFA0522D
    262         Silver               = &hFFC0C0C0
    263         SkyBlue              = &hFF87CEEB
    264         SlateBlue            = &hFF6A5ACD
    265         SlateGray            = &hFF708090
    266         Snow                 = &hFFFFFAFA
    267         SpringGreen          = &hFF00FF7F
    268         SteelBlue            = &hFF4682B4
    269         Tan                  = &hFFD2B48C
    270         Teal                 = &hFF008080
    271         Thistle              = &hFFD8BFD8
    272         Tomato               = &hFFFF6347
    273         Transparent          = &h00FFFFFF
    274         Turquoise            = &hFF40E0D0
    275         Violet               = &hFFEE82EE
    276         Wheat                = &hFFF5DEB3
    277         White                = &hFFFFFFFF
    278         WhiteSmoke           = &hFFF5F5F5
    279         Yellow               = &hFFFFFF00
    280         YellowGreen          = &hFF9ACD32
    281     End Enum
    282 
    283     ' Shift count and bit mask for A, R, G, B components
    284 
    285     Const Enum
    286         AlphaShift  = 24
    287         RedShift    = 16
    288         GreenShift  = 8
    289         BlueShift   = 0
    290     End Enum
    291 
    292     Const Enum
    293         AlphaMask   = &hff000000
    294         RedMask     = &h00ff0000
    295         GreenMask   = &h0000ff00
    296         BlueMask    = &h000000ff
    297     End Enum
    298 */
    299     Static Function MakeARGB(a As Byte, r As Byte, g As Byte, b As Byte) As System.Drawing.Imaging.ARGB
    300         MakeARGB = (((b As System.Drawing.Imaging.ARGB) <<  System.Drawing.Imaging.BLUE_SHIFT) Or _
    301                     ((g As System.Drawing.Imaging.ARGB) << System.Drawing.Imaging.GREEN_SHIFT) Or _
    302                     ((r As System.Drawing.Imaging.ARGB) <<   System.Drawing.Imaging.RED_SHIFT) Or _
    303                     ((a As System.Drawing.Imaging.ARGB) << System.Drawing.Imaging.ALPHA_SHIFT))
    304     End Function
    305 
    306 Protected
    307     argb As System.Drawing.Imaging.ARGB
    308 End Class
     6TypeDef Color = DWord 'ARGB
    3097
    3108End Namespace
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/Drawing2D/Matrix.ab

    r635 r698  
    55
    66Class Matrix
     7Public
     8    Sub Matrix(native As *GpMatrix)
     9        nativeMatrix = native
     10    End Sub
     11    Function NativeMatrix() As *GpMatrix
     12        NativeMatrix = nativeMatrix
     13    End Function
     14    nativeMatrix As *GpMatrix
    715End Class
    816
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/Drawing2D/misc.ab

    r635 r698  
    33Namespace Drawing
    44Namespace Drawing2D
     5   
     6TypeDef GraphicsContainer = DWord
     7TypeDef GraphicsState = DWord
    58
    69Enum CombineMode
     
    8588End Enum
    8689
     90Enum DashStyle
     91    Solid           ' 0
     92    Dash            ' 1
     93    Dot             ' 2
     94    DashDot         ' 3
     95    DashDotDot      ' 4
     96    Custom          ' 5
     97End Enum
     98
     99Enum DashCap
     100    Flat             = 0
     101    Round            = 2
     102    Triangle         = 3
     103End Enum
     104
     105Enum LineCap
     106    Flat             = 0
     107    Square           = 1
     108    Round            = 2
     109    Triangle         = 3
     110    NoAnchor         = &h10
     111    SquareAnchor     = &h11
     112    RoundAnchor      = &h12
     113    DiamondAnchor    = &h13
     114    ArrowAnchor      = &h14
     115    Custom           = &hff
     116    AnchorMask       = &hf0
     117End Enum
     118
     119Enum LineJoin
     120    Miter = 0
     121    Bevel = 1
     122    Round = 2
     123    Clipped = 3
     124End Enum
     125
     126Enum PenAlignment
     127    Center       = 0
     128    Inset        = 1
     129End Enum
     130
     131Enum PenType
     132    SolidColor       = 0 'BrushTypeSolidColor
     133    HatchFill        = 1 'BrushTypeHatchFill
     134    TextureFill      = 2 'BrushTypeTextureFill
     135    PathGradient     = 3 'BrushTypePathGradient
     136    LinearGradient   = 4 'BrushTypeLinearGradient
     137    Unknown          = -1
     138End Enum
     139
    87140End Namespace
    88141End Namespace
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/Font.ab

    r635 r698  
    11Namespace System
    22Namespace Drawing
    3 
    43
    54/**
     
    87*/
    98
    10 Class FontFamily : End Class
    11 Class FontCollection : End Class
     9Class FontCollection
     10Public
     11    nativeCollection As *GpFontCollection
     12End Class
    1213
    1314Class Font
    1415    Implements System.IDisposable
    1516Public
    16 '    friend class Graphics
    17 
    18     Sub Font(/*IN*/ hdc As HDC)
     17    Static Function FromHDC(/*IN*/ hdc As HDC) As Font
    1918        Dim font = 0 As *GpFont
    20         lastResult = GdipCreateFontFromDC(hdc, font)
    21         SetNativeFont(font)
    22     End Sub
    23 
    24     Sub Font(/*IN*/ hdc As HDC, /*IN const*/ ByRef logfont As LOGFONTA)
     19        SetStatus(GdipCreateFontFromDC(hdc, font))
     20        FromHDC = New Font(font)
     21    End Function
     22
     23    Static Function FromLogFont(/*IN*/ hdc As HDC, /*IN const*/ ByRef logfont As LOGFONTA) As Font
    2524        Dim font = 0 As *GpFont
    26         lastResult =GdipCreateFontFromLogfontA(hdc, logfont, font)
    27         SetNativeFont(font)
    28     End Sub
    29 
    30     Sub Font(/*IN*/ hdc As HDC, /*IN const*/ ByRef logfont As LOGFONTW)
     25        SetStatus(GdipCreateFontFromLogfontA(hdc, logfont, font))
     26        FromLogFont = New Font(font)
     27    End Function
     28
     29    Static Function FromLogFont(/*IN*/ hdc As HDC, /*IN const*/ ByRef logfont As LOGFONTW) As Font
    3130        Dim font = 0 As *GpFont
    32         lastResult =GdipCreateFontFromLogfontW(hdc, logfont, font)
    33         SetNativeFont(font)
    34     End Sub
    35 
    36     Sub Font(/*IN*/ hdc As HDC, /*IN const*/ hfont As HFONT)
     31        SetStatus(GdipCreateFontFromLogfontW(hdc, logfont, font))
     32        FromLogFont = New Font(font)
     33    End Function
     34
     35    Static Function FromHFont(/*IN*/ hdc As HDC, /*IN const*/ hfont As HFONT) As Font
    3736        Dim font = 0 As *GpFont
    3837        If hfont <> 0 Then
    3938            Dim lf As LOGFONTA
    40             If GetObjectA(hfont, sizeof (LOGFONTA), lf) <> 0 Then
    41                 lastResult = GdipCreateFontFromLogfontA(hdc, lf, font)
     39            If GetObjectA(hfont, Len(lf), lf) <> 0 Then
     40                SetStatus(GdipCreateFontFromLogfontA(hdc, lf, font))
    4241            Else
    43                 lastResult = GdipCreateFontFromDC(hdc, font)
     42                SetStatus(GdipCreateFontFromDC(hdc, font))
    4443            End If
    4544        Else
    46             lastResult = GdipCreateFontFromDC(hdc, font)
    47         End If
    48         SetNativeFont(font)
     45            SetStatus(GdipCreateFontFromDC(hdc, font))
     46        End If
     47        FromHFont = New Font(font)
     48    End Function
     49
     50    Sub Font(f As *GpFont)
     51        nativeFont = f
    4952    End Sub
    5053
    5154    Sub Font(/*IN const*/ family As FontFamily, /*IN*/ emSize As Single)
    52         Font(family, emSize, FontStyleRegular, UnitPoint)
    53     End Sub
    54 
    55     Sub Font(/*IN const*/ family As FontFamily,
    56         /*IN*/ emSize As Single, /*IN*/ style As Long)
    57 
    58         Font(family, emSize, style, UnitPoint)
     55        initFont(family, emSize, FontStyle.Regular, GraphicsUnit.Point)
     56    End Sub
     57
     58    Sub Font(/*IN const*/ family As FontFamily, /*IN*/ emSize As Single, /*IN*/ style As FontStyle)
     59        initFont(family, emSize, style, GraphicsUnit.Point)
     60    End Sub
     61
     62    Sub Font(/*IN const*/ family As FontFamily, /*IN*/ emSize As Single, /*IN*/ unit As GraphicsUnit)
     63        initFont(family, emSize, FontStyle.Regular, unit)
    5964    End Sub
    6065
    6166    Sub Font(/*IN const*/ family As FontFamily, /*IN*/ emSize As Single,
    62         /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit)
    63 
    64         Dim font = 0 As *GpFont
    65         lastResult = GdipCreateFont(
    66             family.NativeFamily, emSize, style, unit, font)
    67         SetNativeFont(font)
     67        /*IN*/ style As FontStyle, /*IN*/ unit As GraphicsUnit)
     68
     69        initFont(family, emSize, style, unit)
    6870    End Sub
    6971
    7072    Sub Font(/*IN const*/ familyName As PCWSTR, /*IN*/ emSize As Single)
    71         Font(familyName, emSize, FontStyleRegular, Unit.Point, ByVal 0)
     73        initFromName(familyName, emSize, FontStyle.Regular, GraphicsUnit.Point, Nothing)
    7274    End Sub
    7375
    7476    Sub Font(/*IN const*/ familyName As String, /*IN*/ emSize As Single)
    75         Font(familyName, emSize, FontStyleRegular, Unit.Point, ByVal 0)
     77        initFromName(ToWCStr(familyName), emSize, FontStyle.Regular, GraphicsUnit.Point, Nothing)
     78    End Sub
     79
     80    Sub Font(/*IN const*/ familyName As PCWSTR, /*IN*/ emSize As Single, /*IN*/ style As FontStyle)
     81        initFromName(familyName, emSize, style, GraphicsUnit.Point, Nothing)
     82    End Sub
     83
     84    Sub Font(/*IN const*/ familyName As String, /*IN*/ emSize As Single, /*IN*/ style As FontStyle)
     85        initFromName(ToWCStr(familyName), emSize, style, GraphicsUnit.Point, Nothing)
     86    End Sub
     87
     88    Sub Font(/*IN const*/ familyName As PCWSTR, /*IN*/ emSize As Single, /*IN*/ unit As GraphicsUnit)
     89        initFromName(familyName, emSize, FontStyle.Regular, unit, Nothing)
     90    End Sub
     91
     92    Sub Font(/*IN const*/ familyName As String, /*IN*/ emSize As Single, /*IN*/ unit As GraphicsUnit)
     93        initFromName(ToWCStr(familyName), emSize, FontStyle.Regular, unit, Nothing)
    7694    End Sub
    7795
    7896    Sub Font(/*IN const*/ familyName As PCWSTR, /*IN*/ emSize As Single,
    79          /*IN*/ style As Long)
    80         Font(familyName, emSize, style, Unit.Point, ByVal 0)
     97         /*IN*/ style As FontStyle, /*IN*/ unit As GraphicsUnit)
     98
     99        initFromName(familyName, emSize, style, unit, Nothing)
    81100    End Sub
    82101
    83102    Sub Font(/*IN const*/ familyName As String, /*IN*/ emSize As Single,
    84          /*IN*/ style As Long)
    85         Font(familyName, emSize, style, Unit.Point, ByVal 0)
     103         /*IN*/ style As FontStyle, /*IN*/ unit As GraphicsUnit)
     104
     105        initFromName(ToWCStr(familyName), emSize, style, unit, Nothing)
    86106    End Sub
    87107
    88108    Sub Font(/*IN const*/ familyName As PCWSTR, /*IN*/ emSize As Single,
    89          /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit)
    90         Font(familyName, emSize, style, unit, ByVal 0)
     109        /*IN*/ style As FontStyle, /*IN*/ unit As GraphicsUnit,
     110        /*IN const*/ fontCollection As FontCollection)
     111
     112        initFromName(familyName, emSize, style, unit, fontCollection)
    91113    End Sub
    92114
    93115    Sub Font(/*IN const*/ familyName As String, /*IN*/ emSize As Single,
    94          /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit)
    95         Font(familyName, emSize, style, unit, ByVal 0)
    96     End Sub
    97 
    98     Sub Font(/*IN const*/ familyName As PCWSTR, /*IN*/ emSize As Single,
    99         /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit,
    100         /*IN const*/ ByRef fontCollection As FontCollection)
    101 
    102         nativeFont = 0
    103 
    104         Dim family As FontFamily(familyName, fontCollection)
    105         Dim nativeFamily = family.NativeFamily As *GpFontFamily
    106 
    107         lastResult = family.GetLastStatus()
    108 
    109         If lastResult <> Ok Then
    110             nativeFamily = FontFamily.GenericSansSerif()->NativeFamily
    111             lastResult = FontFamily.GenericSansSerif()->lastResult
    112             If lastResult <> Ok Then
    113                 Exit Sub
    114             End If
    115         End If
    116 
    117         lastResult = GdipCreateFont(
    118             nativeFamily, emSize, style, unit, nativeFont)
    119 
    120         If lastResult <> Ok Then
    121             nativeFamily = FontFamily.GenericSansSerif()->NativeFamily
    122             lastResult = FontFamily.GenericSansSerif()->lastResult
    123             If lastResult <> Ok Then
    124                 Exit Sub
    125             End If
    126 
    127             lastResult = GdipCreateFont(
    128                 nativeFamily, emSize, style, unit, nativeFont)
    129         End If
    130     End Sub
    131 
    132     Sub Font(/*IN const*/ familyName As String, /*IN*/ emSize As Single,
    133         /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit,
     116        /*IN*/ style As FontStyle, /*IN*/ unit As GraphicsUnit,
    134117        /*IN const*/ fontCollection As FontCollection)
    135         Font(ToWCStr(familyName), emSize, style, unit, fontCollection)
    136     End Sub
    137 
    138     Const Function GetLogFontA(/*IN const*/ g As Graphics, /*OUT*/ ByRef lf As LOGFONTA) As Status
    139         Dim nativeGraphics As *GpGraphics
    140         If Not ActiveBasic.IsNothing(g) Then
    141             nativeGraphics = g.nativeGraphics
    142         End If
    143         Return SetStatus(GdipGetLogFontA(nativeFont, nativeGraphics, lf))
    144     End Function
    145 
    146     Const Function GetLogFontW(/*IN const*/ g As Graphics, /*OUT*/ ByRef lf As LOGFONTW) As Status
    147         Dim nativeGraphics As *GpGraphics
    148         If Not ActiveBasic.IsNothing(g) Then
    149             nativeGraphics = g.nativeGraphics
    150         End If
    151         Return SetStatus(GdipGetLogFontW(nativeFont, nativeGraphics, lf))
    152     End Function
    153 
    154     Const Function GetLogFont(/*IN const*/ g As Graphics, /*OUT*/ ByRef lf As LOGFONT) As Status
    155         Dim nativeGraphics As *GpGraphics
    156         If Not ActiveBasic.IsNothing(g) Then
    157             nativeGraphics = g.nativeGraphics
    158         End If
    159 #ifdef UNICODE
    160         Return SetStatus(GdipGetLogFontW(nativeFont, nativeGraphics, lf))
    161 #else
    162         Return SetStatus(GdipGetLogFontA(nativeFont, nativeGraphics, lf))
    163 #endif
    164     End Function
     118
     119        initFromName(ToWCStr(familyName), emSize, style, unit, fontCollection)
     120    End Sub
    165121
    166122    Const Function Clone() As Font
    167123        Dim cloneFont = 0 As *GpFont
    168124        SetStatus(GdipCloneFont(nativeFont, cloneFont))
    169         Return New Font(cloneFont, lastResult)
    170     End Function
     125        Clone = New Font(cloneFont)
     126    End Function
     127
     128    Sub Dispose()
     129        If nativeFont <> 0 Then
     130            GdipDeleteFont(nativeFont)
     131        End If
     132        nativeFont = 0
     133    End Sub
    171134
    172135    Sub ~Font()
    173         GdipDeleteFont(nativeFont)
    174     End Sub
    175 
    176     Const Function IsAvailable() As Boolean
    177         Return nativeFont <> 0
    178     End Function
    179 
    180     Const Function Style() As Long
    181         SetStatus(GdipGetFontStyle(nativeFont, Style))
    182     End Function
     136        Dispose()
     137    End Sub
     138
     139'   Const Function Style() As FontStyle
     140'       SetStatus(GdipGetFontStyle(nativeFont, Style))
     141'   End Function
    183142
    184143    Const Function Size() As Single
     
    186145    End Function
    187146
    188     Const Function SizeInPoints() As Single
    189 
    190     Const Function Unit() As GraphicsUnit
    191         SetStatus(GdipGetFontUnit(nativeFont, Unit))
    192     End Function
    193 
    194     Const Function LastStatus() As Status
    195         Return lastResult
    196     End Function
     147'   Const Function SizeInPoints() As Single
     148'   End Function
     149
     150'   Const Function Unit() As GraphicsUnit
     151'       SetStatus(GdipGetFontUnit(nativeFont, Unit))
     152'   End Function
    197153
    198154    Const Function Height() As Long
    199         Return GetHeight() As Long
     155        Height = GetHeight() As Long
    200156    End Function
    201157
     
    205161
    206162    Const Function GetHeight(/*IN const*/ g As Graphics) As Single
    207         Dim nativeGraphics As *GpGraphics
    208         If Not ActiveBasic.IsNothing(g) Then
    209             nativeGraphics = g.NativeGraphics
    210         End If
     163        Dim nativeGraphics = getNativeGraphics(g)
    211164        SetStatus(GdipGetFontHeight(nativeFont, nativeGraphics, GetHeight))
    212165    End Function
     
    216169    End Function
    217170
    218 '    Const Function FontFamily(/*OUT*/ ByRef family As FontFamily)
    219 '       If VarPtr(family) = 0 Then
    220 '           Return SetStatus(Status.InvalidParameter)
    221 '       End If
    222 '       Dim status = GdipGetFamily(nativeFont, family->nativeFamily)
    223 '       family->SetStatus(status)
    224 '       Return SetStatus(status)
     171'    Const Function FontFamily() As FontFamily
     172'       Dim nativeFamily As *GpFamily
     173'       SetStatus(GdipGetFamily(nativeFont, nativeFamily))
     174'       FontFamily = New FontFamily(nativeFamily)
    225175'   End Function
    226176
    227177    Const Function Bold() As Boolean
    228178        Dim lf As LOGFONT
    229         GetLogFont(0, lf)
     179        ToLogFont(lf)
    230180        Return lf.lfWeight > FW_BOLD
    231181    End Function
     
    233183    Const Function GdiCharSet() As Byte
    234184        Dim lf As LOGFONT
    235         GetLogFont(0, lf)
     185        ToLogFont(lf)
    236186        Return lf.lfCharSet
    237187    End Function
     
    239189    'Const Function GdiVerticalFont() As Boolean
    240190
    241     Const Function NativeFont() As *GpFont
    242         Return nativeFont
    243     End Function
    244 
    245191    'Const Function IsSystemFont() As Boolean
    246192
    247193    Const Function Italic() As Boolean
    248194        Dim lf As LOGFONT
    249         GetLogFont(0, lf)
    250         Return lf.lfItalic <> FALSE
     195        ToLogFont(lf)
     196        Italic = lf.lfItalic <> FALSE
    251197    End Function
    252198
    253199    Const Function Name() As String
    254 #ifdef UNICODE
    255         Dim lf As LOGFONTW
    256         GetLogFontW(0, lf)
    257 #else
    258         Dim lf As LOGFONTA
    259         GetLogFontA(0, lf)
    260 #endif
    261         Return lf.lfFaceName
    262     End Function
    263 
    264     'Const Function SizeInPoint() As Boolean
     200        Dim lf As LOGFONT
     201        ToLogFont(lf)
     202        Dim p = lf.lfFaceName As PCTSTR
     203        Name = New String(p)
     204    End Function
    265205
    266206    Const Function StrikeOut() As Boolean
    267207        Dim lf As LOGFONT
    268         GetLogFont(0, lf)
    269         Return lf.fdwStrikeOut <> FALSE
     208        ToLogFont(lf)
     209        StrikeOut = lf.lfStrikeOut <> FALSE
    270210    End Function
    271211
    272212    Const Function Style() As FontStyle
    273213        Dim lf As LOGFONT
    274         GetLogFont(0, lf)
    275         Return (((lf.lfWeight > FW_BOLD) And FontStyle.Bold) Or _
    276             ((lf.lfItatlic <> FALSE) And FontStyle.Italic) Or _
    277             ((lf.fdwStrikeOut <> FALSE) And FontStyle.Strickeout) Or _
    278             ((lf.fdwUnderline <> FALSE) And FontStyle.Underline)) As FontStyle
     214        ToLogFont(lf)
     215        Style = FontStyle.Regular
     216        If lf.lfWeight > FW_BOLD Then
     217            Style Or= FontStyle.Bold
     218        End If
     219        If lf.lfItalic <> FALSE Then
     220            Style Or= FontStyle.Italic
     221        End If
     222        If lf.lfStrikeOut <> FALSE Then
     223            Style Or= FontStyle.Strikeout
     224        End If
     225        If lf.lfUnderline <> FALSE Then
     226            Style Or= FontStyle.Underline
     227        End If
    279228    End Function
    280229
     
    283232    Const Function Underline() As Boolean
    284233        Dim lf As LOGFONT
    285         GetLogFont(0, lf)
    286         Return lf.fdwUnderline <> FALSE
     234        ToLogFont(lf)
     235        Underline = lf.lfUnderline <> FALSE
    287236    End Function
    288237
    289238    Override Function ToString() As String
    290         Return Name
     239        ToString = Name
    291240    End Function
    292241
    293242    Const Function ToHfont() As HFONT
    294243        Dim lf As LOGFONT
    295         GetLogFont(ByVal 0, lf)
    296         Return CreateFontIndirect(lf)
    297     End Function
    298 
    299     Const Sub ToLogFont(ByRef lf As LOGFONT)
    300         GetLogFont(ByVal 0, lf)
    301     End Sub
    302 
    303     Const Sub ToLogFont(ByRef lf As LOGFONT, g As Graphics)
    304         GetLogFont(g, lf)
    305     End Sub
     244        ToLogFont(lf)
     245        ToHfont = CreateFontIndirect(lf)
     246    End Function
     247
     248    Const Sub ToLogFont(/*OUT*/ ByRef lf As LOGFONTA, /*IN const*/ g As Graphics)
     249        Dim nativeGraphics = getNativeGraphics(g)
     250        SetStatus(GdipGetLogFontA(nativeFont, nativeGraphics, lf))
     251    End Sub
     252
     253    Const Sub ToLogFont(/*OUT*/ ByRef lf As LOGFONTW, /*IN const*/ g As Graphics)
     254        Dim nativeGraphics = getNativeGraphics(g)
     255        SetStatus(GdipGetLogFontW(nativeFont, nativeGraphics, lf))
     256    End Sub
     257
     258    Const Sub ToLogFont(ByRef lf As LOGFONTA)
     259        ToLogFont(lf, Nothing)
     260    End Sub
     261
     262    Const Sub ToLogFont(ByRef lf As LOGFONTW)
     263        ToLogFont(lf, Nothing)
     264    End Sub
     265
     266    Function NativeFont() As *GpFont
     267        NativeFont = nativeFont
     268    End Function
    306269
    307270Private
    308 '   Sub Font(ByRef f As Font)
    309 
    310 Protected
    311     Sub Font(f As *GpFont, status As Status)
    312         lastResult = status
    313         SetNativeFont(f)
    314     End Sub
    315 
    316     Sub SetNativeFont(f As *GpFont)
    317         nativeFont = f
    318     End Sub
    319 
    320     Const Function SetStatus(s As Status) As Status
    321         If s <> Status.Ok Then
    322             lastResult = s
    323             Return s
     271    Sub initFont(/*IN const*/ family As FontFamily, /*IN*/ emSize As Single,
     272        /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit)
     273
     274        If ActiveBasic.IsNothing(family) Then
     275            Throw New ArgumentNullException("family")
     276        End If
     277        SetStatus(GdipCreateFont(family.NativeFamily, emSize, style, unit, nativeFont))
     278    End Sub
     279
     280    Sub initFromName(/*IN const*/ familyName As PCWSTR, /*IN*/ emSize As Single,
     281        /*IN*/ style As Long, /*IN*/ unit As GraphicsUnit, fontCollection As FontCollection)
     282
     283        nativeFont = 0
     284        Dim family = Nothing As FontFamily
     285        Dim nativeFamily = family.NativeFamily
     286
     287        Try
     288            family = New FontFamily(familyName, fontCollection)
     289        Catch e As Exception
     290            nativeFamily = FontFamily.GenericSansSerif().NativeFamily
     291        End Try
     292
     293        Try
     294            SetStatus(GdipCreateFont(nativeFamily, emSize, style, unit, nativeFont))
     295        Catch e As Exception
     296            nativeFamily = FontFamily.GenericSansSerif().NativeFamily
     297            SetStatus(GdipCreateFont(nativeFamily, emSize, style, unit, nativeFont))
     298        End Try
     299    End Sub
     300
     301    Static Function getNativeGraphics(g As Graphics) As *GpGraphics
     302        If ActiveBasic.IsNothing(g) Then
     303            getNativeGraphics = 0
    324304        Else
    325             Return s
    326         End If
    327     End Function
    328 
    329 Protected
     305            getNativeGraphics = g.NativeGraphics
     306        End If
     307    End Function
     308
    330309    nativeFont As *GpFont
    331     /*mutable*/ lastResult As Status
    332310End Class
    333311
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/Graphics.ab

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

    r635 r698  
    4646Const GDIP_EMFPLUSFLAGS_DISPLAY      = &h00000001
    4747
    48 Class MetafileHeader
    49 Private
     48Type MetafileHeader
    5049    mfType As MetafileType
    5150    Size As DWord
     
    6564    logicalDpiX As Long
    6665    logicalDpiY As Long
     66/*
    6767Public
    6868    Function MetafileType() As MetafileType
     
    9191
    9292    Function Bounds() As Rectangle
    93         Dim r(X, Y, Width, Height)
    94         Return r
     93        Bounds.X = X
     94        Bounds.Y = Y
     95        Bounds.Width = Width
     96        Bounds.Height = Height
    9597    End Function
    9698
     
    127129    End Function
    128130
    129     Function IsEmfPlusOnly() As BOOL /*const*/
     131    Function IsEmfPlusOnly() As BOOL
    130132        IsEmfPlusOnly = (mfType = MetafileTypeEmfPlusOnly)
    131133    End Function
     
    133135    Function IsDisplay() As BOOL
    134136        If IsEmfPlus() <> FALSE And ((EmfPlusFlags And GDIP_EMFPLUSFLAGS_DISPLAY) <> 0) Then
    135             IsDisplay = _System_TRUE
     137            IsDisplay = TRUE
    136138        Else
    137             IsDisplay = _System_FALSE
     139            IsDisplay = FALSE
     140        End If
    138141    End Function
    139142
     
    146149    End Function
    147150
    148     Function GetEmfHeader() As * /*const*/ ENHMETAHEADER3 /*const*/
     151    Function GetEmfHeader() As *ENHMETAHEADER3
    149152        If IsEmfOrEmfPlus() Then
    150153            Return VarPtr(EmfHeader) 'VarPtr(WmfHeader)
     
    153156        End If
    154157    End Function
    155 End Class
     158*/
     159End Type
    156160
    157161End Namespace
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/Imaging/misc.ab

    r635 r698  
    11' Classes/System/Drawing/Imaging/misc.ab
     2
     3TypeDef ARGB = DWord
     4TypeDef ARGB64 = QWord
    25
    36Namespace System
    47Namespace Drawing
    58Namespace Imaging
    6 
    7 TypeDef ARGB = DWord
    8 TypeDef ARGB64 = QWord
    99
    1010Enum ColorMode
     
    137137Type Align(8) EncoderParameters
    138138    Count As DWord
    139     Parameter[1] As EncoderParameter
     139    Parameter[0] As EncoderParameter
    140140End Type
    141141
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/Point.ab

    r550 r698  
    44Namespace Drawing
    55
    6 Class Point
    7 Public
    8     Sub Point()
    9         x = 0
    10         y = 0
    11     End Sub
    12 
    13     Sub Point(initX As Long, initY As Long)
    14         x = initX
    15         y = initY
    16     End Sub
    17 
    18     Sub Point(sz As Size)
    19         x = sz.Width
    20         y = sz.Height
    21     End Sub
    22 
    23     Sub Point(dw As DWord)
    24         x = LOWORD(dw)
    25         y = HIWORD(dw)
    26     End Sub
    27 
    28     Function X() As Long
    29         X = x
    30     End Function
    31 
    32     Sub X(newX As Long)
    33         x = newX
    34     End Sub
    35 
    36     Function Y() As Long
    37         Y = y
    38     End Function
    39 
    40     Sub Y(newY As Long)
    41         y = newY
    42     End Sub
    43 
    44     Function IsEmpty() As Boolean
    45         Return x = 0 And y = 0
    46     End Function
    47 
    48     Function Operator +(pt As Point) As Point
    49         Return Add(This, pt)
    50     End Function
    51 
    52     Function Operator +(sz As Size) As Point
    53         Return Add(This, sz)
    54     End Function
    55 
    56     Function Operator -(pt As Point) As Point
    57         Return Substract(This, pt)
    58     End Function
    59 
    60     Function Operator -(sz As Size) As Point
    61         Return Substract(This, sz)
    62     End Function
    63 
    64     Function Operator ==(sz As Point) As Boolean
    65         Return Equals(sz)
    66     End Function
    67 
    68     Function Operator <>(sz As Point) As Boolean
    69         Return Not Equals(sz)
    70     End Function
    71 
    72     Static Function Add(pt1 As Point, pt2 As Point) As Point
    73         Return New Point(pt1.x + pt2.x, pt1.y + pt2.y)
    74     End Function
    75 
    76     Static Function Add(pt As Point, sz As Size) As Point
    77         Return New Point(pt.x + sz.Width, pt.y + sz.Height)
    78     End Function
    79 
    80     Function Offset(pt As Point) As Point
    81         Return New Point(x + pt.x, y + pt.y)
    82     End Function
    83 
    84     Sub Offset(dx As Long, dy As Long)
    85         x += dx
    86         y += dy
    87     End Sub
    88 
    89     Static Function Substract(pt1 As Point, pt2 As Point) As Point
    90         Return New Point(pt1.x - pt2.x, pt1.y - pt2.y)
    91     End Function
    92 
    93     Static Function Substract(pt As Point, sz As Size) As Point
    94         Return New Point(pt.x - sz.Width, pt.y - sz.Height)
    95     End Function
    96 
    97     Function Equals(pt As Point) As Boolean
    98         Return x = pt.x And y = pt.y
    99     End Function
    100 
    101     Override Function GetHashCode() As Long
    102         Return x Xor _System_BSwap(y As DWord)
    103     End Function
    104 
    105     Static Function Ceiling(ptf As PointF) As Point
    106         Return New Point(Math.Ceiling(ptf.X) As Long, Math.Ceiling(ptf.Y) As Long)
    107     End Function
    108 
    109     Static Function Round(ptf As PointF) As Point
    110         Return New Point(Math.Round(ptf.X) As Long, Math.Round(ptf.Y) As Long)
    111     End Function
    112 
    113     Static Function Truncate(ptf As PointF) As Point
    114         Return New Point(Math.Truncate(ptf.X) As Long, Math.Truncate(ptf.Y) As Long)
    115     End Function
    116 
    117     Function Operator () As PointF
    118         Return New PointF(X, Y)
    119     End Function
    120 
    121 Private
    122     x As Long
    123     y As Long
    124 End Class
     6Type Point
     7    X As Long
     8    Y As Long
     9End Type
    12510
    12611End Namespace
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/PointF.ab

    r473 r698  
    44Namespace Drawing
    55
    6 Class PointF
    7 Public
    8     Sub PointF()
    9         x = 0
    10         y = 0
    11     End Sub
    12 
    13     Sub PointF(initX As Single, initY As Single)
    14         x = initX
    15         y = initY
    16     End Sub
    17 
    18     Sub PointF(pt As PointF)
    19         x = pt.x
    20         y = pt.y
    21     End Sub
    22 
    23     Sub PointF(sz As SizeF)
    24         x = sz.Width
    25         y = sz.Height
    26     End Sub
    27 
    28     Function X() As Single
    29         X = x
    30     End Function
    31 
    32     Sub X(newX As Single)
    33         x = newX
    34     End Sub
    35 
    36     Function Y() As Single
    37         Y = y
    38     End Function
    39 
    40     Sub Y(newY As Single)
    41         y = newY
    42     End Sub
    43 
    44     Function IsEmpty() As Boolean
    45         Return x = 0 And y = 0
    46     End Function
    47 
    48     Function Operator + (pt As PointF) As PointF
    49         Return Add(This, pt)
    50     End Function
    51 
    52     Function Operator + (sz As Size) As PointF
    53         Return Add(This, sz)
    54     End Function
    55 
    56     Function Operator + (sz As SizeF) As PointF
    57         Return Add(This, sz)
    58     End Function
    59 
    60     Function Operator - (pt As PointF) As PointF
    61         Return Substract(This, pt)
    62     End Function
    63 
    64     Function Operator - (sz As Size) As PointF
    65         Return Substract(This, sz)
    66     End Function
    67 
    68     Function Operator - (sz As SizeF) As PointF
    69         Return Substract(This, sz)
    70     End Function
    71 
    72     Function Operator == (sz As PointF) As Boolean
    73         Return Equals(sz)
    74     End Function
    75 
    76     Function Operator <> (sz As PointF) As Boolean
    77         Return Not Equals(sz)
    78     End Function
    79 
    80     Static Function Add(pt1 As PointF, pt2 As PointF) As PointF
    81         Return New PointF(pt1.x + pt2.x, pt1.y + pt2.y)
    82     End Function
    83 
    84     Static Function Add(pt As PointF, sz As Size) As PointF
    85         Return New PointF(pt.x + sz.Width, pt.y + sz.Height)
    86     End Function
    87 
    88     Static Function Add(pt As PointF, sz As SizeF) As PointF
    89         Return New PointF(pt.x + sz.Width, pt.y + sz.Height)
    90     End Function
    91 
    92     Static Function Substract(pt1 As PointF, pt2 As PointF) As PointF
    93         Return New PointF(pt1.x - pt2.x, pt1.y - pt2.y)
    94     End Function
    95 
    96     Static Function Substract(pt As PointF, sz As Size) As PointF
    97         Return New PointF(pt.x - sz.Width, pt.y - sz.Height)
    98     End Function
    99 
    100     Static Function Substract(pt As PointF, sz As SizeF) As PointF
    101         Return New PointF(pt.x - sz.Width, pt.y - sz.Height)
    102     End Function
    103 
    104     Function Equals(pt As PointF) As Boolean
    105         Return x = pt.x And y = pt.y
    106     End Function
    107 
    108     Override Function GetHashCode() As Long
    109         Return (GetDWord(VarPtr(x)) Xor _System_BSwap(GetDWord(VarPtr(x)))) As Long
    110     End Function
    111 
    112 Private
    113     x As Single
    114     y As Single
    115 End Class
     6Type PointF
     7    X As Single
     8    Y As Single
     9End Type
    11610
    11711End Namespace
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/Rectangle.ab

    r473 r698  
    44Namespace Drawing
    55
    6 Class Rectangle
    7 Public
    8     Sub Rectangle()
    9         x = 0
    10         y = 0
    11         width = 0
    12         height = 0
    13     End Sub
    14 
    15     Sub Rectangle(x As Long, y As Long, width As Long, height As Long)
    16         x = x
    17         y = y
    18         width = width
    19         height = height
    20     End Sub
    21 
    22     Sub Rectangle(l As Point, s As Size)
    23         x = l.X
    24         y = l.Y
    25         width = s.Height
    26         height = s.Height
    27     End Sub
    28 
    29     Sub Rectangle(ByRef r As RECT)
    30         x = r.left
    31         y = r.top
    32         width = r.right - r.left
    33         height = r.top - r.bottom
    34     End Sub
    35 
    36     Function Location() As Point
    37         Location = New Point(x, y)
    38     End Function
    39 
    40     Sub Location(point As Point)
    41         x = point.X
    42         y = point.Y
    43     End Sub
    44 
    45     Function Size() As Size
    46         Size = New Size(width, height)
    47     End Function
    48 
    49     Sub Size(size As Size)
    50         width = size.Width
    51         height = size.Height
    52     End Sub
    53 
    54     Function X() As Long
    55         X = x
    56     End Function
    57 
    58     Sub X(value As Long)
    59         x = value
    60     End Sub
    61 
    62     Function Y() As Long
    63         Y = y
    64     End Function
    65 
    66     Sub Y(value As Long)
    67         y = value
    68     End Sub
    69 
    70     Function Width() As Long
    71         Width = width
    72     End Function
    73 
    74     Sub Width(value As Long)
    75         width = value
    76     End Sub
    77 
    78     Function Height() As Long
    79         Height = height
    80     End Function
    81 
    82     Sub Height(value As Long)
    83         height = value
    84     End Sub
    85 
    86     Function Left() As Long
    87         Left = X
    88     End Function
    89 
    90     Function Top() As Long
    91         Top = Y
    92     End Function
    93 
    94     Function Right() As Long
    95         Right = X + Width
    96     End Function
    97 
    98     Function Bottom() As Long
    99         Bottom = Y + Height
    100     End Function
    101 
    102     Function IsEmpty() As Boolean
    103         Return Width <= 0 Or Height <= 0
    104     End Function
    105 
    106     Function Operator ==(rc As Rectangle) As Boolean
    107         Return Equals(rc)
    108     End Function
    109 
    110     Function Operator <>(rc As Rectangle) As Boolean
    111         Return (Not Equals(rc))
    112     End Function
    113 
    114     Function Operator () As RectangleF
    115         Return New RectangleF(x, y, width, height)
    116     End Function
    117 
    118     Function Equals(rc As Rectangle) As Boolean
    119         Return X = rc.X And Y = rc.Y And Width = rc.Width And Height = rc.Height
    120     End Function
    121 
    122     Override Function GetHashCode() As Long
    123         Return x As DWord Xor _System_BSwap(y As DWord) Xor width As DWord Xor _System_BSwap(height As DWord)
    124     End Function
    125 
    126     Static Function FromLTRB(l As Long, t As Long, r As Long, b As Long) As Rectangle
    127         return New Rectangle(l, t, r - l, b - t)
    128     End Function
    129 
    130     Function Contains(x As Long, y As Long) As Boolean
    131         Return x >= X And x < X + Width And y >= Y And y < Y + Height
    132     End Function
    133 
    134     Function Contains(pt As Point) As Boolean
    135         Return Contains(pt.X, pt.Y)
    136     End Function
    137 
    138     Function Contains(rc As Rectangle) As Boolean
    139         Return X <= rc.X And rc.Right <= Right And Y <= rc.Y And rc.Bottom <= Bottom
    140     End Function
    141 
    142     Sub Inflate(dx As Long, dy As Long)
    143         x -= dx
    144         y -= dy
    145         width += dx + dx
    146         height += dy + dy
    147     End Sub
    148 
    149     Sub Inflate(sz As Size)
    150         Inflate(sz.Width, sz.Height)
    151     End Sub
    152 
    153     Static Function Inflate(rc As Rectangle, x As Long, y As Long) As Rectangle
    154         Inflate = New Rectangle(rc.X, rc.Y, rc.Width, rc.Height)
    155         Inflate.Inflate(x, y)
    156     End Function
    157 
    158     Sub Intersect(rect As Rectangle)
    159         Dim r = Rectangle.Intersect(This, rect)
    160         x = r.x
    161         y = r.y
    162         width = r.width
    163         height = r.height
    164     End Sub
    165 
    166     Static Function Intersect(a As Rectangle, ByRef b As Rectangle) As Rectangle
    167         Dim right As Long, bottom As Long, left As Long, top As Long
    168         right = System.Math.Min(a.Right, b.Right)
    169         bottom = System.Math.Min(a.Bottom, b.Bottom)
    170         left = System.Math.Min(a.Left, b.Left)
    171         top = System.Math.Min(a.Top, b.Top)
    172         Return Rectangle.FromLTRB(left, top, right, bottom)
    173     End Function
    174 
    175     Function IntersectsWith(rc As Rectangle) As Boolean
    176         Return Left < rc.Right And _
    177             Top < rc.Bottom And _
    178             Right > rc.Left And _
    179             Bottom > rc.Top
    180     End Function
    181 
    182     Static Function Union(a As Rectangle, b As Rectangle) As Rectangle
    183         Dim right As Long, bottom As Long, left As Long, top As Long
    184         right = System.Math.Max(a.Right(), b.Right())
    185         bottom = System.Math.Max(a.Bottom(), b.Bottom())
    186         left = System.Math.Max(a.Left(), b.Left())
    187         top = System.Math.Max(a.Top(), b.Top())
    188         Return FromLTRB(left, top, right, bottom)
    189     End Function
    190 
    191     Sub Offset(pt As Point)
    192         Offset(pt.X, pt.Y)
    193     End Sub
    194 
    195     Sub Offset(dx As Long, dy As Long)
    196         x += dx
    197         y += dy
    198     End Sub
    199 
    200     Static Function Ceiling(rcf As RectangleF) As Rectangle
    201         Dim r As Rectangle(
    202             Math.Ceiling(rcf.X) As Long,
    203             Math.Ceiling(rcf.Y) As Long,
    204             Math.Ceiling(rcf.Width) As Long,
    205             Math.Ceiling(rcf.Height) As Long)
    206         Return r
    207     End Function
    208 
    209     Static Function Round(rcf As RectangleF) As Rectangle
    210         Dim r As Rectangle(
    211             Math.Round(rcf.X) As Long,
    212             Math.Round(rcf.Y) As Long,
    213             Math.Round(rcf.Width) As Long,
    214             Math.Round(rcf.Height) As Long)
    215         Return r
    216     End Function
    217 
    218     Static Function Truncate(rcf As RectangleF) As Rectangle
    219         Dim r As Rectangle(
    220             Math.Truncate(rcf.X) As Long,
    221             Math.Truncate(rcf.Y) As Long,
    222             Math.Truncate(rcf.Width) As Long,
    223             Math.Truncate(rcf.Height) As Long)
    224         Return r
    225     End Function
    226 
    227     Function ToRECT() As RECT
    228         With ToRECT
    229             .left = x
    230             .top = y
    231             .right = x + width
    232             .bottom = y + height
    233         End With
    234     End Function
    235 
    236 Public
    237     x As Long
    238     y As Long
    239     width As Long
    240     height As Long
    241 End Class
     6Type Rectangle
     7    X As Long
     8    Y As Long
     9    Width As Long
     10    Height As Long
     11End Type
    24212
    24313End Namespace
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/RectangleF.ab

    r473 r698  
    44Namespace Drawing
    55
    6 Class RectangleF
    7 Public
    8     Sub RectangleF()
    9         x = 0
    10         y = 0
    11         width = 0
    12         height = 0
    13     End Sub
    14 
    15     Sub RectangleF(x As Single, y As Single, width As Single, height As Single)
    16         x = x
    17         y = y
    18         width = width
    19         height = height
    20     End Sub
    21 
    22     Sub RectangleF(location As PointF, size As SizeF)
    23         x = location.X
    24         y = location.Y
    25         width = size.Height
    26         height = size.Height
    27     End Sub
    28 
    29     Sub RectangleF(rc As RectangleF)
    30         x = rc.x
    31         y = rc.y
    32         width = rc.width
    33         height = rc.height
    34     End Sub
    35 
    36     Function Location() As PointF
    37         Location = New PointF(x, y)
    38     End Function
    39 
    40     Sub Location(point As PointF)
    41         x = point.X
    42         y = point.Y
    43     End Sub
    44 
    45     Function Size() As SizeF
    46         Size = New SizeF(width, height)
    47     End Function
    48 
    49     Sub Size(size As SizeF)
    50         width = size.Width
    51         height = size.Height
    52     End Sub
    53 
    54     Function X() As Single
    55         X = x
    56     End Function
    57 
    58     Sub X(value As Single)
    59         x = value
    60     End Sub
    61 
    62     Function Y() As Single
    63         Y = y
    64     End Function
    65 
    66     Sub Y(value As Single)
    67         y = value
    68     End Sub
    69 
    70     Function Width() As Single
    71         Width = width
    72     End Function
    73 
    74     Sub Width(value As Single)
    75         width = value
    76     End Sub
    77 
    78     Function Height() As Single
    79         Height = height
    80     End Function
    81 
    82     Sub Height(value As Single)
    83         height = value
    84     End Sub
    85 
    86     Function Left() As Single
    87         Left = X
    88     End Function
    89 
    90     Function Top() As Single
    91         Top = Y
    92     End Function
    93 
    94     Function Right() As Single
    95         Right = X + Width
    96     End Function
    97 
    98     Function Bottom() As Single
    99         Bottom = Y + Height
    100     End Function
    101 
    102     Function IsEmpty() As Boolean
    103         Return Width <= 0 Or Height <= 0
    104     End Function
    105 
    106     Function Operator ==(rc As RectangleF) As Boolean
    107         Return Equals(rc)
    108     End Function
    109 
    110     Function Operator <>(rc As RectangleF) As Boolean
    111         Return Not Equals(rc)
    112     End Function
    113 
    114     Function Equals(rc As RectangleF) As Boolean
    115         Equals = (X = rc.X And Y = rc.Y And Width = rc.Width And Height = rc.Height)
    116     End Function
    117 
    118     Override Function GetHashCode() As Long
    119         Return GetDWord(VarPtr(x)) Xor _System_BSwap(GetDWord(VarPtr(y))) Xor GetDWord(VarPtr(width)) Xor _System_BSwap(GetDWord(VarPtr(height)))
    120     End Function
    121 
    122     Static Function FromLTRB(l As Single, t As Single, r As Single, b As Single) As RectangleF
    123         return New RectangleF(l, t, r - l, b - t)
    124     End Function
    125 
    126     Function Contains(x As Single, y As Single) As Boolean
    127         Contains = (x >= X And x < X + Width And y >= Y And y < Y + Height)
    128     End Function
    129 
    130     Function Contains(pt As PointF) As Boolean
    131         Return Contains(pt.X, pt.Y)
    132     End Function
    133 
    134     Function Contains(rc As RectangleF) As Boolean
    135         Contains = (X <= rc.X And rc.Right <= Right And Y <= rc.Y And rc.Bottom <= Bottom)
    136     End Function
    137 
    138     Sub Inflate(dx As Single, dy As Single)
    139         x -= dx
    140         y -= dy
    141         width += dx + dx
    142         height += dy + dy
    143     End Sub
    144 
    145     Sub Inflate(sz As SizeF)
    146         Inflate(sz.Width, sz.Height)
    147     End Sub
    148 
    149     Static Function Inflate(rc As RectangleF, x As Single, y As Single) As RectangleF
    150         Inflate = New RectangleF(rc.X, rc.Y, rc.Width, rc.Height)
    151         Inflate.Inflate(x, y)
    152     End Function
    153 
    154     Sub Intersect(rect As RectangleF)
    155         Dim r = RectangleF.Intersect(This, rect)
    156         x = r.x
    157         y = r.y
    158         width = r.width
    159         height = r.height
    160     End Sub
    161    
    162     Static Function Intersect(a As RectangleF, b As RectangleF) As RectangleF
    163         Dim right As Single, bottom As Single, left As Single, top As Single
    164         right = System.Math.Min(a.Right, b.Right)
    165         bottom = System.Math.Min(a.Bottom, b.Bottom)
    166         left = System.Math.Min(a.Left, b.Left)
    167         top = System.Math.Min(a.Top, b.Top)
    168         Return FromLTRB(left, top, right, bottom)
    169     End Function
    170 
    171     Function IntersectsWith(rc As RectangleF) As Boolean
    172         If Left < rc.Right And _
    173             Top < rc.Bottom And _
    174             Right > rc.Left And _
    175             Bottom > rc.Top Then
    176             IntersectsWith = True
    177         Else
    178             IntersectsWith = False
    179         End If
    180     End Function
    181 
    182     Static Function Union(a As RectangleF, b As RectangleF) As RectangleF
    183         Dim right As Single, bottom As Single, left As Single, top As Single
    184         right = System.Math.Max(a.Right(), b.Right())
    185         bottom = System.Math.Max(a.Bottom(), b.Bottom())
    186         left = System.Math.Max(a.Left(), b.Left())
    187         top = System.Math.Max(a.Top(), b.Top())
    188         Return FromLTRB(left, top, right, bottom)
    189     End Function
    190 
    191     Sub Offset(pt As PointF)
    192         Offset(pt.X, pt.Y)
    193     End Sub
    194 
    195     Sub Offset(dx As Single, dy As Single)
    196         x += dx
    197         y += dy
    198     End Sub
    199 
    200 Public
    201     x As Single
    202     y As Single
    203     width As Single
    204     height As Single
    205 End Class
     6Type RectangleF
     7    X As Single
     8    Y As Single
     9    Width As Single
     10    Height As Single
     11End Type
    20612
    20713End Namespace
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/Size.ab

    r473 r698  
    44Namespace Drawing
    55
    6 Class Size
    7 Public
    8     Sub Size()
    9         width = 0
    10         height = 0
    11     End Sub
    12 
    13     Sub Size(initWidth As Long, initHeight As Long)
    14         width = initWidth
    15         height = initHeight
    16     End Sub
    17 
    18     Sub Size(sz As Size)
    19         width = sz.width
    20         height = sz.height
    21     End Sub
    22 
    23     Function Width() As Long
    24         Return width
    25     End Function
    26 
    27     Sub Width(w As Long)
    28         width = w
    29     End Sub
    30 
    31     Function Height() As Long
    32         Return height
    33     End Function
    34 
    35     Sub Height(h As Long)
    36         height = h
    37     End Sub
    38 
    39     Function Operator +(sz As Size) As Size
    40         Return New Size(width + sz.width, height + sz.height)
    41     End Function
    42 
    43     Function Operator -(sz As Size) As Size
    44         Return New Size(width - sz.width, height - sz.height)
    45     End Function
    46 
    47     Function Operator () As SizeF
    48         Return New SizeF(width, height)
    49     End Function
    50 
    51     Function Operator ==(sz As Size) As Boolean
    52         Return Equals(sz)
    53     End Function
    54 
    55     Function Operator <>(sz As Size) As Boolean
    56         Return Not Equals(sz)
    57     End Function
    58 
    59     Function Equals(sz As Size) As Boolean
    60         If width = sz.width And height = sz.height Then
    61             Equals = True
    62         Else
    63             Equals = False
    64         End If
    65     End Function
    66 
    67     Override Function GetHashCode() As Long
    68         Return width As DWord Xor _System_BSwap(height As DWord)
    69     End Function
    70 
    71     Function IsEmpty() As Boolean
    72         Return width = 0 And height = 0
    73     End Function
    74 
    75     Function Add(sz As Size) As Size
    76         Return This + sz
    77     End Function
    78 
    79     Function Subtract(sz As Size) As Size
    80         Return This - sz
    81     End Function
    82 
    83     Static Function Ceiling(szf As SizeF) As Size
    84         Return New Size(System.Math.Ceiling(szf.Width) As Long, System.Math.Ceiling(szf.Height) As Long)
    85     End Function
    86 
    87     Static Function Round(szf As SizeF) As Size
    88         Return New Size(System.Math.Round(szf.Width) As Long, System.Math.Round(szf.Height) As Long)
    89     End Function
    90 
    91     Static Function Truncate(szf As SizeF) As Size
    92         Return New Size(System.Math.Truncate(szf.Width) As Long, System.Math.Truncate(szf.Height) As Long)
    93     End Function
    94 
    95 Private
    96     width As Long
    97     height As Long
    98 End Class
     6Type Size
     7    Width As Long
     8    Height As Long
     9End Type
    9910
    10011End Namespace
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/SizeF.ab

    r473 r698  
    44Namespace Drawing
    55
    6 Class SizeF
    7 Public
    8     Sub SizeF()
    9         width = 0
    10         height = 0
    11     End Sub
    12 
    13     Sub SizeF(initWidth As Single, initHeight As Single)
    14         width = initWidth
    15         height = initHeight
    16     End Sub
    17 
    18     Sub SizeF(sz As SizeF)
    19         width = sz.width
    20         height = sz.height
    21     End Sub
    22 
    23     Function Width() As Single
    24         Return width
    25     End Function
    26 
    27     Sub Width(w As Single)
    28         width = w
    29     End Sub
    30 
    31     Function Height() As Single
    32         Return height
    33     End Function
    34 
    35     Sub Height(h As Single)
    36         height = h
    37     End Sub
    38 
    39     Function Operator +(sz As SizeF) As SizeF
    40         Return New SizeF(width + sz.width, height + sz.height)
    41     End Function
    42 
    43     Function Operator -(sz As SizeF) As SizeF
    44         Return New SizeF(width - sz.width, height - sz.height)
    45     End Function
    46 
    47     Function Operator ==(sz As SizeF) As Boolean
    48         Return Equals(sz)
    49     End Function
    50 
    51     Function Operator <>(sz As SizeF) As Boolean
    52         Return Not Equals(sz)
    53     End Function
    54 
    55     Function Equals(sz As SizeF) As Boolean
    56         Return width = sz.width And height = sz.height
    57     End Function
    58 
    59     Override Function GetHashCode() As Long
    60         Return GetDWord(VarPtr(width)) Xor _System_BSwap(GetDWord(VarPtr(height)))
    61     End Function
    62 
    63     Function IsEmpty() As Boolean
    64         Return width = 0 And height = 0
    65     End Function
    66 
    67     Function Add(sz As SizeF) As SizeF
    68         Return This + sz
    69     End Function
    70 
    71     Function Subtract(sz As SizeF) As SizeF
    72         Return This - sz
    73     End Function
    74 
    75     Function ToSize() As Size
    76         Return Size.Round(This)
    77     End Function
    78 
    79     Function ToPointF() As PointF
    80         Return New PointF(width, height)
    81     End Function
    82 Private
    83     width As Single
    84     height As Single
    85 End Class
     6Type SizeF
     7    Width As Single
     8    Height As Single
     9End Type
    8610
    8711End Namespace
  • trunk/ab5.0/ablib/src/Classes/System/Drawing/misc.ab

    r635 r698  
    3737
    3838Enum FontStyle
    39 /*
    4039    Regular = 0
    4140    Bold = 1
    4241    Italic = 2
    4342    Strikeout = 4
    44     Underline  = 8
    45 */
     43    Underline = 8
    4644End Enum
    4745
     46Enum TextRenderingHint
     47    TextRenderingHintSystemDefault = 0
     48    TextRenderingHintSingleBitPerPixelGridFit
     49    TextRenderingHintSingleBitPerPixel
     50    TextRenderingHintAntiAliasGridFit
     51    TextRenderingHintAntiAlias
     52    TextRenderingHintClearTypeGridFit
     53End Enum
     54
     55Enum MetafileFrameUnit
     56    Pixel      = 2
     57    Point      = 3
     58    Inch       = 4
     59    Document   = 5
     60    Millimeter = 6
     61    Gdi
     62End Enum
     63
     64Namespace Detail
     65    Sub ThrowGdiplusException(status As Status)
     66        Select Case status
     67            Case Ok
     68                Exit Sub
     69'           Case OutOfMemory
     70'               Throw New System.OutOfMemroyException("GDI+")
     71            Case NotImplemented
     72                Throw New System.NotImplementedException("GDI+")
     73'           Case FileNotFoundException
     74'               Throw New System.IO.FileNotFoundException("GDI+")
     75            Case Else
     76                Throw New System.Exception("GDI+")
     77        End Select
     78    End Sub
     79End Namespace
     80
     81Sub SetStatus(status As Status)
     82    Detail.ThrowGdiplusException(status)
     83End Sub
    4884
    4985End Namespace
Note: See TracChangeset for help on using the changeset viewer.