source: trunk/ab5.0/ablib/src/Classes/System/Drawing/Graphics.ab@ 703

Last change on this file since 703 was 703, checked in by イグトランス (egtra), 15 years ago

Imageクラスを追加
(#242)

File size: 49.3 KB
Line 
1' Classes/System/Drawing/Graphics.ab
2
3Namespace System
4Namespace Drawing
5
6Class ImageAttributes
7Public
8 nativeImage As *GpImageAttributes
9End Class
10Class Metafile
11Inherits Image
12End Class
13Class Region
14Public
15 nativeRegion As *GpRegion
16End Class
17Class GraphicsPath
18Public
19 Sub GraphicsPath(native As *GpPath)
20 nativePath = native
21 End Sub
22 Function NativePath() As *GpPath
23 End Function
24 nativePath As *GpPath
25End Class
26Class CachedBitmap
27Public
28 nativeCachedBitmap As *GpCachedBitmap
29End Class
30
31Delegate Function EnumerateMetafileProc(recordType As Imaging.EmfPlusRecordType, flags As DWord, dataSize As DWord, data As *Byte, callbackData As VoidPtr) As Boolean
32
33Namespace Detail
34
35TypeDef NativeEnumerateMetafileProc = *Function(recordType As Imaging.EmfPlusRecordType, flags As DWord, dataSize As DWord, data As *Byte, callbackData As VoidPtr) As Boolean
36
37Type EnumerateMetafileProcData
38 Proc As EnumerateMetafileProc
39 Data As VoidPtr
40End Type
41
42Function NativeEnumerateMetafileProcEntry(recordType As Imaging.EmfPlusRecordType, flags As DWord, dataSize As DWord, data As *Byte, callbackData As VoidPtr) As Boolean
43 Dim procData = callbackData As *EnumerateMetafileProcData
44 Dim proc = procData->Proc
45 NativeEnumerateMetafileProcEntry = proc(recordType, flags, dataSize, data, procData->Data)
46End Function
47
48End Namespace
49
50Class Graphics
51Public
52 '=========================================================================
53 ' Properties
54 '=========================================================================
55 Const Function Clip() As Region
56 Clip = New Region
57 SetStatus(GdipGetClip(nativeGraphics, Clip.nativeRegion))
58 End Function
59
60 Sub Clip(region As Region)
61 Imports System.Drawing.Drawing2D
62 SetStatus(GdipSetClipRegion(nativeGraphics, region.nativeRegion, CombineMode.Replace))
63 End Sub
64
65 Const Function ClipBounds() As RectangleF
66 SetStatus(GdipGetClipBounds(nativeGraphics, ClipBounds))
67 End Function
68
69 Const Function ClipBoundsI() As Rectangle
70 SetStatus(GdipGetClipBoundsI(nativeGraphics, ClipBoundsI))
71 End Function
72/*
73 Const Function CompositingMode() As Drawing2D.CompositingMode
74 SetStatus(GdipGetCompositingMode(nativeGraphics, CompositingMode))
75 End Function
76
77 Sub CompositingMode(mode As Drawing2D.CompositingMode)
78 SetStatus(GdipSetCompositingMode(nativeGraphics, mode))
79 End Sub
80
81 Function CompositingQuality() As Drawing2D.CompositingQuality
82 SetStatus(GdipGetCompositingQuality(nativeGraphics, CompositingQuality))
83 End Function
84
85 Sub CompositingQuality(cq As Drawing2D.CompositingQuality)
86 Return SetStatus(GdipSetCompositingQuality(nativeGraphics, cq))
87 End Sub
88*/
89 Const Function DpiX() As Single
90 SetStatus(GdipGetDpiX(nativeGraphics, DpiX))
91 End Function
92
93 Const Function DpiY() As Single
94 SetStatus(GdipGetDpiY(nativeGraphics, DpiY))
95 End Function
96/*
97 Const Function InterpolationMode() As Drawing2D.InterpolationMode
98 SetStatus(GdipGetInterpolationMode(nativeGraphics, InterpolationMode))
99 End Function
100
101 Sub InterpolationMode(im As Drawing2D.InterpolationMode)
102 InterpolationMode = SetStatus(GdipSetInterpolationMode(nativeGraphics, im))
103 End Sub
104*/
105 Const Function IsClipEmpty() As Boolean
106 Dim b = FALSE As BOOL
107 SetStatus(GdipIsClipEmpty(nativeGraphics, b))
108 IsClipEmpty = b As Boolean
109 End Function
110
111 Const Function IsVisibleClipEmpty() As Boolean
112 Dim b = FALSE As BOOL
113 SetStatus(GdipIsVisibleClipEmpty(nativeGraphics, b))
114 IsVisibleClipEmpty = b As Boolean
115 End Function
116
117 Sub PageScale(scale As Single)
118 SetStatus(GdipSetPageScale(nativeGraphics, scale))
119 End Sub
120
121 Const Function PageScale() As Single
122 SetStatus(GdipGetPageScale(nativeGraphics, PageScale))
123 End Function
124/*
125 Const Function PageUnit() As GraphicsUnit
126 SetStatus(GdipGetPageUnit(nativeGraphics, PageUnit))
127 End Function
128*/
129 Sub PageUnit(unit As GraphicsUnit)
130 SetStatus(GdipSetPageUnit(nativeGraphics, unit))
131 End Sub
132/*
133 Function PixelOffsetMode() As Drawing2D.PixelOffsetMode
134 PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.Invalid
135 SetStatus(GdipGetPixelOffsetMode(nativeGraphics, PixelOffsetMode))
136 End Function
137*/
138 Sub PixelOffsetMode(mode As Drawing2D.PixelOffsetMode)
139 SetStatus(GdipSetPixelOffsetMode(nativeGraphics, mode))
140 End Sub
141
142 Function RenderingOrigin() As Point
143 With RenderingOrigin
144 .X = 0
145 .Y = 0
146 SetStatus(GdipGetRenderingOrigin(nativeGraphics, .X, .Y))
147 End With
148 End Function
149
150 Sub RenderingOrigin(pt As Point)
151 SetStatus(GdipSetRenderingOrigin(nativeGraphics, pt.X, pt.Y))
152 End Sub
153/*
154 Function SmoothingMode() As Drawing2D.SmoothingMode
155 SetStatus(GdipGetSmoothingMode(nativeGraphics, SmoothingMode))
156 End Function
157*/
158 Sub SmoothingMode(mode As Drawing2D.SmoothingMode)
159 SetStatus(GdipSetSmoothingMode(nativeGraphics, mode))
160 End Sub
161
162 Function TextContrast() As DWord
163 SetStatus(GdipGetTextContrast(nativeGraphics, TextContrast))
164 End Function
165
166 Sub TextContrast(contrast As DWord)
167 SetStatus(GdipSetTextContrast(nativeGraphics, contrast))
168 End Sub
169/*
170 Function TextRenderingHint() As Text.TextRenderingHint
171 SetStatus(GdipGetTextRenderingHint(nativeGraphics, ByVal VarPtr(TextRenderingHint)))
172 End Function
173*/
174 Sub TextRenderingHint(mode As TextRenderingHint)
175 SetStatus(GdipSetTextRenderingHint(nativeGraphics, mode))
176 End Sub
177
178 Function Transform() As Drawing2D.Matrix
179 Dim native As *GpMatrix
180 SetStatus(GdipGetWorldTransform(nativeGraphics, native))
181 Transform = New Drawing2D.Matrix(native)
182 End Function
183
184 Sub Transform(matrix As Drawing2D.Matrix)
185 SetStatus(GdipSetWorldTransform(nativeGraphics, matrix.nativeMatrix))
186 End Sub
187
188 Function VisibleClipBounds() As RectangleF
189 SetStatus(GdipGetVisibleClipBounds(nativeGraphics, VisibleClipBounds))
190 End Function
191
192 Function VisibleClipBoundsI() As Rectangle
193 SetStatus(GdipGetVisibleClipBoundsI(nativeGraphics, VisibleClipBoundsI))
194 End Function
195
196 '=========================================================================
197 ' Methods
198 '=========================================================================
199 Static Function FromHDC(hdc As HDC) As Graphics
200 Dim graphics = 0 As *GpGraphics
201 SetStatus(GdipCreateFromHDC(hdc, graphics))
202 Return New Graphics(graphics)
203 End Function
204
205 Static Function FromHDC(hdc As HDC, hdevice As HANDLE) As Graphics
206 Dim graphics = 0 As *GpGraphics
207 SetStatus(GdipCreateFromHDC2(hdc, hdevice, graphics))
208 Return New Graphics(graphics)
209 End Function
210
211 Static Function FromHwnd(hwnd As HWND) As Graphics
212 Dim graphics = 0 As *GpGraphics
213 SetStatus(GdipCreateFromHWND(hwnd, graphics))
214 Return New Graphics(graphics)
215 End Function
216
217 Static Function FromHwnd(hwnd As HWND, icm As Boolean) As Graphics
218 Dim graphics = 0 As *GpGraphics
219 If icm Then
220 SetStatus(GdipCreateFromHWNDICM(hwnd, graphics))
221 Else
222 SetStatus(GdipCreateFromHWND(hwnd, graphics))
223 End If
224 Return New Graphics(graphics)
225 End Function
226
227 Static Function FromImage(image As Image) As Graphics
228 If ActiveBasic.IsNothing(image) Then
229 Throw New ArgumentNullException("image")
230 End If
231 Dim graphics = 0 As *GpGraphics
232 SetStatus(GdipGetImageGraphicsContext(image.NativeImage, graphics))
233 Return New Graphics(graphics)
234 End Function
235
236 Sub Dispose()
237 GdipDeleteGraphics(nativeGraphics)
238 nativeGraphics = 0
239 End Sub
240
241 Sub ~Graphics()
242 Dispose()
243 End Sub
244
245 Sub Flush()
246 GdipFlush(nativeGraphics, System.Drawing.Drawing2D.FlushIntention.Flush)
247 End Sub
248
249 Sub Flush(intention As Drawing2D.FlushIntention)
250 GdipFlush(nativeGraphics, intention)
251 End Sub
252
253 Function GetHDC() As HDC
254 GetHDC = 0
255 SetStatus(GdipGetDC(nativeGraphics, GetHDC))
256 End Function
257
258 Sub ReleaseHDC(hdc As HDC)
259 SetStatus(GdipReleaseDC(nativeGraphics, hdc))
260 End Sub
261
262 Sub ResetTransform()
263 SetStatus(GdipResetWorldTransform(nativeGraphics))
264 End Sub
265
266 Sub MultiplyTransform(matrix As Drawing2D.Matrix)
267 SetStatus(GdipMultiplyWorldTransform(nativeGraphics, matrix.nativeMatrix, System.Drawing.Drawing2D.MatrixOrder.Prepend))
268 End Sub
269
270 Sub MultiplyTransform(matrix As Drawing2D.Matrix, order As Drawing2D.MatrixOrder)
271 SetStatus(GdipMultiplyWorldTransform(nativeGraphics, matrix.nativeMatrix, order))
272 End Sub
273
274 Sub TranslateTransform(dx As Single, dy As Single)
275 SetStatus(GdipTranslateWorldTransform(nativeGraphics, dx, dy, System.Drawing.Drawing2D.MatrixOrder.Prepend))
276 End Sub
277
278 Sub TranslateTransform(dx As Single, dy As Single, order As Drawing2D.MatrixOrder)
279 SetStatus(GdipTranslateWorldTransform(nativeGraphics, dx, dy, order))
280 End Sub
281
282 Sub ScaleTransform(sx As Single, sy As Single)
283 SetStatus(GdipScaleWorldTransform(nativeGraphics, sx, sy, System.Drawing.Drawing2D.MatrixOrder.Prepend))
284 End Sub
285
286 Sub ScaleTransform(sx As Single, sy As Single, order As Drawing2D.MatrixOrder)
287 SetStatus(GdipScaleWorldTransform(nativeGraphics, sx, sy, order))
288 End Sub
289
290 Sub RotateTransform(angle As Single)
291 SetStatus(GdipRotateWorldTransform(nativeGraphics, angle, System.Drawing.Drawing2D.MatrixOrder.Prepend))
292 End Sub
293
294 Sub RotateTransform(angle As Single, order As Drawing2D.MatrixOrder)
295 SetStatus(GdipRotateWorldTransform(nativeGraphics, angle, order))
296 End Sub
297
298 Sub TransformPoints(destSpace As Drawing2D.CoordinateSpace, srcSpace As Drawing2D.CoordinateSpace, pts As *PointF, count As Long)
299 SetStatus(GdipTransformPoints(nativeGraphics, destSpace, srcSpace, pts, count))
300 End Sub
301
302 Sub TransformPoints(destSpace As Drawing2D.CoordinateSpace, srcSpace As Drawing2D.CoordinateSpace, pts As *Point, count As Long)
303 SetStatus(GdipTransformPointsI(nativeGraphics, destSpace, srcSpace, pts, count))
304 End Sub
305
306 Const Function GetNearestColor(color As Color) As Color
307 GetNearestColor = color
308 SetStatus(GdipGetNearestColor(nativeGraphics, GetNearestColor))
309 End Function
310
311 Sub DrawLine(pen As Pen, x1 As Single, y1 As Single, x2 As Single, y2 As Single)
312 SetStatus(GdipDrawLine(nativeGraphics, pen.NativePen, x1, y1, x2, y2))
313 End Sub
314
315 Sub DrawLine(pen As Pen, ByRef pt1 As PointF, ByRef pt2 As PointF)
316 DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y)
317 End Sub
318
319 Sub DrawLines(pen As Pen, points As *PointF, count As Long)
320 SetStatus(GdipDrawLines(nativeGraphics, pen.NativePen, points, count))
321 End Sub
322
323 Sub DrawLine(pen As Pen, x1 As Long, y1 As Long, x2 As Long, y2 As Long)
324 SetStatus(GdipDrawLineI(nativeGraphics, pen.NativePen, x1, y1, x2, y2))
325 End Sub
326
327 Sub DrawLine(pen As Pen, ByRef pt1 As Point, ByRef pt2 As Point)
328 DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y)
329 End Sub
330
331 Sub DrawLines(pen As Pen, points As *Point, count As Long)
332 SetStatus(GdipDrawLinesI(nativeGraphics, pen.NativePen, points, count))
333 End Sub
334
335 Sub DrawArc(pen As Pen, x As Single, y As Single, width As Single, height As Single, startAngle As Single, sweepAngle As Single)
336 SetStatus(GdipDrawArc(nativeGraphics, pen.NativePen, x, y, width, height, startAngle, sweepAngle))
337 End Sub
338
339 Sub DrawArc(pen As Pen, ByRef rect As RectangleF, startAngle As Single, sweepAngle As Single)
340 DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
341 End Sub
342
343 Sub DrawArc(pen As Pen, x As Long, y As Long, width As Long, height As Long, startAngle As Single, sweepAngle As Single)
344 SetStatus(GdipDrawArcI(nativeGraphics, pen.NativePen, x, y, width, height, startAngle, sweepAngle))
345 End Sub
346
347 Sub DrawArc(pen As Pen, ByRef rect As Rectangle, startAngle As Single, sweepAngle As Single)
348 DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
349 End Sub
350
351 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)
352 SetStatus(GdipDrawBezier(nativeGraphics, pen.NativePen, x1, y1,x2, y2, x3, y3, x4, y4))
353 End Sub
354
355 Sub DrawBezier(pen As Pen, ByRef pt1 As PointF, ByRef pt2 As PointF, ByRef pt3 As PointF, ByRef pt4 As PointF)
356 DrawBezier(pen, pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y)
357 End Sub
358
359 Sub DrawBeziers(pen As Pen, points As *PointF, count As Long)
360 SetStatus(GdipDrawBeziers(nativeGraphics, pen.NativePen, points, count))
361 End Sub
362
363 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)
364 SetStatus(GdipDrawBezierI(nativeGraphics, pen.NativePen, x1, y1, x2, y2, x3, y3, x4, y4))
365 End Sub
366
367 Sub DrawBezier(pen As Pen, ByRef pt1 As Point, ByRef pt2 As Point, ByRef pt3 As Point, ByRef pt4 As Point)
368 DrawBezier(pen, pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y)
369 End Sub
370
371 Sub DrawBeziers(pen As Pen, points As *Point, count As Long)
372 SetStatus(GdipDrawBeziersI(nativeGraphics, pen.NativePen, points, count))
373 End Sub
374
375 Sub DrawRectangle(pen As Pen, ByRef rect As RectangleF)
376 DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height)
377 End Sub
378
379 Sub DrawRectangle(pen As Pen, x As Single, y As Single, width As Single, height As Single)
380 SetStatus(GdipDrawRectangle(nativeGraphics, pen.NativePen, x, y, width, height))
381 End Sub
382
383 Sub DrawRectangles(pen As Pen, rects As *RectangleF, count As Long)
384 SetStatus(GdipDrawRectangles(nativeGraphics, pen.NativePen, rects, count))
385 End Sub
386
387 Sub DrawRectangle(pen As Pen, ByRef rect As Rectangle)
388 DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height)
389 End Sub
390
391 Sub DrawRectangle(pen As Pen, x As Long, y As Long, width As Long, height As Long)
392 SetStatus(GdipDrawRectangleI(nativeGraphics, pen.NativePen, x, y, width, height))
393 End Sub
394
395 Sub DrawRectangles(pen As Pen, rects As *Rectangle, count As Long)
396 SetStatus(GdipDrawRectanglesI(nativeGraphics, pen.NativePen, rects, count))
397 End Sub
398
399 Sub DrawEllipse(pen As Pen, ByRef rect As RectangleF)
400 DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height)
401 End Sub
402
403 Sub DrawEllipse(pen As Pen, x As Single, y As Single, width As Single, height As Single)
404 SetStatus(GdipDrawEllipse(nativeGraphics, pen.NativePen, x, y, width, height))
405 End Sub
406
407 Sub DrawEllipse(pen As Pen, ByRef rect As Rectangle)
408 DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height)
409 End Sub
410
411 Sub DrawEllipse(pen As Pen, x As Long, y As Long, width As Long, height As Long)
412 SetStatus(GdipDrawEllipseI(nativeGraphics, pen.NativePen, x, y, width, height))
413 End Sub
414
415 Sub DrawPie(pen As Pen, ByRef rect As RectangleF, startAngle As Single, sweepAngle As Single)
416 DrawPie(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
417 End Sub
418
419 Sub DrawPie(pen As Pen, x As Single, y As Single, width As Single, height As Single, startAngle As Single, sweepAngle As Single)
420 SetStatus(GdipDrawPie(nativeGraphics, pen.NativePen, x, y, width, height, startAngle, sweepAngle))
421 End Sub
422
423 Sub DrawPie(pen As Pen, ByRef rect As Rectangle, startAngle As Single, sweepAngle As Single)
424 DrawPie(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
425 End Sub
426
427 Sub DrawPie(pen As Pen, x As Long, y As Long, width As Long, height As Long, startAngle As Single, sweepAngle As Single)
428 SetStatus(GdipDrawPieI(nativeGraphics, pen.NativePen, x, y, width, height, startAngle, sweepAngle))
429 End Sub
430
431 Sub DrawPolygon(pen As Pen, points As *PointF, count As Long)
432 SetStatus(GdipDrawPolygon(nativeGraphics, pen.NativePen, points, count))
433 End Sub
434
435 Sub DrawPolygon(pen As Pen, points As *Point, count As Long)
436 SetStatus(GdipDrawPolygonI(nativeGraphics, pen.NativePen, points, count))
437 End Sub
438
439 Sub DrawPath(pen As Pen, path As GraphicsPath)
440 If ActiveBasic.IsNothing(pen) Or ActiveBasic.IsNothing(path) Then
441 Throw New ArgumentNullException("pen or path or both")
442 End If
443 SetStatus(GdipDrawPath(nativeGraphics, pen.NativePen, path.nativePath))
444 End Sub
445
446 Sub DrawCurve(pen As Pen, points As *PointF, count As Long)
447 SetStatus(GdipDrawCurve(nativeGraphics, pen.NativePen, points, count))
448 End Sub
449
450 Sub DrawCurve(pen As Pen, points As *PointF, count As Long, tension As Single)
451 SetStatus(GdipDrawCurve2(nativeGraphics, pen.NativePen, points,count, tension))
452 End Sub
453
454 Sub DrawCurve(pen As Pen, points As *PointF, count As Long, offset As Long, numberOfSegments As Long)
455 SetStatus(GdipDrawCurve3(nativeGraphics, pen.NativePen, points, count, offset,numberOfSegments, 0.5))
456 End Sub
457
458 Sub DrawCurve(pen As Pen, points As *PointF, count As Long, offset As Long, numberOfSegments As Long, tension As Single)
459 SetStatus(GdipDrawCurve3(nativeGraphics, pen.NativePen, points, count, offset,numberOfSegments, tension))
460 End Sub
461
462 Sub DrawCurve(pen As Pen, points As *Point, count As Long)
463 SetStatus(GdipDrawCurveI(nativeGraphics, pen.NativePen, points, count))
464 End Sub
465
466 Sub DrawCurve(pen As Pen, points As *Point, count As Long, tension As Single)
467 SetStatus(GdipDrawCurve2I(nativeGraphics, pen.NativePen, points, count, tension))
468 End Sub
469
470 Sub DrawCurve(pen As Pen, points As *Point, count As Long, offset As Long, numberOfSegments As Long)
471 SetStatus(GdipDrawCurve3I(nativeGraphics, pen.NativePen, points, count, offset, numberOfSegments, 0.5))
472 End Sub
473
474 Sub DrawCurve(pen As Pen, points As *Point, count As Long, offset As Long, numberOfSegments As Long, tension As Single)
475 SetStatus(GdipDrawCurve3I(nativeGraphics, pen.NativePen, points, count, offset, numberOfSegments, tension))
476 End Sub
477
478 Sub DrawClosedCurve(pen As Pen, points As *PointF, count As Long)
479 SetStatus(GdipDrawClosedCurve(nativeGraphics, pen.NativePen, points, count))
480 End Sub
481
482 Sub DrawClosedCurve(pen As Pen, points As *PointF, count As Long, tension As Single)
483 SetStatus(GdipDrawClosedCurve2(nativeGraphics, pen.NativePen, points, count, tension))
484 End Sub
485
486 Sub DrawClosedCurve(pen As Pen, points As *Point, count As Long)
487 SetStatus(GdipDrawClosedCurveI(nativeGraphics, pen.NativePen, points, count))
488 End Sub
489
490 Sub DrawClosedCurve(pen As Pen, points As *Point, count As Long, tension As Single)
491 SetStatus(GdipDrawClosedCurve2I(nativeGraphics, pen.NativePen, points, count, tension))
492 End Sub
493
494 Sub Clear(color As Color)
495 SetStatus(GdipGraphicsClear(nativeGraphics, color))
496 End Sub
497
498 Sub FillRectangle(brush As Brush, ByRef rect As RectangleF)
499 FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height)
500 End Sub
501
502 Sub FillRectangle(brush As Brush, x As Single, y As Single, width As Single, height As Single)
503 SetStatus(GdipFillRectangle(nativeGraphics, brush.NativeBrush, x, y, width, height))
504 End Sub
505
506 Sub FillRectangles(brush As Brush, rects As *RectangleF, count As Long)
507 SetStatus(GdipFillRectangles(nativeGraphics,brush.NativeBrush,rects, count))
508 End Sub
509
510 Sub FillRectangle(brush As Brush, ByRef rect As Rectangle)
511 FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height)
512 End Sub
513
514 Sub FillRectangle(brush As Brush, x As Long, y As Long, width As Long, height As Long)
515 SetStatus(GdipFillRectangleI(nativeGraphics, brush.NativeBrush, x, y, width, height))
516 End Sub
517
518 Sub FillRectangles(brush As Brush, rects As *Rectangle, count As Long)
519 SetStatus(GdipFillRectanglesI(nativeGraphics, brush.NativeBrush, rects, count))
520 End Sub
521
522' Sub FillPolygon(brush As Brush, points As *PointF, count As Long)
523' FillPolygon(brush, points, count, System.Drawing.Drawing2D.FillMode.Alternate)
524' End Sub
525
526 Sub FillPolygon(brush As Brush, points As *PointF, count As Long, fillMode As Drawing2D.FillMode)
527 SetStatus(GdipFillPolygon(nativeGraphics, brush.NativeBrush, points, count, fillMode))
528 End Sub
529
530' Sub FillPolygon(brush As Brush, points As *Point, count As Long)
531' FillPolygon(brush, points, count, System.Drawing.Drawing2D.FillMode.Alternate)
532' End Sub
533
534 Sub FillPolygon(brush As Brush, points As *Point, count As Long, fillMode As Drawing2D.FillMode)
535 SetStatus(GdipFillPolygonI(nativeGraphics, brush.NativeBrush, points, count, fillMode))
536 End Sub
537
538 Sub FillEllipse(brush As Brush, ByRef rect As RectangleF)
539 FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height)
540 End Sub
541
542 Sub FillEllipse(brush As Brush, x As Single, y As Single, width As Single, height As Single)
543 SetStatus(GdipFillEllipse(nativeGraphics, brush.NativeBrush, x, y, width, height))
544 End Sub
545
546 Sub FillEllipse(brush As Brush, ByRef rect As Rectangle)
547 FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height)
548 End Sub
549
550 Sub FillEllipse(brush As Brush, x As Long, y As Long, width As Long, height As Long)
551 SetStatus(GdipFillEllipseI(nativeGraphics, brush.NativeBrush, x, y, width, height))
552 End Sub
553
554 Sub FillPie(brush As Brush, ByRef rect As RectangleF, startAngle As Single, sweepAngle As Single)
555 FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
556 End Sub
557
558 Sub FillPie(brush As Brush, x As Single, y As Single, width As Single, height As Single, startAngle As Single, sweepAngle As Single)
559 SetStatus(GdipFillPie(nativeGraphics, brush.NativeBrush, x, y, width, height, startAngle, sweepAngle))
560 End Sub
561
562 Sub FillPie(brush As Brush, ByRef rect As Rectangle, startAngle As Single, sweepAngle As Single)
563 FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle)
564 End Sub
565
566 Sub FillPie(brush As Brush, x As Long, y As Long, width As Long, height As Long, startAngle As Single, sweepAngle As Single)
567 SetStatus(GdipFillPieI(nativeGraphics, brush.NativeBrush, x, y, width, height, startAngle, sweepAngle))
568 End Sub
569
570 Sub FillPath(brush As Brush, path As GraphicsPath)
571 If ActiveBasic.IsNothing(brush) Or ActiveBasic.IsNothing(path) Then
572 Throw New ArgumentNullException("brush or path or both")
573 End If
574 SetStatus(GdipFillPath(nativeGraphics, brush.NativeBrush, path.nativePath))
575 End Sub
576
577 Sub FillClosedCurve(brush As Brush, points As *PointF, count As Long)
578 SetStatus(GdipFillClosedCurve(nativeGraphics, brush.NativeBrush, points, count))
579 End Sub
580
581 Sub FillClosedCurve(brush As Brush, points As *PointF, count As Long, fillMode As Drawing2D.FillMode)
582 SetStatus(GdipFillClosedCurve2(nativeGraphics, brush.NativeBrush, points, count, 0.5, fillMode))
583 End Sub
584
585 Sub FillClosedCurve(brush As Brush, points As *PointF, count As Long, fillMode As Drawing2D.FillMode, tension As Single)
586 SetStatus(GdipFillClosedCurve2(nativeGraphics, brush.NativeBrush, points, count, tension, fillMode))
587 End Sub
588
589 Sub FillClosedCurve(brush As Brush, points As *Point, count As Long)
590 SetStatus(GdipFillClosedCurveI(nativeGraphics, brush.NativeBrush, points, count))
591 End Sub
592
593 Sub FillClosedCurve(brush As Brush, points As *Point, count As Long, fillMode As Drawing2D.FillMode)
594 SetStatus(GdipFillClosedCurve2I(nativeGraphics, brush.NativeBrush, points, count, 0.5, fillMode))
595 End Sub
596
597 Sub FillClosedCurve(brush As Brush, points As *Point, count As Long, fillMode As Drawing2D.FillMode, tension As Single)
598 SetStatus(GdipFillClosedCurve2I(nativeGraphics, brush.NativeBrush, points, count, tension, fillMode))
599 End Sub
600
601 Sub FillRegion(brush As Brush, region As Region)
602 SetStatus(GdipFillRegion(nativeGraphics, brush.NativeBrush, region.nativeRegion))
603 End Sub
604
605'DrawStringは次の組み合わせからなる。
606'(PCWSTR, Long) or String
607'PointF or (Single, Single) or Rectangle
608'StringFormatの有無
609 Sub DrawString(str As PCWSTR, length As Long, font As Font, brush As Brush, ByRef origin As PointF, stringFormat = Nothing As StringFormat)
610 DrawString(str, length, font, brush, origin.X, origin.Y, stringFormat)
611 End Sub
612
613 Sub DrawString(str As PCWSTR, length As Long, font As Font, brush As Brush, x As Single, y As Single, stringFormat = Nothing As StringFormat)
614 Dim rc As RectangleF
615 rc.X = x
616 rc.Y = y
617 rc.Width = 0
618 rc.Height = 0
619 DrawString(str, length, font, brush, rc, stringFormat)
620 End Sub
621
622 Sub DrawString(str As PCWSTR, length As Long, font As Font, brush As Brush, ByRef layoutRect As RectangleF, stringFormat = Nothing As StringFormat)
623 Dim nativeFont = getNativeFont(font)
624 Dim nativeFormat = GetNativeStringFormat(stringFormat)
625 Dim nativeBrush = getNativeBrush(brush)
626 SetStatus(GdipDrawString(nativeGraphics, str, length, nativeFont, layoutRect, nativeFormat, nativeBrush))
627 End Sub
628
629 Sub DrawString(s As String, font As Font, brush As Brush, ByRef origin As PointF, stringFormat = Nothing As StringFormat)
630 DrawString(s, font, brush, origin.X, origin.Y, stringFormat)
631 End Sub
632
633 Sub DrawString(s As String, font As Font, brush As Brush, x As Single, y As Single, stringFormat = Nothing As StringFormat)
634 Dim rc As RectangleF
635 rc.X = x
636 rc.Y = y
637 rc.Width = 0
638 rc.Height = 0
639 DrawString(s, font, brush, rc, stringFormat)
640 End Sub
641
642 Sub DrawString(s As String, font As Font, brush As Brush, ByRef layoutRect As RectangleF, stringFormat = Nothing As StringFormat)
643 Dim wcs As PCWSTR
644 Dim len = GetStr(s, wcs) As Long
645 DrawString(wcs, len As Long, font, brush, layoutRect, stringFormat)
646 End Sub
647
648 Function MeasureString(s As String, font As Font) As SizeF
649 Dim pt As PointF
650 MeasureString = MeasureString(s, font, pt, Nothing)
651 End Function
652
653 Function MeasureString(s As String, font As Font, ByRef layoutRectSize As SizeF) As SizeF
654 MeasureString = MeasureString(s, font, layoutRectSize, Nothing)
655 End Function
656
657 Function MeasureString(s As String, font As Font, ByRef layoutRectSize As SizeF, stringFormat As StringFormat) As SizeF
658 Dim wcs As PCWSTR
659 Dim len = GetStr(s, wcs) As Long
660 MeasureString = MeasureString(wcs, len, font, layoutRectSize, stringFormat)
661 End Function
662
663 Function MeasureString(s As String, font As Font, ByRef origin As PointF, stringFormat As StringFormat) As SizeF
664 Dim wcs As PCWSTR
665 Dim len = GetStr(s, wcs) As Long
666 MeasureString = MeasureString(wcs, len, font, origin, stringFormat)
667 End Function
668
669 Function MeasureString(s As String, font As Font, width As Long, stringFormat As StringFormat) As SizeF
670 Dim wcs As PCWSTR
671 Dim len = GetStr(s, wcs) As Long
672 MeasureString = MeasureString(wcs, len, font, width, stringFormat)
673 End Function
674
675 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
676 Dim wcs As PCWSTR
677 Dim len = GetStr(s, wcs) As Long
678 MeasureString = MeasureString(wcs, len, font, layoutRectSize, stringFormat, codepointsFitted, linesFilled)
679 End Function
680
681 Function MeasureString(str As PCWSTR, length As Long, font As Font) As SizeF
682 Dim pt As PointF
683 MeasureString = MeasureString(str, length, font, pt, Nothing)
684 End Function
685
686 Function MeasureString(str As PCWSTR, length As Long, font As Font, ByRef layoutRectSize As SizeF) As SizeF
687 MeasureString = MeasureString(str, length, font, layoutRectSize, Nothing)
688 End Function
689
690 Function MeasureString(str As PCWSTR, length As Long, font As Font, ByRef layoutRectSize As SizeF, stringFormat As StringFormat) As SizeF
691 MeasureString = measureStringPt(str, length, font, layoutRectSize, stringFormat, 0, 0)
692 End Function
693
694 Function MeasureString(str As PCWSTR, length As Long, font As Font, ByRef origin As PointF, stringFormat As StringFormat) As SizeF
695 Dim layoutRect As RectangleF
696 With layoutRect
697 .X = origin.X
698 .Y = origin.Y
699 .Width = 0
700 .Height = 0
701 End With
702 MeasureString = measureString(str, length, font, layoutRect, stringFormat, 0, 0)
703 End Function
704
705 Function MeasureString(str As PCWSTR, length As Long, font As Font, width As Long, stringFormat As StringFormat) As SizeF
706 Dim layoutRect As RectangleF
707 With layoutRect
708 .X = 0
709 .Y = 0
710 .Width = width
711 .Height = 0
712 End With
713 MeasureString = measureString(str, length, font, layoutRect, stringFormat, 0, 0)
714 End Function
715
716 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
717 MeasureString = measureStringPt(str, length, font, layoutRectSize, stringFormat, VarPtr(codepointsFitted), VarPtr(linesFilled))
718 End Function
719
720Private
721 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
722 Dim layoutRect As RectangleF
723 With layoutRect
724 .X = 0
725 .Y = 0
726 .Width = layoutRectSize.Width
727 .Height = layoutRectSize.Height
728 End With
729 measureStringPt = measureString(str, length, font, layoutRect, stringFormat, codepointsFitted, linesFilled)
730 End Function
731
732 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
733 Dim nativeFont = getNativeFont(font)
734 Dim nativeFormat = GetNativeStringFormat(stringFormat)
735 Dim boundingBox As RectangleF
736 SetStatus(GdipMeasureString(nativeGraphics, str, length, nativeFont, layoutRect, nativeFormat, boundingBox, codepointsFitted, linesFilled))
737 measureString.Width = boundingBox.Width
738 measureString.Height = boundingBox.Height
739 End Function
740
741Public
742
743 Function MeasureCharacterRanges(s As String, font As Font, ByRef layoutRect As RectangleF, stringFormat As StringFormat) As System.Collections.Generic.IList<Region>
744 Dim wcs As PCWSTR
745 Dim len = GetStr(s, wcs)
746 MeasureCharacterRanges = MeasureCharacterRanges(wcs, len, font, layoutRect, stringFormat)
747 End Function
748
749 Function MeasureCharacterRanges(str As PCWSTR, length As Long, font As Font, ByRef layoutRect As RectangleF, stringFormat As StringFormat) As System.Collections.Generic.IList<Region>
750 If ActiveBasic.IsNothing(stringFormat) Then
751 stringFormat = New StringFormat
752 End If
753 Dim count As Long
754 SetStatus(GdipGetStringFormatMeasurableCharacterRangeCount(stringFormat.NativeFormat, count))
755 Dim nativeRegions As **GpRegion 'ここで = GC_mallocとすると、エラーになる。
756 nativeRegions = GC_malloc(count * SizeOf(*GpRegion))
757 Dim regions = New System.Collections.Generic.List<Region>(count)
758 MeasureCharacterRanges = regions
759
760 Dim i As Long
761 For i = 0 To ELM(count)
762 Dim t = regions[i]
763 nativeRegions[i] = t.nativeRegion
764 Next
765 Dim nativeFont = getNativeFont(font)
766 SetStatus(GdipMeasureCharacterRanges(nativeGraphics, str, length, nativeFont, layoutRect, stringFormat.NativeFormat, count, nativeRegions))
767 End Function
768
769 'DrawDriverString
770 'MeasureDriverString
771
772 Sub DrawCachedBitmap(cb As CachedBitmap, x As Long, y As Long)
773 SetStatus(GdipDrawCachedBitmap(nativeGraphics, cb.nativeCachedBitmap, x, y))
774 End Sub
775
776 Sub DrawImage(image As Image, ByRef point As PointF)
777 DrawImage(image, point.X, point.Y)
778 End Sub
779
780 Sub DrawImage(image As Image, x As Single, y As Single)
781 Dim nativeImage = getNativeImage(image)
782 SetStatus(GdipDrawImage(nativeGraphics, nativeImage, x, y))
783 End Sub
784
785 Sub DrawImage(image As Image, ByRef rect As RectangleF)
786 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height)
787 End Sub
788
789 Sub DrawImage(image As Image, x As Single, y As Single, width As Single, height As Single)
790 Dim nativeImage = getNativeImage(image)
791 SetStatus(GdipDrawImageRect(nativeGraphics, nativeImage, x, y, width, height))
792 End Sub
793
794 Sub DrawImage(image As Image, ByRef point As Point)
795 DrawImage(image, point.X, point.Y)
796 End Sub
797
798 Sub DrawImage(image As Image, x As Long, y As Long)
799 Dim nativeImage = getNativeImage(image)
800 SetStatus(GdipDrawImageI(nativeGraphics, nativeImage, x, y))
801 End Sub
802
803 Sub DrawImage(image As Image, ByRef rect As Rectangle)
804 DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height)
805 End Sub
806
807 Sub DrawImage(image As Image, x As Long, y As Long, width As Long, height As Long)
808 Dim nativeImage = getNativeImage(image)
809 SetStatus(GdipDrawImageRectI(nativeGraphics, nativeImage, x, y, width, height))
810 End Sub
811
812 ' Affine Draw Image
813 ' destPoints.length = 3: rect => parallelogram
814 ' destPoints[0] <=> top-left corner of the source rectangle
815 ' destPoints[1] <=> top-right corner
816 ' destPoints[2] <=> bottom-left corner
817 ' destPoints.length = 4: rect => quad
818 ' destPoints[3] <=> bottom-right corner
819
820 Sub DrawImage(image As Image, destPoints As *PointF, count As Long)
821 If count <> 3 And count <> 4 Then
822 SetStatus(InvalidParameter)
823 End If
824
825 Dim nativeImage = getNativeImage(image)
826 SetStatus(GdipDrawImagePoints(nativeGraphics, nativeImage, destPoints, count))
827 End Sub
828
829 Sub DrawImage(image As Image, destPoints As *Point, count As Long)
830 If count <> 3 And count <> 4 Then
831 SetStatus(InvalidParameter)
832 End If
833
834 Dim nativeImage = getNativeImage(image)
835 SetStatus(GdipDrawImagePointsI(nativeGraphics, nativeImage, destPoints, count))
836 End Sub
837
838 Sub DrawImage(image As Image, ByRef destRect As Rectangle, ByRef src As Rectangle, srcUnit As GraphicsUnit)
839 DrawImage(image, destRect, src.X, src.Y, src.Width, src.Height, srcUnit)
840 End Sub
841
842 Sub DrawImage(image As Image, ByRef destRect As RectangleF, ByRef src As RectangleF, srcUnit As GraphicsUnit)
843 DrawImage(image, destRect, src.X, src.Y, src.Width, src.Height, srcUnit)
844 End Sub
845
846 Sub DrawImage(image As Image, x As Long, y As Long, ByRef src As Rectangle, srcUnit As GraphicsUnit)
847 Dim nativeImage = getNativeImage(image)
848 SetStatus(GdipDrawImagePointRectI(nativeGraphics, nativeImage, x, y, src.X, src.Y, src.Width, src.Height, srcUnit))
849 End Sub
850
851 Sub DrawImage(image As Image, x As Single, y As Single, ByRef src As RectangleF, srcUnit As GraphicsUnit)
852 Dim nativeImage = getNativeImage(image)
853 SetStatus(GdipDrawImagePointRect(nativeGraphics, nativeImage, x, y, src.X, src.Y, src.Width, src.Height, srcUnit))
854 End Sub
855
856 Sub DrawImage(image As Image, destPoints As *Point, count As Long, ByRef src As Rectangle, srcUnit As GraphicsUnit, _
857 imageAttr = Nothing As ImageAttributes, callback = Nothing As DrawImageAbort, callbackData = 0 As VoidPtr)
858
859 Dim nativeImage = getNativeImage(image)
860 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
861 SetStatus(GdipDrawImagePointsRectI(nativeGraphics, nativeImage, destPoints, count,
862 src.X, src.Y, src.Width, src.Height, srcUnit, nativeImageAttr, callback, callbackData))
863 End Sub
864
865 Sub DrawImage(image As Image, destPoints As *PointF, count As Long, ByRef src As RectangleF, srcUnit As GraphicsUnit,
866 imageAttr = Nothing As ImageAttributes, callback = Nothing As DrawImageAbort, callbackData = 0 As VoidPtr)
867
868 Dim nativeImage = getNativeImage(image)
869 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
870 SetStatus(GdipDrawImagePointsRect(nativeGraphics, nativeImage, destPoints, count,
871 src.X, src.Y, src.Width, src.Height, srcUnit, nativeImageAttr, callback, callbackData))
872 End Sub
873
874 Sub DrawImage(image As Image, ByRef destRect As RectangleF,
875 srcx As Single, srcy As Single, srcwidth As Single, srcheight As Single, srcUnit As GraphicsUnit,
876 imageAttr = Nothing As ImageAttributes, callback = Nothing As DrawImageAbort, callbackData = 0 As VoidPtr)
877
878 Dim nativeImage = getNativeImage(image)
879 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
880 SetStatus(GdipDrawImageRectRect(nativeGraphics, nativeImageAttr,
881 destRect.X, destRect.Y, destRect.Width, destRect.Height, srcx, srcy, srcwidth, srcheight,
882 srcUnit, nativeImageAttr, callback, callbackData))
883 End Sub
884
885 Sub DrawImage(image As Image, ByRef destRect As Rectangle,
886 srcx As Long, srcy As Long, srcwidth As Long, srcheight As Long, srcUnit As GraphicsUnit,
887 imageAttr = Nothing As ImageAttributes, callback = Nothing As DrawImageAbort, callbackData = 0 As VoidPtr)
888
889 Dim nativeImage = getNativeImage(image)
890 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
891 SetStatus(GdipDrawImageRectRectI(nativeGraphics, nativeImage,
892 destRect.X, destRect.Y, destRect.Width, destRect.Height,
893 srcx, srcy, srcwidth, srcheight, srcUnit, nativeImageAttr, callback, callbackData))
894 End Sub
895
896 Sub EnumerateMetafile(metafile As Metafile, ByRef destPoint As PointF,
897 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
898
899 Dim nativeImage = getNativeImage(metafile)
900 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
901 Dim procData As Detail.EnumerateMetafileProcData
902 procData.Proc = callback
903 procData.Data = callbackData
904 SetStatus(GdipEnumerateMetafileDestPoint(nativeGraphics,
905 nativeImage, destPoint, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
906 End Sub
907
908 Sub EnumerateMetafile(metafile As Metafile, ByRef destPoint As Point,
909 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
910
911 Dim nativeImage = getNativeImage(metafile)
912 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
913 Dim procData As Detail.EnumerateMetafileProcData
914 procData.Proc = callback
915 procData.Data = callbackData
916 SetStatus(GdipEnumerateMetafileDestPointI(nativeGraphics,
917 nativeImage, destPoint, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
918 End Sub
919
920 Sub EnumerateMetafile(metafile As Metafile, ByRef destRect As RectangleF,
921 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
922
923 Dim nativeImage = getNativeImage(metafile)
924 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
925 Dim procData As Detail.EnumerateMetafileProcData
926 procData.Proc = callback
927 procData.Data = callbackData
928 SetStatus(GdipEnumerateMetafileDestRect(nativeGraphics,
929 nativeImage, destRect, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
930 End Sub
931
932 Sub EnumerateMetafile(metafile As Metafile, ByRef destRect As Rectangle,
933 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
934
935 Dim nativeImage = getNativeImage(metafile)
936 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
937 Dim procData As Detail.EnumerateMetafileProcData
938 procData.Proc = callback
939 procData.Data = callbackData
940 SetStatus(GdipEnumerateMetafileDestRectI(nativeGraphics,
941 nativeImage, destRect, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
942 End Sub
943
944 Sub EnumerateMetafile(metafile As Metafile, destPoints As *PointF, count As Long,
945 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
946
947 Dim nativeImage = getNativeImage(metafile)
948 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
949 Dim procData As Detail.EnumerateMetafileProcData
950 procData.Proc = callback
951 procData.Data = callbackData
952 SetStatus(GdipEnumerateMetafileDestPoints(nativeGraphics,
953 nativeImage,destPoints, count, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
954 End Sub
955
956 Sub EnumerateMetafile(metafile As Metafile, destPoints As *Point, count As Long,
957 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
958
959 Dim nativeImage = getNativeImage(metafile)
960 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
961 Dim procData As Detail.EnumerateMetafileProcData
962 procData.Proc = callback
963 procData.Data = callbackData
964 SetStatus(GdipEnumerateMetafileDestPointsI(nativeGraphics,
965 nativeImage,destPoints, count, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
966 End Sub
967
968 Sub EnumerateMetafile(metafile As Metafile,
969 ByRef destPoint As PointF, ByRef srcRect As RectangleF, srcUnit As GraphicsUnit,
970 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
971
972 Dim nativeImage = getNativeImage(metafile)
973 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
974 Dim procData As Detail.EnumerateMetafileProcData
975 procData.Proc = callback
976 procData.Data = callbackData
977 SetStatus(GdipEnumerateMetafileSrcRectDestPoint(nativeGraphics,
978 nativeImage, destPoint, srcRect, srcUnit, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
979 End Sub
980
981 Sub EnumerateMetafile(metafile As Metafile,
982 ByRef destPoint As Point, ByRef srcRect As Rectangle, srcUnit As GraphicsUnit,
983 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
984
985 Dim nativeImage = getNativeImage(metafile)
986 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
987 Dim procData As Detail.EnumerateMetafileProcData
988 procData.Proc = callback
989 procData.Data = callbackData
990 SetStatus(GdipEnumerateMetafileSrcRectDestPointI(nativeGraphics,
991 nativeImage, destPoint, srcRect, srcUnit, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
992 End Sub
993
994 Sub EnumerateMetafile(metafile As Metafile,
995 ByRef destRect As RectangleF, ByRef srcRect As RectangleF, srcUnit As GraphicsUnit,
996 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
997
998 Dim nativeImage = getNativeImage(metafile)
999 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
1000 Dim procData As Detail.EnumerateMetafileProcData
1001 procData.Proc = callback
1002 procData.Data = callbackData
1003 SetStatus(GdipEnumerateMetafileSrcRectDestRect(nativeGraphics,
1004 nativeImage, destRect, srcRect, srcUnit, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
1005 End Sub
1006
1007 Sub EnumerateMetafile(metafile As Metafile,
1008 ByRef destRect As Rectangle, ByRef srcRect As Rectangle, srcUnit As GraphicsUnit,
1009 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
1010
1011 Dim nativeImage = getNativeImage(metafile)
1012 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
1013 Dim procData As Detail.EnumerateMetafileProcData
1014 procData.Proc = callback
1015 procData.Data = callbackData
1016 SetStatus(GdipEnumerateMetafileSrcRectDestRectI(nativeGraphics,
1017 nativeImage, destRect, srcRect, srcUnit, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
1018 End Sub
1019
1020 Sub EnumerateMetafile(metafile As Metafile,
1021 destPoints As *PointF, count As Long, ByRef srcRect As RectangleF, srcUnit As GraphicsUnit,
1022 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
1023
1024 Dim nativeImage = getNativeImage(metafile)
1025 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
1026 Dim procData As Detail.EnumerateMetafileProcData
1027 procData.Proc = callback
1028 procData.Data = callbackData
1029 SetStatus(GdipEnumerateMetafileSrcRectDestPoints(nativeGraphics,
1030 nativeImage, destPoints, count, srcRect, srcUnit, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
1031 End Sub
1032
1033 Sub EnumerateMetafile(metafile As Metafile,
1034 destPoints As *Point, count As Long, ByRef srcRect As Rectangle, srcUnit As GraphicsUnit,
1035 callback As EnumerateMetafileProc, callbackData = 0 As VoidPtr, imageAttr = Nothing As ImageAttributes)
1036
1037 Dim nativeImage = getNativeImage(metafile)
1038 Dim nativeImageAttr = getNativeImageAttributes(imageAttr)
1039 Dim procData As Detail.EnumerateMetafileProcData
1040 procData.Proc = callback
1041 procData.Data = callbackData
1042 SetStatus(GdipEnumerateMetafileSrcRectDestPointsI(nativeGraphics, nativeImage,
1043 destPoints, count, srcRect, srcUnit, AddressOf(Detail.NativeEnumerateMetafileProcEntry), VarPtr(procData), nativeImageAttr))
1044 End Sub
1045
1046 Sub SetClip(g As Graphics)
1047 SetClip(g, System.Drawing.Drawing2D.CombineMode.Replace)
1048 End Sub
1049
1050 Sub SetClip(g As Graphics, combineMode As Drawing2D.CombineMode)
1051 SetStatus(GdipSetClipGraphics(nativeGraphics, g.nativeGraphics, combineMode))
1052 End Sub
1053
1054 Sub SetClip(ByRef rc As RectangleF)
1055 SetClip(rc, System.Drawing.Drawing2D.CombineMode.Replace)
1056 End Sub
1057
1058 Sub SetClip(ByRef rc As RectangleF, combineMode As Drawing2D.CombineMode)
1059 SetStatus(GdipSetClipRect(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, combineMode))
1060 End Sub
1061
1062 Sub SetClip(ByRef rc As Rectangle)
1063 SetClip(rc, System.Drawing.Drawing2D.CombineMode.Replace)
1064 End Sub
1065
1066 Sub SetClip(ByRef rc As Rectangle, combineMode As Drawing2D.CombineMode)
1067 SetStatus(GdipSetClipRectI(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, combineMode))
1068 End Sub
1069
1070 Sub SetClip(path As GraphicsPath)
1071 SetClip(path, System.Drawing.Drawing2D.CombineMode.Replace)
1072 End Sub
1073
1074 Sub SetClip(path As GraphicsPath, combineMode As Drawing2D.CombineMode)
1075 SetStatus(GdipSetClipPath(nativeGraphics, path.nativePath, combineMode))
1076 End Sub
1077
1078 Sub SetClip(region As Region)
1079 SetClip(region, System.Drawing.Drawing2D.CombineMode.Replace)
1080 End Sub
1081
1082 Sub SetClip(region As Region, combineMode As Drawing2D.CombineMode)
1083 SetStatus(GdipSetClipRegion(nativeGraphics, region.nativeRegion, combineMode))
1084 End Sub
1085
1086 Sub SetClip(hrgn As HRGN)
1087 SetClip(hrgn, System.Drawing.Drawing2D.CombineMode.Replace)
1088 End Sub
1089
1090 Sub SetClip(hrgn As HRGN, combineMode As Drawing2D.CombineMode)
1091 SetStatus(GdipSetClipHrgn(nativeGraphics, hrgn, combineMode))
1092 End Sub
1093
1094 Sub IntersectClip(ByRef rc As RectangleF)
1095 SetStatus(GdipSetClipRect(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, System.Drawing.Drawing2D.CombineMode.Intersect))
1096 End Sub
1097
1098 Sub IntersectClip(ByRef rc As Rectangle)
1099 SetStatus(GdipSetClipRectI(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, System.Drawing.Drawing2D.CombineMode.Intersect))
1100 End Sub
1101
1102 Sub IntersectClip(region As Region)
1103 SetStatus(GdipSetClipRegion(nativeGraphics, region.nativeRegion, System.Drawing.Drawing2D.CombineMode.Intersect))
1104 End Sub
1105
1106 Sub ExcludeClip(ByRef rc As RectangleF)
1107 SetStatus(GdipSetClipRect(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, System.Drawing.Drawing2D.CombineMode.Exclude))
1108 End Sub
1109
1110 Sub ExcludeClip(ByRef rc As Rectangle)
1111 SetStatus(GdipSetClipRectI(nativeGraphics, rc.X, rc.Y, rc.Width, rc.Height, System.Drawing.Drawing2D.CombineMode.Exclude))
1112 End Sub
1113
1114 Sub ExcludeClip(region As Region)
1115 SetStatus(GdipSetClipRegion(nativeGraphics, region.nativeRegion, System.Drawing.Drawing2D.CombineMode.Exclude))
1116 End Sub
1117
1118 Sub ResetClip()
1119 SetStatus(GdipResetClip(nativeGraphics))
1120 End Sub
1121
1122 Sub TranslateClip(dx As Single, dy As Single)
1123 SetStatus(GdipTranslateClip(nativeGraphics, dx, dy))
1124 End Sub
1125
1126 Sub TranslateClip(dx As Long, dy As Long)
1127 SetStatus(GdipTranslateClipI(nativeGraphics, dx, dy))
1128 End Sub
1129
1130 Const Function IsVisible(x As Long, y As Long) As Boolean
1131 Dim b = FALSE As BOOL
1132 SetStatus(GdipIsVisiblePointI(nativeGraphics, x, y, b))
1133 IsVisible = b As Boolean
1134 End Function
1135
1136 Const Function IsVisible(ByRef pt As Point) As Boolean
1137 IsVisible(pt.X, pt.Y)
1138 End Function
1139
1140 Const Function IsVisible(x As Long, y As Long, width As Long, height As Long) As Boolean
1141 Dim b = FALSE As BOOL
1142 SetStatus(GdipIsVisibleRectI(nativeGraphics, x, y, width, height, b))
1143 IsVisible = b As Boolean
1144 End Function
1145
1146 Const Function IsVisible(ByRef rc As Rectangle) As Boolean
1147 IsVisible = IsVisible(rc.X, rc.Y, rc.Width, rc.Height)
1148 End Function
1149
1150 Const Function IsVisible(x As Single, y As Single) As Boolean
1151 Dim b = FALSE As BOOL
1152 SetStatus(GdipIsVisiblePoint(nativeGraphics, x, y, b))
1153 IsVisible = b As Boolean
1154 End Function
1155
1156 Const Function IsVisible(ByRef pt As PointF) As Boolean
1157 IsVisible = IsVisible(pt.X, pt.Y)
1158 End Function
1159
1160 Const Function IsVisible(x As Single, y As Single, width As Single, height As Single) As Boolean
1161 Dim b = FALSE As BOOL
1162 SetStatus(GdipIsVisibleRect(nativeGraphics, x, y, width, height, b))
1163 IsVisible = b As Boolean
1164 End Function
1165
1166 Const Function IsVisible(ByRef rc As RectangleF) As Boolean
1167 IsVisible = IsVisible(rc.X, rc.Y, rc.Width, rc.Height)
1168 End Function
1169
1170 Const Function Save() As Drawing2D.GraphicsState
1171 SetStatus(GdipSaveGraphics(nativeGraphics, Save))
1172 End Function
1173
1174 Sub Restore(gstate As Drawing2D.GraphicsState)
1175 SetStatus(GdipRestoreGraphics(nativeGraphics, gstate))
1176 End Sub
1177
1178 Function BeginContainer(ByRef dstrect As RectangleF, ByRef srcrect As RectangleF, unit As GraphicsUnit) As Drawing2D.GraphicsContainer
1179 SetStatus(GdipBeginContainer(nativeGraphics, dstrect, srcrect, unit, BeginContainer))
1180 End Function
1181
1182 Function BeginContainer(ByRef dstrect As Rectangle, ByRef srcrect As Rectangle, unit As GraphicsUnit) As Drawing2D.GraphicsContainer
1183 SetStatus(GdipBeginContainerI(nativeGraphics, dstrect, srcrect, unit, BeginContainer))
1184 End Function
1185
1186 Function BeginContainer() As Drawing2D.GraphicsContainer
1187 SetStatus(GdipBeginContainer2(nativeGraphics, BeginContainer))
1188 End Function
1189
1190 Sub EndContainer(state As Drawing2D.GraphicsContainer)
1191 SetStatus(GdipEndContainer(nativeGraphics, state))
1192 End Sub
1193
1194 Sub AddMetafileComment(data As *Byte, sizeData As DWord)
1195 SetStatus(GdipComment(nativeGraphics, sizeData, data))
1196 End Sub
1197
1198 Static Function GetHalftonePalette() As HPALETTE
1199 GdipCreateHalftonePalette()
1200 End Function
1201
1202 Function NativeGraphics() As *GpGraphics
1203 NativeGraphics = nativeGraphics
1204 End Function
1205
1206 Sub Graphics(graphics As *GpGraphics)
1207 nativeGraphics = graphics
1208 End Sub
1209
1210Private
1211 Static Function getNativePen(pen As Pen) As *GpPen
1212 If ActiveBasic.IsNothing(pen) Then
1213 getNativePen = 0
1214 Else
1215 getNativePen = pen.NativePen
1216 End If
1217 End Function
1218
1219 Static Function getNativeBrush(br As Brush) As *GpBrush
1220 If ActiveBasic.IsNothing(br) Then
1221 getNativeBrush = 0
1222 Else
1223 getNativeBrush = br.NativeBrush
1224 End If
1225 End Function
1226
1227 Static Function getNativeFont(font As Font) As *GpFont
1228 If ActiveBasic.IsNothing(font) Then
1229 getNativeFont = 0
1230 Else
1231 getNativeFont = font.NativeFont
1232 End If
1233 End Function
1234
1235 Static Function getNativeImage(image As Image) As *GpImage
1236 If ActiveBasic.IsNothing(image) Then
1237 getNativeImage = 0
1238 Else
1239 getNativeImage = image.NativeImage
1240 End If
1241 End Function
1242
1243 Static Function getNativeImageAttributes(imageAttr As ImageAttributes) As *GpImageAttributes
1244 If ActiveBasic.IsNothing(imageAttr) Then
1245 getNativeImageAttributes = 0
1246 Else
1247 getNativeImageAttributes = imageAttr.nativeImage
1248 End If
1249 End Function
1250
1251 nativeGraphics As *GpGraphics
1252End Class
1253
1254End Namespace
1255End Namespace
Note: See TracBrowser for help on using the repository browser.