2006-08-10 Sebastien Pouliot <sebastien@ximian.com>
[mono.git] / mcs / class / System.Drawing / Test / System.Drawing / GDIPlusTest.cs
1 //
2 // Direct GDI+ API unit tests
3 //
4 // Authors:
5 //      Sebastien Pouliot  <sebastien@ximian.com>
6 //
7 // Copyright (C) 2006 Novell, Inc (http://www.novell.com)
8 //
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 //
28
29 using System;
30 using System.Drawing;
31 using System.Drawing.Drawing2D;
32 using System.Drawing.Imaging;
33 using System.Runtime.InteropServices;
34 using NUnit.Framework;
35
36 namespace MonoTests.System.Drawing {
37
38         // copied from Mono's System.Drawing.dll gdiEnums.cs
39         internal enum Status {
40                 Ok = 0,
41                 GenericError = 1,
42                 InvalidParameter = 2,
43                 OutOfMemory = 3,
44                 ObjectBusy = 4,
45                 InsufficientBuffer = 5,
46                 NotImplemented = 6,
47                 Win32Error = 7,
48                 WrongState = 8,
49                 Aborted = 9,
50                 FileNotFound = 10,
51                 ValueOverflow = 11,
52                 AccessDenied = 12,
53                 UnknownImageFormat = 13,
54                 FontFamilyNotFound = 14,
55                 FontStyleNotFound = 15,
56                 NotTrueTypeFont = 16,
57                 UnsupportedGdiplusVersion = 17,
58                 GdiplusNotInitialized = 18,
59                 PropertyNotFound = 19,
60                 PropertyNotSupported = 20,
61                 ProfileNotFound = 21
62         }
63
64         // copied from Mono's System.Drawing.dll gdiEnums.cs
65         internal enum Unit {
66                 UnitWorld = 0,
67                 UnitDisplay = 1,
68                 UnitPixel = 2,
69                 UnitPoint = 3,
70                 UnitInch = 4,
71                 UnitDocument = 5,
72                 UnitMillimeter = 6
73         }
74
75         [StructLayout (LayoutKind.Sequential, CharSet = CharSet.Auto)]
76         public class LOGFONT {
77                 public int lfHeight = 0;
78                 public int lfWidth = 0;
79                 public int lfEscapement = 0;
80                 public int lfOrientation = 0;
81                 public int lfWeight = 0;
82                 public byte lfItalic = 0;
83                 public byte lfUnderline = 0;
84                 public byte lfStrikeOut = 0;
85                 public byte lfCharSet = 0;
86                 public byte lfOutPrecision = 0;
87                 public byte lfClipPrecision = 0;
88                 public byte lfQuality = 0;
89                 public byte lfPitchAndFamily = 0;
90                 [MarshalAs (UnmanagedType.ByValTStr, SizeConst = 32)]
91                 public string lfFaceName = null;
92         }
93
94         [TestFixture]
95         public class GDIPlusTest {
96
97                 // FontFamily
98
99                 [DllImport ("gdiplus.dll", CharSet=CharSet.Auto)]
100                 internal static extern Status GdipCreateFontFamilyFromName (
101                         [MarshalAs (UnmanagedType.LPWStr)] string fName, IntPtr collection, out IntPtr fontFamily);
102
103                 [DllImport ("gdiplus.dll")]
104                 internal static extern Status GdipGetGenericFontFamilySerif (out IntPtr fontFamily);
105
106                 [DllImport ("gdiplus.dll")]
107                 internal static extern Status GdipDeleteFontFamily (IntPtr fontfamily);
108
109                 [Test]
110                 public void DeleteFontFamily ()
111                 {
112                         // invalid image pointer (null)
113                         Assert.AreEqual (Status.InvalidParameter, GdipDeleteFontFamily (IntPtr.Zero), "null");
114
115                         IntPtr font_family;
116                         GdipCreateFontFamilyFromName ("Arial", IntPtr.Zero, out font_family);
117                         Assert.IsTrue (font_family != IntPtr.Zero, "GdipCreateFontFamilyFromName");
118                         Assert.AreEqual (Status.Ok, GdipDeleteFontFamily (font_family), "first");
119                 }
120
121                 [Test]
122                 [Category ("NotWorking")]
123                 public void DeleteFontFamily_DoubleDispose ()
124                 {
125                         IntPtr font_family;
126                         GdipGetGenericFontFamilySerif (out font_family);
127                         // first dispose
128                         Assert.AreEqual (Status.Ok, GdipDeleteFontFamily (font_family), "first");
129                         // second dispose
130                         Assert.AreEqual (Status.Ok, GdipDeleteFontFamily (font_family), "second");
131                 }
132
133                 // Font
134
135                 [DllImport ("gdiplus.dll")]
136                 internal static extern Status GdipCreateFont (IntPtr fontFamily, float emSize, FontStyle style, GraphicsUnit unit, out IntPtr font);
137
138                 [DllImport ("gdiplus.dll", CharSet = CharSet.Auto)]
139                 internal static extern Status GdipGetLogFont (IntPtr font, IntPtr graphics, [MarshalAs (UnmanagedType.AsAny), Out] object logfontA);
140
141                 [DllImport ("gdiplus.dll")]
142                 internal static extern Status GdipDeleteFont (IntPtr font);             
143
144                 [Test]
145                 public void CreateFont ()
146                 {
147                         IntPtr family;
148                         GdipCreateFontFamilyFromName ("Arial", IntPtr.Zero, out family);
149                         Assert.IsTrue (family != IntPtr.Zero, "family");
150
151                         IntPtr font;
152                         Assert.AreEqual (Status.Ok, GdipCreateFont (family, 10f, FontStyle.Regular, GraphicsUnit.Point, out font), "GdipCreateFont");
153                         Assert.IsTrue (font != IntPtr.Zero, "font");
154
155                         LOGFONT lf = new LOGFONT ();
156                         lf.lfCharSet = 1;
157                         Assert.AreEqual (Status.InvalidParameter, GdipGetLogFont (font, IntPtr.Zero, (object) lf), "GdipGetLogFont-null-graphics");
158                         Assert.AreEqual (0, lf.lfCharSet, "lfCharSet-null-graphics");
159
160                         IntPtr image;
161                         GdipCreateBitmapFromScan0 (10, 10, 0, PixelFormat.Format32bppArgb, IntPtr.Zero, out image);
162                         Assert.IsTrue (image != IntPtr.Zero, "image");
163
164                         IntPtr graphics;
165                         GdipGetImageGraphicsContext (image, out graphics);
166                         Assert.IsTrue (graphics != IntPtr.Zero, "graphics");
167
168                         lf.lfCharSet = 1;
169                         Assert.AreEqual (Status.InvalidParameter, GdipGetLogFont (IntPtr.Zero, graphics, (object) lf), "GdipGetLogFont-null");
170                         Assert.AreEqual (0, lf.lfCharSet, "lfCharSet-null");
171
172                         lf.lfCharSet = 1;
173                         Assert.AreEqual (Status.Ok, GdipGetLogFont (font, graphics, (object) lf), "GdipGetLogFont");
174                         Assert.AreEqual (0, lf.lfCharSet, "lfCharSet");
175                         // strangely this is 1 in the managed side
176
177                         Assert.AreEqual (Status.Ok, GdipDeleteFont (font), "GdipDeleteFont");
178                         Assert.AreEqual (Status.InvalidParameter, GdipDeleteFont (IntPtr.Zero), "GdipDeleteFont-null");
179
180                         Assert.AreEqual (Status.Ok, GdipDeleteFontFamily (family), "GdipDeleteFontFamily");
181                         Assert.AreEqual (Status.Ok, GdipDisposeImage (image), "GdipDisposeImage");
182                         Assert.AreEqual (Status.Ok, GdipDeleteGraphics (graphics), "GdipDeleteGraphics");
183                 }
184
185                 // Bitmap
186
187                 [DllImport ("gdiplus.dll")]
188                 internal static extern Status GdipCreateBitmapFromScan0 (int width, int height, int stride, PixelFormat format, IntPtr scan0, out IntPtr bmp);
189
190                 [Test]
191                 public void CreateBitmapFromScan0 ()
192                 {
193                         IntPtr bmp;
194                         Assert.AreEqual (Status.InvalidParameter, GdipCreateBitmapFromScan0 (-1, 10, 10, PixelFormat.Format32bppArgb, IntPtr.Zero, out bmp), "negative width");
195                 }
196
197                 // Brush
198
199                 [DllImport ("gdiplus.dll")]
200                 static internal extern Status GdipDeleteBrush (IntPtr brush);
201
202                 [Test]
203                 public void DeleteBrush ()
204                 {
205                         Assert.AreEqual (Status.InvalidParameter, GdipDeleteBrush (IntPtr.Zero), "GdipDeleteBrush");
206                 }
207
208                 // Graphics
209
210                 [DllImport ("gdiplus.dll")]
211                 internal static extern Status GdipGetImageGraphicsContext (IntPtr image, out IntPtr graphics);
212
213                 [DllImport ("gdiplus.dll")]
214                 static internal extern Status GdipDeleteGraphics (IntPtr graphics);
215
216                 [Test]
217                 public void Graphics ()
218                 {
219                         IntPtr graphics;
220                         Assert.AreEqual (Status.InvalidParameter, GdipGetImageGraphicsContext (IntPtr.Zero, out graphics), "GdipGetImageGraphicsContext");
221
222                         IntPtr image;
223                         GdipCreateBitmapFromScan0 (10, 10, 0, PixelFormat.Format32bppArgb, IntPtr.Zero, out image);
224                         Assert.IsTrue (image != IntPtr.Zero, "image");
225
226                         Assert.AreEqual (Status.Ok, GdipGetImageGraphicsContext (image, out graphics), "GdipGetImageGraphicsContext");
227                         Assert.IsTrue (graphics != IntPtr.Zero, "graphics");
228
229                         Assert.AreEqual (Status.Ok, GdipDeleteGraphics (graphics), "GdipDeleteGraphics");
230                         Assert.AreEqual (Status.InvalidParameter, GdipDeleteGraphics (IntPtr.Zero), "GdipDeleteGraphics-null");
231
232                         Assert.AreEqual (Status.Ok, GdipDisposeImage (image), "GdipDisposeImage");
233                 }
234
235                 // GraphicsPath
236
237                 [DllImport ("gdiplus.dll")]
238                 internal static extern Status GdipCreatePath (FillMode brushMode, out IntPtr path);
239
240                 [DllImport ("gdiplus.dll")]
241                 internal static extern Status GdipGetPointCount (IntPtr path, out int count);
242
243                 [DllImport ("gdiplus.dll")]
244                 internal static extern Status GdipGetPathPoints (IntPtr path, [Out] PointF[] points, int count);
245
246                 [DllImport ("gdiplus.dll")]
247                 internal static extern Status GdipGetPathTypes (IntPtr path, [Out] byte[] types, int count);
248
249                 [DllImport ("gdiplus.dll")]
250                 internal static extern Status GdipResetPath (IntPtr path);
251
252                 [DllImport ("gdiplus.dll")]
253                 internal static extern Status GdipWidenPath (IntPtr path, IntPtr pen, IntPtr matrix, float flatness);
254
255                 [DllImport ("gdiplus.dll")]                
256                 internal static extern Status GdipDeletePath (IntPtr path);
257
258                 [Test]
259                 public void GetPointCount_Zero ()
260                 {
261                         IntPtr path;
262                         Assert.AreEqual (Status.Ok, GdipCreatePath (FillMode.Alternate, out path), "GdipCreatePath");
263                         Assert.IsTrue (path != IntPtr.Zero, "Handle");
264
265                         int count;
266                         Assert.AreEqual (Status.InvalidParameter, GdipGetPointCount (IntPtr.Zero, out count), "GdipGetPointCount-null");
267                         Assert.AreEqual (Status.Ok, GdipGetPointCount (path, out count), "GdipGetPointCount");
268                         Assert.AreEqual (0, count, "Count");
269
270                         PointF[] points = new PointF[count];
271                         Assert.AreEqual (Status.InvalidParameter, GdipGetPathPoints (IntPtr.Zero, points, count), "GdipGetPathPoints-null-1");
272                         Assert.AreEqual (Status.InvalidParameter, GdipGetPathPoints (path, null, count), "GdipGetPathPoints-null-2");
273                         Assert.AreEqual (Status.InvalidParameter, GdipGetPathPoints (path, points, count), "GdipGetPathPoints");
274                         // can't get the points if the count is zero!
275
276                         byte[] types = new byte[count];
277                         Assert.AreEqual (Status.InvalidParameter, GdipGetPathTypes (IntPtr.Zero, types, count), "GdipGetPathTypes-null-1");
278                         Assert.AreEqual (Status.InvalidParameter, GdipGetPathTypes (path, null, count), "GdipGetPathTypes-null-2");
279                         Assert.AreEqual (Status.InvalidParameter, GdipGetPathTypes (path, types, count), "GdipGetPathTypes");
280                         // can't get the types if the count is zero!
281
282                         Assert.AreEqual (Status.Ok, GdipResetPath (path), "GdipResetPath");
283                         Assert.AreEqual (Status.InvalidParameter, GdipResetPath (IntPtr.Zero), "GdipResetPath-null");
284
285                         Assert.AreEqual (Status.Ok, GdipDeletePath (path), "GdipDeletePath");
286                         Assert.AreEqual (Status.InvalidParameter, GdipDeletePath (IntPtr.Zero), "GdipDeletePath-null");
287                 }
288
289                 [Test]
290                 public void Widen ()
291                 {
292                         IntPtr pen;
293                         Assert.AreEqual (Status.Ok, GdipCreatePen1 (0, 0f, Unit.UnitWorld, out pen), "GdipCreatePen1");
294
295                         IntPtr path;
296                         Assert.AreEqual (Status.Ok, GdipCreatePath (FillMode.Alternate, out path), "GdipCreatePath");
297
298                         IntPtr matrix;
299                         Assert.AreEqual (Status.Ok, GdipCreateMatrix (out matrix), "GdipCreateMatrix");
300
301                         Assert.AreEqual (Status.InvalidParameter, GdipWidenPath (IntPtr.Zero, pen, matrix, 1.0f), "GdipWidenPath-null-path");
302                         // empty path
303                         Assert.AreEqual (Status.OutOfMemory, GdipWidenPath (path, pen, matrix, 1.0f), "GdipWidenPath");
304
305                         // todo: add something to the path
306
307                         Assert.AreEqual (Status.Ok, GdipDeleteMatrix (matrix), "GdipDeleteMatrix");
308                         Assert.AreEqual (Status.Ok, GdipDeletePath (path), "GdipDeletePath");
309                         Assert.AreEqual (Status.Ok, GdipDeletePen (pen), "GdipDeletePen");
310                 }
311
312                 // Matrix
313
314                 [DllImport ("gdiplus.dll")]
315                 internal static extern Status GdipCreateMatrix (out IntPtr matrix);
316
317                 [DllImport ("gdiplus.dll")]
318                 internal static extern Status GdipDeleteMatrix (IntPtr matrix);
319
320                 [Test]
321                 public void Matrix ()
322                 {
323                         IntPtr matrix;
324                         Assert.AreEqual (Status.Ok, GdipCreateMatrix (out matrix), "GdipCreateMatrix");
325                         Assert.IsTrue (matrix != IntPtr.Zero, "Handle");
326
327                         Assert.AreEqual (Status.InvalidParameter, GdipDeleteMatrix (IntPtr.Zero), "GdipDeleteMatrix-null");
328                         Assert.AreEqual (Status.Ok, GdipDeleteMatrix (matrix), "GdipDeleteMatrix");
329                 }
330
331                 // Image
332
333                 [DllImport ("gdiplus.dll")]
334                 internal static extern Status GdipDisposeImage (IntPtr image);
335
336                 [Test]
337                 public void DisposeImage ()
338                 {
339                         // invalid image pointer (null)
340                         Assert.AreEqual (Status.InvalidParameter, GdipDisposeImage (IntPtr.Zero), "null");
341
342                         IntPtr image;
343                         GdipCreateBitmapFromScan0 (10, 10, 0, PixelFormat.Format32bppArgb, IntPtr.Zero, out image);
344                         Assert.AreEqual (Status.Ok, GdipDisposeImage (image), "first");
345                 }
346
347                 [Test]
348                 [Category ("NotWorking")]
349                 public void DisposeImage_Dual ()
350                 {
351                         IntPtr image;
352                         GdipCreateBitmapFromScan0 (10, 10, 0, PixelFormat.Format32bppArgb, IntPtr.Zero, out image);
353                         // first dispose
354                         Assert.AreEqual (Status.Ok, GdipDisposeImage (image), "first");
355                         // second dispose
356                         Assert.AreEqual (Status.ObjectBusy, GdipDisposeImage (image), "second");
357                 }
358
359
360                 [DllImport ("gdiplus.dll")]
361                 internal static extern Status GdipGetImageThumbnail (IntPtr image, uint width, uint height, out IntPtr thumbImage, IntPtr callback, IntPtr callBackData);
362
363                 [Test]
364                 [Category ("NotWorking")] // libgdiplus doesn't implement GdipGetImageThumbnail (it is done inside S.D)
365                 public void GetImageThumbnail ()
366                 {
367                         IntPtr ptr;
368
369                         // invalid image pointer (null)
370                         Assert.AreEqual (Status.InvalidParameter, GdipGetImageThumbnail (IntPtr.Zero, 10, 10, out ptr, IntPtr.Zero, IntPtr.Zero));
371
372                         IntPtr image;
373                         GdipCreateBitmapFromScan0 (10, 10, 0, PixelFormat.Format32bppArgb, IntPtr.Zero, out image);
374                         try {
375                                 // invalid width (0)
376                                 Assert.AreEqual (Status.OutOfMemory, GdipGetImageThumbnail (image, 0, 10, out ptr, IntPtr.Zero, IntPtr.Zero));
377                                 // invalid width (negative)
378                                 Assert.AreEqual (Status.OutOfMemory, GdipGetImageThumbnail (image, 0x8000000, 10, out ptr, IntPtr.Zero, IntPtr.Zero));
379                                 // invalid height (0)
380                                 Assert.AreEqual (Status.OutOfMemory, GdipGetImageThumbnail (image, 10, 0, out ptr, IntPtr.Zero, IntPtr.Zero));
381                                 // invalid height (negative)
382                                 Assert.AreEqual (Status.OutOfMemory, GdipGetImageThumbnail (image, 10, 0x8000000, out ptr, IntPtr.Zero, IntPtr.Zero));
383                         }
384                         finally {
385                                 GdipDisposeImage (image);
386                         }
387                 }
388
389                 // PathGradientBrush
390
391                 [DllImport ("gdiplus.dll")]
392                 static internal extern Status GdipCreatePathGradient (PointF[] points, int count, WrapMode wrapMode, out IntPtr brush);
393
394                 [DllImport ("gdiplus.dll")]
395                 static internal extern Status GdipGetPathGradientBlendCount (IntPtr brush, out int count);
396
397                 [DllImport ("gdiplus.dll")]
398                 static internal extern Status GdipGetPathGradientPresetBlend (IntPtr brush, int[] blend, float[] positions, int count);
399
400
401                 [Test]
402                 public void CreatePathGradient ()
403                 {
404                         PointF[] points = null;
405                         IntPtr brush;
406                         Assert.AreEqual (Status.OutOfMemory, GdipCreatePathGradient (points, 0, WrapMode.Clamp, out brush), "null");
407
408                         points = new PointF [0];
409                         Assert.AreEqual (Status.OutOfMemory, GdipCreatePathGradient (points, 0, WrapMode.Clamp, out brush), "empty");
410
411                         points = new PointF[1];
412                         Assert.AreEqual (Status.OutOfMemory, GdipCreatePathGradient (points, 1, WrapMode.Clamp, out brush), "one");
413
414                         points = new PointF[2] { new PointF (1, 2), new PointF (20, 30) };
415                         Assert.AreEqual (Status.Ok, GdipCreatePathGradient (points, 2, WrapMode.Clamp, out brush), "two");
416
417                         int count;
418                         Assert.AreEqual (Status.Ok, GdipGetPathGradientBlendCount (brush, out count), "GdipGetPathGradientBlendCount");
419                         Assert.AreEqual (1, count, "blend count");
420
421                         int[] colors = new int[count];
422                         float[] positions = new float[count];
423                         Assert.AreEqual (Status.InvalidParameter, GdipGetPathGradientPresetBlend (brush, colors, positions, count), "GdipGetPathGradientBlend");
424                         // can't call that for 1 count!
425
426                         Assert.AreEqual (Status.Ok, GdipDeleteBrush (brush), "GdipDeleteBrush");
427                 }
428
429                 // Pen
430
431                 [DllImport ("gdiplus.dll")]
432                 internal static extern Status GdipCreatePen1 (int argb, float width, Unit unit, out IntPtr pen);
433
434                 [DllImport ("gdiplus.dll")]
435                 internal static extern Status GdipGetPenDashStyle (IntPtr pen, out DashStyle dashStyle);
436
437                 [DllImport ("gdiplus.dll")]
438                 internal static extern Status GdipSetPenDashStyle (IntPtr pen, DashStyle dashStyle);
439
440                 [DllImport ("gdiplus.dll")]
441                 internal static extern Status GdipGetPenDashCount (IntPtr pen, out int count);
442
443                 [DllImport ("gdiplus.dll")]
444                 internal static extern Status GdipGetPenDashArray (IntPtr pen, float[] dash, int count);
445
446                 [DllImport ("gdiplus.dll")]
447                 internal static extern Status GdipDeletePen (IntPtr pen);
448
449                 [Test]
450                 public void CreatePen ()
451                 {
452                         IntPtr pen;
453                         Assert.AreEqual (Status.Ok, GdipCreatePen1 (0, 0f, Unit.UnitWorld, out pen), "GdipCreatePen1");
454                         Assert.IsTrue (pen != IntPtr.Zero, "pen");
455
456                         DashStyle ds;
457                         Assert.AreEqual (Status.Ok, GdipGetPenDashStyle (pen, out ds), "GdipGetPenDashStyle");
458                         Assert.AreEqual (Status.InvalidParameter, GdipGetPenDashStyle (IntPtr.Zero, out ds), "GdipGetPenDashStyle-null");
459
460                         ds = DashStyle.Custom;
461                         Assert.AreEqual (Status.Ok, GdipSetPenDashStyle (pen, ds), "GdipSetPenDashStyle");
462                         Assert.AreEqual (Status.InvalidParameter, GdipSetPenDashStyle (IntPtr.Zero, ds), "GdipSetPenDashStyle-null");
463
464                         int count;
465                         Assert.AreEqual (Status.Ok, GdipGetPenDashCount (pen, out count), "GdipGetPenDashCount");
466                         Assert.AreEqual (Status.InvalidParameter, GdipGetPenDashCount (IntPtr.Zero, out count), "GdipGetPenDashCount-null");
467                         Assert.AreEqual (0, count, "count");
468
469                         float[] dash = new float[count];
470                         Assert.AreEqual (Status.OutOfMemory, GdipGetPenDashArray (pen, dash, count), "GdipGetPenDashArray");
471                         Assert.AreEqual (Status.InvalidParameter, GdipGetPenDashArray (IntPtr.Zero, dash, count), "GdipGetPenDashArray-null-pen");
472                         Assert.AreEqual (Status.InvalidParameter, GdipGetPenDashArray (pen, null, count), "GdipGetPenDashArray-null-dash");
473
474                         Assert.AreEqual (Status.Ok, GdipDeletePen (pen), "GdipDeletePen");
475                         Assert.AreEqual (Status.InvalidParameter, GdipDeletePen (IntPtr.Zero), "GdipDeletePen-null");
476                 }
477
478                 // Region
479
480                 [DllImport ("gdiplus.dll")]
481                 static internal extern Status GdipCreateRegionRgnData (byte[] data, int size, out IntPtr region);
482
483                 [Test]
484                 public void CreateRegionRgnData ()
485                 {
486                         IntPtr region;
487                         Assert.AreEqual (Status.InvalidParameter, GdipCreateRegionRgnData (null, 0, out region));
488
489                         byte[] data = new byte[0];
490                         Assert.AreEqual (Status.GenericError, GdipCreateRegionRgnData (data, 0, out region));
491                 }
492         }
493 }