1 /*
2 * gdiplusimpl.h
3 *
4 * GDI+ Bitmap, CachedBitmap, CustomLineCap, Font, FontCollection, FontFamily,
5 * Image, InstalledFontCollection, PrivateFontCollection, Region
6 * implementation. Definitions of these classes are in gdiplusheaders.h.
7 *
8 * This file is part of the w32api package.
9 *
10 * Contributors:
11 * Created by Markus Koenig <markus@stber-koenig.de>
12 *
13 * THIS SOFTWARE IS NOT COPYRIGHTED
14 *
15 * This source code is offered for use in the public domain. You may
16 * use, modify or distribute it freely.
17 *
18 * This code is distributed in the hope that it will be useful but
19 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
20 * DISCLAIMED. This includes but is not limited to warranties of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 *
23 */
24
25 #ifndef __GDIPLUS_IMPL_H
26 #define __GDIPLUS_IMPL_H
27 #if __GNUC__ >=3
28 #pragma GCC system_header
29 #endif
30
31 #ifndef __cplusplus
32 #error "A C++ compiler is required to include gdiplusimpl.h."
33 #endif
34
35 /*
36 * FIXME: I called this file gdiplusimpl.h, but what should it really be called?
37 * Or did Microsoft create separate files for each class implemented here?
38 */
39
40
41 // Image
42
FromFile(const WCHAR * filename,BOOL useEmbeddedColorManagement)43 __inline__ Image* Image::FromFile(const WCHAR *filename,
44 BOOL useEmbeddedColorManagement)
45 {
46 return new Image(filename, useEmbeddedColorManagement);
47 }
48
FromStream(IStream * stream,BOOL useEmbeddedColorManagement)49 __inline__ Image* Image::FromStream(IStream *stream,
50 BOOL useEmbeddedColorManagement)
51 {
52 return new Image(stream, useEmbeddedColorManagement);
53 }
54
Image(const WCHAR * filename,BOOL useEmbeddedColorManagement)55 __inline__ Image::Image(const WCHAR *filename, BOOL useEmbeddedColorManagement):
56 nativeImage(NULL), lastStatus(Ok)
57 {
58 if (useEmbeddedColorManagement) {
59 lastStatus = DllExports::GdipLoadImageFromFileICM(
60 filename, &nativeImage);
61 } else {
62 lastStatus = DllExports::GdipLoadImageFromFile(
63 filename, &nativeImage);
64 }
65 }
66
Image(IStream * stream,BOOL useEmbeddedColorManagement)67 __inline__ Image::Image(IStream *stream, BOOL useEmbeddedColorManagement):
68 nativeImage(NULL), lastStatus(Ok)
69 {
70 if (useEmbeddedColorManagement) {
71 lastStatus = DllExports::GdipLoadImageFromStreamICM(
72 stream, &nativeImage);
73 } else {
74 lastStatus = DllExports::GdipLoadImageFromStream(
75 stream, &nativeImage);
76 }
77 }
78
FindFirstItem(ImageItemData * item)79 __inline__ Status Image::FindFirstItem(ImageItemData *item)
80 {
81 // FIXME: can't test GdipFindFirstImageItem b/c it isn't exported in 1.0
82 return updateStatus(DllExports::GdipFindFirstImageItem(
83 nativeImage, item));
84 }
85
FindNextItem(ImageItemData * item)86 __inline__ Status Image::FindNextItem(ImageItemData *item)
87 {
88 // FIXME: can't test GdipFindFirstImageItem b/c it isn't exported in 1.0
89 return updateStatus(DllExports::GdipFindNextImageItem(
90 nativeImage, item));
91 }
92
GetAllPropertyItems(UINT totalBufferSize,UINT numProperties,PropertyItem * allItems)93 __inline__ Status Image::GetAllPropertyItems(UINT totalBufferSize,
94 UINT numProperties, PropertyItem *allItems)
95 {
96 return updateStatus(DllExports::GdipGetAllPropertyItems(
97 nativeImage, totalBufferSize, numProperties, allItems));
98 }
99
GetBounds(RectF * srcRect,Unit * srcUnit)100 __inline__ Status Image::GetBounds(RectF *srcRect, Unit *srcUnit)
101 {
102 return updateStatus(DllExports::GdipGetImageBounds(
103 nativeImage, srcRect, srcUnit));
104 }
105
GetEncoderParameterList(const CLSID * clsidEncoder,UINT size,EncoderParameters * buffer)106 __inline__ Status Image::GetEncoderParameterList(const CLSID *clsidEncoder,
107 UINT size, EncoderParameters *buffer)
108 {
109 return updateStatus(DllExports::GdipGetEncoderParameterList(
110 nativeImage, clsidEncoder, size, buffer));
111 }
112
GetEncoderParameterListSize(const CLSID * clsidEncoder)113 __inline__ UINT Image::GetEncoderParameterListSize(const CLSID *clsidEncoder)
114 {
115 UINT result = 0;
116 updateStatus(DllExports::GdipGetEncoderParameterListSize(
117 nativeImage, clsidEncoder, &result));
118 return result;
119 }
120
GetFlags()121 __inline__ UINT Image::GetFlags()
122 {
123 UINT result = 0;
124 updateStatus(DllExports::GdipGetImageFlags(nativeImage, &result));
125 return result;
126 }
127
GetFrameCount(const GUID * dimensionID)128 __inline__ UINT Image::GetFrameCount(const GUID *dimensionID)
129 {
130 UINT result = 0;
131 updateStatus(DllExports::GdipImageGetFrameCount(
132 nativeImage, dimensionID, &result));
133 return result;
134 }
135
GetFrameDimensionsCount()136 __inline__ UINT Image::GetFrameDimensionsCount()
137 {
138 UINT result = 0;
139 updateStatus(DllExports::GdipImageGetFrameDimensionsCount(
140 nativeImage, &result));
141 return result;
142 }
143
GetFrameDimensionsList(GUID * dimensionIDs,UINT count)144 __inline__ Status Image::GetFrameDimensionsList(GUID *dimensionIDs, UINT count)
145 {
146 return updateStatus(DllExports::GdipImageGetFrameDimensionsList(
147 nativeImage, dimensionIDs, count));
148 }
149
GetHeight()150 __inline__ UINT Image::GetHeight()
151 {
152 UINT result = 0;
153 updateStatus(DllExports::GdipGetImageHeight(nativeImage, &result));
154 return result;
155 }
156
GetHorizontalResolution()157 __inline__ REAL Image::GetHorizontalResolution()
158 {
159 REAL result = 0.0f;
160 updateStatus(DllExports::GdipGetImageHorizontalResolution(
161 nativeImage, &result));
162 return result;
163 }
164
GetItemData(ImageItemData * item)165 __inline__ Status Image::GetItemData(ImageItemData *item)
166 {
167 // FIXME: can't test GdipGetImageItemData b/c it isn't exported in 1.0
168 return updateStatus(DllExports::GdipGetImageItemData(
169 nativeImage, item));
170 }
171
GetPalette(ColorPalette * palette,INT size)172 __inline__ Status Image::GetPalette(ColorPalette *palette, INT size)
173 {
174 return updateStatus(DllExports::GdipGetImagePalette(
175 nativeImage, palette, size));
176 }
177
GetPaletteSize()178 __inline__ INT Image::GetPaletteSize()
179 {
180 INT result = 0;
181 updateStatus(DllExports::GdipGetImagePaletteSize(nativeImage, &result));
182 return result;
183 }
184
GetPhysicalDimension(SizeF * size)185 __inline__ Status Image::GetPhysicalDimension(SizeF *size)
186 {
187 if (!size) return lastStatus = InvalidParameter;
188 return updateStatus(DllExports::GdipGetImageDimension(
189 nativeImage, &size->Width, &size->Height));
190 }
191
GetPixelFormat()192 __inline__ PixelFormat Image::GetPixelFormat()
193 {
194 PixelFormat result = (PixelFormat) 0;
195 updateStatus(DllExports::GdipGetImagePixelFormat(nativeImage, &result));
196 return result;
197 }
198
GetPropertyCount()199 __inline__ UINT Image::GetPropertyCount()
200 {
201 UINT result = 0;
202 updateStatus(DllExports::GdipGetPropertyCount(nativeImage, &result));
203 return result;
204 }
205
GetPropertyIdList(UINT numOfProperty,PROPID * list)206 __inline__ Status Image::GetPropertyIdList(UINT numOfProperty, PROPID *list)
207 {
208 return updateStatus(DllExports::GdipGetPropertyIdList(
209 nativeImage, numOfProperty, list));
210 }
211
GetPropertyItem(PROPID propId,UINT propSize,PropertyItem * buffer)212 __inline__ Status Image::GetPropertyItem(PROPID propId, UINT propSize,
213 PropertyItem *buffer)
214 {
215 return updateStatus(DllExports::GdipGetPropertyItem(
216 nativeImage, propId, propSize, buffer));
217 }
218
GetPropertyItemSize(PROPID propId)219 __inline__ UINT Image::GetPropertyItemSize(PROPID propId)
220 {
221 UINT result = 0;
222 updateStatus(DllExports::GdipGetPropertyItemSize(
223 nativeImage, propId, &result));
224 return result;
225 }
226
GetPropertySize(UINT * totalBufferSize,UINT * numProperties)227 __inline__ Status Image::GetPropertySize(
228 UINT *totalBufferSize, UINT *numProperties)
229 {
230 return updateStatus(DllExports::GdipGetPropertySize(
231 nativeImage, totalBufferSize, numProperties));
232 }
233
GetRawFormat(GUID * format)234 __inline__ Status Image::GetRawFormat(GUID *format)
235 {
236 return updateStatus(DllExports::GdipGetImageRawFormat(
237 nativeImage, format));
238 }
239
GetThumbnailImage(UINT thumbWidth,UINT thumbHeight,GetThumbnailImageAbort callback,VOID * callbackData)240 __inline__ Image* Image::GetThumbnailImage(UINT thumbWidth, UINT thumbHeight,
241 GetThumbnailImageAbort callback, VOID *callbackData)
242 {
243 GpImage *thumbImage = NULL;
244 Status status = updateStatus(DllExports::GdipGetImageThumbnail(
245 nativeImage, thumbWidth, thumbHeight, &thumbImage,
246 callback, callbackData));
247
248 if (status == Ok) {
249 Image *result = new Image(thumbImage, Ok);
250 if (!result) {
251 DllExports::GdipDisposeImage(thumbImage);
252 lastStatus = OutOfMemory;
253 }
254 return result;
255 } else {
256 return NULL;
257 }
258 }
259
GetType()260 __inline__ ImageType Image::GetType() const
261 {
262 ImageType result = ImageTypeUnknown;
263 updateStatus(DllExports::GdipGetImageType(nativeImage, &result));
264 return result;
265 }
266
GetVerticalResolution()267 __inline__ REAL Image::GetVerticalResolution()
268 {
269 REAL result = 0.0f;
270 updateStatus(DllExports::GdipGetImageVerticalResolution(
271 nativeImage, &result));
272 return result;
273 }
274
GetWidth()275 __inline__ UINT Image::GetWidth()
276 {
277 UINT result = 0;
278 updateStatus(DllExports::GdipGetImageWidth(nativeImage, &result));
279 return result;
280 }
281
RemovePropertyItem(PROPID propId)282 __inline__ Status Image::RemovePropertyItem(PROPID propId)
283 {
284 return updateStatus(DllExports::GdipRemovePropertyItem(
285 nativeImage, propId));
286 }
287
RotateFlip(RotateFlipType rotateFlipType)288 __inline__ Status Image::RotateFlip(RotateFlipType rotateFlipType)
289 {
290 return updateStatus(DllExports::GdipImageRotateFlip(
291 nativeImage, rotateFlipType));
292 }
293
Save(const WCHAR * filename,const CLSID * clsidEncoder,const EncoderParameters * encoderParams)294 __inline__ Status Image::Save(const WCHAR *filename, const CLSID *clsidEncoder,
295 const EncoderParameters *encoderParams)
296 {
297 return updateStatus(DllExports::GdipSaveImageToFile(
298 nativeImage, filename, clsidEncoder, encoderParams));
299 }
300
Save(IStream * stream,const CLSID * clsidEncoder,const EncoderParameters * encoderParams)301 __inline__ Status Image::Save(IStream *stream, const CLSID *clsidEncoder,
302 const EncoderParameters *encoderParams)
303 {
304 return updateStatus(DllExports::GdipSaveImageToStream(
305 nativeImage, stream, clsidEncoder, encoderParams));
306 }
307
SaveAdd(const EncoderParameters * encoderParams)308 __inline__ Status Image::SaveAdd(const EncoderParameters *encoderParams)
309 {
310 return updateStatus(DllExports::GdipSaveAdd(
311 nativeImage, encoderParams));
312 }
313
SaveAdd(Image * newImage,const EncoderParameters * encoderParams)314 __inline__ Status Image::SaveAdd(Image *newImage,
315 const EncoderParameters *encoderParams)
316 {
317 return updateStatus(DllExports::GdipSaveAddImage(
318 nativeImage,
319 newImage ? newImage->nativeImage : NULL,
320 encoderParams));
321 }
322
SelectActiveFrame(const GUID * dimensionID,UINT frameIndex)323 __inline__ Status Image::SelectActiveFrame(
324 const GUID *dimensionID, UINT frameIndex)
325 {
326 return updateStatus(DllExports::GdipImageSelectActiveFrame(
327 nativeImage, dimensionID, frameIndex));
328 }
329
SetAbort(GdiplusAbort * pIAbort)330 __inline__ Status Image::SetAbort(GdiplusAbort *pIAbort)
331 {
332 // FIXME: can't test GdipImageSetAbort because it isn't exported in 1.0
333 return updateStatus(DllExports::GdipImageSetAbort(
334 nativeImage, pIAbort));
335 }
336
SetPalette(const ColorPalette * palette)337 __inline__ Status Image::SetPalette(const ColorPalette *palette)
338 {
339 return updateStatus(DllExports::GdipSetImagePalette(
340 nativeImage, palette));
341 }
342
SetPropertyItem(const PropertyItem * item)343 __inline__ Status Image::SetPropertyItem(const PropertyItem *item)
344 {
345 return updateStatus(DllExports::GdipSetPropertyItem(nativeImage, item));
346 }
347
348
349 // Bitmap
350
FromBITMAPINFO(const BITMAPINFO * gdiBitmapInfo,VOID * gdiBitmapData)351 __inline__ Bitmap* Bitmap::FromBITMAPINFO(const BITMAPINFO *gdiBitmapInfo,
352 VOID *gdiBitmapData)
353 {
354 return new Bitmap(gdiBitmapInfo, gdiBitmapData);
355 }
356
FromDirectDrawSurface7(IDirectDrawSurface7 * surface)357 __inline__ Bitmap* Bitmap::FromDirectDrawSurface7(IDirectDrawSurface7 *surface)
358 {
359 return new Bitmap(surface);
360 }
361
FromFile(const WCHAR * filename,BOOL useEmbeddedColorManagement)362 __inline__ Bitmap* Bitmap::FromFile(const WCHAR *filename,
363 BOOL useEmbeddedColorManagement)
364 {
365 return new Bitmap(filename, useEmbeddedColorManagement);
366 }
367
FromHBITMAP(HBITMAP hbm,HPALETTE hpal)368 __inline__ Bitmap* Bitmap::FromHBITMAP(HBITMAP hbm, HPALETTE hpal)
369 {
370 return new Bitmap(hbm, hpal);
371 }
372
FromHICON(HICON icon)373 __inline__ Bitmap* Bitmap::FromHICON(HICON icon)
374 {
375 return new Bitmap(icon);
376 }
377
FromResource(HINSTANCE hInstance,const WCHAR * bitmapName)378 __inline__ Bitmap* Bitmap::FromResource(
379 HINSTANCE hInstance, const WCHAR *bitmapName)
380 {
381 return new Bitmap(hInstance, bitmapName);
382 }
383
FromStream(IStream * stream,BOOL useEmbeddedColorManagement)384 __inline__ Bitmap* Bitmap::FromStream(IStream *stream,
385 BOOL useEmbeddedColorManagement)
386 {
387 return new Bitmap(stream, useEmbeddedColorManagement);
388 }
389
390 //TODO: [GDI+ 1.1] Bitmap::ApplyEffect
391 //__inline__ Status Bitmap::ApplyEffect(Bitmap **inputs, INT numInputs,
392 // Effect *effect, RECT *ROI, RECT *outputRect, Bitmap **output)
393 //{
394 // return NotImplemented;
395 //}
396
InitializePalette(ColorPalette * palette,PaletteType paletteType,INT optimalColors,BOOL useTransparentColor,Bitmap * bitmap)397 __inline__ Status Bitmap::InitializePalette(ColorPalette *palette,
398 PaletteType paletteType, INT optimalColors,
399 BOOL useTransparentColor, Bitmap *bitmap)
400 {
401 // FIXME: can't test GdipInitializePalette b/c it isn't exported in 1.0
402 return DllExports::GdipInitializePalette(palette, paletteType,
403 optimalColors, useTransparentColor,
404 bitmap ? (GpBitmap*) bitmap->nativeImage : NULL);
405 }
406
Bitmap(const BITMAPINFO * gdiBitmapInfo,VOID * gdiBitmapData)407 __inline__ Bitmap::Bitmap(const BITMAPINFO *gdiBitmapInfo, VOID *gdiBitmapData):
408 Image(NULL, Ok)
409 {
410 GpBitmap *nativeBitmap = NULL;
411 lastStatus = DllExports::GdipCreateBitmapFromGdiDib(
412 gdiBitmapInfo, gdiBitmapData, &nativeBitmap);
413 nativeImage = nativeBitmap;
414 }
415
Bitmap(IDirectDrawSurface7 * surface)416 __inline__ Bitmap::Bitmap(IDirectDrawSurface7 *surface): Image(NULL, Ok)
417 {
418 GpBitmap *nativeBitmap = NULL;
419 lastStatus = DllExports::GdipCreateBitmapFromDirectDrawSurface(
420 surface, &nativeBitmap);
421 nativeImage = nativeBitmap;
422 }
423
Bitmap(const WCHAR * filename,BOOL useEmbeddedColorManagement)424 __inline__ Bitmap::Bitmap(const WCHAR *filename,
425 BOOL useEmbeddedColorManagement): Image(NULL, Ok)
426 {
427 GpBitmap *nativeBitmap = NULL;
428 if (useEmbeddedColorManagement) {
429 lastStatus = DllExports::GdipCreateBitmapFromFileICM(
430 filename, &nativeBitmap);
431 } else {
432 lastStatus = DllExports::GdipCreateBitmapFromFile(
433 filename, &nativeBitmap);
434 }
435 nativeImage = nativeBitmap;
436 }
437
Bitmap(HBITMAP hbm,HPALETTE hpal)438 __inline__ Bitmap::Bitmap(HBITMAP hbm, HPALETTE hpal):
439 Image(NULL, Ok)
440 {
441 GpBitmap *nativeBitmap = NULL;
442 lastStatus = DllExports::GdipCreateBitmapFromHBITMAP(
443 hbm, hpal, &nativeBitmap);
444 nativeImage = nativeBitmap;
445 }
446
Bitmap(HICON hicon)447 __inline__ Bitmap::Bitmap(HICON hicon):
448 Image(NULL, Ok)
449 {
450 GpBitmap *nativeBitmap = NULL;
451 lastStatus = DllExports::GdipCreateBitmapFromHICON(hicon, &nativeBitmap);
452 nativeImage = nativeBitmap;
453 }
454
Bitmap(HINSTANCE hInstance,const WCHAR * bitmapName)455 __inline__ Bitmap::Bitmap(HINSTANCE hInstance, const WCHAR *bitmapName):
456 Image(NULL, Ok)
457 {
458 GpBitmap *nativeBitmap = NULL;
459 lastStatus = DllExports::GdipCreateBitmapFromResource(
460 hInstance, bitmapName, &nativeBitmap);
461 nativeImage = nativeBitmap;
462 }
463
Bitmap(IStream * stream,BOOL useEmbeddedColorManagement)464 __inline__ Bitmap::Bitmap(IStream *stream, BOOL useEmbeddedColorManagement):
465 Image(NULL, Ok)
466 {
467 GpBitmap *nativeBitmap = NULL;
468 if (useEmbeddedColorManagement) {
469 lastStatus = DllExports::GdipCreateBitmapFromStreamICM(
470 stream, &nativeBitmap);
471 } else {
472 lastStatus = DllExports::GdipCreateBitmapFromStream(
473 stream, &nativeBitmap);
474 }
475 nativeImage = nativeBitmap;
476 }
477
Bitmap(INT width,INT height,Graphics * target)478 __inline__ Bitmap::Bitmap(INT width, INT height, Graphics *target):
479 Image(NULL, Ok)
480 {
481 GpBitmap *nativeBitmap = NULL;
482 lastStatus = DllExports::GdipCreateBitmapFromGraphics(
483 width, height, target ? target->nativeGraphics : NULL,
484 &nativeBitmap);
485 nativeImage = nativeBitmap;
486 }
487
Bitmap(INT width,INT height,PixelFormat format)488 __inline__ Bitmap::Bitmap(INT width, INT height, PixelFormat format):
489 Image(NULL, Ok)
490 {
491 GpBitmap *nativeBitmap = NULL;
492 lastStatus = DllExports::GdipCreateBitmapFromScan0(
493 width, height, 0, format, NULL, &nativeBitmap);
494 nativeImage = nativeBitmap;
495 }
496
Bitmap(INT width,INT height,INT stride,PixelFormat format,BYTE * scan0)497 __inline__ Bitmap::Bitmap(INT width, INT height, INT stride,
498 PixelFormat format, BYTE *scan0): Image(NULL, Ok)
499 {
500 GpBitmap *nativeBitmap = NULL;
501 lastStatus = DllExports::GdipCreateBitmapFromScan0(
502 width, height, stride, format, scan0, &nativeBitmap);
503 nativeImage = nativeBitmap;
504 }
505
Clone(const RectF & rect,PixelFormat format)506 __inline__ Bitmap* Bitmap::Clone(const RectF& rect, PixelFormat format) const
507 {
508 return Clone(rect.X, rect.Y, rect.Width, rect.Height, format);
509 }
510
Clone(const Rect & rect,PixelFormat format)511 __inline__ Bitmap* Bitmap::Clone(const Rect& rect, PixelFormat format) const
512 {
513 return Clone(rect.X, rect.Y, rect.Width, rect.Height, format);
514 }
515
Clone(REAL x,REAL y,REAL width,REAL height,PixelFormat format)516 __inline__ Bitmap* Bitmap::Clone(REAL x, REAL y, REAL width, REAL height,
517 PixelFormat format) const
518 {
519 GpBitmap *cloneBitmap = NULL;
520 Status status = updateStatus(DllExports::GdipCloneBitmapArea(
521 x, y, width, height, format,
522 (GpBitmap*) nativeImage, &cloneBitmap));
523 if (status == Ok) {
524 Bitmap *result = new Bitmap(cloneBitmap, lastStatus);
525 if (!result) {
526 DllExports::GdipDisposeImage(cloneBitmap);
527 lastStatus = OutOfMemory;
528 }
529 return result;
530 } else {
531 return NULL;
532 }
533 }
534
Clone(INT x,INT y,INT width,INT height,PixelFormat format)535 __inline__ Bitmap* Bitmap::Clone(INT x, INT y, INT width, INT height,
536 PixelFormat format) const
537 {
538 GpBitmap *cloneBitmap = NULL;
539 Status status = updateStatus(DllExports::GdipCloneBitmapAreaI(
540 x, y, width, height, format,
541 (GpBitmap*) nativeImage, &cloneBitmap));
542 if (status == Ok) {
543 Bitmap *result = new Bitmap(cloneBitmap, lastStatus);
544 if (!result) {
545 DllExports::GdipDisposeImage(cloneBitmap);
546 lastStatus = OutOfMemory;
547 }
548 return result;
549 } else {
550 return NULL;
551 }
552 }
553
554 //TODO: [GDI+ 1.1] Bitmap::ApplyEffect
555 //__inline__ Status Bitmap::ApplyEffect(Effect *effect, RECT *ROI)
556 //{
557 // return NotImplemented;
558 //}
559
ConvertFormat(PixelFormat format,DitherType ditherType,PaletteType paletteType,ColorPalette * palette,REAL alphaThresholdPercent)560 __inline__ Status Bitmap::ConvertFormat(PixelFormat format,
561 DitherType ditherType, PaletteType paletteType,
562 ColorPalette *palette, REAL alphaThresholdPercent)
563 {
564 // FIXME: can't test GdipBitmapConvertFormat b/c it isn't exported in 1.0
565 return updateStatus(DllExports::GdipBitmapConvertFormat(
566 (GpBitmap*) nativeImage, format, ditherType,
567 paletteType, palette, alphaThresholdPercent));
568 }
569
GetHBITMAP(const Color & colorBackground,HBITMAP * hbmReturn)570 __inline__ Status Bitmap::GetHBITMAP(
571 const Color& colorBackground, HBITMAP *hbmReturn) const
572 {
573 return updateStatus(DllExports::GdipCreateHBITMAPFromBitmap(
574 (GpBitmap*) nativeImage, hbmReturn,
575 colorBackground.GetValue()));
576 }
577
GetHICON(HICON * icon)578 __inline__ Status Bitmap::GetHICON(HICON *icon) const
579 {
580 return updateStatus(DllExports::GdipCreateHICONFromBitmap(
581 (GpBitmap*) nativeImage, icon));
582 }
583
GetHistogram(HistogramFormat format,UINT numberOfEntries,UINT * channel0,UINT * channel1,UINT * channel2,UINT * channel3)584 __inline__ Status Bitmap::GetHistogram(HistogramFormat format,
585 UINT numberOfEntries,
586 UINT *channel0, UINT *channel1,
587 UINT *channel2, UINT *channel3) const
588 {
589 return updateStatus(DllExports::GdipBitmapGetHistogram(
590 (GpBitmap*) nativeImage, format, numberOfEntries,
591 channel0, channel1, channel2, channel3));
592 }
593
GetHistogramSize(HistogramFormat format,UINT * numberOfEntries)594 __inline__ Status Bitmap::GetHistogramSize(HistogramFormat format,
595 UINT *numberOfEntries) const
596 {
597 return updateStatus(DllExports::GdipBitmapGetHistogramSize(
598 format, numberOfEntries));
599 }
600
GetPixel(INT x,INT y,Color * color)601 __inline__ Status Bitmap::GetPixel(INT x, INT y, Color *color) const
602 {
603 return updateStatus(DllExports::GdipBitmapGetPixel(
604 (GpBitmap*) nativeImage, x, y,
605 color ? &color->Value : NULL));
606 }
607
LockBits(const Rect * rect,UINT flags,PixelFormat format,BitmapData * lockedBitmapData)608 __inline__ Status Bitmap::LockBits(const Rect *rect, UINT flags,
609 PixelFormat format, BitmapData *lockedBitmapData)
610 {
611 return updateStatus(DllExports::GdipBitmapLockBits(
612 (GpBitmap*) nativeImage, rect, flags, format,
613 lockedBitmapData));
614 }
615
SetPixel(INT x,INT y,const Color & color)616 __inline__ Status Bitmap::SetPixel(INT x, INT y, const Color& color)
617 {
618 return updateStatus(DllExports::GdipBitmapSetPixel(
619 (GpBitmap*) nativeImage, x, y, color.GetValue()));
620 }
621
SetResolution(REAL xdpi,REAL ydpi)622 __inline__ Status Bitmap::SetResolution(REAL xdpi, REAL ydpi)
623 {
624 return updateStatus(DllExports::GdipBitmapSetResolution(
625 (GpBitmap*) nativeImage, xdpi, ydpi));
626 }
627
UnlockBits(BitmapData * lockedBitmapData)628 __inline__ Status Bitmap::UnlockBits(BitmapData *lockedBitmapData)
629 {
630 return updateStatus(DllExports::GdipBitmapUnlockBits(
631 (GpBitmap*) nativeImage, lockedBitmapData));
632 }
633
634
635 // CachedBitmap
636
CachedBitmap(Bitmap * bitmap,Graphics * graphics)637 __inline__ CachedBitmap::CachedBitmap(Bitmap *bitmap, Graphics *graphics):
638 nativeCachedBitmap(NULL), lastStatus(Ok)
639 {
640 lastStatus = DllExports::GdipCreateCachedBitmap(
641 bitmap ? ((GpBitmap*) bitmap->nativeImage) : NULL,
642 graphics ? graphics->nativeGraphics : NULL,
643 &nativeCachedBitmap);
644 }
645
~CachedBitmap()646 __inline__ CachedBitmap::~CachedBitmap()
647 {
648 DllExports::GdipDeleteCachedBitmap(nativeCachedBitmap);
649 }
650
651
652 // CustomLineCap
653
CustomLineCap(const GraphicsPath * fillPath,const GraphicsPath * strokePath,LineCap baseCap,REAL baseInset)654 __inline__ CustomLineCap::CustomLineCap(
655 const GraphicsPath *fillPath,
656 const GraphicsPath *strokePath,
657 LineCap baseCap, REAL baseInset):
658 nativeCustomLineCap(NULL), lastStatus(Ok)
659 {
660 lastStatus = DllExports::GdipCreateCustomLineCap(
661 fillPath ? fillPath->nativePath : NULL,
662 strokePath ? strokePath->nativePath : NULL,
663 baseCap, baseInset, &nativeCustomLineCap);
664 }
665
GetBaseCap()666 __inline__ LineCap CustomLineCap::GetBaseCap() const
667 {
668 LineCap result = LineCapFlat;
669 updateStatus(DllExports::GdipGetCustomLineCapBaseCap(
670 nativeCustomLineCap, &result));
671 return result;
672 }
673
GetBaseInset()674 __inline__ REAL CustomLineCap::GetBaseInset() const
675 {
676 REAL result = 0.0f;
677 updateStatus(DllExports::GdipGetCustomLineCapBaseInset(
678 nativeCustomLineCap, &result));
679 return result;
680 }
681
GetStrokeCaps(LineCap * startCap,LineCap * endCap)682 __inline__ Status CustomLineCap::GetStrokeCaps(LineCap *startCap,
683 LineCap *endCap) const
684 {
685 return updateStatus(DllExports::GdipGetCustomLineCapStrokeCaps(
686 nativeCustomLineCap, startCap, endCap));
687 }
688
GetStrokeJoin()689 __inline__ LineJoin CustomLineCap::GetStrokeJoin() const
690 {
691 LineJoin result = LineJoinMiter;
692 updateStatus(DllExports::GdipGetCustomLineCapStrokeJoin(
693 nativeCustomLineCap, &result));
694 return result;
695 }
696
GetWidthScale()697 __inline__ REAL CustomLineCap::GetWidthScale() const
698 {
699 REAL result = 0.0f;
700 updateStatus(DllExports::GdipGetCustomLineCapWidthScale(
701 nativeCustomLineCap, &result));
702 return result;
703 }
704
SetBaseCap(LineCap baseCap)705 __inline__ Status CustomLineCap::SetBaseCap(LineCap baseCap)
706 {
707 return updateStatus(DllExports::GdipSetCustomLineCapBaseCap(
708 nativeCustomLineCap, baseCap));
709 }
710
SetBaseInset(REAL inset)711 __inline__ Status CustomLineCap::SetBaseInset(REAL inset)
712 {
713 return updateStatus(DllExports::GdipSetCustomLineCapBaseInset(
714 nativeCustomLineCap, inset));
715 }
716
SetStrokeCap(LineCap strokeCap)717 __inline__ Status CustomLineCap::SetStrokeCap(LineCap strokeCap)
718 {
719 return updateStatus(DllExports::GdipSetCustomLineCapStrokeCaps(
720 nativeCustomLineCap, strokeCap, strokeCap));
721 }
722
SetStrokeCaps(LineCap startCap,LineCap endCap)723 __inline__ Status CustomLineCap::SetStrokeCaps(LineCap startCap, LineCap endCap)
724 {
725 return updateStatus(DllExports::GdipSetCustomLineCapStrokeCaps(
726 nativeCustomLineCap, startCap, endCap));
727 }
728
SetStrokeJoin(LineJoin lineJoin)729 __inline__ Status CustomLineCap::SetStrokeJoin(LineJoin lineJoin)
730 {
731 return updateStatus(DllExports::GdipSetCustomLineCapStrokeJoin(
732 nativeCustomLineCap, lineJoin));
733 }
734
SetWidthScale(REAL widthScale)735 __inline__ Status CustomLineCap::SetWidthScale(REAL widthScale)
736 {
737 return updateStatus(DllExports::GdipSetCustomLineCapWidthScale(
738 nativeCustomLineCap, widthScale));
739 }
740
741
742 // Font
743
Font(const FontFamily * family,REAL emSize,INT style,Unit unit)744 __inline__ Font::Font(const FontFamily *family,
745 REAL emSize, INT style, Unit unit):
746 nativeFont(NULL), lastStatus(Ok)
747 {
748 lastStatus = DllExports::GdipCreateFont(
749 family ? family->nativeFontFamily : NULL,
750 emSize, style, unit, &nativeFont);
751 }
752
Font(HDC hdc,HFONT hfont)753 __inline__ Font::Font(HDC hdc, HFONT hfont):
754 nativeFont(NULL), lastStatus(Ok)
755 {
756 LOGFONTA logfont;
757 if (hfont && GetObjectA(hfont, sizeof logfont, &logfont)) {
758 lastStatus = DllExports::GdipCreateFontFromLogfontA(
759 hdc, &logfont, &nativeFont);
760 } else {
761 lastStatus = DllExports::GdipCreateFontFromDC(
762 hdc, &nativeFont);
763 }
764 }
765
Font(HDC hdc,const LOGFONTA * logfont)766 __inline__ Font::Font(HDC hdc, const LOGFONTA *logfont):
767 nativeFont(NULL), lastStatus(Ok)
768 {
769 lastStatus = DllExports::GdipCreateFontFromLogfontA(
770 hdc, logfont, &nativeFont);
771 }
772
Font(HDC hdc,const LOGFONTW * logfont)773 __inline__ Font::Font(HDC hdc, const LOGFONTW *logfont):
774 nativeFont(NULL), lastStatus(Ok)
775 {
776 lastStatus = DllExports::GdipCreateFontFromLogfontW(
777 hdc, logfont, &nativeFont);
778 }
779
Font(HDC hdc)780 __inline__ Font::Font(HDC hdc):
781 nativeFont(NULL), lastStatus(Ok)
782 {
783 lastStatus = DllExports::GdipCreateFontFromDC(hdc, &nativeFont);
784 }
785
Font(const WCHAR * familyName,REAL emSize,INT style,Unit unit,const FontCollection * fontCollection)786 __inline__ Font::Font(const WCHAR *familyName, REAL emSize, INT style,
787 Unit unit, const FontCollection *fontCollection):
788 nativeFont(NULL), lastStatus(Ok)
789 {
790 GpFontFamily *nativeFamily = NULL;
791 lastStatus = DllExports::GdipCreateFontFamilyFromName(
792 familyName,
793 fontCollection ? fontCollection->nativeFontCollection : NULL,
794 &nativeFamily);
795
796 if (nativeFamily) {
797 lastStatus = DllExports::GdipCreateFont(
798 nativeFamily, emSize, style, unit, &nativeFont);
799 DllExports::GdipDeleteFontFamily(nativeFamily);
800 }
801 }
802
~Font()803 __inline__ Font::~Font()
804 {
805 DllExports::GdipDeleteFont(nativeFont);
806 }
807
Clone()808 __inline__ Font* Font::Clone() const
809 {
810 GpFont *cloneFont = NULL;
811 Status status = updateStatus(DllExports::GdipCloneFont(
812 nativeFont, &cloneFont));
813 if (status == Ok) {
814 Font *result = new Font(cloneFont, lastStatus);
815 if (!result) {
816 DllExports::GdipDeleteFont(cloneFont);
817 lastStatus = OutOfMemory;
818 }
819 return result;
820 } else {
821 return NULL;
822 }
823 }
824
GetFamily(FontFamily * family)825 __inline__ Status Font::GetFamily(FontFamily *family) const
826 {
827 if (!family) return lastStatus = InvalidParameter;
828 // FIXME: do we need to call GdipDeleteFontFamily first?
829 return family->lastStatus = updateStatus(DllExports::GdipGetFamily(
830 nativeFont, &family->nativeFontFamily));
831 }
832
GetHeight(const Graphics * graphics)833 __inline__ REAL Font::GetHeight(const Graphics *graphics) const
834 {
835 REAL result = 0.0f;
836 updateStatus(DllExports::GdipGetFontHeight(
837 nativeFont, graphics ? graphics->nativeGraphics : NULL,
838 &result));
839 return result;
840 }
841
GetHeight(REAL dpi)842 __inline__ REAL Font::GetHeight(REAL dpi) const
843 {
844 REAL result = 0.0f;
845 updateStatus(DllExports::GdipGetFontHeightGivenDPI(
846 nativeFont, dpi, &result));
847 return result;
848 }
849
GetLogFontA(const Graphics * graphics,LOGFONTA * logfontA)850 __inline__ Status Font::GetLogFontA(const Graphics *graphics, LOGFONTA *logfontA)
851 const
852 {
853 return updateStatus(DllExports::GdipGetLogFontA(
854 nativeFont, graphics ? graphics->nativeGraphics : NULL,
855 logfontA));
856 }
857
GetLogFontW(const Graphics * graphics,LOGFONTW * logfontW)858 __inline__ Status Font::GetLogFontW(const Graphics *graphics, LOGFONTW *logfontW)
859 const
860 {
861 return updateStatus(DllExports::GdipGetLogFontW(
862 nativeFont, graphics ? graphics->nativeGraphics : NULL,
863 logfontW));
864 }
865
GetSize()866 __inline__ REAL Font::GetSize() const
867 {
868 REAL result = 0.0;
869 updateStatus(DllExports::GdipGetFontSize(nativeFont, &result));
870 return result;
871 }
872
GetStyle()873 __inline__ INT Font::GetStyle() const
874 {
875 INT result = FontStyleRegular;
876 updateStatus(DllExports::GdipGetFontStyle(nativeFont, &result));
877 return result;
878 }
879
GetUnit()880 __inline__ Unit Font::GetUnit() const
881 {
882 Unit result = UnitPoint;
883 updateStatus(DllExports::GdipGetFontUnit(nativeFont, &result));
884 return result;
885 }
886
887
888 // FontCollection
889
FontCollection()890 __inline__ FontCollection::FontCollection():
891 nativeFontCollection(NULL), lastStatus(Ok)
892 {
893 }
894
GetFamilies(INT numSought,FontFamily * families,INT * numFound)895 __inline__ Status FontCollection::GetFamilies(INT numSought,
896 FontFamily *families, INT *numFound) const
897 {
898 if (numSought <= 0 || !families || !numFound)
899 return lastStatus = InvalidParameter;
900
901 for (int i = 0; i < numSought; ++i) {
902 families[i].nativeFontFamily = NULL;
903 families[i].lastStatus = FontFamilyNotFound;
904 }
905 *numFound = 0;
906
907 GpFontFamily **nativeFamilyArray = (GpFontFamily**)
908 DllExports::GdipAlloc(numSought * sizeof (GpFontFamily*));
909 if (!nativeFamilyArray)
910 return lastStatus = OutOfMemory;
911
912 Status status = updateStatus(DllExports::GdipGetFontCollectionFamilyList(
913 nativeFontCollection, numSought, nativeFamilyArray,
914 numFound));
915
916 // FIXME: must the native GpFontFamily objects be cloned? Seems so.
917 // (if this is not done, the "Creating a Private Font Collection"
918 // example crashes on "delete[] pFontFamily")
919
920 if (status == Ok) {
921 for (int i = 0; i < *numFound; ++i) {
922 families[i].lastStatus =
923 updateStatus(DllExports::GdipCloneFontFamily(
924 nativeFamilyArray[i],
925 &families[i].nativeFontFamily));
926 }
927 }
928
929 DllExports::GdipFree(nativeFamilyArray);
930 return status;
931 }
932
GetFamilyCount()933 __inline__ INT FontCollection::GetFamilyCount() const
934 {
935 INT result = 0;
936 updateStatus(DllExports::GdipGetFontCollectionFamilyCount(
937 nativeFontCollection, &result));
938 return result;
939 }
940
941
942 // FontFamily
943
944 // FIXME: do FontFamily::GenericMonospace() et al. need to be thread safe?
945 // FIXME: maybe put parts of this in gdiplus.c
946
947 extern "C" void *_GdipFontFamilyCachedGenericMonospace;
948 extern "C" void *_GdipFontFamilyCachedGenericSansSerif;
949 extern "C" void *_GdipFontFamilyCachedGenericSerif;
950
GenericMonospace()951 __inline__ const FontFamily* FontFamily::GenericMonospace()
952 {
953 if (!_GdipFontFamilyCachedGenericMonospace) {
954 GpFontFamily *nativeFontFamily = 0;
955 Status status = DllExports::GdipGetGenericFontFamilyMonospace(
956 &nativeFontFamily);
957 if (status == Ok && nativeFontFamily) {
958 _GdipFontFamilyCachedGenericMonospace = (void*)
959 new FontFamily(nativeFontFamily, Ok);
960 }
961 }
962 return (FontFamily*) _GdipFontFamilyCachedGenericMonospace;
963 }
964
GenericSansSerif()965 __inline__ const FontFamily* FontFamily::GenericSansSerif()
966 {
967 if (!_GdipFontFamilyCachedGenericSansSerif) {
968 GpFontFamily *nativeFontFamily = 0;
969 Status status = DllExports::GdipGetGenericFontFamilySansSerif(
970 &nativeFontFamily);
971 if (status == Ok && nativeFontFamily) {
972 _GdipFontFamilyCachedGenericSansSerif = (void*)
973 new FontFamily(nativeFontFamily, Ok);
974 }
975 }
976 return (FontFamily*) _GdipFontFamilyCachedGenericSansSerif;
977 }
978
GenericSerif()979 __inline__ const FontFamily* FontFamily::GenericSerif()
980 {
981 if (!_GdipFontFamilyCachedGenericSerif) {
982 GpFontFamily *nativeFontFamily = 0;
983 Status status = DllExports::GdipGetGenericFontFamilySerif(
984 &nativeFontFamily);
985 if (status == Ok && nativeFontFamily) {
986 _GdipFontFamilyCachedGenericSerif = (void*)
987 new FontFamily(nativeFontFamily, Ok);
988 }
989 }
990 return (FontFamily*) _GdipFontFamilyCachedGenericSerif;
991 }
992
FontFamily()993 __inline__ FontFamily::FontFamily():
994 nativeFontFamily(NULL), lastStatus(Ok)
995 {
996 }
997
FontFamily(const WCHAR * name,const FontCollection * fontCollection)998 __inline__ FontFamily::FontFamily(const WCHAR *name,
999 const FontCollection *fontCollection):
1000 nativeFontFamily(NULL), lastStatus(Ok)
1001 {
1002 lastStatus = DllExports::GdipCreateFontFamilyFromName(name,
1003 fontCollection ? fontCollection->nativeFontCollection : NULL,
1004 &nativeFontFamily);
1005 }
1006
~FontFamily()1007 __inline__ FontFamily::~FontFamily()
1008 {
1009 DllExports::GdipDeleteFontFamily(nativeFontFamily);
1010 }
1011
Clone()1012 __inline__ FontFamily* FontFamily::Clone() const
1013 {
1014 GpFontFamily *cloneFontFamily = NULL;
1015 Status status = updateStatus(DllExports::GdipCloneFontFamily(
1016 nativeFontFamily, &cloneFontFamily));
1017 if (status == Ok) {
1018 FontFamily *result = new FontFamily(cloneFontFamily, lastStatus);
1019 if (!result) {
1020 DllExports::GdipDeleteFontFamily(cloneFontFamily);
1021 lastStatus = OutOfMemory;
1022 }
1023 return result;
1024 } else {
1025 return NULL;
1026 }
1027 }
1028
GetCellAscent(INT style)1029 __inline__ UINT16 FontFamily::GetCellAscent(INT style) const
1030 {
1031 UINT16 result = 0;
1032 updateStatus(DllExports::GdipGetCellAscent(
1033 nativeFontFamily, style, &result));
1034 return result;
1035 }
1036
GetCellDescent(INT style)1037 __inline__ UINT16 FontFamily::GetCellDescent(INT style) const
1038 {
1039 UINT16 result = 0;
1040 updateStatus(DllExports::GdipGetCellDescent(
1041 nativeFontFamily, style, &result));
1042 return result;
1043 }
1044
GetEmHeight(INT style)1045 __inline__ UINT16 FontFamily::GetEmHeight(INT style) const
1046 {
1047 UINT16 result = 0;
1048 updateStatus(DllExports::GdipGetEmHeight(
1049 nativeFontFamily, style, &result));
1050 return result;
1051 }
1052
GetFamilyName(WCHAR name[LF_FACESIZE],LANGID language)1053 __inline__ Status FontFamily::GetFamilyName(WCHAR name[LF_FACESIZE],
1054 LANGID language) const
1055 {
1056 return updateStatus(DllExports::GdipGetFamilyName(
1057 nativeFontFamily, name, language));
1058 }
1059
GetLineSpacing(INT style)1060 __inline__ UINT16 FontFamily::GetLineSpacing(INT style) const
1061 {
1062 UINT16 result = 0;
1063 updateStatus(DllExports::GdipGetLineSpacing(
1064 nativeFontFamily, style, &result));
1065 return result;
1066 }
1067
IsStyleAvailable(INT style)1068 __inline__ BOOL FontFamily::IsStyleAvailable(INT style) const
1069 {
1070 BOOL result = FALSE;
1071 updateStatus(DllExports::GdipIsStyleAvailable(
1072 nativeFontFamily, style, &result));
1073 return result;
1074 }
1075
1076
1077 // InstalledFontCollection
1078
InstalledFontCollection()1079 __inline__ InstalledFontCollection::InstalledFontCollection()
1080 {
1081 lastStatus = DllExports::GdipNewInstalledFontCollection(
1082 &nativeFontCollection);
1083 }
1084
1085
1086 // PrivateFontCollection
1087
PrivateFontCollection()1088 __inline__ PrivateFontCollection::PrivateFontCollection()
1089 {
1090 lastStatus = DllExports::GdipNewPrivateFontCollection(
1091 &nativeFontCollection);
1092 }
1093
AddFontFile(const WCHAR * filename)1094 __inline__ Status PrivateFontCollection::AddFontFile(const WCHAR *filename)
1095 {
1096 return updateStatus(DllExports::GdipPrivateAddFontFile(
1097 nativeFontCollection, filename));
1098 }
1099
AddMemoryFont(const VOID * memory,INT length)1100 __inline__ Status PrivateFontCollection::AddMemoryFont(
1101 const VOID *memory, INT length)
1102 {
1103 return updateStatus(DllExports::GdipPrivateAddMemoryFont(
1104 nativeFontCollection, memory, length));
1105 }
1106
1107
1108 // Region
1109
FromHRGN(HRGN hrgn)1110 __inline__ Region* Region::FromHRGN(HRGN hrgn)
1111 {
1112 return new Region(hrgn);
1113 }
1114
Region()1115 __inline__ Region::Region(): nativeRegion(NULL), lastStatus(Ok)
1116 {
1117 lastStatus = DllExports::GdipCreateRegion(&nativeRegion);
1118 }
1119
Region(const RectF & rect)1120 __inline__ Region::Region(const RectF& rect): nativeRegion(NULL), lastStatus(Ok)
1121 {
1122 lastStatus = DllExports::GdipCreateRegionRect(&rect, &nativeRegion);
1123 }
1124
Region(const Rect & rect)1125 __inline__ Region::Region(const Rect& rect): nativeRegion(NULL), lastStatus(Ok)
1126 {
1127 lastStatus = DllExports::GdipCreateRegionRectI(&rect, &nativeRegion);
1128 }
1129
Region(const GraphicsPath * path)1130 __inline__ Region::Region(const GraphicsPath *path):
1131 nativeRegion(NULL), lastStatus(Ok)
1132 {
1133 lastStatus = DllExports::GdipCreateRegionPath(
1134 path ? path->nativePath : NULL, &nativeRegion);
1135 }
1136
Region(const BYTE * regionData,INT size)1137 __inline__ Region::Region(const BYTE *regionData, INT size):
1138 nativeRegion(NULL), lastStatus(Ok)
1139 {
1140 lastStatus = DllExports::GdipCreateRegionRgnData(
1141 regionData, size, &nativeRegion);
1142 }
1143
Region(HRGN hrgn)1144 __inline__ Region::Region(HRGN hrgn): nativeRegion(NULL), lastStatus(Ok)
1145 {
1146 lastStatus = DllExports::GdipCreateRegionHrgn(hrgn, &nativeRegion);
1147 }
1148
~Region()1149 __inline__ Region::~Region()
1150 {
1151 DllExports::GdipDeleteRegion(nativeRegion);
1152 }
1153
Clone()1154 __inline__ Region* Region::Clone() const
1155 {
1156 GpRegion *cloneRegion = NULL;
1157 Status status = updateStatus(DllExports::GdipCloneRegion(
1158 nativeRegion, &cloneRegion));
1159 if (status == Ok) {
1160 Region *result = new Region(cloneRegion, lastStatus);
1161 if (!result) {
1162 DllExports::GdipDeleteRegion(cloneRegion);
1163 lastStatus = OutOfMemory;
1164 }
1165 return result;
1166 } else {
1167 return NULL;
1168 }
1169 }
1170
Complement(const RectF & rect)1171 __inline__ Status Region::Complement(const RectF& rect)
1172 {
1173 return updateStatus(DllExports::GdipCombineRegionRect(
1174 nativeRegion, &rect, CombineModeComplement));
1175 }
1176
Complement(const Rect & rect)1177 __inline__ Status Region::Complement(const Rect& rect)
1178 {
1179 return updateStatus(DllExports::GdipCombineRegionRectI(
1180 nativeRegion, &rect, CombineModeComplement));
1181 }
1182
Complement(const Region * region)1183 __inline__ Status Region::Complement(const Region *region)
1184 {
1185 return updateStatus(DllExports::GdipCombineRegionRegion(
1186 nativeRegion, region ? region->nativeRegion : NULL,
1187 CombineModeComplement));
1188 }
1189
Complement(const GraphicsPath * path)1190 __inline__ Status Region::Complement(const GraphicsPath *path)
1191 {
1192 return updateStatus(DllExports::GdipCombineRegionPath(
1193 nativeRegion, path ? path->nativePath : NULL,
1194 CombineModeComplement));
1195 }
1196
Equals(const Region * region,const Graphics * graphics)1197 __inline__ BOOL Region::Equals(const Region *region, const Graphics *graphics)
1198 const
1199 {
1200 BOOL result = FALSE;
1201 updateStatus(DllExports::GdipIsEqualRegion(
1202 nativeRegion, region ? region->nativeRegion : NULL,
1203 graphics ? graphics->nativeGraphics : NULL, &result));
1204 return result;
1205 }
1206
Exclude(const RectF & rect)1207 __inline__ Status Region::Exclude(const RectF& rect)
1208 {
1209 return updateStatus(DllExports::GdipCombineRegionRect(
1210 nativeRegion, &rect, CombineModeExclude));
1211 }
1212
Exclude(const Rect & rect)1213 __inline__ Status Region::Exclude(const Rect& rect)
1214 {
1215 return updateStatus(DllExports::GdipCombineRegionRectI(
1216 nativeRegion, &rect, CombineModeExclude));
1217 }
1218
Exclude(const Region * region)1219 __inline__ Status Region::Exclude(const Region *region)
1220 {
1221 return updateStatus(DllExports::GdipCombineRegionRegion(
1222 nativeRegion, region ? region->nativeRegion : NULL,
1223 CombineModeExclude));
1224 }
1225
Exclude(const GraphicsPath * path)1226 __inline__ Status Region::Exclude(const GraphicsPath *path)
1227 {
1228 return updateStatus(DllExports::GdipCombineRegionPath(
1229 nativeRegion, path ? path->nativePath : NULL,
1230 CombineModeExclude));
1231 }
1232
GetBounds(RectF * rect,const Graphics * graphics)1233 __inline__ Status Region::GetBounds(RectF *rect, const Graphics *graphics) const
1234 {
1235 return updateStatus(DllExports::GdipGetRegionBounds(nativeRegion,
1236 graphics ? graphics->nativeGraphics : NULL, rect));
1237 }
1238
GetBounds(Rect * rect,const Graphics * graphics)1239 __inline__ Status Region::GetBounds(Rect *rect, const Graphics *graphics) const
1240 {
1241 return updateStatus(DllExports::GdipGetRegionBoundsI(nativeRegion,
1242 graphics ? graphics->nativeGraphics : NULL, rect));
1243 }
1244
GetData(BYTE * buffer,UINT bufferSize,UINT * sizeFilled)1245 __inline__ Status Region::GetData(BYTE *buffer, UINT bufferSize,
1246 UINT *sizeFilled) const
1247 {
1248 return updateStatus(DllExports::GdipGetRegionData(
1249 nativeRegion, buffer, bufferSize, sizeFilled));
1250 }
1251
GetDataSize()1252 __inline__ UINT Region::GetDataSize() const
1253 {
1254 UINT result = 0;
1255 updateStatus(DllExports::GdipGetRegionDataSize(nativeRegion, &result));
1256 return result;
1257 }
1258
GetHRGN(const Graphics * graphics)1259 __inline__ HRGN Region::GetHRGN(const Graphics *graphics) const
1260 {
1261 HRGN result = NULL;
1262 updateStatus(DllExports::GdipGetRegionHRgn(nativeRegion,
1263 graphics ? graphics->nativeGraphics : NULL, &result));
1264 return result;
1265 }
1266
GetRegionScans(const Matrix * matrix,RectF * rects,INT * count)1267 __inline__ Status Region::GetRegionScans(const Matrix *matrix,
1268 RectF *rects, INT *count) const
1269 {
1270 return updateStatus(DllExports::GdipGetRegionScans(
1271 nativeRegion, rects, count,
1272 matrix ? matrix->nativeMatrix : NULL));
1273 }
1274
GetRegionScans(const Matrix * matrix,Rect * rects,INT * count)1275 __inline__ Status Region::GetRegionScans(const Matrix *matrix,
1276 Rect *rects, INT *count) const
1277 {
1278 return updateStatus(DllExports::GdipGetRegionScansI(
1279 nativeRegion, rects, count,
1280 matrix ? matrix->nativeMatrix : NULL));
1281 }
1282
GetRegionScansCount(const Matrix * matrix)1283 __inline__ UINT Region::GetRegionScansCount(const Matrix *matrix) const
1284 {
1285 UINT result = 0;
1286 updateStatus(DllExports::GdipGetRegionScansCount(
1287 nativeRegion, &result,
1288 matrix ? matrix->nativeMatrix : NULL));
1289 return result;
1290 }
1291
Intersect(const RectF & rect)1292 __inline__ Status Region::Intersect(const RectF& rect)
1293 {
1294 return updateStatus(DllExports::GdipCombineRegionRect(
1295 nativeRegion, &rect, CombineModeIntersect));
1296 }
1297
Intersect(const Rect & rect)1298 __inline__ Status Region::Intersect(const Rect& rect)
1299 {
1300 return updateStatus(DllExports::GdipCombineRegionRectI(
1301 nativeRegion, &rect, CombineModeIntersect));
1302 }
1303
Intersect(const Region * region)1304 __inline__ Status Region::Intersect(const Region *region)
1305 {
1306 return updateStatus(DllExports::GdipCombineRegionRegion(
1307 nativeRegion, region ? region->nativeRegion : NULL,
1308 CombineModeIntersect));
1309 }
1310
Intersect(const GraphicsPath * path)1311 __inline__ Status Region::Intersect(const GraphicsPath *path)
1312 {
1313 return updateStatus(DllExports::GdipCombineRegionPath(
1314 nativeRegion, path ? path->nativePath : NULL,
1315 CombineModeIntersect));
1316 }
1317
IsEmpty(const Graphics * graphics)1318 __inline__ BOOL Region::IsEmpty(const Graphics *graphics) const
1319 {
1320 BOOL result = FALSE;
1321 updateStatus(DllExports::GdipIsEmptyRegion(nativeRegion,
1322 graphics ? graphics->nativeGraphics : NULL, &result));
1323 return result;
1324 }
1325
IsInfinite(const Graphics * graphics)1326 __inline__ BOOL Region::IsInfinite(const Graphics *graphics) const
1327 {
1328 BOOL result = FALSE;
1329 updateStatus(DllExports::GdipIsInfiniteRegion(nativeRegion,
1330 graphics ? graphics->nativeGraphics : NULL, &result));
1331 return result;
1332 }
1333
IsVisible(REAL x,REAL y,const Graphics * graphics)1334 __inline__ BOOL Region::IsVisible(REAL x, REAL y,
1335 const Graphics *graphics) const
1336 {
1337 BOOL result = FALSE;
1338 updateStatus(DllExports::GdipIsVisibleRegionPoint(
1339 nativeRegion, x, y,
1340 graphics ? graphics->nativeGraphics : NULL, &result));
1341 return result;
1342 }
1343
IsVisible(INT x,INT y,const Graphics * graphics)1344 __inline__ BOOL Region::IsVisible(INT x, INT y,
1345 const Graphics *graphics) const
1346 {
1347 BOOL result = FALSE;
1348 updateStatus(DllExports::GdipIsVisibleRegionPointI(
1349 nativeRegion, x, y,
1350 graphics ? graphics->nativeGraphics : NULL, &result));
1351 return result;
1352 }
1353
IsVisible(const PointF & point,const Graphics * graphics)1354 __inline__ BOOL Region::IsVisible(const PointF& point,
1355 const Graphics *graphics) const
1356 {
1357 BOOL result = FALSE;
1358 updateStatus(DllExports::GdipIsVisibleRegionPoint(
1359 nativeRegion, point.X, point.Y,
1360 graphics ? graphics->nativeGraphics : NULL, &result));
1361 return result;
1362 }
1363
IsVisible(const Point & point,const Graphics * graphics)1364 __inline__ BOOL Region::IsVisible(const Point& point,
1365 const Graphics *graphics) const
1366 {
1367 BOOL result = FALSE;
1368 updateStatus(DllExports::GdipIsVisibleRegionPointI(
1369 nativeRegion, point.X, point.Y,
1370 graphics ? graphics->nativeGraphics : NULL, &result));
1371 return result;
1372 }
1373
IsVisible(REAL x,REAL y,REAL width,REAL height,const Graphics * graphics)1374 __inline__ BOOL Region::IsVisible(REAL x, REAL y, REAL width, REAL height,
1375 const Graphics *graphics) const
1376 {
1377 BOOL result = FALSE;
1378 updateStatus(DllExports::GdipIsVisibleRegionRect(
1379 nativeRegion, x, y, width, height,
1380 graphics ? graphics->nativeGraphics : NULL, &result));
1381 return result;
1382 }
1383
IsVisible(INT x,INT y,INT width,INT height,const Graphics * graphics)1384 __inline__ BOOL Region::IsVisible(INT x, INT y, INT width, INT height,
1385 const Graphics *graphics) const
1386 {
1387 BOOL result = FALSE;
1388 updateStatus(DllExports::GdipIsVisibleRegionRectI(
1389 nativeRegion, x, y, width, height,
1390 graphics ? graphics->nativeGraphics : NULL, &result));
1391 return result;
1392 }
1393
IsVisible(const RectF & rect,const Graphics * graphics)1394 __inline__ BOOL Region::IsVisible(const RectF& rect,
1395 const Graphics *graphics) const
1396 {
1397 BOOL result = FALSE;
1398 updateStatus(DllExports::GdipIsVisibleRegionRect(
1399 nativeRegion, rect.X, rect.Y, rect.Width, rect.Height,
1400 graphics ? graphics->nativeGraphics : NULL, &result));
1401 return result;
1402 }
1403
IsVisible(const Rect & rect,const Graphics * graphics)1404 __inline__ BOOL Region::IsVisible(const Rect& rect,
1405 const Graphics *graphics) const
1406 {
1407 BOOL result = FALSE;
1408 updateStatus(DllExports::GdipIsVisibleRegionRectI(
1409 nativeRegion, rect.X, rect.Y, rect.Width, rect.Height,
1410 graphics ? graphics->nativeGraphics : NULL, &result));
1411 return result;
1412 }
1413
MakeEmpty()1414 __inline__ Status Region::MakeEmpty()
1415 {
1416 return updateStatus(DllExports::GdipSetEmpty(nativeRegion));
1417 }
1418
MakeInfinite()1419 __inline__ Status Region::MakeInfinite()
1420 {
1421 return updateStatus(DllExports::GdipSetInfinite(nativeRegion));
1422 }
1423
Transform(const Matrix * matrix)1424 __inline__ Status Region::Transform(const Matrix *matrix)
1425 {
1426 return updateStatus(DllExports::GdipTransformRegion(
1427 nativeRegion, matrix ? matrix->nativeMatrix : NULL));
1428 }
1429
Translate(REAL dx,REAL dy)1430 __inline__ Status Region::Translate(REAL dx, REAL dy)
1431 {
1432 return updateStatus(DllExports::GdipTranslateRegion(
1433 nativeRegion, dx, dy));
1434 }
1435
Translate(INT dx,INT dy)1436 __inline__ Status Region::Translate(INT dx, INT dy)
1437 {
1438 return updateStatus(DllExports::GdipTranslateRegionI(
1439 nativeRegion, dx, dy));
1440 }
1441
Union(const RectF & rect)1442 __inline__ Status Region::Union(const RectF& rect)
1443 {
1444 return updateStatus(DllExports::GdipCombineRegionRect(
1445 nativeRegion, &rect, CombineModeUnion));
1446 }
1447
Union(const Rect & rect)1448 __inline__ Status Region::Union(const Rect& rect)
1449 {
1450 return updateStatus(DllExports::GdipCombineRegionRectI(
1451 nativeRegion, &rect, CombineModeUnion));
1452 }
1453
Union(const Region * region)1454 __inline__ Status Region::Union(const Region *region)
1455 {
1456 return updateStatus(DllExports::GdipCombineRegionRegion(
1457 nativeRegion, region ? region->nativeRegion : NULL,
1458 CombineModeUnion));
1459 }
1460
Union(const GraphicsPath * path)1461 __inline__ Status Region::Union(const GraphicsPath *path)
1462 {
1463 return updateStatus(DllExports::GdipCombineRegionPath(
1464 nativeRegion, path ? path->nativePath : NULL,
1465 CombineModeUnion));
1466 }
1467
Xor(const RectF & rect)1468 __inline__ Status Region::Xor(const RectF& rect)
1469 {
1470 return updateStatus(DllExports::GdipCombineRegionRect(
1471 nativeRegion, &rect, CombineModeXor));
1472 }
1473
Xor(const Rect & rect)1474 __inline__ Status Region::Xor(const Rect& rect)
1475 {
1476 return updateStatus(DllExports::GdipCombineRegionRectI(
1477 nativeRegion, &rect, CombineModeXor));
1478 }
1479
Xor(const Region * region)1480 __inline__ Status Region::Xor(const Region *region)
1481 {
1482 return updateStatus(DllExports::GdipCombineRegionRegion(
1483 nativeRegion, region ? region->nativeRegion : NULL,
1484 CombineModeXor));
1485 }
1486
Xor(const GraphicsPath * path)1487 __inline__ Status Region::Xor(const GraphicsPath *path)
1488 {
1489 return updateStatus(DllExports::GdipCombineRegionPath(
1490 nativeRegion, path ? path->nativePath : NULL,
1491 CombineModeXor));
1492 }
1493
1494
1495 // GraphicsPath
1496
IsOutlineVisible(REAL x,REAL y,const Pen * pen,const Graphics * g)1497 __inline__ BOOL GraphicsPath::IsOutlineVisible(REAL x, REAL y, const Pen *pen,
1498 const Graphics *g) const
1499 {
1500 BOOL result = FALSE;
1501 updateStatus(DllExports::GdipIsOutlineVisiblePathPoint(
1502 nativePath, x, y, pen ? pen->nativePen : NULL,
1503 g ? g->nativeGraphics : NULL, &result));
1504 return result;
1505 }
1506
IsOutlineVisible(INT x,INT y,const Pen * pen,const Graphics * g)1507 __inline__ BOOL GraphicsPath::IsOutlineVisible(INT x, INT y, const Pen *pen,
1508 const Graphics *g) const
1509 {
1510 BOOL result = FALSE;
1511 updateStatus(DllExports::GdipIsOutlineVisiblePathPointI(
1512 nativePath, x, y, pen ? pen->nativePen : NULL,
1513 g ? g->nativeGraphics : NULL, &result));
1514 return result;
1515 }
1516
IsOutlineVisible(const PointF & point,const Pen * pen,const Graphics * g)1517 __inline__ BOOL GraphicsPath::IsOutlineVisible(const PointF& point, const Pen *pen,
1518 const Graphics *g) const
1519 {
1520 BOOL result = FALSE;
1521 updateStatus(DllExports::GdipIsOutlineVisiblePathPoint(
1522 nativePath, point.X, point.Y,
1523 pen ? pen->nativePen : NULL,
1524 g ? g->nativeGraphics : NULL, &result));
1525 return result;
1526 }
1527
IsOutlineVisible(const Point & point,const Pen * pen,const Graphics * g)1528 __inline__ BOOL GraphicsPath::IsOutlineVisible(const Point& point, const Pen *pen,
1529 const Graphics *g) const
1530 {
1531 BOOL result = FALSE;
1532 updateStatus(DllExports::GdipIsOutlineVisiblePathPointI(
1533 nativePath, point.X, point.Y,
1534 pen ? pen->nativePen : NULL,
1535 g ? g->nativeGraphics : NULL, &result));
1536 return result;
1537 }
1538
IsVisible(REAL x,REAL y,const Graphics * g)1539 __inline__ BOOL GraphicsPath::IsVisible(REAL x, REAL y, const Graphics *g) const
1540 {
1541 BOOL result = FALSE;
1542 updateStatus(DllExports::GdipIsVisiblePathPoint(
1543 nativePath, x, y,
1544 g ? g->nativeGraphics : NULL, &result));
1545 return result;
1546 }
IsVisible(INT x,INT y,const Graphics * g)1547 __inline__ BOOL GraphicsPath::IsVisible(INT x, INT y, const Graphics *g) const
1548 {
1549 BOOL result = FALSE;
1550 updateStatus(DllExports::GdipIsVisiblePathPointI(
1551 nativePath, x, y,
1552 g ? g->nativeGraphics : NULL, &result));
1553 return result;
1554 }
1555
IsVisible(const PointF & point,const Graphics * g)1556 __inline__ BOOL GraphicsPath::IsVisible(const PointF& point,
1557 const Graphics *g) const
1558 {
1559 BOOL result = FALSE;
1560 updateStatus(DllExports::GdipIsVisiblePathPoint(
1561 nativePath, point.X, point.Y,
1562 g ? g->nativeGraphics : NULL, &result));
1563 return result;
1564 }
1565
IsVisible(const Point & point,const Graphics * g)1566 __inline__ BOOL GraphicsPath::IsVisible(const Point& point, const Graphics *g) const
1567 {
1568 BOOL result = FALSE;
1569 updateStatus(DllExports::GdipIsVisiblePathPointI(
1570 nativePath, point.X, point.Y,
1571 g ? g->nativeGraphics : NULL, &result));
1572 return result;
1573 }
1574
1575
1576 // PathData
1577
AllocateArrays(INT capacity)1578 __inline__ Status PathData::AllocateArrays(INT capacity)
1579 {
1580 if (capacity < 0) {
1581 return InvalidParameter;
1582 } else if (Count < capacity) {
1583 FreeArrays();
1584
1585 PointF *pointArray = (PointF*)
1586 DllExports::GdipAlloc(capacity * sizeof(PointF));
1587 if (!pointArray)
1588 return OutOfMemory;
1589
1590 BYTE *typeArray = (BYTE*)
1591 DllExports::GdipAlloc(capacity * sizeof(BYTE));
1592 if (!typeArray) {
1593 DllExports::GdipFree(pointArray);
1594 return OutOfMemory;
1595 }
1596
1597 Count = capacity;
1598 Points = pointArray;
1599 Types = typeArray;
1600 }
1601 return Ok;
1602 }
1603
FreeArrays()1604 __inline__ VOID PathData::FreeArrays()
1605 {
1606 if (Points) DllExports::GdipFree(Points);
1607 if (Types) DllExports::GdipFree(Types);
1608 Count = 0;
1609 Points = NULL;
1610 Types = NULL;
1611 }
1612
1613 #endif /* __GDIPLUS_IMPL_H */
1614