Embed:
(wiki syntax)
Show/hide line numbers
gdiplusimpl.h
00001 /* 00002 * gdiplusimpl.h 00003 * 00004 * GDI+ Bitmap, CachedBitmap, CustomLineCap, Font, FontCollection, FontFamily, 00005 * Image, InstalledFontCollection, PrivateFontCollection, Region 00006 * implementation. Definitions of these classes are in gdiplusheaders.h. 00007 * 00008 * This file is part of the w32api package. 00009 * 00010 * Contributors: 00011 * Created by Markus Koenig <markus@stber-koenig.de> 00012 * 00013 * THIS SOFTWARE IS NOT COPYRIGHTED 00014 * 00015 * This source code is offered for use in the public domain. You may 00016 * use, modify or distribute it freely. 00017 * 00018 * This code is distributed in the hope that it will be useful but 00019 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 00020 * DISCLAIMED. This includes but is not limited to warranties of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 * 00023 */ 00024 00025 #ifndef __GDIPLUS_IMPL_H 00026 #define __GDIPLUS_IMPL_H 00027 #if __GNUC__ >=3 00028 #pragma GCC system_header 00029 #endif 00030 00031 #ifndef __cplusplus 00032 #error "A C++ compiler is required to include gdiplusimpl.h." 00033 #endif 00034 00035 /* 00036 * FIXME: I called this file gdiplusimpl.h, but what should it really be called? 00037 * Or did Microsoft create separate files for each class implemented here? 00038 */ 00039 00040 00041 // Image 00042 00043 __inline__ Image* Image::FromFile(const WCHAR *filename, 00044 BOOL useEmbeddedColorManagement) 00045 { 00046 return new Image(filename, useEmbeddedColorManagement); 00047 } 00048 00049 __inline__ Image* Image::FromStream(IStream *stream, 00050 BOOL useEmbeddedColorManagement) 00051 { 00052 return new Image(stream, useEmbeddedColorManagement); 00053 } 00054 00055 __inline__ Image::Image(const WCHAR *filename, BOOL useEmbeddedColorManagement): 00056 nativeImage(NULL), lastStatus(Ok) 00057 { 00058 if (useEmbeddedColorManagement) { 00059 lastStatus = DllExports::GdipLoadImageFromFileICM( 00060 filename, &nativeImage); 00061 } else { 00062 lastStatus = DllExports::GdipLoadImageFromFile( 00063 filename, &nativeImage); 00064 } 00065 } 00066 00067 __inline__ Image::Image(IStream *stream, BOOL useEmbeddedColorManagement): 00068 nativeImage(NULL), lastStatus(Ok) 00069 { 00070 if (useEmbeddedColorManagement) { 00071 lastStatus = DllExports::GdipLoadImageFromStreamICM( 00072 stream, &nativeImage); 00073 } else { 00074 lastStatus = DllExports::GdipLoadImageFromStream( 00075 stream, &nativeImage); 00076 } 00077 } 00078 00079 __inline__ Status Image::FindFirstItem(ImageItemData *item) 00080 { 00081 // FIXME: can't test GdipFindFirstImageItem b/c it isn't exported in 1.0 00082 return updateStatus(DllExports::GdipFindFirstImageItem( 00083 nativeImage, item)); 00084 } 00085 00086 __inline__ Status Image::FindNextItem(ImageItemData *item) 00087 { 00088 // FIXME: can't test GdipFindFirstImageItem b/c it isn't exported in 1.0 00089 return updateStatus(DllExports::GdipFindNextImageItem( 00090 nativeImage, item)); 00091 } 00092 00093 __inline__ Status Image::GetAllPropertyItems(UINT totalBufferSize, 00094 UINT numProperties, PropertyItem *allItems) 00095 { 00096 return updateStatus(DllExports::GdipGetAllPropertyItems( 00097 nativeImage, totalBufferSize, numProperties, allItems)); 00098 } 00099 00100 __inline__ Status Image::GetBounds(RectF *srcRect, Unit *srcUnit) 00101 { 00102 return updateStatus(DllExports::GdipGetImageBounds( 00103 nativeImage, srcRect, srcUnit)); 00104 } 00105 00106 __inline__ Status Image::GetEncoderParameterList(const CLSID *clsidEncoder, 00107 UINT size, EncoderParameters *buffer) 00108 { 00109 return updateStatus(DllExports::GdipGetEncoderParameterList( 00110 nativeImage, clsidEncoder, size, buffer)); 00111 } 00112 00113 __inline__ UINT Image::GetEncoderParameterListSize(const CLSID *clsidEncoder) 00114 { 00115 UINT result = 0; 00116 updateStatus(DllExports::GdipGetEncoderParameterListSize( 00117 nativeImage, clsidEncoder, &result)); 00118 return result; 00119 } 00120 00121 __inline__ UINT Image::GetFlags() 00122 { 00123 UINT result = 0; 00124 updateStatus(DllExports::GdipGetImageFlags(nativeImage, &result)); 00125 return result; 00126 } 00127 00128 __inline__ UINT Image::GetFrameCount(const GUID *dimensionID) 00129 { 00130 UINT result = 0; 00131 updateStatus(DllExports::GdipImageGetFrameCount( 00132 nativeImage, dimensionID, &result)); 00133 return result; 00134 } 00135 00136 __inline__ UINT Image::GetFrameDimensionsCount() 00137 { 00138 UINT result = 0; 00139 updateStatus(DllExports::GdipImageGetFrameDimensionsCount( 00140 nativeImage, &result)); 00141 return result; 00142 } 00143 00144 __inline__ Status Image::GetFrameDimensionsList(GUID *dimensionIDs, UINT count) 00145 { 00146 return updateStatus(DllExports::GdipImageGetFrameDimensionsList( 00147 nativeImage, dimensionIDs, count)); 00148 } 00149 00150 __inline__ UINT Image::GetHeight() 00151 { 00152 UINT result = 0; 00153 updateStatus(DllExports::GdipGetImageHeight(nativeImage, &result)); 00154 return result; 00155 } 00156 00157 __inline__ REAL Image::GetHorizontalResolution() 00158 { 00159 REAL result = 0.0f; 00160 updateStatus(DllExports::GdipGetImageHorizontalResolution( 00161 nativeImage, &result)); 00162 return result; 00163 } 00164 00165 __inline__ Status Image::GetItemData(ImageItemData *item) 00166 { 00167 // FIXME: can't test GdipGetImageItemData b/c it isn't exported in 1.0 00168 return updateStatus(DllExports::GdipGetImageItemData( 00169 nativeImage, item)); 00170 } 00171 00172 __inline__ Status Image::GetPalette(ColorPalette *palette, INT size) 00173 { 00174 return updateStatus(DllExports::GdipGetImagePalette( 00175 nativeImage, palette, size)); 00176 } 00177 00178 __inline__ INT Image::GetPaletteSize() 00179 { 00180 INT result = 0; 00181 updateStatus(DllExports::GdipGetImagePaletteSize(nativeImage, &result)); 00182 return result; 00183 } 00184 00185 __inline__ Status Image::GetPhysicalDimension(SizeF *size) 00186 { 00187 if (!size) return lastStatus = InvalidParameter; 00188 return updateStatus(DllExports::GdipGetImageDimension( 00189 nativeImage, &size->Width, &size->Height)); 00190 } 00191 00192 __inline__ PixelFormat Image::GetPixelFormat() 00193 { 00194 PixelFormat result = (PixelFormat) 0; 00195 updateStatus(DllExports::GdipGetImagePixelFormat(nativeImage, &result)); 00196 return result; 00197 } 00198 00199 __inline__ UINT Image::GetPropertyCount() 00200 { 00201 UINT result = 0; 00202 updateStatus(DllExports::GdipGetPropertyCount(nativeImage, &result)); 00203 return result; 00204 } 00205 00206 __inline__ Status Image::GetPropertyIdList(UINT numOfProperty, PROPID *list) 00207 { 00208 return updateStatus(DllExports::GdipGetPropertyIdList( 00209 nativeImage, numOfProperty, list)); 00210 } 00211 00212 __inline__ Status Image::GetPropertyItem(PROPID propId, UINT propSize, 00213 PropertyItem *buffer) 00214 { 00215 return updateStatus(DllExports::GdipGetPropertyItem( 00216 nativeImage, propId, propSize, buffer)); 00217 } 00218 00219 __inline__ UINT Image::GetPropertyItemSize(PROPID propId) 00220 { 00221 UINT result = 0; 00222 updateStatus(DllExports::GdipGetPropertyItemSize( 00223 nativeImage, propId, &result)); 00224 return result; 00225 } 00226 00227 __inline__ Status Image::GetPropertySize( 00228 UINT *totalBufferSize, UINT *numProperties) 00229 { 00230 return updateStatus(DllExports::GdipGetPropertySize( 00231 nativeImage, totalBufferSize, numProperties)); 00232 } 00233 00234 __inline__ Status Image::GetRawFormat(GUID *format) 00235 { 00236 return updateStatus(DllExports::GdipGetImageRawFormat( 00237 nativeImage, format)); 00238 } 00239 00240 __inline__ Image* Image::GetThumbnailImage(UINT thumbWidth, UINT thumbHeight, 00241 GetThumbnailImageAbort callback, VOID *callbackData) 00242 { 00243 GpImage *thumbImage = NULL; 00244 Status status = updateStatus(DllExports::GdipGetImageThumbnail( 00245 nativeImage, thumbWidth, thumbHeight, &thumbImage, 00246 callback, callbackData)); 00247 00248 if (status == Ok) { 00249 Image *result = new Image(thumbImage, Ok); 00250 if (!result) { 00251 DllExports::GdipDisposeImage(thumbImage); 00252 lastStatus = OutOfMemory; 00253 } 00254 return result; 00255 } else { 00256 return NULL; 00257 } 00258 } 00259 00260 __inline__ ImageType Image::GetType() const 00261 { 00262 ImageType result = ImageTypeUnknown; 00263 updateStatus(DllExports::GdipGetImageType(nativeImage, &result)); 00264 return result; 00265 } 00266 00267 __inline__ REAL Image::GetVerticalResolution() 00268 { 00269 REAL result = 0.0f; 00270 updateStatus(DllExports::GdipGetImageVerticalResolution( 00271 nativeImage, &result)); 00272 return result; 00273 } 00274 00275 __inline__ UINT Image::GetWidth() 00276 { 00277 UINT result = 0; 00278 updateStatus(DllExports::GdipGetImageWidth(nativeImage, &result)); 00279 return result; 00280 } 00281 00282 __inline__ Status Image::RemovePropertyItem(PROPID propId) 00283 { 00284 return updateStatus(DllExports::GdipRemovePropertyItem( 00285 nativeImage, propId)); 00286 } 00287 00288 __inline__ Status Image::RotateFlip(RotateFlipType rotateFlipType) 00289 { 00290 return updateStatus(DllExports::GdipImageRotateFlip( 00291 nativeImage, rotateFlipType)); 00292 } 00293 00294 __inline__ Status Image::Save(const WCHAR *filename, const CLSID *clsidEncoder, 00295 const EncoderParameters *encoderParams) 00296 { 00297 return updateStatus(DllExports::GdipSaveImageToFile( 00298 nativeImage, filename, clsidEncoder, encoderParams)); 00299 } 00300 00301 __inline__ Status Image::Save(IStream *stream, const CLSID *clsidEncoder, 00302 const EncoderParameters *encoderParams) 00303 { 00304 return updateStatus(DllExports::GdipSaveImageToStream( 00305 nativeImage, stream, clsidEncoder, encoderParams)); 00306 } 00307 00308 __inline__ Status Image::SaveAdd(const EncoderParameters *encoderParams) 00309 { 00310 return updateStatus(DllExports::GdipSaveAdd( 00311 nativeImage, encoderParams)); 00312 } 00313 00314 __inline__ Status Image::SaveAdd(Image *newImage, 00315 const EncoderParameters *encoderParams) 00316 { 00317 return updateStatus(DllExports::GdipSaveAddImage( 00318 nativeImage, 00319 newImage ? newImage->nativeImage : NULL, 00320 encoderParams)); 00321 } 00322 00323 __inline__ Status Image::SelectActiveFrame( 00324 const GUID *dimensionID, UINT frameIndex) 00325 { 00326 return updateStatus(DllExports::GdipImageSelectActiveFrame( 00327 nativeImage, dimensionID, frameIndex)); 00328 } 00329 00330 __inline__ Status Image::SetAbort(GdiplusAbort *pIAbort) 00331 { 00332 // FIXME: can't test GdipImageSetAbort because it isn't exported in 1.0 00333 return updateStatus(DllExports::GdipImageSetAbort( 00334 nativeImage, pIAbort)); 00335 } 00336 00337 __inline__ Status Image::SetPalette(const ColorPalette *palette) 00338 { 00339 return updateStatus(DllExports::GdipSetImagePalette( 00340 nativeImage, palette)); 00341 } 00342 00343 __inline__ Status Image::SetPropertyItem(const PropertyItem *item) 00344 { 00345 return updateStatus(DllExports::GdipSetPropertyItem(nativeImage, item)); 00346 } 00347 00348 00349 // Bitmap 00350 00351 __inline__ Bitmap* Bitmap::FromBITMAPINFO(const BITMAPINFO *gdiBitmapInfo, 00352 VOID *gdiBitmapData) 00353 { 00354 return new Bitmap(gdiBitmapInfo, gdiBitmapData); 00355 } 00356 00357 __inline__ Bitmap* Bitmap::FromDirectDrawSurface7(IDirectDrawSurface7 *surface) 00358 { 00359 return new Bitmap(surface); 00360 } 00361 00362 __inline__ Bitmap* Bitmap::FromFile(const WCHAR *filename, 00363 BOOL useEmbeddedColorManagement) 00364 { 00365 return new Bitmap(filename, useEmbeddedColorManagement); 00366 } 00367 00368 __inline__ Bitmap* Bitmap::FromHBITMAP(HBITMAP hbm, HPALETTE hpal) 00369 { 00370 return new Bitmap(hbm, hpal); 00371 } 00372 00373 __inline__ Bitmap* Bitmap::FromHICON(HICON icon) 00374 { 00375 return new Bitmap(icon); 00376 } 00377 00378 __inline__ Bitmap* Bitmap::FromResource( 00379 HINSTANCE hInstance, const WCHAR *bitmapName) 00380 { 00381 return new Bitmap(hInstance, bitmapName); 00382 } 00383 00384 __inline__ Bitmap* Bitmap::FromStream(IStream *stream, 00385 BOOL useEmbeddedColorManagement) 00386 { 00387 return new Bitmap(stream, useEmbeddedColorManagement); 00388 } 00389 00390 //TODO: [GDI+ 1.1] Bitmap::ApplyEffect 00391 //__inline__ Status Bitmap::ApplyEffect(Bitmap **inputs, INT numInputs, 00392 // Effect *effect, RECT *ROI, RECT *outputRect, Bitmap **output) 00393 //{ 00394 // return NotImplemented; 00395 //} 00396 00397 __inline__ Status Bitmap::InitializePalette(ColorPalette *palette, 00398 PaletteType paletteType, INT optimalColors, 00399 BOOL useTransparentColor, Bitmap *bitmap) 00400 { 00401 // FIXME: can't test GdipInitializePalette b/c it isn't exported in 1.0 00402 return DllExports::GdipInitializePalette(palette, paletteType, 00403 optimalColors, useTransparentColor, 00404 bitmap ? (GpBitmap*) bitmap->nativeImage : NULL); 00405 } 00406 00407 __inline__ Bitmap::Bitmap(const BITMAPINFO *gdiBitmapInfo, VOID *gdiBitmapData): 00408 Image(NULL, Ok) 00409 { 00410 GpBitmap *nativeBitmap = NULL; 00411 lastStatus = DllExports::GdipCreateBitmapFromGdiDib( 00412 gdiBitmapInfo, gdiBitmapData, &nativeBitmap); 00413 nativeImage = nativeBitmap; 00414 } 00415 00416 __inline__ Bitmap::Bitmap(IDirectDrawSurface7 *surface): Image(NULL, Ok) 00417 { 00418 GpBitmap *nativeBitmap = NULL; 00419 lastStatus = DllExports::GdipCreateBitmapFromDirectDrawSurface( 00420 surface, &nativeBitmap); 00421 nativeImage = nativeBitmap; 00422 } 00423 00424 __inline__ Bitmap::Bitmap(const WCHAR *filename, 00425 BOOL useEmbeddedColorManagement): Image(NULL, Ok) 00426 { 00427 GpBitmap *nativeBitmap = NULL; 00428 if (useEmbeddedColorManagement) { 00429 lastStatus = DllExports::GdipCreateBitmapFromFileICM( 00430 filename, &nativeBitmap); 00431 } else { 00432 lastStatus = DllExports::GdipCreateBitmapFromFile( 00433 filename, &nativeBitmap); 00434 } 00435 nativeImage = nativeBitmap; 00436 } 00437 00438 __inline__ Bitmap::Bitmap(HBITMAP hbm, HPALETTE hpal): 00439 Image(NULL, Ok) 00440 { 00441 GpBitmap *nativeBitmap = NULL; 00442 lastStatus = DllExports::GdipCreateBitmapFromHBITMAP( 00443 hbm, hpal, &nativeBitmap); 00444 nativeImage = nativeBitmap; 00445 } 00446 00447 __inline__ Bitmap::Bitmap(HICON hicon): 00448 Image(NULL, Ok) 00449 { 00450 GpBitmap *nativeBitmap = NULL; 00451 lastStatus = DllExports::GdipCreateBitmapFromHICON(hicon, &nativeBitmap); 00452 nativeImage = nativeBitmap; 00453 } 00454 00455 __inline__ Bitmap::Bitmap(HINSTANCE hInstance, const WCHAR *bitmapName): 00456 Image(NULL, Ok) 00457 { 00458 GpBitmap *nativeBitmap = NULL; 00459 lastStatus = DllExports::GdipCreateBitmapFromResource( 00460 hInstance, bitmapName, &nativeBitmap); 00461 nativeImage = nativeBitmap; 00462 } 00463 00464 __inline__ Bitmap::Bitmap(IStream *stream, BOOL useEmbeddedColorManagement): 00465 Image(NULL, Ok) 00466 { 00467 GpBitmap *nativeBitmap = NULL; 00468 if (useEmbeddedColorManagement) { 00469 lastStatus = DllExports::GdipCreateBitmapFromStreamICM( 00470 stream, &nativeBitmap); 00471 } else { 00472 lastStatus = DllExports::GdipCreateBitmapFromStream( 00473 stream, &nativeBitmap); 00474 } 00475 nativeImage = nativeBitmap; 00476 } 00477 00478 __inline__ Bitmap::Bitmap(INT width, INT height, Graphics *target): 00479 Image(NULL, Ok) 00480 { 00481 GpBitmap *nativeBitmap = NULL; 00482 lastStatus = DllExports::GdipCreateBitmapFromGraphics( 00483 width, height, target ? target->nativeGraphics : NULL, 00484 &nativeBitmap); 00485 nativeImage = nativeBitmap; 00486 } 00487 00488 __inline__ Bitmap::Bitmap(INT width, INT height, PixelFormat format): 00489 Image(NULL, Ok) 00490 { 00491 GpBitmap *nativeBitmap = NULL; 00492 lastStatus = DllExports::GdipCreateBitmapFromScan0( 00493 width, height, 0, format, NULL, &nativeBitmap); 00494 nativeImage = nativeBitmap; 00495 } 00496 00497 __inline__ Bitmap::Bitmap(INT width, INT height, INT stride, 00498 PixelFormat format, BYTE *scan0): Image(NULL, Ok) 00499 { 00500 GpBitmap *nativeBitmap = NULL; 00501 lastStatus = DllExports::GdipCreateBitmapFromScan0( 00502 width, height, stride, format, scan0, &nativeBitmap); 00503 nativeImage = nativeBitmap; 00504 } 00505 00506 __inline__ Bitmap* Bitmap::Clone(const RectF& rect, PixelFormat format) const 00507 { 00508 return Clone(rect.X, rect.Y, rect.Width, rect.Height, format); 00509 } 00510 00511 __inline__ Bitmap* Bitmap::Clone(const Rect& rect, PixelFormat format) const 00512 { 00513 return Clone(rect.X, rect.Y, rect.Width, rect.Height, format); 00514 } 00515 00516 __inline__ Bitmap* Bitmap::Clone(REAL x, REAL y, REAL width, REAL height, 00517 PixelFormat format) const 00518 { 00519 GpBitmap *cloneBitmap = NULL; 00520 Status status = updateStatus(DllExports::GdipCloneBitmapArea( 00521 x, y, width, height, format, 00522 (GpBitmap*) nativeImage, &cloneBitmap)); 00523 if (status == Ok) { 00524 Bitmap *result = new Bitmap(cloneBitmap, lastStatus); 00525 if (!result) { 00526 DllExports::GdipDisposeImage(cloneBitmap); 00527 lastStatus = OutOfMemory; 00528 } 00529 return result; 00530 } else { 00531 return NULL; 00532 } 00533 } 00534 00535 __inline__ Bitmap* Bitmap::Clone(INT x, INT y, INT width, INT height, 00536 PixelFormat format) const 00537 { 00538 GpBitmap *cloneBitmap = NULL; 00539 Status status = updateStatus(DllExports::GdipCloneBitmapAreaI( 00540 x, y, width, height, format, 00541 (GpBitmap*) nativeImage, &cloneBitmap)); 00542 if (status == Ok) { 00543 Bitmap *result = new Bitmap(cloneBitmap, lastStatus); 00544 if (!result) { 00545 DllExports::GdipDisposeImage(cloneBitmap); 00546 lastStatus = OutOfMemory; 00547 } 00548 return result; 00549 } else { 00550 return NULL; 00551 } 00552 } 00553 00554 //TODO: [GDI+ 1.1] Bitmap::ApplyEffect 00555 //__inline__ Status Bitmap::ApplyEffect(Effect *effect, RECT *ROI) 00556 //{ 00557 // return NotImplemented; 00558 //} 00559 00560 __inline__ Status Bitmap::ConvertFormat(PixelFormat format, 00561 DitherType ditherType, PaletteType paletteType, 00562 ColorPalette *palette, REAL alphaThresholdPercent) 00563 { 00564 // FIXME: can't test GdipBitmapConvertFormat b/c it isn't exported in 1.0 00565 return updateStatus(DllExports::GdipBitmapConvertFormat( 00566 (GpBitmap*) nativeImage, format, ditherType, 00567 paletteType, palette, alphaThresholdPercent)); 00568 } 00569 00570 __inline__ Status Bitmap::GetHBITMAP( 00571 const Color& colorBackground, HBITMAP *hbmReturn) const 00572 { 00573 return updateStatus(DllExports::GdipCreateHBITMAPFromBitmap( 00574 (GpBitmap*) nativeImage, hbmReturn, 00575 colorBackground.GetValue())); 00576 } 00577 00578 __inline__ Status Bitmap::GetHICON(HICON *icon) const 00579 { 00580 return updateStatus(DllExports::GdipCreateHICONFromBitmap( 00581 (GpBitmap*) nativeImage, icon)); 00582 } 00583 00584 __inline__ Status Bitmap::GetHistogram(HistogramFormat format, 00585 UINT numberOfEntries, 00586 UINT *channel0, UINT *channel1, 00587 UINT *channel2, UINT *channel3) const 00588 { 00589 return updateStatus(DllExports::GdipBitmapGetHistogram( 00590 (GpBitmap*) nativeImage, format, numberOfEntries, 00591 channel0, channel1, channel2, channel3)); 00592 } 00593 00594 __inline__ Status Bitmap::GetHistogramSize(HistogramFormat format, 00595 UINT *numberOfEntries) const 00596 { 00597 return updateStatus(DllExports::GdipBitmapGetHistogramSize( 00598 format, numberOfEntries)); 00599 } 00600 00601 __inline__ Status Bitmap::GetPixel(INT x, INT y, Color *color) const 00602 { 00603 return updateStatus(DllExports::GdipBitmapGetPixel( 00604 (GpBitmap*) nativeImage, x, y, 00605 color ? &color->Value : NULL)); 00606 } 00607 00608 __inline__ Status Bitmap::LockBits(const Rect *rect, UINT flags, 00609 PixelFormat format, BitmapData *lockedBitmapData) 00610 { 00611 return updateStatus(DllExports::GdipBitmapLockBits( 00612 (GpBitmap*) nativeImage, rect, flags, format, 00613 lockedBitmapData)); 00614 } 00615 00616 __inline__ Status Bitmap::SetPixel(INT x, INT y, const Color& color) 00617 { 00618 return updateStatus(DllExports::GdipBitmapSetPixel( 00619 (GpBitmap*) nativeImage, x, y, color.GetValue())); 00620 } 00621 00622 __inline__ Status Bitmap::SetResolution(REAL xdpi, REAL ydpi) 00623 { 00624 return updateStatus(DllExports::GdipBitmapSetResolution( 00625 (GpBitmap*) nativeImage, xdpi, ydpi)); 00626 } 00627 00628 __inline__ Status Bitmap::UnlockBits(BitmapData *lockedBitmapData) 00629 { 00630 return updateStatus(DllExports::GdipBitmapUnlockBits( 00631 (GpBitmap*) nativeImage, lockedBitmapData)); 00632 } 00633 00634 00635 // CachedBitmap 00636 00637 __inline__ CachedBitmap::CachedBitmap(Bitmap *bitmap, Graphics *graphics): 00638 nativeCachedBitmap(NULL), lastStatus(Ok) 00639 { 00640 lastStatus = DllExports::GdipCreateCachedBitmap( 00641 bitmap ? ((GpBitmap*) bitmap->nativeImage) : NULL, 00642 graphics ? graphics->nativeGraphics : NULL, 00643 &nativeCachedBitmap); 00644 } 00645 00646 __inline__ CachedBitmap::~CachedBitmap() 00647 { 00648 DllExports::GdipDeleteCachedBitmap(nativeCachedBitmap); 00649 } 00650 00651 00652 // CustomLineCap 00653 00654 __inline__ CustomLineCap::CustomLineCap( 00655 const GraphicsPath *fillPath, 00656 const GraphicsPath *strokePath, 00657 LineCap baseCap, REAL baseInset): 00658 nativeCustomLineCap(NULL), lastStatus(Ok) 00659 { 00660 lastStatus = DllExports::GdipCreateCustomLineCap( 00661 fillPath ? fillPath->nativePath : NULL, 00662 strokePath ? strokePath->nativePath : NULL, 00663 baseCap, baseInset, &nativeCustomLineCap); 00664 } 00665 00666 __inline__ LineCap CustomLineCap::GetBaseCap() const 00667 { 00668 LineCap result = LineCapFlat; 00669 updateStatus(DllExports::GdipGetCustomLineCapBaseCap( 00670 nativeCustomLineCap, &result)); 00671 return result; 00672 } 00673 00674 __inline__ REAL CustomLineCap::GetBaseInset() const 00675 { 00676 REAL result = 0.0f; 00677 updateStatus(DllExports::GdipGetCustomLineCapBaseInset( 00678 nativeCustomLineCap, &result)); 00679 return result; 00680 } 00681 00682 __inline__ Status CustomLineCap::GetStrokeCaps(LineCap *startCap, 00683 LineCap *endCap) const 00684 { 00685 return updateStatus(DllExports::GdipGetCustomLineCapStrokeCaps( 00686 nativeCustomLineCap, startCap, endCap)); 00687 } 00688 00689 __inline__ LineJoin CustomLineCap::GetStrokeJoin() const 00690 { 00691 LineJoin result = LineJoinMiter; 00692 updateStatus(DllExports::GdipGetCustomLineCapStrokeJoin( 00693 nativeCustomLineCap, &result)); 00694 return result; 00695 } 00696 00697 __inline__ REAL CustomLineCap::GetWidthScale() const 00698 { 00699 REAL result = 0.0f; 00700 updateStatus(DllExports::GdipGetCustomLineCapWidthScale( 00701 nativeCustomLineCap, &result)); 00702 return result; 00703 } 00704 00705 __inline__ Status CustomLineCap::SetBaseCap(LineCap baseCap) 00706 { 00707 return updateStatus(DllExports::GdipSetCustomLineCapBaseCap( 00708 nativeCustomLineCap, baseCap)); 00709 } 00710 00711 __inline__ Status CustomLineCap::SetBaseInset(REAL inset) 00712 { 00713 return updateStatus(DllExports::GdipSetCustomLineCapBaseInset( 00714 nativeCustomLineCap, inset)); 00715 } 00716 00717 __inline__ Status CustomLineCap::SetStrokeCap(LineCap strokeCap) 00718 { 00719 return updateStatus(DllExports::GdipSetCustomLineCapStrokeCaps( 00720 nativeCustomLineCap, strokeCap, strokeCap)); 00721 } 00722 00723 __inline__ Status CustomLineCap::SetStrokeCaps(LineCap startCap, LineCap endCap) 00724 { 00725 return updateStatus(DllExports::GdipSetCustomLineCapStrokeCaps( 00726 nativeCustomLineCap, startCap, endCap)); 00727 } 00728 00729 __inline__ Status CustomLineCap::SetStrokeJoin(LineJoin lineJoin) 00730 { 00731 return updateStatus(DllExports::GdipSetCustomLineCapStrokeJoin( 00732 nativeCustomLineCap, lineJoin)); 00733 } 00734 00735 __inline__ Status CustomLineCap::SetWidthScale(REAL widthScale) 00736 { 00737 return updateStatus(DllExports::GdipSetCustomLineCapWidthScale( 00738 nativeCustomLineCap, widthScale)); 00739 } 00740 00741 00742 // Font 00743 00744 __inline__ Font::Font(const FontFamily *family, 00745 REAL emSize, INT style, Unit unit): 00746 nativeFont(NULL), lastStatus(Ok) 00747 { 00748 lastStatus = DllExports::GdipCreateFont( 00749 family ? family->nativeFontFamily : NULL, 00750 emSize, style, unit, &nativeFont); 00751 } 00752 00753 __inline__ Font::Font(HDC hdc, HFONT hfont): 00754 nativeFont(NULL), lastStatus(Ok) 00755 { 00756 LOGFONTW logfont; 00757 if (GetObject(hfont, sizeof logfont, &logfont)) { 00758 lastStatus = DllExports::GdipCreateFontFromLogfontW( 00759 hdc, &logfont, &nativeFont); 00760 } else { 00761 lastStatus = DllExports::GdipCreateFontFromDC( 00762 hdc, &nativeFont); 00763 } 00764 } 00765 00766 __inline__ Font::Font(HDC hdc, const LOGFONTA *logfont): 00767 nativeFont(NULL), lastStatus(Ok) 00768 { 00769 lastStatus = DllExports::GdipCreateFontFromLogfontA( 00770 hdc, logfont, &nativeFont); 00771 } 00772 00773 __inline__ Font::Font(HDC hdc, const LOGFONTW *logfont): 00774 nativeFont(NULL), lastStatus(Ok) 00775 { 00776 lastStatus = DllExports::GdipCreateFontFromLogfontW( 00777 hdc, logfont, &nativeFont); 00778 } 00779 00780 __inline__ Font::Font(HDC hdc): 00781 nativeFont(NULL), lastStatus(Ok) 00782 { 00783 lastStatus = DllExports::GdipCreateFontFromDC(hdc, &nativeFont); 00784 } 00785 00786 __inline__ Font::Font(const WCHAR *familyName, REAL emSize, INT style, 00787 Unit unit, const FontCollection *fontCollection): 00788 nativeFont(NULL), lastStatus(Ok) 00789 { 00790 GpFontFamily *nativeFamily = NULL; 00791 lastStatus = DllExports::GdipCreateFontFamilyFromName( 00792 familyName, 00793 fontCollection ? fontCollection->nativeFontCollection : NULL, 00794 &nativeFamily); 00795 00796 if (nativeFamily) { 00797 lastStatus = DllExports::GdipCreateFont( 00798 nativeFamily, emSize, style, unit, &nativeFont); 00799 DllExports::GdipDeleteFontFamily(nativeFamily); 00800 } 00801 } 00802 00803 __inline__ Font::~Font() 00804 { 00805 DllExports::GdipDeleteFont(nativeFont); 00806 } 00807 00808 __inline__ Font* Font::Clone() const 00809 { 00810 GpFont *cloneFont = NULL; 00811 Status status = updateStatus(DllExports::GdipCloneFont( 00812 nativeFont, &cloneFont)); 00813 if (status == Ok) { 00814 Font *result = new Font(cloneFont, lastStatus); 00815 if (!result) { 00816 DllExports::GdipDeleteFont(cloneFont); 00817 lastStatus = OutOfMemory; 00818 } 00819 return result; 00820 } else { 00821 return NULL; 00822 } 00823 } 00824 00825 __inline__ Status Font::GetFamily(FontFamily *family) const 00826 { 00827 if (!family) return lastStatus = InvalidParameter; 00828 // FIXME: do we need to call GdipDeleteFontFamily first? 00829 return family->lastStatus = updateStatus(DllExports::GdipGetFamily( 00830 nativeFont, &family->nativeFontFamily)); 00831 } 00832 00833 __inline__ REAL Font::GetHeight(const Graphics *graphics) const 00834 { 00835 REAL result = 0.0f; 00836 updateStatus(DllExports::GdipGetFontHeight( 00837 nativeFont, graphics ? graphics->nativeGraphics : NULL, 00838 &result)); 00839 return result; 00840 } 00841 00842 __inline__ REAL Font::GetHeight(REAL dpi) const 00843 { 00844 REAL result = 0.0f; 00845 updateStatus(DllExports::GdipGetFontHeightGivenDPI( 00846 nativeFont, dpi, &result)); 00847 return result; 00848 } 00849 00850 __inline__ Status Font::GetLogFontA(const Graphics *graphics, LOGFONTA *logfontA) 00851 const 00852 { 00853 return updateStatus(DllExports::GdipGetLogFontA( 00854 nativeFont, graphics ? graphics->nativeGraphics : NULL, 00855 logfontA)); 00856 } 00857 00858 __inline__ Status Font::GetLogFontW(const Graphics *graphics, LOGFONTW *logfontW) 00859 const 00860 { 00861 return updateStatus(DllExports::GdipGetLogFontW( 00862 nativeFont, graphics ? graphics->nativeGraphics : NULL, 00863 logfontW)); 00864 } 00865 00866 __inline__ REAL Font::GetSize() const 00867 { 00868 REAL result = 0.0; 00869 updateStatus(DllExports::GdipGetFontSize(nativeFont, &result)); 00870 return result; 00871 } 00872 00873 __inline__ INT Font::GetStyle() const 00874 { 00875 INT result = FontStyleRegular; 00876 updateStatus(DllExports::GdipGetFontStyle(nativeFont, &result)); 00877 return result; 00878 } 00879 00880 __inline__ Unit Font::GetUnit() const 00881 { 00882 Unit result = UnitPoint; 00883 updateStatus(DllExports::GdipGetFontUnit(nativeFont, &result)); 00884 return result; 00885 } 00886 00887 00888 // FontCollection 00889 00890 __inline__ FontCollection::FontCollection(): 00891 nativeFontCollection(NULL), lastStatus(Ok) 00892 { 00893 } 00894 00895 __inline__ Status FontCollection::GetFamilies(INT numSought, 00896 FontFamily *families, INT *numFound) const 00897 { 00898 if (numSought <= 0 || !families || !numFound) 00899 return lastStatus = InvalidParameter; 00900 00901 for (int i = 0; i < numSought; ++i) { 00902 families[i].nativeFontFamily = NULL; 00903 families[i].lastStatus = FontFamilyNotFound; 00904 } 00905 *numFound = 0; 00906 00907 GpFontFamily **nativeFamilyArray = (GpFontFamily**) 00908 DllExports::GdipAlloc(numSought * sizeof (GpFontFamily*)); 00909 if (!nativeFamilyArray) 00910 return lastStatus = OutOfMemory; 00911 00912 Status status = updateStatus(DllExports::GdipGetFontCollectionFamilyList( 00913 nativeFontCollection, numSought, nativeFamilyArray, 00914 numFound)); 00915 00916 // FIXME: must the native GpFontFamily objects be cloned? Seems so. 00917 // (if this is not done, the "Creating a Private Font Collection" 00918 // example crashes on "delete[] pFontFamily") 00919 00920 if (status == Ok) { 00921 for (int i = 0; i < *numFound; ++i) { 00922 families[i].lastStatus = 00923 updateStatus(DllExports::GdipCloneFontFamily( 00924 nativeFamilyArray[i], 00925 &families[i].nativeFontFamily)); 00926 } 00927 } 00928 00929 DllExports::GdipFree(nativeFamilyArray); 00930 return status; 00931 } 00932 00933 __inline__ INT FontCollection::GetFamilyCount() const 00934 { 00935 INT result = 0; 00936 updateStatus(DllExports::GdipGetFontCollectionFamilyCount( 00937 nativeFontCollection, &result)); 00938 return result; 00939 } 00940 00941 00942 // FontFamily 00943 00944 // FIXME: do FontFamily::GenericMonospace() et al. need to be thread safe? 00945 // FIXME: maybe put parts of this in gdiplus.c 00946 00947 extern "C" void *_GdipFontFamilyCachedGenericMonospace; 00948 extern "C" void *_GdipFontFamilyCachedGenericSansSerif; 00949 extern "C" void *_GdipFontFamilyCachedGenericSerif; 00950 00951 __inline__ const FontFamily* FontFamily::GenericMonospace() 00952 { 00953 if (!_GdipFontFamilyCachedGenericMonospace) { 00954 GpFontFamily *nativeFontFamily = 0; 00955 Status status = DllExports::GdipGetGenericFontFamilyMonospace( 00956 &nativeFontFamily); 00957 if (status == Ok && nativeFontFamily) { 00958 _GdipFontFamilyCachedGenericMonospace = (void*) 00959 new FontFamily(nativeFontFamily, Ok); 00960 } 00961 } 00962 return (FontFamily*) _GdipFontFamilyCachedGenericMonospace; 00963 } 00964 00965 __inline__ const FontFamily* FontFamily::GenericSansSerif() 00966 { 00967 if (!_GdipFontFamilyCachedGenericSansSerif) { 00968 GpFontFamily *nativeFontFamily = 0; 00969 Status status = DllExports::GdipGetGenericFontFamilySansSerif( 00970 &nativeFontFamily); 00971 if (status == Ok && nativeFontFamily) { 00972 _GdipFontFamilyCachedGenericSansSerif = (void*) 00973 new FontFamily(nativeFontFamily, Ok); 00974 } 00975 } 00976 return (FontFamily*) _GdipFontFamilyCachedGenericSansSerif; 00977 } 00978 00979 __inline__ const FontFamily* FontFamily::GenericSerif() 00980 { 00981 if (!_GdipFontFamilyCachedGenericSerif) { 00982 GpFontFamily *nativeFontFamily = 0; 00983 Status status = DllExports::GdipGetGenericFontFamilySerif( 00984 &nativeFontFamily); 00985 if (status == Ok && nativeFontFamily) { 00986 _GdipFontFamilyCachedGenericSerif = (void*) 00987 new FontFamily(nativeFontFamily, Ok); 00988 } 00989 } 00990 return (FontFamily*) _GdipFontFamilyCachedGenericSerif; 00991 } 00992 00993 __inline__ FontFamily::FontFamily(): 00994 nativeFontFamily(NULL), lastStatus(Ok) 00995 { 00996 } 00997 00998 __inline__ FontFamily::FontFamily(const WCHAR *name, 00999 const FontCollection *fontCollection): 01000 nativeFontFamily(NULL), lastStatus(Ok) 01001 { 01002 lastStatus = DllExports::GdipCreateFontFamilyFromName(name, 01003 fontCollection ? fontCollection->nativeFontCollection : NULL, 01004 &nativeFontFamily); 01005 } 01006 01007 __inline__ FontFamily::~FontFamily() 01008 { 01009 DllExports::GdipDeleteFontFamily(nativeFontFamily); 01010 } 01011 01012 __inline__ FontFamily* FontFamily::Clone() const 01013 { 01014 GpFontFamily *cloneFontFamily = NULL; 01015 Status status = updateStatus(DllExports::GdipCloneFontFamily( 01016 nativeFontFamily, &cloneFontFamily)); 01017 if (status == Ok) { 01018 FontFamily *result = new FontFamily(cloneFontFamily, lastStatus); 01019 if (!result) { 01020 DllExports::GdipDeleteFontFamily(cloneFontFamily); 01021 lastStatus = OutOfMemory; 01022 } 01023 return result; 01024 } else { 01025 return NULL; 01026 } 01027 } 01028 01029 __inline__ UINT16 FontFamily::GetCellAscent(INT style) const 01030 { 01031 UINT16 result = 0; 01032 updateStatus(DllExports::GdipGetCellAscent( 01033 nativeFontFamily, style, &result)); 01034 return result; 01035 } 01036 01037 __inline__ UINT16 FontFamily::GetCellDescent(INT style) const 01038 { 01039 UINT16 result = 0; 01040 updateStatus(DllExports::GdipGetCellDescent( 01041 nativeFontFamily, style, &result)); 01042 return result; 01043 } 01044 01045 __inline__ UINT16 FontFamily::GetEmHeight(INT style) const 01046 { 01047 UINT16 result = 0; 01048 updateStatus(DllExports::GdipGetEmHeight( 01049 nativeFontFamily, style, &result)); 01050 return result; 01051 } 01052 01053 __inline__ Status FontFamily::GetFamilyName(WCHAR name[LF_FACESIZE], 01054 LANGID language) const 01055 { 01056 return updateStatus(DllExports::GdipGetFamilyName( 01057 nativeFontFamily, name, language)); 01058 } 01059 01060 __inline__ UINT16 FontFamily::GetLineSpacing(INT style) const 01061 { 01062 UINT16 result = 0; 01063 updateStatus(DllExports::GdipGetLineSpacing( 01064 nativeFontFamily, style, &result)); 01065 return result; 01066 } 01067 01068 __inline__ BOOL FontFamily::IsStyleAvailable(INT style) const 01069 { 01070 BOOL result = FALSE; 01071 updateStatus(DllExports::GdipIsStyleAvailable( 01072 nativeFontFamily, style, &result)); 01073 return result; 01074 } 01075 01076 01077 // InstalledFontCollection 01078 01079 __inline__ InstalledFontCollection::InstalledFontCollection() 01080 { 01081 lastStatus = DllExports::GdipNewInstalledFontCollection( 01082 &nativeFontCollection); 01083 } 01084 01085 01086 // PrivateFontCollection 01087 01088 __inline__ PrivateFontCollection::PrivateFontCollection() 01089 { 01090 lastStatus = DllExports::GdipNewPrivateFontCollection( 01091 &nativeFontCollection); 01092 } 01093 01094 __inline__ Status PrivateFontCollection::AddFontFile(const WCHAR *filename) 01095 { 01096 return updateStatus(DllExports::GdipPrivateAddFontFile( 01097 nativeFontCollection, filename)); 01098 } 01099 01100 __inline__ Status PrivateFontCollection::AddMemoryFont( 01101 const VOID *memory, INT length) 01102 { 01103 return updateStatus(DllExports::GdipPrivateAddMemoryFont( 01104 nativeFontCollection, memory, length)); 01105 } 01106 01107 01108 // Region 01109 01110 __inline__ Region* Region::FromHRGN(HRGN hrgn) 01111 { 01112 return new Region(hrgn); 01113 } 01114 01115 __inline__ Region::Region(): nativeRegion(NULL), lastStatus(Ok) 01116 { 01117 lastStatus = DllExports::GdipCreateRegion(&nativeRegion); 01118 } 01119 01120 __inline__ Region::Region(const RectF& rect): nativeRegion(NULL), lastStatus(Ok) 01121 { 01122 lastStatus = DllExports::GdipCreateRegionRect(&rect, &nativeRegion); 01123 } 01124 01125 __inline__ Region::Region(const Rect& rect): nativeRegion(NULL), lastStatus(Ok) 01126 { 01127 lastStatus = DllExports::GdipCreateRegionRectI(&rect, &nativeRegion); 01128 } 01129 01130 __inline__ Region::Region(const GraphicsPath *path): 01131 nativeRegion(NULL), lastStatus(Ok) 01132 { 01133 lastStatus = DllExports::GdipCreateRegionPath( 01134 path ? path->nativePath : NULL, &nativeRegion); 01135 } 01136 01137 __inline__ Region::Region(const BYTE *regionData, INT size): 01138 nativeRegion(NULL), lastStatus(Ok) 01139 { 01140 lastStatus = DllExports::GdipCreateRegionRgnData( 01141 regionData, size, &nativeRegion); 01142 } 01143 01144 __inline__ Region::Region(HRGN hrgn): nativeRegion(NULL), lastStatus(Ok) 01145 { 01146 lastStatus = DllExports::GdipCreateRegionHrgn(hrgn, &nativeRegion); 01147 } 01148 01149 __inline__ Region::~Region() 01150 { 01151 DllExports::GdipDeleteRegion(nativeRegion); 01152 } 01153 01154 __inline__ Region* Region::Clone() const 01155 { 01156 GpRegion *cloneRegion = NULL; 01157 Status status = updateStatus(DllExports::GdipCloneRegion( 01158 nativeRegion, &cloneRegion)); 01159 if (status == Ok) { 01160 Region *result = new Region(cloneRegion, lastStatus); 01161 if (!result) { 01162 DllExports::GdipDeleteRegion(cloneRegion); 01163 lastStatus = OutOfMemory; 01164 } 01165 return result; 01166 } else { 01167 return NULL; 01168 } 01169 } 01170 01171 __inline__ Status Region::Complement(const RectF& rect) 01172 { 01173 return updateStatus(DllExports::GdipCombineRegionRect( 01174 nativeRegion, &rect, CombineModeComplement)); 01175 } 01176 01177 __inline__ Status Region::Complement(const Rect& rect) 01178 { 01179 return updateStatus(DllExports::GdipCombineRegionRectI( 01180 nativeRegion, &rect, CombineModeComplement)); 01181 } 01182 01183 __inline__ Status Region::Complement(const Region *region) 01184 { 01185 return updateStatus(DllExports::GdipCombineRegionRegion( 01186 nativeRegion, region ? region->nativeRegion : NULL, 01187 CombineModeComplement)); 01188 } 01189 01190 __inline__ Status Region::Complement(const GraphicsPath *path) 01191 { 01192 return updateStatus(DllExports::GdipCombineRegionPath( 01193 nativeRegion, path ? path->nativePath : NULL, 01194 CombineModeComplement)); 01195 } 01196 01197 __inline__ BOOL Region::Equals(const Region *region, const Graphics *graphics) 01198 const 01199 { 01200 BOOL result = FALSE; 01201 updateStatus(DllExports::GdipIsEqualRegion( 01202 nativeRegion, region ? region->nativeRegion : NULL, 01203 graphics ? graphics->nativeGraphics : NULL, &result)); 01204 return result; 01205 } 01206 01207 __inline__ Status Region::Exclude(const RectF& rect) 01208 { 01209 return updateStatus(DllExports::GdipCombineRegionRect( 01210 nativeRegion, &rect, CombineModeExclude)); 01211 } 01212 01213 __inline__ Status Region::Exclude(const Rect& rect) 01214 { 01215 return updateStatus(DllExports::GdipCombineRegionRectI( 01216 nativeRegion, &rect, CombineModeExclude)); 01217 } 01218 01219 __inline__ Status Region::Exclude(const Region *region) 01220 { 01221 return updateStatus(DllExports::GdipCombineRegionRegion( 01222 nativeRegion, region ? region->nativeRegion : NULL, 01223 CombineModeExclude)); 01224 } 01225 01226 __inline__ Status Region::Exclude(const GraphicsPath *path) 01227 { 01228 return updateStatus(DllExports::GdipCombineRegionPath( 01229 nativeRegion, path ? path->nativePath : NULL, 01230 CombineModeExclude)); 01231 } 01232 01233 __inline__ Status Region::GetBounds(RectF *rect, const Graphics *graphics) const 01234 { 01235 return updateStatus(DllExports::GdipGetRegionBounds(nativeRegion, 01236 graphics ? graphics->nativeGraphics : NULL, rect)); 01237 } 01238 01239 __inline__ Status Region::GetBounds(Rect *rect, const Graphics *graphics) const 01240 { 01241 return updateStatus(DllExports::GdipGetRegionBoundsI(nativeRegion, 01242 graphics ? graphics->nativeGraphics : NULL, rect)); 01243 } 01244 01245 __inline__ Status Region::GetData(BYTE *buffer, UINT bufferSize, 01246 UINT *sizeFilled) const 01247 { 01248 return updateStatus(DllExports::GdipGetRegionData( 01249 nativeRegion, buffer, bufferSize, sizeFilled)); 01250 } 01251 01252 __inline__ UINT Region::GetDataSize() const 01253 { 01254 UINT result = 0; 01255 updateStatus(DllExports::GdipGetRegionDataSize(nativeRegion, &result)); 01256 return result; 01257 } 01258 01259 __inline__ HRGN Region::GetHRGN(const Graphics *graphics) const 01260 { 01261 HRGN result = NULL; 01262 updateStatus(DllExports::GdipGetRegionHRgn(nativeRegion, 01263 graphics ? graphics->nativeGraphics : NULL, &result)); 01264 return result; 01265 } 01266 01267 __inline__ Status Region::GetRegionScans(const Matrix *matrix, 01268 RectF *rects, INT *count) const 01269 { 01270 return updateStatus(DllExports::GdipGetRegionScans( 01271 nativeRegion, rects, count, 01272 matrix ? matrix->nativeMatrix : NULL)); 01273 } 01274 01275 __inline__ Status Region::GetRegionScans(const Matrix *matrix, 01276 Rect *rects, INT *count) const 01277 { 01278 return updateStatus(DllExports::GdipGetRegionScansI( 01279 nativeRegion, rects, count, 01280 matrix ? matrix->nativeMatrix : NULL)); 01281 } 01282 01283 __inline__ UINT Region::GetRegionScansCount(const Matrix *matrix) const 01284 { 01285 UINT result = 0; 01286 updateStatus(DllExports::GdipGetRegionScansCount( 01287 nativeRegion, &result, 01288 matrix ? matrix->nativeMatrix : NULL)); 01289 return result; 01290 } 01291 01292 __inline__ Status Region::Intersect(const RectF& rect) 01293 { 01294 return updateStatus(DllExports::GdipCombineRegionRect( 01295 nativeRegion, &rect, CombineModeIntersect)); 01296 } 01297 01298 __inline__ Status Region::Intersect(const Rect& rect) 01299 { 01300 return updateStatus(DllExports::GdipCombineRegionRectI( 01301 nativeRegion, &rect, CombineModeIntersect)); 01302 } 01303 01304 __inline__ Status Region::Intersect(const Region *region) 01305 { 01306 return updateStatus(DllExports::GdipCombineRegionRegion( 01307 nativeRegion, region ? region->nativeRegion : NULL, 01308 CombineModeIntersect)); 01309 } 01310 01311 __inline__ Status Region::Intersect(const GraphicsPath *path) 01312 { 01313 return updateStatus(DllExports::GdipCombineRegionPath( 01314 nativeRegion, path ? path->nativePath : NULL, 01315 CombineModeIntersect)); 01316 } 01317 01318 __inline__ BOOL Region::IsEmpty(const Graphics *graphics) const 01319 { 01320 BOOL result = FALSE; 01321 updateStatus(DllExports::GdipIsEmptyRegion(nativeRegion, 01322 graphics ? graphics->nativeGraphics : NULL, &result)); 01323 return result; 01324 } 01325 01326 __inline__ BOOL Region::IsInfinite(const Graphics *graphics) const 01327 { 01328 BOOL result = FALSE; 01329 updateStatus(DllExports::GdipIsInfiniteRegion(nativeRegion, 01330 graphics ? graphics->nativeGraphics : NULL, &result)); 01331 return result; 01332 } 01333 01334 __inline__ BOOL Region::IsVisible(REAL x, REAL y, 01335 const Graphics *graphics) const 01336 { 01337 BOOL result = FALSE; 01338 updateStatus(DllExports::GdipIsVisibleRegionPoint( 01339 nativeRegion, x, y, 01340 graphics ? graphics->nativeGraphics : NULL, &result)); 01341 return result; 01342 } 01343 01344 __inline__ BOOL Region::IsVisible(INT x, INT y, 01345 const Graphics *graphics) const 01346 { 01347 BOOL result = FALSE; 01348 updateStatus(DllExports::GdipIsVisibleRegionPointI( 01349 nativeRegion, x, y, 01350 graphics ? graphics->nativeGraphics : NULL, &result)); 01351 return result; 01352 } 01353 01354 __inline__ BOOL Region::IsVisible(const PointF& point, 01355 const Graphics *graphics) const 01356 { 01357 BOOL result = FALSE; 01358 updateStatus(DllExports::GdipIsVisibleRegionPoint( 01359 nativeRegion, point.X, point.Y, 01360 graphics ? graphics->nativeGraphics : NULL, &result)); 01361 return result; 01362 } 01363 01364 __inline__ BOOL Region::IsVisible(const Point& point, 01365 const Graphics *graphics) const 01366 { 01367 BOOL result = FALSE; 01368 updateStatus(DllExports::GdipIsVisibleRegionPointI( 01369 nativeRegion, point.X, point.Y, 01370 graphics ? graphics->nativeGraphics : NULL, &result)); 01371 return result; 01372 } 01373 01374 __inline__ BOOL Region::IsVisible(REAL x, REAL y, REAL width, REAL height, 01375 const Graphics *graphics) const 01376 { 01377 BOOL result = FALSE; 01378 updateStatus(DllExports::GdipIsVisibleRegionRect( 01379 nativeRegion, x, y, width, height, 01380 graphics ? graphics->nativeGraphics : NULL, &result)); 01381 return result; 01382 } 01383 01384 __inline__ BOOL Region::IsVisible(INT x, INT y, INT width, INT height, 01385 const Graphics *graphics) const 01386 { 01387 BOOL result = FALSE; 01388 updateStatus(DllExports::GdipIsVisibleRegionRectI( 01389 nativeRegion, x, y, width, height, 01390 graphics ? graphics->nativeGraphics : NULL, &result)); 01391 return result; 01392 } 01393 01394 __inline__ BOOL Region::IsVisible(const RectF& rect, 01395 const Graphics *graphics) const 01396 { 01397 BOOL result = FALSE; 01398 updateStatus(DllExports::GdipIsVisibleRegionRect( 01399 nativeRegion, rect.X, rect.Y, rect.Width, rect.Height, 01400 graphics ? graphics->nativeGraphics : NULL, &result)); 01401 return result; 01402 } 01403 01404 __inline__ BOOL Region::IsVisible(const Rect& rect, 01405 const Graphics *graphics) const 01406 { 01407 BOOL result = FALSE; 01408 updateStatus(DllExports::GdipIsVisibleRegionRectI( 01409 nativeRegion, rect.X, rect.Y, rect.Width, rect.Height, 01410 graphics ? graphics->nativeGraphics : NULL, &result)); 01411 return result; 01412 } 01413 01414 __inline__ Status Region::MakeEmpty() 01415 { 01416 return updateStatus(DllExports::GdipSetEmpty(nativeRegion)); 01417 } 01418 01419 __inline__ Status Region::MakeInfinite() 01420 { 01421 return updateStatus(DllExports::GdipSetInfinite(nativeRegion)); 01422 } 01423 01424 __inline__ Status Region::Transform(const Matrix *matrix) 01425 { 01426 return updateStatus(DllExports::GdipTransformRegion( 01427 nativeRegion, matrix ? matrix->nativeMatrix : NULL)); 01428 } 01429 01430 __inline__ Status Region::Translate(REAL dx, REAL dy) 01431 { 01432 return updateStatus(DllExports::GdipTranslateRegion( 01433 nativeRegion, dx, dy)); 01434 } 01435 01436 __inline__ Status Region::Translate(INT dx, INT dy) 01437 { 01438 return updateStatus(DllExports::GdipTranslateRegionI( 01439 nativeRegion, dx, dy)); 01440 } 01441 01442 __inline__ Status Region::Union(const RectF& rect) 01443 { 01444 return updateStatus(DllExports::GdipCombineRegionRect( 01445 nativeRegion, &rect, CombineModeUnion)); 01446 } 01447 01448 __inline__ Status Region::Union(const Rect& rect) 01449 { 01450 return updateStatus(DllExports::GdipCombineRegionRectI( 01451 nativeRegion, &rect, CombineModeUnion)); 01452 } 01453 01454 __inline__ Status Region::Union(const Region *region) 01455 { 01456 return updateStatus(DllExports::GdipCombineRegionRegion( 01457 nativeRegion, region ? region->nativeRegion : NULL, 01458 CombineModeUnion)); 01459 } 01460 01461 __inline__ Status Region::Union(const GraphicsPath *path) 01462 { 01463 return updateStatus(DllExports::GdipCombineRegionPath( 01464 nativeRegion, path ? path->nativePath : NULL, 01465 CombineModeUnion)); 01466 } 01467 01468 __inline__ Status Region::Xor(const RectF& rect) 01469 { 01470 return updateStatus(DllExports::GdipCombineRegionRect( 01471 nativeRegion, &rect, CombineModeXor)); 01472 } 01473 01474 __inline__ Status Region::Xor(const Rect& rect) 01475 { 01476 return updateStatus(DllExports::GdipCombineRegionRectI( 01477 nativeRegion, &rect, CombineModeXor)); 01478 } 01479 01480 __inline__ Status Region::Xor(const Region *region) 01481 { 01482 return updateStatus(DllExports::GdipCombineRegionRegion( 01483 nativeRegion, region ? region->nativeRegion : NULL, 01484 CombineModeXor)); 01485 } 01486 01487 __inline__ Status Region::Xor(const GraphicsPath *path) 01488 { 01489 return updateStatus(DllExports::GdipCombineRegionPath( 01490 nativeRegion, path ? path->nativePath : NULL, 01491 CombineModeXor)); 01492 } 01493 01494 01495 // GraphicsPath 01496 01497 __inline__ BOOL GraphicsPath::IsOutlineVisible(REAL x, REAL y, const Pen *pen, 01498 const Graphics *g) const 01499 { 01500 BOOL result = FALSE; 01501 updateStatus(DllExports::GdipIsOutlineVisiblePathPoint( 01502 nativePath, x, y, pen ? pen->nativePen : NULL, 01503 g ? g->nativeGraphics : NULL, &result)); 01504 return result; 01505 } 01506 01507 __inline__ BOOL GraphicsPath::IsOutlineVisible(INT x, INT y, const Pen *pen, 01508 const Graphics *g) const 01509 { 01510 BOOL result = FALSE; 01511 updateStatus(DllExports::GdipIsOutlineVisiblePathPointI( 01512 nativePath, x, y, pen ? pen->nativePen : NULL, 01513 g ? g->nativeGraphics : NULL, &result)); 01514 return result; 01515 } 01516 01517 __inline__ BOOL GraphicsPath::IsOutlineVisible(const PointF& point, const Pen *pen, 01518 const Graphics *g) const 01519 { 01520 BOOL result = FALSE; 01521 updateStatus(DllExports::GdipIsOutlineVisiblePathPoint( 01522 nativePath, point.X, point.Y, 01523 pen ? pen->nativePen : NULL, 01524 g ? g->nativeGraphics : NULL, &result)); 01525 return result; 01526 } 01527 01528 __inline__ BOOL GraphicsPath::IsOutlineVisible(const Point& point, const Pen *pen, 01529 const Graphics *g) const 01530 { 01531 BOOL result = FALSE; 01532 updateStatus(DllExports::GdipIsOutlineVisiblePathPointI( 01533 nativePath, point.X, point.Y, 01534 pen ? pen->nativePen : NULL, 01535 g ? g->nativeGraphics : NULL, &result)); 01536 return result; 01537 } 01538 01539 __inline__ BOOL GraphicsPath::IsVisible(REAL x, REAL y, const Graphics *g) const 01540 { 01541 BOOL result = FALSE; 01542 updateStatus(DllExports::GdipIsVisiblePathPoint( 01543 nativePath, x, y, 01544 g ? g->nativeGraphics : NULL, &result)); 01545 return result; 01546 } 01547 __inline__ BOOL GraphicsPath::IsVisible(INT x, INT y, const Graphics *g) const 01548 { 01549 BOOL result = FALSE; 01550 updateStatus(DllExports::GdipIsVisiblePathPointI( 01551 nativePath, x, y, 01552 g ? g->nativeGraphics : NULL, &result)); 01553 return result; 01554 } 01555 01556 __inline__ BOOL GraphicsPath::IsVisible(const PointF& point, 01557 const Graphics *g) const 01558 { 01559 BOOL result = FALSE; 01560 updateStatus(DllExports::GdipIsVisiblePathPoint( 01561 nativePath, point.X, point.Y, 01562 g ? g->nativeGraphics : NULL, &result)); 01563 return result; 01564 } 01565 01566 __inline__ BOOL GraphicsPath::IsVisible(const Point& point, const Graphics *g) const 01567 { 01568 BOOL result = FALSE; 01569 updateStatus(DllExports::GdipIsVisiblePathPointI( 01570 nativePath, point.X, point.Y, 01571 g ? g->nativeGraphics : NULL, &result)); 01572 return result; 01573 } 01574 01575 01576 // PathData 01577 01578 __inline__ Status PathData::AllocateArrays(INT capacity) 01579 { 01580 if (capacity < 0) { 01581 return InvalidParameter; 01582 } else if (Count < capacity) { 01583 FreeArrays(); 01584 01585 PointF *pointArray = (PointF*) 01586 DllExports::GdipAlloc(capacity * sizeof(PointF)); 01587 if (!pointArray) 01588 return OutOfMemory; 01589 01590 BYTE *typeArray = (BYTE*) 01591 DllExports::GdipAlloc(capacity * sizeof(BYTE)); 01592 if (!typeArray) { 01593 DllExports::GdipFree(pointArray); 01594 return OutOfMemory; 01595 } 01596 01597 Count = capacity; 01598 Points = pointArray; 01599 Types = typeArray; 01600 } 01601 return Ok; 01602 } 01603 01604 __inline__ VOID PathData::FreeArrays() 01605 { 01606 if (Points) DllExports::GdipFree(Points); 01607 if (Types) DllExports::GdipFree(Types); 01608 Count = 0; 01609 Points = NULL; 01610 Types = NULL; 01611 } 01612 01613 #endif /* __GDIPLUS_IMPL_H */
Generated on Tue Jul 12 2022 19:59:54 by
1.7.2