home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 May / CMCD0504.ISO / Software / Freeware / Programare / gdiplusdelphi / pas / GDIPOBJ.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2003-04-05  |  289.4 KB  |  7,992 lines

  1.       {******************************************************************}
  2.       { GDI+ Class                                                       }
  3.       {                                                                  }
  4.       { home page : http://www.progdigy.com                              }
  5.       { email     : hgourvest@progdigy.com                               }
  6.       {                                                                  }
  7.       { date      : 15-02-2002                                           }
  8.       {                                                                  }
  9.       { The contents of this file are used with permission, subject to   }
  10.       { the Mozilla Public License Version 1.1 (the "License"); you may  }
  11.       { not use this file except in compliance with the License. You may }
  12.       { obtain a copy of the License at                                  }
  13.       { http://www.mozilla.org/MPL/MPL-1.1.html                          }
  14.       {                                                                  }
  15.       { Software distributed under the License is distributed on an      }
  16.       { "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or   }
  17.       { implied. See the License for the specific language governing     }
  18.       { rights and limitations under the License.                        }
  19.       {                                                                  }
  20.       { *****************************************************************}
  21.  
  22. unit GDIPOBJ;
  23.  
  24. interface
  25. uses
  26.   Windows,
  27.   ActiveX,
  28.   DirectDraw,
  29.   GDIPAPI;
  30.  
  31. (**************************************************************************\
  32. *
  33. *   GDI+ Codec Image APIs
  34. *
  35. \**************************************************************************)
  36.  
  37. //--------------------------------------------------------------------------
  38. // Codec Management APIs
  39. //--------------------------------------------------------------------------
  40.  
  41.   function GetImageDecodersSize(out numDecoders, size: UINT): TStatus;
  42.   function GetImageDecoders(numDecoders, size: UINT;
  43.     decoders: PImageCodecInfo): TStatus;
  44.   function GetImageEncodersSize(out numEncoders, size: UINT): TStatus;
  45.   function GetImageEncoders(numEncoders, size: UINT;
  46.     encoders: PImageCodecInfo): TStatus;
  47.  
  48. (**************************************************************************\
  49. *
  50. *   Private GDI+ header file.
  51. *
  52. \**************************************************************************)
  53.  
  54. //---------------------------------------------------------------------------
  55. // GDI+ classes for forward reference
  56. //---------------------------------------------------------------------------
  57.  
  58. type
  59.   TGPGraphics = class;
  60.   TGPPen = class;
  61.   TGPBrush = class;
  62.   TGPMatrix = class;
  63.   TGPBitmap = class;
  64.   TGPMetafile = class;
  65.   TGPFontFamily = class;
  66.   TGPGraphicsPath = class;
  67.   TGPRegion = class;
  68.   TGPImage = class;
  69.   TGPHatchBrush = class;
  70.   TGPSolidBrush = class;
  71.   TGPLinearGradientBrush = class;
  72.   TGPPathGradientBrush = class;
  73.   TGPFont = class;
  74.   TGPFontCollection = class;
  75.   TGPInstalledFontCollection = class;
  76.   TGPPrivateFontCollection = class;
  77.   TGPImageAttributes = class;
  78.   TGPCachedBitmap = class;
  79.  
  80. (**************************************************************************\
  81. *
  82. *   GDI+ Region, Font, Image, CustomLineCap class definitions.
  83. *
  84. \**************************************************************************)
  85.  
  86.   TGPRegion = class(TGdiplusBase)
  87.   protected
  88.     nativeRegion: GpRegion;
  89.     lastResult: TStatus;
  90.     function SetStatus(status: TStatus): TStatus;
  91.     procedure SetNativeRegion(nativeRegion: GpRegion);
  92.     constructor Create(nativeRegion: GpRegion); reintroduce; overload;
  93.   public
  94.     constructor Create; reintroduce; overload;
  95.     constructor Create(rect: TGPRectF); reintroduce; overload;
  96.     constructor Create(rect: TGPRect); reintroduce; overload;
  97.     constructor Create(path: TGPGraphicsPath); reintroduce; overload;
  98.     constructor Create(regionData: PBYTE; size: Integer); reintroduce; overload;
  99.     constructor Create(hRgn: HRGN); reintroduce; overload;
  100.     function FromHRGN(hRgn: HRGN): TGPRegion;
  101.     destructor Destroy; override;
  102.     function Clone: TGPRegion;
  103.     function MakeInfinite: TStatus;
  104.     function MakeEmpty: TStatus;
  105.     function GetDataSize: UINT;
  106.     // buffer     - where to put the data
  107.     // bufferSize - how big the buffer is (should be at least as big as GetDataSize())
  108.     // sizeFilled - if not NULL, this is an OUT param that says how many bytes
  109.     //              of data were written to the buffer.
  110.     function GetData(buffer: PBYTE; bufferSize: UINT;
  111.        sizeFilled: PUINT = nil): TStatus;
  112.     function Intersect(const rect: TGPRect): TStatus; overload;
  113.     function Intersect(const rect: TGPRectF): TStatus; overload;
  114.     function Intersect(path: TGPGraphicsPath): TStatus; overload;
  115.     function Intersect(region: TGPRegion): TStatus; overload;
  116.     function Union(const rect: TGPRect): TStatus; overload;
  117.     function Union(const rect: TGPRectF): TStatus; overload;
  118.     function Union(path: TGPGraphicsPath): TStatus; overload;
  119.     function Union(region: TGPRegion): TStatus; overload;
  120.     function Xor_(const rect: TGPRect): TStatus; overload;
  121.     function Xor_(const rect: TGPRectF): TStatus; overload;
  122.     function Xor_(path: TGPGraphicsPath): TStatus; overload;
  123.     function Xor_(region: TGPRegion): TStatus; overload;
  124.     function Exclude(const rect: TGPRect): TStatus; overload;
  125.     function Exclude(const rect: TGPRectF): TStatus; overload;
  126.     function Exclude(path: TGPGraphicsPath): TStatus; overload;
  127.     function Exclude(region: TGPRegion): TStatus; overload;
  128.     function Complement(const rect: TGPRect): TStatus; overload;
  129.     function Complement(const rect: TGPRectF): TStatus; overload;
  130.     function Complement(path: TGPGraphicsPath): TStatus; overload;
  131.     function Complement(region: TGPRegion): TStatus; overload;
  132.     function Translate(dx, dy: Single): TStatus; overload;
  133.     function Translate(dx, dy: Integer): TStatus; overload;
  134.     function Transform(matrix: TGPMatrix): TStatus;
  135.     function GetBounds(out rect: TGPRect; g: TGPGraphics): TStatus; overload;
  136.     function GetBounds(out rect: TGPRectF; g: TGPGraphics): TStatus; overload;
  137.     function GetHRGN(g: TGPGraphics): HRGN;
  138.     function IsEmpty(g: TGPGraphics): BOOL;
  139.     function IsInfinite(g: TGPGraphics): BOOL ;
  140.     function IsVisible(x, y: Integer; g: TGPGraphics = nil): BOOL; overload;
  141.     function IsVisible(const point: TGPPoint; g: TGPGraphics = nil): BOOL; overload;
  142.     function IsVisible(x, y: Single; g: TGPGraphics = nil): BOOL; overload;
  143.     function IsVisible(const point: TGPPointF; g: TGPGraphics = nil): BOOL; overload;
  144.     function IsVisible(x, y, width, height: Integer; g: TGPGraphics): BOOL; overload;
  145.     function IsVisible(const rect: TGPRect; g: TGPGraphics = nil): BOOL; overload;
  146.     function IsVisible(x, y, width, height: Single; g: TGPGraphics = nil): BOOL; overload;
  147.     function IsVisible(const rect: TGPRectF; g: TGPGraphics = nil): BOOL; overload;
  148.     function Equals(region: TGPRegion; g: TGPGraphics): BOOL;
  149.     function GetRegionScansCount(matrix: TGPMatrix): UINT;
  150.     function GetRegionScans(matrix: TGPMatrix ;rects: PGPRectF; out count: Integer): TStatus; overload;
  151.     function GetRegionScans(matrix: TGPMatrix; rects: PGPRect; out count: Integer): TStatus; overload;
  152.     function GetLastStatus: TStatus;
  153.   end;
  154.  
  155. //--------------------------------------------------------------------------
  156. // FontFamily
  157. //--------------------------------------------------------------------------
  158.  
  159.   TGPFontFamily = class(TGdiplusBase)
  160.   protected
  161.     nativeFamily: GpFontFamily;
  162.     lastResult: TStatus;
  163.     function SetStatus(status: TStatus): TStatus;
  164.     constructor Create(nativeOrig: GpFontFamily;
  165.       status: TStatus); reintroduce; overload;
  166.   public
  167.     constructor Create; reintroduce; overload;
  168.     constructor Create(name: WideString; fontCollection: TGPFontCollection = nil); reintroduce; overload;
  169.     destructor Destroy; override;
  170.     class function GenericSansSerif: TGPFontFamily;
  171.     class function GenericSerif: TGPFontFamily;
  172.     class function GenericMonospace: TGPFontFamily;
  173.     function GetFamilyName(out name: String; language: LANGID = 0): TStatus;
  174.     function Clone: TGPFontFamily;
  175.     function IsAvailable: BOOL;
  176.     function IsStyleAvailable(style: Integer): BOOL;
  177.     function GetEmHeight(style: Integer): UINT16;
  178.     function GetCellAscent(style: Integer): UINT16;
  179.     function GetCellDescent(style: Integer): UINT16;
  180.     function GetLineSpacing(style: Integer): UINT16;
  181.     function GetLastStatus: TStatus;
  182.   end;
  183.  
  184. //--------------------------------------------------------------------------
  185. // Font Collection
  186. //--------------------------------------------------------------------------
  187.  
  188.   TGPFontCollection = class(TGdiplusBase)
  189.   protected
  190.     nativeFontCollection: GpFontCollection;
  191.     lastResult: TStatus;
  192.     function SetStatus(status: TStatus): TStatus;
  193.   public
  194.     constructor Create;
  195.     destructor Destroy; override;
  196.     function GetFamilyCount: Integer;
  197.     function GetFamilies(numSought: Integer; out gpfamilies: array of TGPFontFamily;
  198.       out numFound: Integer): TStatus;
  199.     function GetLastStatus: TStatus;
  200.   end;
  201.  
  202.   TGPInstalledFontCollection = class(TGPFontCollection)
  203.   public
  204.     constructor Create; reintroduce;
  205.     destructor Destroy; override;
  206.   end;
  207.  
  208.   TGPPrivateFontCollection = class(TGPFontCollection)
  209.   public
  210.     constructor Create; reintroduce;
  211.     destructor destroy; override;
  212.     function AddFontFile(filename: WideString): TStatus;
  213.     function AddMemoryFont(memory: Pointer; length: Integer): TStatus;
  214.   end;
  215.  
  216. //--------------------------------------------------------------------------
  217. // TFont
  218. //--------------------------------------------------------------------------
  219.  
  220.   TGPFont = class(TGdiplusBase)
  221.   protected
  222.     nativeFont: GpFont;
  223.     lastResult: TStatus;
  224.     procedure SetNativeFont(Font: GpFont);
  225.     function SetStatus(status: TStatus): TStatus;
  226.     constructor Create(font: GpFont; status: TStatus); overload;
  227.   public
  228.     constructor Create(hdc: HDC); reintroduce; overload;
  229.     constructor Create(hdc: HDC; logfont: PLogFontA); reintroduce; overload;
  230.     constructor Create(hdc: HDC; logfont: PLogFontW); reintroduce; overload;
  231.     constructor Create(hdc: HDC; hfont: HFONT); reintroduce; overload;
  232.     constructor Create(family: TGPFontFamily; emSize: Single;
  233.       style: TFontStyle = FontStyleRegular;
  234.       unit_: TUnit = UnitPoint); reintroduce; overload;
  235.     constructor Create(familyName: WideString; emSize: Single;
  236.       style: TFontStyle = FontStyleRegular; unit_: TUnit = UnitPoint;
  237.       fontCollection: TGPFontCollection = nil); reintroduce; overload;
  238.     function GetLogFontA(g: TGPGraphics; out logfontA: TLogFontA): TStatus;
  239.     function GetLogFontW(g: TGPGraphics; out logfontW: TLogFontW): TStatus;
  240.     function Clone: TGPFont;
  241.     destructor Destroy; override;
  242.     function IsAvailable: BOOL;
  243.     function GetStyle: Integer;
  244.     function GetSize: Single;
  245.     function GetUnit: TUnit;
  246.     function GetLastStatus: TStatus;
  247.     function GetHeight(graphics: TGPGraphics): Single; overload;
  248.     function GetHeight(dpi: Single): Single; overload;
  249.     function GetFamily(family: TGPFontFamily): TStatus;
  250.   end;
  251.  
  252. //--------------------------------------------------------------------------
  253. // Abstract base class for Image and Metafile
  254. //--------------------------------------------------------------------------
  255.  
  256.   TGPImage = class(TGdiplusBase)
  257.   protected
  258.     nativeImage: GpImage;
  259.     lastResult: TStatus;
  260.     loadStatus: TStatus;
  261.     procedure SetNativeImage(nativeImage: GpImage);
  262.     function SetStatus(status: TStatus): TStatus;
  263.     constructor Create(nativeImage: GpImage; status: TStatus); reintroduce; overload;
  264.   public
  265.     constructor Create(filename: WideString; useEmbeddedColorManagement: BOOL = FALSE); reintroduce; overload;
  266.     constructor Create(stream: IStream; useEmbeddedColorManagement: BOOL  = FALSE); reintroduce; overload;
  267.     function FromFile(filename: WideString; useEmbeddedColorManagement: BOOL = FALSE): TGPImage;
  268.     function FromStream(stream: IStream; useEmbeddedColorManagement: BOOL = FALSE): TGPImage;
  269.     destructor destroy; override;
  270.     function Clone: TGPImage;
  271.     function Save(filename: WideString; const clsidEncoder: TGUID;
  272.       encoderParams: PEncoderParameters = nil): TStatus; overload;
  273.     function Save(stream: IStream; const clsidEncoder: TGUID;
  274.       encoderParams: PEncoderParameters  = nil): TStatus; overload;
  275.     function SaveAdd(encoderParams: PEncoderParameters): TStatus; overload;
  276.     function SaveAdd(newImage: TGPImage; encoderParams: PEncoderParameters): TStatus; overload;
  277.     function GetType: TImageType;
  278.     function GetPhysicalDimension(out size: TGPSizeF): TStatus;
  279.     function GetBounds(out srcRect: TGPRectF; out srcUnit: TUnit): TStatus;
  280.     function GetWidth: UINT;
  281.     function GetHeight: UINT;
  282.     function GetHorizontalResolution: Single;
  283.     function GetVerticalResolution: Single;
  284.     function GetFlags: UINT;
  285.     function GetRawFormat(out format: TGUID): TStatus;
  286.     function GetPixelFormat: TPixelFormat;
  287.     function GetPaletteSize: Integer;
  288.     function GetPalette(palette: PColorPalette; size: Integer): TStatus;
  289.     function SetPalette(palette: PColorPalette): TStatus;
  290.     function GetThumbnailImage(thumbWidth, thumbHeight: UINT;
  291.       callback: GetThumbnailImageAbort = nil; callbackData: pointer = nil): TGPImage;
  292.     function GetFrameDimensionsCount: UINT;
  293.     function GetFrameDimensionsList(dimensionIDs: PGUID; count: UINT): TStatus;
  294.     function GetFrameCount(const dimensionID: TGUID): UINT;
  295.     function SelectActiveFrame(const dimensionID: TGUID; frameIndex: UINT): TStatus;
  296.     function RotateFlip(rotateFlipType: TRotateFlipType): TStatus;
  297.     function GetPropertyCount: UINT;
  298.     function GetPropertyIdList(numOfProperty: UINT; list: PPropID): TStatus;
  299.     function GetPropertyItemSize(propId: PROPID): UINT;
  300.     function GetPropertyItem(propId: PROPID; propSize: UINT; buffer: PPropertyItem): TStatus;
  301.     function GetPropertySize(out totalBufferSize, numProperties : UINT): TStatus;
  302.     function GetAllPropertyItems(totalBufferSize, numProperties: UINT;
  303.       allItems: PPROPERTYITEM): TStatus;
  304.     function RemovePropertyItem(propId: TPROPID): TStatus;
  305.     function SetPropertyItem(const item: TPropertyItem): TStatus;
  306.     function GetEncoderParameterListSize(const clsidEncoder: TGUID): UINT;
  307.     function GetEncoderParameterList(const clsidEncoder: TGUID; size: UINT;
  308.       buffer: PEncoderParameters): TStatus;
  309.     function GetLastStatus: TStatus;
  310.   end;
  311.  
  312.   TGPBitmap = class(TGPImage)
  313.   protected
  314.     constructor Create(nativeBitmap: GpBitmap);  reintroduce; overload;
  315.   public
  316.     constructor Create(filename: WideString; useEmbeddedColorManagement: BOOL = FALSE); reintroduce; overload;
  317.     constructor Create(stream: IStream; useEmbeddedColorManagement: BOOL = FALSE); reintroduce; overload;
  318.     function FromFile(filename: WideString; useEmbeddedColorManagement: BOOL = FALSE): TGPBitmap;
  319.     function FromStream(stream: IStream; useEmbeddedColorManagement: BOOL = FALSE): TGPBitmap;
  320.     constructor Create(width, height, stride: Integer; format: TPixelFormat; scan0: PBYTE); reintroduce; overload;
  321.     constructor Create(width, height: Integer; format: TPixelFormat = PixelFormat32bppARGB); reintroduce; overload;
  322.     constructor Create(width, height: Integer; target: TGPGraphics); reintroduce; overload;
  323.     function Clone(rect: TGPRect; format: TPixelFormat): TGPBitmap; overload;
  324.     function Clone(x, y, width, height: Integer; format: TPixelFormat): TGPBitmap; overload;
  325.     function Clone(rect: TGPRectF; format: TPixelFormat): TGPBitmap; overload;
  326.     function Clone(x, y, width, height: Single; format: TPixelFormat): TGPBitmap; overload;
  327.     function LockBits(rect: TGPRect; flags: UINT; format: TPixelFormat; out lockedBitmapData: TBitmapData): TStatus; 
  328.     function UnlockBits(var lockedBitmapData: TBitmapData): TStatus;
  329.     function GetPixel(x, y: Integer; out color: TGPColor): TStatus;
  330.     function SetPixel(x, y: Integer; color: TGPColor): TStatus;
  331.     function SetResolution(xdpi, ydpi: Single): TStatus;
  332.     constructor Create(surface: IDirectDrawSurface7); reintroduce; overload;
  333.     constructor Create(var gdiBitmapInfo: TBITMAPINFO; gdiBitmapData: Pointer); reintroduce; overload;
  334.     constructor Create(hbm: HBITMAP; hpal: HPALETTE); reintroduce; overload;
  335.     constructor Create(hicon: HICON); reintroduce; overload;
  336.     constructor Create(hInstance: HMODULE; bitmapName: WideString); reintroduce; overload;
  337.     function FromDirectDrawSurface7(surface: IDirectDrawSurface7): TGPBitmap;
  338.     function FromBITMAPINFO(var gdiBitmapInfo: TBITMAPINFO; gdiBitmapData: Pointer): TGPBitmap;
  339.     function FromHBITMAP(hbm: HBITMAP; hpal: HPALETTE): TGPBitmap;
  340.     function FromHICON(hicon: HICON): TGPBitmap;
  341.     function FromResource(hInstance: HMODULE; bitmapName: WideString): TGPBitmap;
  342.     function GetHBITMAP(colorBackground: TGPColor; out hbmReturn: HBITMAP): TStatus;
  343.     function GetHICON(out hicon: HICON): TStatus;
  344.   end;
  345.  
  346.   TGPCustomLineCap = class(TGdiplusBase)
  347.   protected
  348.     nativeCap: GpCustomLineCap;
  349.     lastResult: TStatus;
  350.     procedure SetNativeCap(nativeCap: GpCustomLineCap);
  351.     function SetStatus(status: TStatus): TStatus;
  352.     constructor Create(nativeCap: GpCustomLineCap;
  353.       status: TStatus); reintroduce; overload;
  354.   public
  355.     constructor Create; reintroduce; overload;
  356.     constructor Create(fillPath, strokePath: TGPGraphicsPath;
  357.       baseCap: TLineCap = LineCapFlat;
  358.       baseInset: Single = 0); reintroduce; overload;
  359.     destructor Destroy; override;
  360.     function Clone: TGPCustomLineCap;
  361.     function SetStrokeCap(strokeCap: TLineCap): TStatus;
  362.     function SetStrokeCaps(startCap, endCap: TLineCap): TStatus;
  363.     function GetStrokeCaps(out startCap, endCap: TLineCap): TStatus;
  364.     function SetStrokeJoin(lineJoin: TLineJoin): TStatus;
  365.     function GetStrokeJoin: TLineJoin;
  366.     function SetBaseCap(baseCap: TLineCap): TStatus;
  367.     function GetBaseCap: TLineCap;
  368.     function SetBaseInset(inset: Single): TStatus;
  369.     function GetBaseInset: Single;
  370.     function SetWidthScale(widthScale: Single): TStatus;
  371.     function GetWidthScale: Single;                                
  372.     function GetLastStatus: TStatus;
  373.   end;
  374.  
  375.   TGPCachedBitmap = class(TGdiplusBase)
  376.   protected
  377.     nativeCachedBitmap: GpCachedBitmap;
  378.     lastResult: TStatus;
  379.   public
  380.     constructor Create(bitmap: TGPBitmap; graphics: TGPGraphics); reintroduce;
  381.     destructor Destroy; override;
  382.     function GetLastStatus: TStatus;
  383.   end;
  384.  
  385. (**************************************************************************\
  386. *
  387. *   GDI+ Image Attributes used with Graphics.DrawImage
  388. *
  389. * There are 5 possible sets of color adjustments:
  390. *          ColorAdjustDefault,
  391. *          ColorAdjustBitmap,
  392. *          ColorAdjustBrush,
  393. *          ColorAdjustPen,
  394. *          ColorAdjustText,
  395. *
  396. * Bitmaps, Brushes, Pens, and Text will all use any color adjustments
  397. * that have been set into the default ImageAttributes until their own
  398. * color adjustments have been set.  So as soon as any "Set" method is
  399. * called for Bitmaps, Brushes, Pens, or Text, then they start from
  400. * scratch with only the color adjustments that have been set for them.
  401. * Calling Reset removes any individual color adjustments for a type
  402. * and makes it revert back to using all the default color adjustments
  403. * (if any).  The SetToIdentity method is a way to force a type to
  404. * have no color adjustments at all, regardless of what previous adjustments
  405. * have been set for the defaults or for that type.
  406. *
  407. \********************************************************************F******)
  408.  
  409.   TGPImageAttributes = class(TGdiplusBase)
  410.   protected
  411.     nativeImageAttr: GpImageAttributes;
  412.     lastResult: TStatus;
  413.     procedure SetNativeImageAttr(nativeImageAttr: GpImageAttributes);
  414.     function SetStatus(status: TStatus): TStatus;
  415.     constructor Create(imageAttr: GpImageAttributes;
  416.       status: GpStatus); reintroduce; overload;
  417.   public
  418.     constructor Create; reintroduce; overload;
  419.     destructor Destroy; override;
  420.     function Clone: TGPImageAttributes;
  421.     function SetToIdentity(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  422.     function Reset(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  423.     function SetColorMatrix(const colorMatrix: TColorMatrix;
  424.       mode: TColorMatrixFlags = ColorMatrixFlagsDefault;
  425.       type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  426.     function ClearColorMatrix(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  427.     function SetColorMatrices(const colorMatrix: TColorMatrix; const grayMatrix: TColorMatrix;
  428.       mode: TColorMatrixFlags  = ColorMatrixFlagsDefault;
  429.       type_: TColorAdjustType  = ColorAdjustTypeDefault): TStatus;
  430.     function ClearColorMatrices(Type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  431.     function SetThreshold(threshold: Single; type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  432.     function ClearThreshold(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  433.     function SetGamma(gamma: Single; type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  434.     function ClearGamma( type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  435.     function SetNoOp(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  436.     function ClearNoOp(Type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  437.     function SetColorKey(colorLow, colorHigh: TGPColor; type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  438.     function ClearColorKey(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  439.     function SetOutputChannel(channelFlags: TColorChannelFlags; type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  440.     function ClearOutputChannel(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  441.     function SetOutputChannelColorProfile(colorProfileFilename: WideString;
  442.       type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  443.     function ClearOutputChannelColorProfile(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  444.     function SetRemapTable(mapSize: Cardinal; map: PColorMap; type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  445.     function ClearRemapTable(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  446.     function SetBrushRemapTable(mapSize: Cardinal; map: PColorMap): TStatus;
  447.     function ClearBrushRemapTable: TStatus;
  448.     function SetWrapMode(wrap: TWrapMode; color: TGPColor = aclBlack; clamp: BOOL = FALSE): TStatus;
  449.     // The flags of the palette are ignored.
  450.     function GetAdjustedPalette(colorPalette: PColorPalette; colorAdjustType: TColorAdjustType): TStatus;
  451.     function GetLastStatus: TStatus;
  452.   end;
  453.  
  454. (**************************************************************************\
  455. *
  456. *   GDI+ Matrix class
  457. *
  458. \**************************************************************************)
  459.  
  460.   TMatrixArray = array[0..5] of Single;
  461.  
  462.   TGPMatrix = class(TGdiplusBase)
  463.   protected
  464.     nativeMatrix: GpMatrix;
  465.     lastResult: GpStatus ;
  466.     procedure SetNativeMatrix(nativeMatrix: GpMatrix);
  467.     function SetStatus(status: GpStatus): TStatus;
  468.     constructor Create(nativeMatrix: GpMatrix); reintroduce; overload;
  469.   public
  470.     // Default constructor is set to identity matrix.
  471.     constructor Create; reintroduce; overload;
  472.     constructor Create(m11, m12, m21, m22, dx, dy: Single); reintroduce; overload;
  473.     constructor Create(const rect: TGPRectF; const dstplg: TGPPointF); reintroduce; overload;
  474.     constructor Create(const rect: TGPRect; const dstplg: TGPPoint); reintroduce; overload;
  475.     destructor Destroy; override;
  476.     function Clone: TGPMatrix;
  477.     function GetElements(const m: TMatrixArray): TStatus;
  478.     function SetElements(m11, m12, m21, m22, dx, dy: Single): TStatus;
  479.     function OffsetX: Single;
  480.     function OffsetY: Single;
  481.     function Reset: TStatus;
  482.     function Multiply(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus;                // ok
  483.     function Translate(offsetX, offsetY: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;      // ok
  484.     function Scale(scaleX, scaleY: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;            // ok
  485.     function Rotate(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;                    // ok
  486.     function RotateAt(angle: Single; const center: TGPPointF; order: TMatrixOrder = MatrixOrderPrepend): TStatus; // ok
  487.     function Shear(shearX, shearY: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;            // ok
  488.     function Invert: TStatus;                                                                             // ok
  489.  
  490.     function TransformPoints(pts: PGPPointF; count: Integer = 1): TStatus; overload;
  491.     function TransformPoints(pts: PGPPoint; count: Integer = 1): TStatus; overload;
  492.  
  493.     function TransformVectors(pts: PGPPointF; count: Integer = 1): TStatus; overload;
  494.     function TransformVectors(pts: PGPPoint; count: Integer = 1): TStatus; overload;
  495.  
  496.     function IsInvertible: BOOL;
  497.     function IsIdentity: BOOL;
  498.     function Equals(matrix: TGPMatrix): BOOL;
  499.     function GetLastStatus: TStatus;
  500.   end;
  501.  
  502. (**************************************************************************\
  503. *
  504. *   GDI+ Brush class
  505. *
  506. \**************************************************************************)
  507.  
  508.   //--------------------------------------------------------------------------
  509.   // Abstract base class for various brush types
  510.   //--------------------------------------------------------------------------
  511.  
  512.   TGPBrush = class(TGdiplusBase)
  513.   protected
  514.     nativeBrush: GpBrush;
  515.     lastResult: TStatus;
  516.     procedure SetNativeBrush(nativeBrush: GpBrush);
  517.     function SetStatus(status: TStatus): TStatus;
  518.     constructor Create(nativeBrush: GpBrush; status: TStatus); overload;
  519.   public
  520.     constructor Create; overload;
  521.     destructor Destroy; override;
  522.     function Clone: TGPBrush; virtual;
  523.     function GetType: TBrushType;
  524.     function GetLastStatus: TStatus;
  525.   end;
  526.  
  527.   //--------------------------------------------------------------------------
  528.   // Solid Fill Brush Object
  529.   //--------------------------------------------------------------------------
  530.  
  531.   TGPSolidBrush = class(TGPBrush)
  532.   public
  533.     constructor Create(color: TGPColor); reintroduce; overload;
  534.     constructor Create; reintroduce; overload;
  535.     function GetColor(out color: TGPColor): TStatus;
  536.     function SetColor(color: TGPColor): TStatus;
  537.   end;
  538.  
  539.   //--------------------------------------------------------------------------
  540.   // Texture Brush Fill Object
  541.   //--------------------------------------------------------------------------
  542.  
  543.   TGPTextureBrush = class(TGPBrush)
  544.   public
  545.     constructor Create(image: TGPImage; wrapMode: TWrapMode = WrapModeTile); reintroduce; overload;
  546.     constructor Create(image: TGPImage; wrapMode: TWrapMode; dstRect: TGPRectF); reintroduce; overload;
  547.     constructor Create(image: TGPImage; dstRect: TGPRectF; imageAttributes: TGPImageAttributes = nil); reintroduce; overload;
  548.     constructor Create(image: TGPImage; dstRect: TGPRect; imageAttributes: TGPImageAttributes = nil); reintroduce; overload;
  549.     constructor Create(image: TGPImage; wrapMode: TWrapMode; dstRect: TGPRect); reintroduce; overload;
  550.     constructor Create(image: TGPImage; wrapMode: TWrapMode; dstX, dstY, dstWidth,
  551.       dstHeight: Single); reintroduce; overload;
  552.     constructor Create(image: TGPImage; wrapMode: TWrapMode; dstX, dstY, dstWidth,
  553.       dstHeight: Integer); reintroduce; overload;
  554.     constructor Create; reintroduce; overload;
  555.     function SetTransform(matrix: TGPMatrix): TStatus;
  556.     function GetTransform(matrix: TGPMatrix): TStatus;
  557.     function ResetTransform: TStatus;
  558.     function MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  559.     function TranslateTransform(dx, dy: Single; order: MatrixOrder = MatrixOrderPrepend): TStatus;
  560.     function ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  561.     function RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  562.     function SetWrapMode(wrapMode: TWrapMode): TStatus;
  563.     function GetWrapMode: TWrapMode;
  564.     function GetImage: TGPImage;
  565.   end;
  566.  
  567.   //--------------------------------------------------------------------------
  568.   // Linear Gradient Brush Object
  569.   //--------------------------------------------------------------------------
  570.  
  571.   TGPLinearGradientBrush = class(TGPBrush)
  572.   public
  573.     constructor Create; reintroduce; overload;
  574.     constructor Create(const point1, point2: TGPPointF; color1,
  575.       color2: TGPColor); reintroduce; overload;
  576.     constructor Create(const point1, point2: TGPPoint; color1,
  577.       color2: TGPColor); reintroduce; overload;
  578.     constructor Create(rect: TGPRectF; color1, color2: TGPColor;
  579.       mode: TLinearGradientMode); reintroduce; overload;
  580.     constructor Create(rect: TGPRect; color1, color2: TGPColor;
  581.       mode: TLinearGradientMode); reintroduce; overload;
  582.     constructor Create(rect: TGPRectF; color1, color2: TGPColor; angle: Single;
  583.       isAngleScalable: BOOL = FALSE); overload;
  584.     constructor Create(rect: TGPRect; color1, color2: TGPColor; angle: Single;
  585.       isAngleScalable: BOOL = FALSE); overload;
  586.     function SetLinearColors(color1, color2: TGPColor): TStatus;
  587.     function GetLinearColors(out color1, color2: TGPColor): TStatus;
  588.     function GetRectangle(out rect: TGPRectF): TStatus; overload;
  589.     function GetRectangle(out rect: TGPRect): TStatus; overload;
  590.     function SetGammaCorrection(useGammaCorrection: BOOL): TStatus;
  591.     function GetGammaCorrection: BOOL;
  592.     function GetBlendCount: Integer;
  593.     function SetBlend(blendFactors, blendPositions: PSingle; count: Integer): TStatus;
  594.     function GetBlend(blendFactors, blendPositions: PSingle; count: Integer): TStatus;
  595.     function GetInterpolationColorCount: Integer;
  596.     function SetInterpolationColors(presetColors: PGPColor; blendPositions: PSingle; count: Integer): TStatus;
  597.     function GetInterpolationColors(presetColors: PGPColor; blendPositions: PSingle; count: Integer): TStatus;
  598.     function SetBlendBellShape(focus: Single; scale: Single = 1.0): TStatus;
  599.     function SetBlendTriangularShape(focus: Single; scale: Single = 1.0): TStatus;
  600.     function SetTransform(matrix: TGPMatrix): TStatus;
  601.     function GetTransform(matrix: TGPMatrix): TStatus;
  602.     function ResetTransform: TStatus;
  603.     function MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  604.     function TranslateTransform(dx, dy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  605.     function ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  606.     function RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  607.     function SetWrapMode(wrapMode: TWrapMode): TStatus;
  608.     function GetWrapMode: TWrapMode;
  609.   end;
  610.  
  611.   //--------------------------------------------------------------------------
  612.   // Hatch Brush Object
  613.   //--------------------------------------------------------------------------
  614.  
  615.   TGPHatchBrush = class(TGPBrush)
  616.   public
  617.     constructor Create; reintroduce; overload;
  618.     constructor Create(hatchStyle: THatchStyle; foreColor: TGPColor; backColor: TGPColor = aclBlack); reintroduce; overload; // ok
  619.     function GetHatchStyle: THatchStyle;
  620.     function GetForegroundColor(out color: TGPColor): TStatus;
  621.     function GetBackgroundColor(out color: TGPColor): TStatus;
  622.   end;
  623.  
  624. (**************************************************************************\
  625. *
  626. *   GDI+ Pen class
  627. *
  628. \**************************************************************************)
  629.  
  630. //--------------------------------------------------------------------------
  631. // Pen class 
  632. //--------------------------------------------------------------------------
  633.  
  634.   TGPPen = class(TGdiplusBase)
  635.   protected
  636.     nativePen: GpPen;
  637.     lastResult: TStatus;
  638.     procedure SetNativePen(nativePen: GpPen);
  639.     function SetStatus(status: TStatus): TStatus;
  640.     constructor Create(nativePen: GpPen; status: TStatus); reintroduce; overload;
  641.   public
  642.     constructor Create(color: TGPColor; width: Single = 1.0); reintroduce; overload;
  643.     constructor Create(brush: TGPBrush; width: Single = 1.0); reintroduce; overload;
  644.     destructor Destroy; override;
  645.     function Clone: TGPPen;
  646.     function SetWidth(width: Single): TStatus;
  647.     function GetWidth: Single;
  648.     // Set/get line caps: start, end, and dash
  649.     // Line cap and join APIs by using LineCap and LineJoin enums.
  650.     function SetLineCap(startCap, endCap: TLineCap; dashCap: TDashCap): TStatus;
  651.     function SetStartCap(startCap: TLineCap): TStatus;
  652.     function SetEndCap(endCap: TLineCap): TStatus;
  653.     function SetDashCap(dashCap: TDashCap): TStatus;
  654.     function GetStartCap: TLineCap;
  655.     function GetEndCap: TLineCap;
  656.     function GetDashCap: TDashCap;
  657.     function SetLineJoin(lineJoin: TLineJoin): TStatus;
  658.     function GetLineJoin: TLineJoin;
  659.     function SetCustomStartCap(customCap: TGPCustomLineCap): TStatus;
  660.     function GetCustomStartCap(customCap: TGPCustomLineCap): TStatus;
  661.     function SetCustomEndCap(customCap: TGPCustomLineCap): TStatus;
  662.     function GetCustomEndCap(customCap: TGPCustomLineCap): TStatus;
  663.     function SetMiterLimit(miterLimit: Single): TStatus;
  664.     function GetMiterLimit: Single;
  665.     function SetAlignment(penAlignment: TPenAlignment): TStatus;
  666.     function GetAlignment: TPenAlignment;
  667.     function SetTransform(matrix: TGPMatrix): TStatus;
  668.     function GetTransform(matrix: TGPMatrix): TStatus;
  669.     function ResetTransform: TStatus;
  670.     function MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  671.     function TranslateTransform(dx, dy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  672.     function ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  673.     function RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  674.     function GetPenType: TPenType;
  675.     function SetColor(color: TGPColor): TStatus;
  676.     function SetBrush(brush: TGPBrush): TStatus;
  677.     function GetColor(out Color: TGPColor): TStatus;
  678.     function GetBrush: TGPBrush;
  679.     function GetDashStyle: TDashStyle;
  680.     function SetDashStyle(dashStyle: TDashStyle): TStatus;
  681.     function GetDashOffset: Single;
  682.     function SetDashOffset(dashOffset: Single): TStatus;
  683.     function SetDashPattern(dashArray: PSingle; count: Integer): TStatus;
  684.     function GetDashPatternCount: Integer;
  685.     function GetDashPattern(dashArray: PSingle; count: Integer): TStatus;
  686.     function SetCompoundArray(compoundArray: PSingle; count: Integer): TStatus;
  687.     function GetCompoundArrayCount: Integer;
  688.     function GetCompoundArray(compoundArray: PSingle; count: Integer): TStatus;
  689.     function GetLastStatus: TStatus;
  690.   end;
  691.  
  692. (**************************************************************************\
  693. *
  694. *   GDI+ StringFormat class
  695. *
  696. \**************************************************************************)
  697.  
  698.   TGPStringFormat = class(TGdiplusBase)
  699.   protected
  700.     nativeFormat: GpStringFormat;
  701.     lastError: TStatus;
  702.     function SetStatus(newStatus: GpStatus): TStatus;
  703.     procedure Assign(source: TGPStringFormat);
  704.     constructor Create(clonedStringFormat: GpStringFormat; status: TStatus); reintroduce; overload;
  705.   public
  706.     constructor Create(formatFlags: Integer = 0; language: LANGID = LANG_NEUTRAL); reintroduce; overload;
  707.     constructor Create(format: TGPStringFormat); reintroduce; overload;
  708.     destructor Destroy; override;
  709.     class function GenericDefault: TGPStringFormat;
  710.     class function GenericTypographic: TGPStringFormat;
  711.     function Clone: TGPStringFormat;
  712.     function SetFormatFlags(flags: Integer): TStatus;
  713.     function GetFormatFlags: Integer;
  714.     function SetAlignment(align: TStringAlignment): TStatus;
  715.     function GetAlignment: TStringAlignment;
  716.     function SetLineAlignment(align: TStringAlignment): TStatus;
  717.     function GetLineAlignment: TStringAlignment;
  718.     function SetHotkeyPrefix(hotkeyPrefix: THotkeyPrefix): TStatus;
  719.     function GetHotkeyPrefix: THotkeyPrefix;
  720.     function SetTabStops(firstTabOffset: Single; count: Integer; tabStops: PSingle): TStatus;
  721.     function GetTabStopCount: Integer;
  722.     function GetTabStops(count: Integer; firstTabOffset, tabStops: PSingle): TStatus;
  723.     function SetDigitSubstitution(language: LANGID; substitute: TStringDigitSubstitute): TStatus;
  724.     function GetDigitSubstitutionLanguage: LANGID;
  725.     function GetDigitSubstitutionMethod: TStringDigitSubstitute;
  726.     function SetTrimming(trimming: TStringTrimming): TStatus;
  727.     function GetTrimming: TStringTrimming;
  728.     function SetMeasurableCharacterRanges(rangeCount: Integer; ranges: PCharacterRange): TStatus;
  729.     function GetMeasurableCharacterRangeCount: Integer;
  730.     function GetLastStatus: TStatus;
  731.   end;
  732.  
  733. (**************************************************************************\
  734. *
  735. *   GDI+ Graphics Path class
  736. *
  737. \**************************************************************************)
  738.  
  739.   TGPGraphicsPath = class(TGdiplusBase)
  740.   protected
  741.     nativePath: GpPath;
  742.     lastResult: TStatus;
  743.     procedure SetNativePath(nativePath: GpPath);
  744.     function SetStatus(status: TStatus): TStatus;
  745.     constructor Create(nativePath: GpPath); reintroduce; overload;
  746.   public
  747.     constructor Create(path: TGPGraphicsPath); reintroduce; overload;
  748.     constructor Create(fillMode: TFillMode = FillModeAlternate); reintroduce; overload;      
  749.     constructor Create(points: PGPPointF; types: PBYTE; count: Integer;
  750.       fillMode: TFillMode = FillModeAlternate); reintroduce; overload;
  751.     constructor Create(points: PGPPoint; types: PBYTE; count: Integer;
  752.       fillMode: TFillMode = FillModeAlternate); reintroduce; overload;
  753.     destructor destroy; override;
  754.     function Clone: TGPGraphicsPath;
  755.     // Reset the path object to empty (and fill mode to FillModeAlternate)
  756.     function Reset: TStatus;
  757.     function GetFillMode: TFillMode;
  758.     function SetFillMode(fillmode: TFillMode): TStatus;
  759.     function GetPathData(pathData: TPathData): TStatus;
  760.     function StartFigure: TStatus;
  761.     function CloseFigure: TStatus;
  762.     function CloseAllFigures: TStatus;
  763.     function SetMarker: TStatus;
  764.     function ClearMarkers: TStatus;
  765.     function Reverse: TStatus;
  766.     function GetLastPoint(out lastPoint: TGPPointF): TStatus;
  767.  
  768.     function AddLine(const pt1, pt2: TGPPointF): TStatus; overload;
  769.     function AddLine(x1, y1, x2, y2: Single): TStatus; overload;
  770.     function AddLines(points: PGPPointF; count: Integer): TStatus; overload;
  771.     function AddLine(const pt1, pt2: TGPPoint): TStatus; overload;
  772.     function AddLine(x1, y1, x2, y2: Integer): TStatus; overload;
  773.     function AddLines(points: PGPPoint; count: Integer): TStatus; overload;
  774.  
  775.     function AddArc(rect: TGPRectF; startAngle, sweepAngle: Single): TStatus; overload;
  776.     function AddArc(x, y, width, height, startAngle, sweepAngle: Single): TStatus; overload;
  777.     function AddArc(rect: TGPRect; startAngle, sweepAngle: Single): TStatus; overload;
  778.     function AddArc(x, y, width, height: Integer; startAngle, sweepAngle: Single): TStatus; overload;
  779.  
  780.     function AddBezier(pt1, pt2, pt3, pt4: TGPPointF): TStatus; overload;
  781.     function AddBezier(x1, y1, x2, y2, x3, y3, x4, y4: Single): TStatus; overload;
  782.     function AddBeziers(points: PGPPointF; count: Integer): TStatus; overload;
  783.     function AddBezier(pt1, pt2, pt3, pt4: TGPPoint): TStatus; overload;
  784.     function AddBezier(x1, y1, x2, y2, x3, y3, x4, y4: Integer): TStatus; overload;
  785.     function AddBeziers(points: PGPPoint; count: Integer): TStatus; overload;
  786.  
  787.     function AddCurve(points: PGPPointF; count: Integer): TStatus; overload;
  788.     function AddCurve(points: PGPPointF; count: Integer; tension: Single): TStatus; overload;
  789.     function AddCurve(points: PGPPointF; count, offset, numberOfSegments: Integer; tension: Single): TStatus; overload;
  790.     function AddCurve(points: PGPPoint; count: Integer): TStatus; overload;
  791.     function AddCurve(points: PGPPoint; count: Integer; tension: Single): TStatus; overload;
  792.     function AddCurve(points: PGPPoint; count, offset, numberOfSegments: Integer; tension: Single): TStatus; overload;
  793.  
  794.     function AddClosedCurve(points: PGPPointF; count: Integer): TStatus; overload;
  795.     function AddClosedCurve(points: PGPPointF; count: Integer; tension: Single): TStatus; overload;
  796.     function AddClosedCurve(points: PGPPoint; count: Integer): TStatus; overload;
  797.     function AddClosedCurve(points: PGPPoint; count: Integer; tension: Single): TStatus; overload;
  798.  
  799.     function AddRectangle(rect: TGPRectF): TStatus; overload;
  800.     function AddRectangles(rects: PGPRectF; count: Integer): TStatus; overload;
  801.     function AddRectangle(rect: TGPRect): TStatus; overload;
  802.     function AddRectangles(rects: PGPRect; count: Integer): TStatus; overload;
  803.  
  804.     function AddEllipse(rect: TGPRectF): TStatus; overload;
  805.     function AddEllipse(x, y, width, height: Single): TStatus; overload;
  806.     function AddEllipse(rect: TGPRect): TStatus; overload;
  807.     function AddEllipse(x, y, width, height: Integer): TStatus; overload;
  808.  
  809.     function AddPie(rect: TGPRectF; startAngle, sweepAngle: Single): TStatus; overload;
  810.     function AddPie(x, y, width, height, startAngle, sweepAngle: Single): TStatus; overload;
  811.     function AddPie(rect: TGPRect; startAngle, sweepAngle: Single): TStatus; overload;
  812.     function AddPie(x, y, width, height: Integer; startAngle, sweepAngle: Single): TStatus; overload;
  813.  
  814.     function AddPolygon(points: PGPPointF; count: Integer): TStatus; overload;
  815.     function AddPolygon(points: PGPPoint; count: Integer): TStatus; overload;
  816.  
  817.     function AddPath(addingPath: TGPGraphicsPath; connect: Bool): TStatus;
  818.  
  819.     function AddString(string_: WideString; length: Integer; family : TGPFontFamily;
  820.       style  : Integer; emSize : Single; origin : TGPPointF; format : TGPStringFormat): TStatus; overload;
  821.     function AddString(string_: WideString; length : Integer; family : TGPFontFamily;
  822.       style  : Integer; emSize : Single; layoutRect: TGPRectF; format : TGPStringFormat): TStatus; overload;
  823.     function AddString(string_: WideString; length : Integer; family : TGPFontFamily;
  824.       style  : Integer; emSize : Single; origin : TGPPoint; format : TGPStringFormat): TStatus; overload;
  825.     function AddString(string_: WideString; length : Integer; family : TGPFontFamily;
  826.       style  : Integer; emSize : Single; layoutRect: TGPRect; format : TGPStringFormat): TStatus; overload;
  827.  
  828.     function Transform(matrix: TGPMatrix): TStatus;
  829.  
  830.     // This is not always the tightest bounds.
  831.     function GetBounds(out bounds: TGPRectF; matrix: TGPMatrix = nil; pen: TGPPen = nil): TStatus; overload;
  832.     function GetBounds(out bounds: TGPRect; matrix: TGPMatrix = nil; pen: TGPPen = nil): TStatus;  overload;
  833.     // Once flattened, the resultant path is made of line segments and
  834.     // the original path information is lost.  When matrix is NULL the
  835.     // identity matrix is assumed.
  836.     function Flatten(matrix: TGPMatrix = nil; flatness: Single = FlatnessDefault): TStatus;
  837.     function Widen(pen: TGPPen; matrix: TGPMatrix = nil; flatness: Single = FlatnessDefault): TStatus;
  838.     function Outline(matrix: TGPMatrix = nil; flatness: Single = FlatnessDefault): TStatus;
  839.     // Once this is called, the resultant path is made of line segments and
  840.     // the original path information is lost.  When matrix is NULL, the
  841.     // identity matrix is assumed.
  842.     function Warp(destPoints: PGPPointF; count: Integer; srcRect: TGPRectF;
  843.       matrix: TGPMatrix = nil; warpMode: TWarpMode = WarpModePerspective;
  844.       flatness: Single = FlatnessDefault): TStatus;
  845.     function GetPointCount: Integer;
  846.     function GetPathTypes(types: PBYTE; count: Integer): TStatus;
  847.     function GetPathPoints(points: PGPPointF; count: Integer): TStatus; overload;
  848.     function GetPathPoints(points: PGPPoint; count: Integer): TStatus; overload;
  849.     function GetLastStatus: TStatus;
  850.  
  851.     function IsVisible(point: TGPPointF; g: TGPGraphics = nil): BOOL; overload;
  852.     function IsVisible(x, y: Single; g: TGPGraphics = nil): BOOL; overload;
  853.     function IsVisible(point: TGPPoint; g : TGPGraphics = nil): BOOL; overload;
  854.     function IsVisible(x, y: Integer; g: TGPGraphics = nil): BOOL; overload;
  855.  
  856.     function IsOutlineVisible(point: TGPPointF; pen: TGPPen; g: TGPGraphics = nil): BOOL; overload;
  857.     function IsOutlineVisible(x, y: Single; pen: TGPPen; g: TGPGraphics = nil): BOOL; overload;
  858.     function IsOutlineVisible(point: TGPPoint; pen: TGPPen; g: TGPGraphics = nil): BOOL; overload;
  859.     function IsOutlineVisible(x, y: Integer; pen: TGPPen; g: TGPGraphics = nil): BOOL; overload;
  860.   end;
  861.  
  862. //--------------------------------------------------------------------------
  863. // GraphisPathIterator class
  864. //--------------------------------------------------------------------------
  865.  
  866.   TGPGraphicsPathIterator = class(TGdiplusBase)
  867.   protected
  868.     nativeIterator: GpPathIterator;
  869.     lastResult    : TStatus;
  870.     procedure SetNativeIterator(nativeIterator: GpPathIterator);
  871.     function SetStatus(status: TStatus): TStatus;
  872.   public
  873.     constructor Create(path: TGPGraphicsPath); reintroduce;
  874.     destructor Destroy; override;
  875.     function NextSubpath(out startIndex, endIndex: Integer; out isClosed: bool): Integer; overload;
  876.     function NextSubpath(path: TGPGraphicsPath; out isClosed: BOOL): Integer; overload;
  877.     function NextPathType(out pathType: TPathPointType; out startIndex, endIndex: Integer): Integer;
  878.     function NextMarker(out startIndex, endIndex: Integer): Integer; overload;
  879.     function NextMarker(path: TGPGraphicsPath): Integer; overload;
  880.     function GetCount: Integer;
  881.     function GetSubpathCount: Integer;
  882.     function HasCurve: BOOL;
  883.     procedure Rewind;
  884.     function Enumerate(points: PGPPointF; types: PBYTE; count: Integer): Integer;
  885.     function CopyData(points: PGPPointF; types: PBYTE; startIndex, endIndex: Integer): Integer;
  886.     function GetLastStatus: TStatus;
  887.   end;
  888.  
  889. //--------------------------------------------------------------------------
  890. // Path Gradient Brush
  891. //--------------------------------------------------------------------------
  892.  
  893.   TGPPathGradientBrush = class(TGPBrush)
  894.   public
  895.     constructor Create(points: PGPPointF; count: Integer;
  896.       wrapMode: TWrapMode = WrapModeClamp); reintroduce; overload;
  897.     constructor Create(points: PGPPoint; count: Integer;
  898.       wrapMode: TWrapMode = WrapModeClamp); reintroduce; overload;
  899.     constructor Create(path: TGPGraphicsPath); reintroduce; overload;
  900.     constructor Create; reintroduce; overload;
  901.     function GetCenterColor(out Color: TGPColor): TStatus;
  902.     function SetCenterColor(color: TGPColor): TStatus;
  903.     function GetPointCount: Integer;
  904.     function GetSurroundColorCount: Integer;
  905.     function GetSurroundColors(colors: PARGB; var count: Integer): TStatus;
  906.     function SetSurroundColors(colors: PARGB; var count: Integer): TStatus;
  907.     function GetGraphicsPath(path: TGPGraphicsPath): TStatus;
  908.     function SetGraphicsPath(path: TGPGraphicsPath): TStatus;
  909.     function GetCenterPoint(out point: TGPPointF): TStatus; overload;
  910.     function GetCenterPoint(out point: TGPPoint): TStatus; overload;
  911.     function SetCenterPoint(point: TGPPointF): TStatus; overload;
  912.     function SetCenterPoint(point: TGPPoint): TStatus; overload;
  913.     function GetRectangle(out rect: TGPRectF): TStatus; overload;
  914.     function GetRectangle(out rect: TGPRect): TStatus; overload;
  915.     function SetGammaCorrection(useGammaCorrection: BOOL): TStatus; overload;
  916.     function GetGammaCorrection: BOOL; overload;
  917.     function GetBlendCount: Integer;
  918.     function GetBlend(blendFactors, blendPositions: PSingle; count: Integer): TStatus;
  919.     function SetBlend(blendFactors, blendPositions: PSingle; count: Integer): TStatus;
  920.     function GetInterpolationColorCount: Integer;
  921.     function SetInterpolationColors(presetColors: PARGB; blendPositions: PSingle;
  922.       count: Integer): TStatus;
  923.     function GetInterpolationColors(presetColors: PARGB;
  924.       blendPositions: PSingle; count: Integer): TStatus;
  925.     function SetBlendBellShape(focus: Single; scale: Single = 1.0): TStatus;
  926.     function SetBlendTriangularShape(focus: Single; scale: Single = 1.0): TStatus;
  927.     function GetTransform(matrix: TGPMatrix): TStatus;
  928.     function SetTransform(matrix: TGPMatrix): TStatus;
  929.     function ResetTransform: TStatus;
  930.     function MultiplyTransform(matrix: TGPMatrix;
  931.       order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  932.     function TranslateTransform(dx, dy: Single;
  933.       order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  934.     function ScaleTransform(sx, sy: Single;
  935.       order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  936.     function RotateTransform(angle: Single;
  937.       order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  938.     function GetFocusScales(out xScale, yScale: Single): TStatus;
  939.     function SetFocusScales(xScale, yScale: Single): TStatus;
  940.     function GetWrapMode: TWrapMode;
  941.     function SetWrapMode(wrapMode: TWrapMode): TStatus;
  942.   end;
  943.  
  944. (**************************************************************************\
  945. *
  946. *   GDI+ Graphics Object
  947. *
  948. \**************************************************************************)
  949.  
  950.   TGPGraphics = class(TGdiplusBase)
  951.   protected
  952.     nativeGraphics: GpGraphics;
  953.     lastResult: TStatus;
  954.     procedure SetNativeGraphics(graphics: GpGraphics);
  955.     function SetStatus(status: TStatus): TStatus;
  956.     function GetNativeGraphics: GpGraphics;
  957.     function GetNativePen(pen: TGPPen): GpPen;
  958.     constructor Create(graphics: GpGraphics); reintroduce; overload;
  959.   public
  960.     function FromHDC(hdc: HDC): TGPGraphics; overload;
  961.     function FromHDC(hdc: HDC; hdevice: THANDLE): TGPGraphics; overload;
  962.     function FromHWND(hwnd: HWND; icm: BOOL = FALSE): TGPGraphics;
  963.     function FromImage(image: TGPImage): TGPGraphics;
  964.     constructor Create(hdc: HDC); reintroduce; overload;
  965.     constructor Create(hdc: HDC; hdevice: THANDLE); reintroduce; overload;
  966.     constructor Create(hwnd: HWND; icm: BOOL{ = FALSE}); reintroduce; overload;
  967.     constructor Create(image: TGPImage); reintroduce; overload;
  968.     destructor destroy; override;
  969.     procedure Flush(intention: TFlushIntention = FlushIntentionFlush);
  970.     //------------------------------------------------------------------------
  971.     // GDI Interop methods
  972.     //------------------------------------------------------------------------
  973.     // Locks the graphics until ReleaseDC is called
  974.     function GetHDC: HDC;
  975.     procedure ReleaseHDC(hdc: HDC);
  976.     //------------------------------------------------------------------------
  977.     // Rendering modes
  978.     //------------------------------------------------------------------------
  979.     function SetRenderingOrigin(x, y: Integer): TStatus;
  980.     function GetRenderingOrigin(out x, y: Integer): TStatus;
  981.     function SetCompositingMode(compositingMode: TCompositingMode): TStatus;
  982.     function GetCompositingMode: TCompositingMode;
  983.     function SetCompositingQuality(compositingQuality: TCompositingQuality): TStatus;
  984.     function GetCompositingQuality: TCompositingQuality;
  985.     function SetTextRenderingHint(newMode: TTextRenderingHint): TStatus;
  986.     function GetTextRenderingHint: TTextRenderingHint;
  987.     function SetTextContrast(contrast: UINT): TStatus; // 0..12
  988.     function GetTextContrast: UINT;
  989.     function GetInterpolationMode: TInterpolationMode;
  990.     function SetInterpolationMode(interpolationMode: TInterpolationMode): TStatus;
  991.     function GetSmoothingMode: TSmoothingMode;
  992.     function SetSmoothingMode(smoothingMode: TSmoothingMode): TStatus;
  993.     function GetPixelOffsetMode: TPixelOffsetMode;
  994.     function SetPixelOffsetMode(pixelOffsetMode: TPixelOffsetMode): TStatus;
  995.     //------------------------------------------------------------------------
  996.     // Manipulate current world transform
  997.     //------------------------------------------------------------------------
  998.     function SetTransform(matrix: TGPMatrix): TStatus;
  999.     function ResetTransform: TStatus;
  1000.     function MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  1001.     function TranslateTransform(dx, dy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  1002.     function ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  1003.     function RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  1004.     function GetTransform(matrix: TGPMatrix): TStatus;
  1005.     function SetPageUnit(unit_: TUnit): TStatus;
  1006.     function SetPageScale(scale: Single): TStatus;
  1007.     function GetPageUnit: TUnit;
  1008.     function GetPageScale: Single;
  1009.     function GetDpiX: Single;
  1010.     function GetDpiY: Single;
  1011.     function TransformPoints(destSpace: TCoordinateSpace; srcSpace: TCoordinateSpace;
  1012.       pts: PGPPointF; count: Integer): TStatus; overload;
  1013.     function TransformPoints(destSpace: TCoordinateSpace; srcSpace: TCoordinateSpace;
  1014.       pts: PGPPoint; count: Integer): TStatus; overload;
  1015.     //------------------------------------------------------------------------
  1016.     // GetNearestColor (for <= 8bpp surfaces).  Note: Alpha is ignored.
  1017.     //------------------------------------------------------------------------
  1018.     function GetNearestColor(var color: TGPColor): TStatus;
  1019.  
  1020.     // DrawLine(s)
  1021.     function DrawLine(pen: TGPPen; x1, y1, x2, y2: Single): TStatus; overload;
  1022.     function DrawLine(pen: TGPPen; const pt1, pt2: TGPPointF): TStatus; overload;
  1023.     function DrawLines(pen: TGPPen; points: PGPPointF; count: Integer): TStatus; overload;
  1024.     function DrawLine(pen: TGPPen; x1, y1, x2, y2: Integer): TStatus; overload;
  1025.     function DrawLine(pen: TGPPen; const pt1, pt2: TGPPoint): TStatus; overload;
  1026.     function DrawLines(pen: TGPPen; points: PGPPoint; count: Integer): TStatus; overload;
  1027.  
  1028.     // DrawArc
  1029.     function DrawArc(pen: TGPPen; x, y, width, height, startAngle, sweepAngle: Single): TStatus; overload;
  1030.     function DrawArc(pen: TGPPen; const rect: TGPRectF; startAngle, sweepAngle: Single): TStatus; overload;
  1031.     function DrawArc(pen: TGPPen; x, y, width, height: Integer; startAngle, sweepAngle: Single): TStatus; overload;
  1032.     function DrawArc(pen: TGPPen; const rect: TGPRect; startAngle, sweepAngle: Single): TStatus; overload;
  1033.  
  1034.     // DrawBezier(s)
  1035.     function DrawBezier(pen: TGPPen; x1, y1, x2, y2, x3, y3, x4, y4: Single): TStatus; overload;
  1036.     function DrawBezier(pen: TGPPen; const pt1, pt2, pt3, pt4: TGPPointF): TStatus; overload;
  1037.     function DrawBeziers(pen: TGPPen; points: PGPPointF; count: Integer): TStatus; overload;
  1038.     function DrawBezier(pen: TGPPen; x1, y1, x2, y2, x3, y3, x4, y4: Integer): TStatus; overload;
  1039.     function DrawBezier(pen: TGPPen; const pt1, pt2, pt3, pt4: TGPPoint): TStatus; overload;
  1040.     function DrawBeziers(pen: TGPPen; points: PGPPoint; count: Integer): TStatus; overload;
  1041.  
  1042.     // DrawRectangle(s)
  1043.     function DrawRectangle(pen: TGPPen; const rect: TGPRectF): TStatus; overload;
  1044.     function DrawRectangle(pen: TGPPen; x, y, width, height: Single): TStatus; overload;
  1045.     function DrawRectangles(pen: TGPPen; rects: PGPRectF; count: Integer): TStatus; overload;
  1046.     function DrawRectangle(pen: TGPPen; const rect: TGPRect): TStatus; overload;
  1047.     function DrawRectangle(pen: TGPPen; x, y, width, height: Integer): TStatus; overload;
  1048.     function DrawRectangles(pen: TGPPen; rects: PGPRect; count: Integer): TStatus; overload;
  1049.  
  1050.     // DrawEllipse
  1051.     function DrawEllipse(pen: TGPPen; const rect: TGPRectF): TStatus; overload;
  1052.     function DrawEllipse(pen: TGPPen; x, y, width, height: Single): TStatus; overload;
  1053.     function DrawEllipse(pen: TGPPen; const rect: TGPRect): TStatus; overload;
  1054.     function DrawEllipse(pen: TGPPen; x, y, width, height: Integer): TStatus; overload;
  1055.  
  1056.     // DrawPie
  1057.     function DrawPie(pen: TGPPen; const rect: TGPRectF; startAngle, sweepAngle: Single): TStatus; overload;
  1058.     function DrawPie(pen: TGPPen; x, y, width, height, startAngle, sweepAngle: Single): TStatus; overload;
  1059.     function DrawPie(pen: TGPPen; const rect: TGPRect; startAngle, sweepAngle: Single): TStatus; overload;
  1060.     function DrawPie(pen: TGPPen; x, y, width, height: Integer; startAngle, sweepAngle: Single): TStatus; overload;
  1061.  
  1062.     // DrawPolygon
  1063.     function DrawPolygon(pen: TGPPen; points: PGPPointF; count: Integer): TStatus; overload;
  1064.     function DrawPolygon(pen: TGPPen; points: PGPPoint; count: Integer): TStatus; overload;
  1065.  
  1066.     // DrawPath
  1067.     function DrawPath(pen: TGPPen; path: TGPGraphicsPath): TStatus;
  1068.  
  1069.     // DrawCurve
  1070.     function DrawCurve(pen: TGPPen; points: PGPPointF; count: Integer): TStatus; overload;
  1071.     function DrawCurve(pen: TGPPen; points: PGPPointF; count: Integer; tension: Single): TStatus; overload;
  1072.     function DrawCurve(pen: TGPPen; points: PGPPointF; count, offset,
  1073.       numberOfSegments: Integer; tension: Single = 0.5): TStatus; overload;
  1074.     function DrawCurve(pen: TGPPen; points: PGPPoint; count: Integer): TStatus; overload;
  1075.     function DrawCurve(pen: TGPPen; points: PGPPoint; count: Integer; tension: Single): TStatus; overload;
  1076.     function DrawCurve(pen: TGPPen; points: PGPPoint; count, offset, numberOfSegments: Integer;
  1077.       tension: Single = 0.5): TStatus; overload;
  1078.  
  1079.     // DrawClosedCurve
  1080.     function DrawClosedCurve(pen: TGPPen; points: PGPPointF; count: Integer): TStatus; overload;
  1081.     function DrawClosedCurve(pen: TGPPen; points: PGPPointF; count: Integer; tension: Single): TStatus; overload;
  1082.     function DrawClosedCurve(pen: TGPPen; points: PGPPoint;  count: Integer): TStatus; overload;
  1083.     function DrawClosedCurve(pen: TGPPen; points: PGPPoint; count: Integer; tension: Single): TStatus; overload;
  1084.  
  1085.     // Clear
  1086.     function Clear(color: TGPColor): TStatus;
  1087.  
  1088.     // FillRectangle(s)
  1089.     function FillRectangle(brush: TGPBrush; const rect: TGPRectF): TStatus; overload;
  1090.     function FillRectangle(brush: TGPBrush; x, y, width, height: Single): TStatus; overload;
  1091.     function FillRectangles(brush: TGPBrush; rects: PGPRectF; count: Integer): TStatus; overload;
  1092.     function FillRectangle(brush: TGPBrush; const rect: TGPRect): TStatus; overload;
  1093.     function FillRectangle(brush: TGPBrush; x, y, width, height: Integer): TStatus; overload;
  1094.     function FillRectangles(brush: TGPBrush; rects: PGPRect; count: Integer): TStatus; overload;
  1095.  
  1096.     // FillPolygon
  1097.     function FillPolygon(brush: TGPBrush; points: PGPPointF; count: Integer): TStatus; overload;
  1098.     function FillPolygon(brush: TGPBrush; points: PGPPointF; count: Integer; fillMode: TFillMode): TStatus; overload;
  1099.     function FillPolygon(brush: TGPBrush; points: PGPPoint; count: Integer): TStatus; overload;
  1100.     function FillPolygon(brush: TGPBrush; points: PGPPoint; count: Integer; fillMode: TFillMode): TStatus; overload;
  1101.  
  1102.     // FillEllipse
  1103.     function FillEllipse(brush: TGPBrush; const rect: TGPRectF): TStatus; overload;
  1104.     function FillEllipse(brush: TGPBrush; x, y, width, height: Single): TStatus; overload;
  1105.     function FillEllipse(brush: TGPBrush; const rect: TGPRect): TStatus; overload;
  1106.     function FillEllipse(brush: TGPBrush; x, y, width, height: Integer): TStatus; overload;
  1107.  
  1108.     // FillPie
  1109.     function FillPie(brush: TGPBrush; const rect: TGPRectF; startAngle, sweepAngle: Single): TStatus; overload;
  1110.     function FillPie(brush: TGPBrush; x, y, width, height, startAngle, sweepAngle: Single): TStatus; overload;
  1111.     function FillPie(brush: TGPBrush; const rect: TGPRect; startAngle, sweepAngle: Single): TStatus; overload;
  1112.     function FillPie(brush: TGPBrush; x, y, width, height: Integer; startAngle, sweepAngle: Single): TStatus; overload;
  1113.  
  1114.     // FillPath
  1115.     function FillPath(brush: TGPBrush; path: TGPGraphicsPath): TStatus;
  1116.  
  1117.     // FillClosedCurve
  1118.     function FillClosedCurve(brush: TGPBrush; points: PGPPointF; count: Integer): TStatus; overload;
  1119.     function FillClosedCurve(brush: TGPBrush; points: PGPPointF; count: Integer;
  1120.       fillMode: TFillMode; tension: Single = 0.5 ): TStatus; overload;
  1121.     function FillClosedCurve(brush: TGPBrush; points: PGPPoint; count: Integer): TStatus; overload;
  1122.     function FillClosedCurve(brush: TGPBrush; points: PGPPoint; count: Integer;
  1123.       fillMode: TFillMode; tension: Single = 0.5): TStatus; overload;
  1124.  
  1125.     // FillRegion
  1126.     function FillRegion(brush: TGPBrush; region: TGPRegion): TStatus;
  1127.  
  1128.     // DrawString
  1129.     function DrawString(string_: WideString; length: Integer; font: TGPFont;
  1130.       const layoutRect: TGPRectF; stringFormat: TGPStringFormat; brush: TGPBrush): TStatus; overload;
  1131.     function DrawString(string_: WideString; length: Integer; font: TGPFont;
  1132.       const origin: TGPPointF; brush: TGPBrush): TStatus; overload;
  1133.     function DrawString(string_: WideString; length: Integer; font: TGPFont;
  1134.       const origin: TGPPointF; stringFormat: TGPStringFormat; brush: TGPBrush): TStatus; overload;
  1135.  
  1136.     // MeasureString
  1137.     function MeasureString(string_: WideString; length: Integer; font: TGPFont;
  1138.       const layoutRect: TGPRectF; stringFormat: TGPStringFormat; out boundingBox: TGPRectF;
  1139.       codepointsFitted: PInteger = nil; linesFilled: PInteger = nil): TStatus; overload;
  1140.     function MeasureString(string_: WideString; length: Integer; font: TGPFont;
  1141.       const layoutRectSize: TGPSizeF; stringFormat: TGPStringFormat; out size: TGPSizeF;
  1142.       codepointsFitted: PInteger = nil; linesFilled: PInteger = nil): TStatus; overload;
  1143.     function MeasureString(string_: WideString ; length: Integer; font: TGPFont;
  1144.       const origin: TGPPointF; stringFormat: TGPStringFormat;
  1145.       out boundingBox: TGPRectF): TStatus; overload;
  1146.     function MeasureString(string_: WideString; length: Integer; font: TGPFont;
  1147.       const layoutRect: TGPRectF; out boundingBox: TGPRectF): TStatus; overload;
  1148.     function MeasureString(string_: WideString; length: Integer; font: TGPFont;
  1149.       const origin: TGPPointF; out boundingBox: TGPRectF): TStatus; overload;
  1150.  
  1151.     // MeasureCharacterRanges
  1152.     function MeasureCharacterRanges(string_: WideString; length: Integer; font: TGPFont;
  1153.       const layoutRect: TGPRectF; stringFormat: TGPStringFormat; regionCount: Integer;
  1154.       const regions: array of TGPRegion): TStatus; overload;
  1155.  
  1156.     // DrawDriverString
  1157.     function DrawDriverString(text: PUINT16; length: Integer; font: TGPFont;
  1158.       brush: TGPBrush; positions: PGPPointF; flags: Integer; matrix: TGPMatrix): TStatus;
  1159.  
  1160.     // MeasureDriverString
  1161.     function MeasureDriverString(text: PUINT16; length: Integer; font: TGPFont;
  1162.        positions: PGPPointF; flags: Integer; matrix: TGPMatrix;
  1163.        out boundingBox: TGPRectF): TStatus;
  1164.  
  1165.     // Draw a cached bitmap on this graphics destination offset by
  1166.     // x, y. Note this will fail with WrongState if the CachedBitmap
  1167.     // native format differs from this Graphics.
  1168.     function DrawCachedBitmap(cb: TGPCachedBitmap;  x, y: Integer): TStatus;
  1169.     function DrawImage(image: TGPImage; const point: TGPPointF): TStatus; overload;
  1170.     function DrawImage(image: TGPImage; x, y: Single): TStatus; overload;
  1171.     function DrawImage(image: TGPImage; const rect: TGPRectF): TStatus; overload;
  1172.     function DrawImage(image: TGPImage; x, y, width, height: Single): TStatus; overload;
  1173.     function DrawImage(image: TGPImage; const point: TGPPoint): TStatus; overload;
  1174.     function DrawImage(image: TGPImage; x, y: Integer): TStatus; overload;
  1175.     function DrawImage(image: TGPImage; const rect: TGPRect): TStatus; overload;
  1176.     function DrawImage(image: TGPImage; x, y, width, height: Integer): TStatus; overload;
  1177.  
  1178.     // Affine Draw Image
  1179.     // destPoints.length = 3: rect => parallelogram
  1180.     //     destPoints[0] <=> top-left corner of the source rectangle
  1181.     //     destPoints[1] <=> top-right corner
  1182.     //     destPoints[2] <=> bottom-left corner
  1183.     // destPoints.length = 4: rect => quad
  1184.     //     destPoints[3] <=> bottom-right corner
  1185.     function DrawImage(image: TGPImage; destPoints: PGPPointF; count: Integer): TStatus; overload;
  1186.     function DrawImage(image: TGPImage; destPoints: PGPPoint; count: Integer): TStatus; overload;
  1187.     function DrawImage(image: TGPImage; x, y, srcx, srcy, srcwidth, srcheight: Single; srcUnit: TUnit): TStatus; overload;
  1188.     function DrawImage(image: TGPImage; const destRect: TGPRectF; srcx, srcy,
  1189.       srcwidth, srcheight: Single; srcUnit: TUnit;
  1190.       imageAttributes: TGPImageAttributes = nil; callback: DrawImageAbort = nil;
  1191.       callbackData: Pointer = nil): TStatus; overload;
  1192.     function DrawImage(image: TGPImage; destPoints: PGPPointF; count: Integer;
  1193.       srcx, srcy, srcwidth, srcheight: Single; srcUnit: TUnit;
  1194.       imageAttributes: TGPImageAttributes = nil; callback: DrawImageAbort = nil;
  1195.       callbackData: Pointer = nil): TStatus; overload;
  1196.     function DrawImage(image: TGPImage; x, y, srcx, srcy, srcwidth,
  1197.       srcheight: Integer; srcUnit: TUnit): TStatus; overload;
  1198.     function DrawImage(image: TGPImage; const destRect: TGPRect; srcx, srcy,
  1199.       srcwidth, srcheight: Integer; srcUnit: TUnit;
  1200.       imageAttributes: TGPImageAttributes = nil; callback: DrawImageAbort = nil;
  1201.       callbackData: Pointer = nil): TStatus; overload;
  1202.     function DrawImage(image: TGPImage; destPoints: PGPPoint;
  1203.       count, srcx, srcy, srcwidth, srcheight: Integer; srcUnit: TUnit;
  1204.       imageAttributes: TGPImageAttributes = nil; callback: DrawImageAbort = nil;
  1205.       callbackData: Pointer = nil): TStatus; overload;
  1206.  
  1207.     // The following methods are for playing an EMF+ to a graphics
  1208.     // via the enumeration interface.  Each record of the EMF+ is
  1209.     // sent to the callback (along with the callbackData).  Then
  1210.     // the callback can invoke the Metafile::PlayRecord method
  1211.     // to play the particular record.
  1212.     function EnumerateMetafile(metafile: TGPMetafile; const destPoint: TGPPointF;
  1213.       callback: EnumerateMetafileProc; callbackData: Pointer = nil;
  1214.       imageAttributes: TGPImageAttributes = nil): TStatus; overload;
  1215.     function EnumerateMetafile(metafile: TGPMetafile; const destPoint: TGPPoint;    
  1216.        callback: EnumerateMetafileProc; callbackData: pointer = nil;
  1217.        imageAttributes: TGPImageAttributes = nil): TStatus; overload;
  1218.     function EnumerateMetafile(metafile: TGPMetafile; const destRect: TGPRectF;
  1219.        callback: EnumerateMetafileProc; callbackData: Pointer = nil;
  1220.        imageAttributes: TGPImageAttributes = nil): TStatus; overload;
  1221.     function EnumerateMetafile(metafile: TGPMetafile; const destRect: TGPRect;
  1222.        callback: EnumerateMetafileProc; callbackData: Pointer = nil;
  1223.        imageAttributes: TGPImageAttributes = nil): TStatus; overload;
  1224.     function EnumerateMetafile(metafile: TGPMetafile; destPoints: PGPPointF;
  1225.        count: Integer; callback: EnumerateMetafileProc; callbackData: Pointer = nil;
  1226.        imageAttributes: TGPImageAttributes = nil): TStatus; overload;
  1227.     function EnumerateMetafile(metafile: TGPMetafile; destPoints: PGPPoint;
  1228.        count: Integer; callback: EnumerateMetafileProc; callbackData: Pointer = nil;
  1229.        imageAttributes: TGPImageAttributes = nil): TStatus; overload;
  1230.     function EnumerateMetafile(metafile: TGPMetafile; const destPoint: TGPPointF;
  1231.        const srcRect: TGPRectF; srcUnit: TUnit; callback: EnumerateMetafileProc;
  1232.        callbackData: pointer = nil; imageAttributes: TGPImageAttributes = nil
  1233.        ): TStatus; overload;
  1234.     function EnumerateMetafile(metafile : TGPMetafile; const destPoint : TGPPoint;
  1235.        const srcRect : TGPRect; srcUnit : TUnit; callback : EnumerateMetafileProc;
  1236.        callbackData : Pointer = nil; imageAttributes : TGPImageAttributes = nil
  1237.        ): TStatus; overload;
  1238.     function EnumerateMetafile(metafile: TGPMetafile; const destRect: TGPRectF;
  1239.        const srcRect: TGPRectF; srcUnit: TUnit; callback: EnumerateMetafileProc;
  1240.        callbackData: Pointer = nil; imageAttributes: TGPImageAttributes = nil): TStatus; overload;
  1241.     function EnumerateMetafile(metafile : TGPMetafile; const destRect, srcRect: TGPRect;
  1242.        srcUnit : TUnit; callback : EnumerateMetafileProc; callbackData : Pointer = nil;
  1243.        imageAttributes : TGPImageAttributes = nil): TStatus; overload;
  1244.     function EnumerateMetafile( metafile: TGPMetafile; destPoints: PGPPointF;
  1245.         count: Integer; const srcRect: TGPRectF; srcUnit: TUnit; callback: EnumerateMetafileProc;
  1246.         callbackData: Pointer = nil; imageAttributes: TGPImageAttributes = nil): TStatus; overload;
  1247.     function EnumerateMetafile(metafile: TGPMetafile; destPoints: PGPPoint;
  1248.         count: Integer; const srcRect: TGPRect; srcUnit: TUnit; callback: EnumerateMetafileProc;
  1249.         callbackData: Pointer = nil; imageAttributes: TGPImageAttributes = nil): TStatus; overload;
  1250.  
  1251.     // SetClip
  1252.     function SetClip(g: TGPGraphics; combineMode: TCombineMode = CombineModeReplace): TStatus; overload;
  1253.     function SetClip(rect: TGPRectF; combineMode: TCombineMode = CombineModeReplace): TStatus; overload;
  1254.     function SetClip(rect: TGPRect; combineMode: TCombineMode = CombineModeReplace): TStatus; overload;
  1255.     function SetClip(path: TGPGraphicsPath; combineMode: TCombineMode = CombineModeReplace): TStatus; overload;
  1256.     function SetClip(region: TGPRegion; combineMode: TCombineMode = CombineModeReplace): TStatus; overload;
  1257.     // This is different than the other SetClip methods because it assumes
  1258.     // that the HRGN is already in device units, so it doesn't transform
  1259.     // the coordinates in the HRGN.
  1260.     function SetClip(hRgn: HRGN; combineMode: TCombineMode = CombineModeReplace): TStatus; overload;
  1261.  
  1262.     // IntersectClip
  1263.     function IntersectClip(const rect: TGPRectF): TStatus; overload;
  1264.     function IntersectClip(const rect: TGPRect): TStatus; overload;
  1265.     function IntersectClip(region: TGPRegion): TStatus; overload;
  1266.     // ExcludeClip
  1267.     function ExcludeClip(const rect: TGPRectF): TStatus; overload;
  1268.     function ExcludeClip(const rect: TGPRect): TStatus; overload;
  1269.     function ExcludeClip(region: TGPRegion): TStatus; overload;
  1270.  
  1271.     function ResetClip: TStatus;
  1272.  
  1273.     function TranslateClip(dx, dy: Single): TStatus; overload;
  1274.     function TranslateClip(dx, dy: Integer): TStatus; overload;
  1275.  
  1276.     function GetClip(region: TGPRegion): TStatus;
  1277.  
  1278.     function GetClipBounds(out rect: TGPRectF): TStatus; overload;
  1279.     function GetClipBounds(out rect: TGPRect): TStatus; overload;
  1280.  
  1281.     function IsClipEmpty: Bool;
  1282.  
  1283.     function GetVisibleClipBounds(out rect: TGPRectF): TStatus; overload;
  1284.     function GetVisibleClipBounds(out rect: TGPRect): TStatus; overload;
  1285.  
  1286.     function IsVisibleClipEmpty: BOOL;
  1287.  
  1288.     function IsVisible(x, y: Integer): BOOL; overload;
  1289.     function IsVisible(const point: TGPPoint): BOOL; overload;
  1290.     function IsVisible(x, y, width, height: Integer): BOOL; overload;
  1291.     function IsVisible(const rect: TGPRect): BOOL; overload;
  1292.     function IsVisible(x, y: Single): BOOL; overload;
  1293.     function IsVisible(const point: TGPPointF): BOOL; overload;
  1294.     function IsVisible(x, y, width, height: Single): BOOL; overload;
  1295.     function IsVisible(const rect: TGPRectF): BOOL; overload;
  1296.  
  1297.     function Save: GraphicsState;
  1298.     function Restore(gstate: GraphicsState): TStatus;
  1299.  
  1300.     function BeginContainer(const dstrect,srcrect: TGPRectF; unit_: TUnit): GraphicsContainer; overload;
  1301.     function BeginContainer(const dstrect, srcrect: TGPRect; unit_: TUnit): GraphicsContainer; overload;
  1302.     function BeginContainer: GraphicsContainer; overload;
  1303.     function EndContainer(state: GraphicsContainer): TStatus;
  1304.  
  1305.     // Only valid when recording metafiles.
  1306.     function AddMetafileComment(data: PBYTE; sizeData: UINT): TStatus;
  1307.  
  1308.     function GetHalftonePalette: HPALETTE;                                      
  1309.     function GetLastStatus: TStatus;
  1310.   end;
  1311.  
  1312.  
  1313. (**************************************************************************\
  1314. *
  1315. *   GDI+ CustomLineCap APIs
  1316. *
  1317. \**************************************************************************)
  1318.  
  1319.   TGPAdjustableArrowCap = class(TGPCustomLineCap)
  1320.   public
  1321.     constructor Create(height, width: Single; isFilled: Bool = TRUE); 
  1322.     function SetHeight(height: Single): TStatus;
  1323.     function GetHeight: Single;
  1324.     function SetWidth(width: Single): TStatus;
  1325.     function GetWidth: Single;
  1326.     function SetMiddleInset(middleInset: Single): TStatus;
  1327.     function GetMiddleInset: Single;
  1328.     function SetFillState(isFilled: Bool): TStatus;
  1329.     function IsFilled: BOOL;
  1330.   end;
  1331.  
  1332. (**************************************************************************\
  1333. *
  1334. *   GDI+ Metafile class
  1335. *
  1336. \**************************************************************************)
  1337.  
  1338.   TGPMetafile = class(TGPImage)
  1339.   public
  1340.     // Playback a metafile from a HMETAFILE
  1341.     // If deleteWmf is TRUE, then when the metafile is deleted,
  1342.     // the hWmf will also be deleted.  Otherwise, it won't be.
  1343.     constructor Create(hWmf: HMETAFILE; var wmfPlaceableFileHeader: TWmfPlaceableFileHeader;
  1344.       deleteWmf: BOOL = FALSE); overload;
  1345.     // Playback a metafile from a HENHMETAFILE
  1346.     // If deleteEmf is TRUE, then when the metafile is deleted,
  1347.     // the hEmf will also be deleted.  Otherwise, it won't be.
  1348.     constructor Create(hEmf: HENHMETAFILE; deleteEmf: BOOL = FALSE); overload;
  1349.     constructor Create(filename: WideString); overload;
  1350.     // Playback a WMF metafile from a file.
  1351.     constructor Create(filename: WideString; var wmfPlaceableFileHeader: TWmfPlaceableFileHeader); overload;
  1352.     constructor Create(stream: IStream); overload;
  1353.     // Record a metafile to memory.
  1354.     constructor Create(referenceHdc: HDC; type_: TEmfType = EmfTypeEmfPlusDual;
  1355.       description: PWCHAR = nil); overload;
  1356.     // Record a metafile to memory.
  1357.     constructor Create(referenceHdc: HDC; frameRect: TGPRectF;
  1358.       frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi;
  1359.       type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); overload;
  1360.     // Record a metafile to memory.
  1361.     constructor Create(referenceHdc: HDC; frameRect: TGPRect;
  1362.       frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi;
  1363.       type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); overload;
  1364.     constructor Create(fileName: WideString;referenceHdc: HDC;
  1365.       type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); overload;
  1366.     constructor Create(fileName: WideString; referenceHdc: HDC; frameRect: TGPRectF;
  1367.       frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi;
  1368.       type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); overload;
  1369.     constructor Create( fileName: WideString; referenceHdc: HDC; frameRect: TGPRect;
  1370.       frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi;
  1371.       type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); overload;
  1372.     constructor Create(stream: IStream; referenceHdc: HDC;
  1373.       type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); overload;
  1374.     constructor Create(stream: IStream; referenceHdc: HDC; frameRect: TGPRectF;
  1375.       frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi;
  1376.       type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); overload;
  1377.     constructor Create(stream : IStream; referenceHdc : HDC; frameRect : TGPRect;
  1378.      frameUnit : TMetafileFrameUnit = MetafileFrameUnitGdi;
  1379.      type_ : TEmfType = EmfTypeEmfPlusDual; description : PWCHAR = nil); overload;
  1380.     constructor Create; reintroduce; overload;
  1381.     function GetMetafileHeader(hWmf: HMETAFILE; var wmfPlaceableFileHeader: TWmfPlaceableFileHeader;
  1382.       header: TMetafileHeader): TStatus; overload;
  1383.     function GetMetafileHeader(hEmf: HENHMETAFILE; header: TMetafileHeader): TStatus; overload;   // ok
  1384.     function GetMetafileHeader(filename: WideString; header: TMetafileHeader): TStatus; overload; // ok
  1385.     function GetMetafileHeader(stream: IStream; header: TMetafileHeader): TStatus; overload;      // ok
  1386.     function GetMetafileHeader(header: TMetafileHeader): TStatus; overload;                       // ok
  1387.     // Once this method is called, the Metafile object is in an invalid state
  1388.     // and can no longer be used.  It is the responsiblity of the caller to
  1389.     // invoke DeleteEnhMetaFile to delete this hEmf.                                              // ok
  1390.     function GetHENHMETAFILE: HENHMETAFILE;
  1391.     // Used in conjuction with Graphics::EnumerateMetafile to play an EMF+
  1392.     // The data must be DWORD aligned if it's an EMF or EMF+.  It must be
  1393.     // WORD aligned if it's a WMF.
  1394.     function PlayRecord(recordType: TEmfPlusRecordType; flags, dataSize: UINT; data: PBYTE): TStatus;
  1395.     // If you're using a printer HDC for the metafile, but you want the
  1396.     // metafile rasterized at screen resolution, then use this API to set
  1397.     // the rasterization dpi of the metafile to the screen resolution,
  1398.     // e.g. 96 dpi or 120 dpi.
  1399.     function SetDownLevelRasterizationLimit(metafileRasterizationLimitDpi: UINT): TStatus;
  1400.     function GetDownLevelRasterizationLimit: UINT;
  1401.     function EmfToWmfBits(hemf: HENHMETAFILE; cbData16: UINT; pData16: PBYTE;
  1402.       iMapMode: Integer = MM_ANISOTROPIC; eFlags: TEmfToWmfBitsFlags = EmfToWmfBitsFlagsDefault): UINT;
  1403.   end;
  1404.  
  1405. ////////////////////////////////////////////////////////////////////////////////
  1406.  
  1407. var
  1408.    GenericSansSerifFontFamily : TGPFontFamily = nil;
  1409.    GenericSerifFontFamily     : TGPFontFamily = nil;
  1410.    GenericMonospaceFontFamily : TGPFontFamily = nil;
  1411.  
  1412.    GenericTypographicStringFormatBuffer: TGPStringFormat = nil;
  1413.    GenericDefaultStringFormatBuffer    : TGPStringFormat = nil;
  1414.  
  1415.    StartupInput: TGDIPlusStartupInput;
  1416.    gdiplusToken: ULONG;
  1417.  
  1418. ////////////////////////////////////////////////////////////////////////////////
  1419.  
  1420. implementation
  1421.  
  1422. (**************************************************************************\
  1423. *
  1424. * Image Attributes
  1425. *
  1426. * Abstract:
  1427. *
  1428. *   GDI+ Image Attributes used with Graphics.DrawImage
  1429. *
  1430. * There are 5 possible sets of color adjustments:
  1431. *          ColorAdjustDefault,
  1432. *          ColorAdjustBitmap,
  1433. *          ColorAdjustBrush,
  1434. *          ColorAdjustPen,
  1435. *          ColorAdjustText,
  1436. *
  1437. * Bitmaps, Brushes, Pens, and Text will all use any color adjustments
  1438. * that have been set into the default ImageAttributes until their own
  1439. * color adjustments have been set.  So as soon as any "Set" method is
  1440. * called for Bitmaps, Brushes, Pens, or Text, then they start from
  1441. * scratch with only the color adjustments that have been set for them.
  1442. * Calling Reset removes any individual color adjustments for a type
  1443. * and makes it revert back to using all the default color adjustments
  1444. * (if any).  The SetToIdentity method is a way to force a type to
  1445. * have no color adjustments at all, regardless of what previous adjustments
  1446. * have been set for the defaults or for that type.
  1447. *
  1448. \********************************************************************F******)
  1449.  
  1450.   constructor TGPImageAttributes.Create;
  1451.   begin
  1452.     nativeImageAttr := nil;
  1453.     lastResult := GdipCreateImageAttributes(nativeImageAttr);
  1454.   end;
  1455.  
  1456.   destructor TGPImageAttributes.Destroy;
  1457.   begin
  1458.     GdipDisposeImageAttributes(nativeImageAttr);
  1459.     inherited Destroy;
  1460.   end;
  1461.  
  1462.   function TGPImageAttributes.Clone: TGPImageAttributes;
  1463.   var clone: GpImageAttributes;
  1464.   begin
  1465.     SetStatus(GdipCloneImageAttributes(nativeImageAttr, clone));
  1466.     result := TGPImageAttributes.Create(clone, lastResult);
  1467.   end;
  1468.  
  1469.   function TGPImageAttributes.SetToIdentity(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1470.   begin
  1471.     result := SetStatus(GdipSetImageAttributesToIdentity(nativeImageAttr, type_));
  1472.   end;
  1473.  
  1474.   function TGPImageAttributes.Reset(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1475.   begin
  1476.     result := SetStatus(GdipResetImageAttributes(nativeImageAttr, type_));
  1477.   end;
  1478.  
  1479.   function TGPImageAttributes.SetColorMatrix(const colorMatrix: TColorMatrix;
  1480.     mode: TColorMatrixFlags = ColorMatrixFlagsDefault;
  1481.     type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1482.   begin
  1483.     result := SetStatus(GdipSetImageAttributesColorMatrix(nativeImageAttr,
  1484.       type_, TRUE, @colorMatrix, nil, mode));
  1485.   end;
  1486.  
  1487.   function TGPImageAttributes.ClearColorMatrix(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1488.   begin
  1489.     result := SetStatus(GdipSetImageAttributesColorMatrix(nativeImageAttr, type_,
  1490.       FALSE, nil, nil, ColorMatrixFlagsDefault));
  1491.   end;
  1492.  
  1493.     
  1494.   function TGPImageAttributes.SetColorMatrices(const colorMatrix: TColorMatrix;
  1495.     const grayMatrix: TColorMatrix; mode: TColorMatrixFlags  = ColorMatrixFlagsDefault;
  1496.     type_: TColorAdjustType  = ColorAdjustTypeDefault): TStatus;
  1497.   begin
  1498.     result := SetStatus(GdipSetImageAttributesColorMatrix(nativeImageAttr, type_,
  1499.       TRUE, @colorMatrix, @grayMatrix, mode));
  1500.   end;
  1501.  
  1502.   function TGPImageAttributes.ClearColorMatrices(Type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1503.   begin
  1504.     result := SetStatus(GdipSetImageAttributesColorMatrix( nativeImageAttr,
  1505.       type_, FALSE, nil, nil, ColorMatrixFlagsDefault));
  1506.   end;
  1507.  
  1508.   function TGPImageAttributes.SetThreshold(threshold: Single; type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1509.   begin
  1510.     result := SetStatus(GdipSetImageAttributesThreshold( nativeImageAttr, type_,
  1511.       TRUE, threshold));
  1512.   end;
  1513.  
  1514.   function TGPImageAttributes.ClearThreshold(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1515.   begin
  1516.     result := SetStatus(GdipSetImageAttributesThreshold(nativeImageAttr, type_,
  1517.       FALSE, 0.0));
  1518.   end;
  1519.  
  1520.   function TGPImageAttributes.SetGamma(gamma: Single; type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1521.   begin
  1522.     result := SetStatus(GdipSetImageAttributesGamma(nativeImageAttr, type_, TRUE, gamma));
  1523.   end;
  1524.  
  1525.   function TGPImageAttributes.ClearGamma(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1526.   begin
  1527.     result := SetStatus(GdipSetImageAttributesGamma(nativeImageAttr, type_, FALSE, 0.0));
  1528.   end;
  1529.  
  1530.   function TGPImageAttributes.SetNoOp(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1531.   begin
  1532.     result := SetStatus(GdipSetImageAttributesNoOp(nativeImageAttr, type_, TRUE));
  1533.   end;
  1534.  
  1535.   function TGPImageAttributes.ClearNoOp(Type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1536.   begin
  1537.     result := SetStatus(GdipSetImageAttributesNoOp( nativeImageAttr, type_, FALSE));
  1538.   end;
  1539.  
  1540.   function TGPImageAttributes.SetColorKey(colorLow, colorHigh: TGPColor;
  1541.     type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1542.   begin
  1543.     result := SetStatus(GdipSetImageAttributesColorKeys(nativeImageAttr, type_,
  1544.       TRUE, colorLow, colorHigh));
  1545.   end;
  1546.  
  1547.   function TGPImageAttributes.ClearColorKey(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1548.   begin
  1549.     result := SetStatus(GdipSetImageAttributesColorKeys(nativeImageAttr, type_,
  1550.       FALSE, 0, 0));
  1551.   end;
  1552.  
  1553.   function TGPImageAttributes.SetOutputChannel(channelFlags: TColorChannelFlags;
  1554.         type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1555.   begin
  1556.     result := SetStatus(GdipSetImageAttributesOutputChannel(nativeImageAttr,
  1557.       type_, TRUE, channelFlags));
  1558.   end;
  1559.  
  1560.   function TGPImageAttributes.ClearOutputChannel(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1561.   begin
  1562.     result := SetStatus(GdipSetImageAttributesOutputChannel(nativeImageAttr,
  1563.       type_, FALSE, ColorChannelFlagsLast));
  1564.   end;
  1565.  
  1566.   function TGPImageAttributes.SetOutputChannelColorProfile(colorProfileFilename: WideString;
  1567.     type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1568.   begin
  1569.     result := SetStatus(GdipSetImageAttributesOutputChannelColorProfile(nativeImageAttr,
  1570.       type_, TRUE, PWideChar(colorProfileFilename)));
  1571.   end;
  1572.  
  1573.   function TGPImageAttributes.ClearOutputChannelColorProfile(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1574.   begin
  1575.     result := SetStatus(GdipSetImageAttributesOutputChannelColorProfile(nativeImageAttr,
  1576.       type_, FALSE, nil));
  1577.   end;
  1578.  
  1579.   function TGPImageAttributes.SetRemapTable(mapSize: Cardinal; map: PColorMap;
  1580.     type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1581.   begin
  1582.     result := SetStatus(GdipSetImageAttributesRemapTable(nativeImageAttr, type_,
  1583.       TRUE, mapSize, map));
  1584.   end;
  1585.  
  1586.   function TGPImageAttributes.ClearRemapTable(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus;
  1587.   begin
  1588.     result := SetStatus(GdipSetImageAttributesRemapTable(nativeImageAttr, type_,
  1589.       FALSE, 0, nil));
  1590.   end;
  1591.  
  1592.   function TGPImageAttributes.SetBrushRemapTable(mapSize: Cardinal; map: PColorMap): TStatus;
  1593.   begin
  1594.     result := SetRemapTable(mapSize, map, ColorAdjustTypeBrush);
  1595.   end;
  1596.  
  1597.   function TGPImageAttributes.ClearBrushRemapTable: TStatus;
  1598.   begin
  1599.     result := ClearRemapTable(ColorAdjustTypeBrush);
  1600.   end;
  1601.  
  1602.   function TGPImageAttributes.SetWrapMode(wrap: TWrapMode; color: TGPColor = aclBlack;
  1603.     clamp: BOOL = FALSE): TStatus;
  1604.   begin
  1605.     result := SetStatus(GdipSetImageAttributesWrapMode(nativeImageAttr, wrap, color, clamp));
  1606.   end;
  1607.  
  1608.   // The flags of the palette are ignored.
  1609.  
  1610.   function TGPImageAttributes.GetAdjustedPalette(colorPalette: PColorPalette;
  1611.     colorAdjustType: TColorAdjustType): TStatus;
  1612.   begin
  1613.     result := SetStatus(GdipGetImageAttributesAdjustedPalette(nativeImageAttr,
  1614.       colorPalette, colorAdjustType));
  1615.   end;
  1616.  
  1617.   function TGPImageAttributes.GetLastStatus: TStatus;
  1618.   begin
  1619.     result := lastResult;
  1620.     lastResult := Ok;
  1621.   end;
  1622.  
  1623.   constructor TGPImageAttributes.Create(imageAttr: GpImageAttributes; status: TStatus);
  1624.   begin
  1625.     SetNativeImageAttr(imageAttr);
  1626.     lastResult := status;
  1627.   end;
  1628.  
  1629.   procedure TGPImageAttributes.SetNativeImageAttr(nativeImageAttr: GpImageAttributes);
  1630.   begin
  1631.     self.nativeImageAttr := nativeImageAttr;
  1632.   end;
  1633.  
  1634.   function TGPImageAttributes.SetStatus(status: TStatus): TStatus;
  1635.   begin
  1636.     if (status <> Ok) then lastResult := status;
  1637.     result := status;
  1638.   end;
  1639.  
  1640. (**************************************************************************\
  1641. *
  1642. *   GDI+ Matrix class
  1643. *
  1644. \**************************************************************************)
  1645.  
  1646.   // Default constructor is set to identity matrix.
  1647.   constructor TGPMatrix.Create;
  1648.   var matrix: GpMatrix;
  1649.   begin
  1650.     matrix := nil;
  1651.     lastResult := GdipCreateMatrix(matrix);
  1652.     SetNativeMatrix(matrix);
  1653.   end;
  1654.  
  1655.   constructor TGPMatrix.Create(m11, m12, m21, m22, dx, dy: Single);
  1656.   var matrix: GpMatrix;
  1657.   begin
  1658.     matrix := nil;
  1659.     lastResult := GdipCreateMatrix2(m11, m12, m21, m22, dx, dy, matrix);
  1660.     SetNativeMatrix(matrix);
  1661.   end;
  1662.  
  1663.   constructor TGPMatrix.Create(const rect: TGPRectF; const dstplg: TGPPointF);
  1664.   var matrix: GpMatrix;
  1665.   begin
  1666.     matrix := nil;
  1667.     lastResult := GdipCreateMatrix3(@rect, @dstplg, matrix);
  1668.     SetNativeMatrix(matrix);
  1669.   end;
  1670.  
  1671.   constructor TGPMatrix.Create(const rect: TGPRect; const dstplg: TGPPoint);
  1672.   var matrix: GpMatrix;
  1673.   begin
  1674.     matrix := nil;
  1675.     lastResult := GdipCreateMatrix3I(@rect, @dstplg, matrix);
  1676.     SetNativeMatrix(matrix);
  1677.   end;
  1678.  
  1679.   destructor TGPMatrix.Destroy;
  1680.   begin
  1681.     GdipDeleteMatrix(nativeMatrix);
  1682.   end;
  1683.  
  1684.   function TGPMatrix.Clone: TGPMatrix;
  1685.   var cloneMatrix: GpMatrix;
  1686.   begin
  1687.     cloneMatrix := nil;
  1688.     SetStatus(GdipCloneMatrix(nativeMatrix, cloneMatrix));
  1689.     if (lastResult <> Ok) then
  1690.     begin
  1691.       result := nil;
  1692.       exit;
  1693.     end;
  1694.     result := TGPMatrix.Create(cloneMatrix);
  1695.   end;
  1696.  
  1697.   function TGPMatrix.GetElements(const m: TMatrixArray): TStatus;
  1698.   begin
  1699.     result := SetStatus(GdipGetMatrixElements(nativeMatrix, @m));
  1700.   end;
  1701.  
  1702.   function TGPMatrix.SetElements(m11, m12, m21, m22, dx, dy: Single): TStatus;
  1703.   begin
  1704.         result := SetStatus(GdipSetMatrixElements(nativeMatrix,
  1705.                             m11, m12, m21, m22, dx, dy));
  1706.   end;
  1707.  
  1708.   function TGPMatrix.OffsetX: Single;
  1709.   var elements: TMatrixArray;
  1710.   begin
  1711.     if (GetElements(elements) = Ok) then
  1712.       result := elements[4]
  1713.     else
  1714.       result := 0.0;
  1715.   end;
  1716.  
  1717.   function TGPMatrix.OffsetY: Single;
  1718.   var elements: TMatrixArray;
  1719.   begin
  1720.     if (GetElements(elements) = Ok) then result := elements[5]
  1721.                                         else result := 0.0;
  1722.   end;
  1723.  
  1724.   function TGPMatrix.Reset: TStatus;
  1725.   begin
  1726.     // set identity matrix elements
  1727.     result := SetStatus(GdipSetMatrixElements(nativeMatrix, 1.0, 0.0, 0.0, 1.0,
  1728.                 0.0, 0.0));
  1729.   end;
  1730.  
  1731.   function TGPMatrix.Multiply(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  1732.   begin
  1733.     result := SetStatus(GdipMultiplyMatrix(nativeMatrix, matrix.nativeMatrix, order));
  1734.   end;
  1735.  
  1736.   function TGPMatrix.Translate(offsetX, offsetY: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  1737.   begin
  1738.     result := SetStatus(GdipTranslateMatrix(nativeMatrix, offsetX, offsetY, order));
  1739.   end;
  1740.  
  1741.   function TGPMatrix.Scale(scaleX, scaleY: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  1742.   begin
  1743.     result := SetStatus(GdipScaleMatrix(nativeMatrix, scaleX, scaleY, order));
  1744.   end;
  1745.  
  1746.   function TGPMatrix.Rotate(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  1747.   begin
  1748.     result := SetStatus(GdipRotateMatrix(nativeMatrix, angle, order));
  1749.   end;
  1750.  
  1751.   function TGPMatrix.RotateAt(angle: Single; const center: TGPPointF; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  1752.   begin
  1753.     if(order = MatrixOrderPrepend) then
  1754.     begin
  1755.       SetStatus(GdipTranslateMatrix(nativeMatrix, center.X, center.Y, order));
  1756.       SetStatus(GdipRotateMatrix(nativeMatrix, angle, order));
  1757.       result := SetStatus(GdipTranslateMatrix(nativeMatrix, -center.X, -center.Y,
  1758.                   order));
  1759.     end
  1760.     else
  1761.     begin
  1762.       SetStatus(GdipTranslateMatrix(nativeMatrix, - center.X, - center.Y, order));
  1763.       SetStatus(GdipRotateMatrix(nativeMatrix, angle, order));
  1764.       result := SetStatus(GdipTranslateMatrix(nativeMatrix, center.X, center.Y,
  1765.                   order));
  1766.     end;
  1767.   end;
  1768.  
  1769.   function TGPMatrix.Shear(shearX, shearY: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  1770.   begin
  1771.     result := SetStatus(GdipShearMatrix(nativeMatrix, shearX, shearY, order));
  1772.   end;
  1773.  
  1774.   function TGPMatrix.Invert: TStatus;
  1775.   begin
  1776.     result := SetStatus(GdipInvertMatrix(nativeMatrix));
  1777.   end;
  1778.  
  1779.   // float version
  1780.   function TGPMatrix.TransformPoints(pts: PGPPointF; count: Integer = 1): TStatus;
  1781.   begin
  1782.     result := SetStatus(GdipTransformMatrixPoints(nativeMatrix, pts, count));
  1783.   end;
  1784.  
  1785.   function TGPMatrix.TransformPoints(pts: PGPPoint; count: Integer = 1): TStatus;
  1786.   begin
  1787.     result := SetStatus(GdipTransformMatrixPointsI(nativeMatrix, pts, count));
  1788.   end;
  1789.  
  1790.   function TGPMatrix.TransformVectors(pts: PGPPointF; count: Integer = 1): TStatus;
  1791.   begin
  1792.     result := SetStatus(GdipVectorTransformMatrixPoints( nativeMatrix, pts, count));
  1793.   end;
  1794.  
  1795.   function TGPMatrix.TransformVectors(pts: PGPPoint; count: Integer = 1): TStatus;
  1796.   begin
  1797.     result := SetStatus(GdipVectorTransformMatrixPointsI(nativeMatrix, pts, count));
  1798.   end;
  1799.  
  1800.   function TGPMatrix.IsInvertible: BOOL;
  1801.   begin
  1802.     result := FALSE;
  1803.     SetStatus(GdipIsMatrixInvertible(nativeMatrix, result));
  1804.   end;
  1805.  
  1806.   function TGPMatrix.IsIdentity: BOOL;
  1807.   begin
  1808.     result := False;
  1809.     SetStatus(GdipIsMatrixIdentity(nativeMatrix, result));
  1810.   end;
  1811.  
  1812.   function TGPMatrix.Equals(matrix: TGPMatrix): BOOL;
  1813.   begin
  1814.     result := FALSE;
  1815.     SetStatus(GdipIsMatrixEqual(nativeMatrix, matrix.nativeMatrix, result));
  1816.   end;
  1817.  
  1818.   function TGPMatrix.GetLastStatus: TStatus;
  1819.   begin
  1820.     result := lastResult;
  1821.     lastResult := Ok;
  1822.   end;
  1823.  
  1824.   constructor TGPMatrix.Create(nativeMatrix: GpMatrix);
  1825.   begin
  1826.     lastResult := Ok;
  1827.     SetNativeMatrix(nativeMatrix);
  1828.   end;
  1829.  
  1830.   procedure TGPMatrix.SetNativeMatrix(nativeMatrix: GpMatrix);
  1831.   begin
  1832.     self.nativeMatrix := nativeMatrix;
  1833.   end;
  1834.  
  1835.   function TGPMatrix.SetStatus(status: TStatus): TStatus;
  1836.   begin
  1837.     if (status <> Ok) then lastResult := status;
  1838.     result := status;
  1839.   end;
  1840.  
  1841.  
  1842. (**************************************************************************\
  1843. *
  1844. *   GDI+ StringFormat class
  1845. *
  1846. \**************************************************************************)
  1847.  
  1848.   constructor TGPStringFormat.Create(formatFlags: Integer = 0; language: LANGID = LANG_NEUTRAL);
  1849.   begin
  1850.     nativeFormat := nil;
  1851.     lastError := GdipCreateStringFormat(formatFlags, language, nativeFormat);
  1852.   end;
  1853.  
  1854.   class function TGPStringFormat.GenericDefault: TGPStringFormat;
  1855.   begin
  1856.     if not assigned(GenericDefaultStringFormatBuffer) then
  1857.     begin
  1858.       GenericDefaultStringFormatBuffer := TGPStringFormat.Create;
  1859.       GenericDefaultStringFormatBuffer.lastError :=
  1860.         GdipStringFormatGetGenericDefault(GenericDefaultStringFormatBuffer.nativeFormat);
  1861.     end;
  1862.     result := GenericDefaultStringFormatBuffer;
  1863.   end;
  1864.  
  1865.   class function TGPStringFormat.GenericTypographic: TGPStringFormat;
  1866.   begin
  1867.     if not assigned(GenericTypographicStringFormatBuffer) then
  1868.     begin
  1869.       GenericTypographicStringFormatBuffer := TGPStringFormat.Create;
  1870.       GenericTypographicStringFormatBuffer.lastError :=
  1871.         GdipStringFormatGetGenericTypographic(GenericTypographicStringFormatBuffer.nativeFormat);
  1872.     end;
  1873.     result := GenericTypographicStringFormatBuffer;
  1874.   end;
  1875.  
  1876.   constructor TGPStringFormat.Create(format: TGPStringFormat);
  1877.   var gpstf: GPSTRINGFORMAT;
  1878.   begin
  1879.     nativeFormat := nil;
  1880.     if assigned(format) then gpstf := format.nativeFormat
  1881.                         else gpstf := nil;
  1882.     lastError := GdipCloneStringFormat(gpstf, nativeFormat);
  1883.   end;
  1884.  
  1885.   function TGPStringFormat.Clone: TGPStringFormat;
  1886.   var
  1887.     clonedStringFormat: GpStringFormat;
  1888.   begin
  1889.     clonedStringFormat := nil;
  1890.     lastError := GdipCloneStringFormat(nativeFormat, clonedStringFormat);
  1891.     if (lastError = Ok) then
  1892.       result := TGPStringFormat.Create(clonedStringFormat, lastError)
  1893.     else
  1894.       result := nil;
  1895.   end;
  1896.  
  1897.   destructor TGPStringFormat.Destroy;
  1898.   begin
  1899.     GdipDeleteStringFormat(nativeFormat);
  1900.   end;
  1901.  
  1902.   function TGPStringFormat.SetFormatFlags(flags: Integer): TStatus;
  1903.   begin
  1904.     result := SetStatus(GdipSetStringFormatFlags(nativeFormat, flags));
  1905.   end;
  1906.  
  1907.   function TGPStringFormat.GetFormatFlags: Integer;
  1908.   begin
  1909.     SetStatus(GdipGetStringFormatFlags(nativeFormat, result));
  1910.   end;
  1911.  
  1912.   function TGPStringFormat.SetAlignment(align: TStringAlignment): TStatus;
  1913.   begin
  1914.     result := SetStatus(GdipSetStringFormatAlign(nativeFormat, align));
  1915.   end;
  1916.  
  1917.   function TGPStringFormat.GetAlignment: TStringAlignment;
  1918.   begin
  1919.     SetStatus(GdipGetStringFormatAlign(nativeFormat, result));
  1920.   end;
  1921.  
  1922.   function TGPStringFormat.SetLineAlignment(align: TStringAlignment): TStatus;
  1923.   begin
  1924.     result := SetStatus(GdipSetStringFormatLineAlign(nativeFormat, align));
  1925.   end;
  1926.  
  1927.   function TGPStringFormat.GetLineAlignment: TStringAlignment;
  1928.   begin
  1929.     SetStatus(GdipGetStringFormatLineAlign(nativeFormat, result));
  1930.   end;
  1931.  
  1932.   function TGPStringFormat.SetHotkeyPrefix(hotkeyPrefix: THotkeyPrefix): TStatus;
  1933.   begin
  1934.     result := SetStatus(GdipSetStringFormatHotkeyPrefix(nativeFormat, Integer(hotkeyPrefix)));
  1935.   end;
  1936.  
  1937.   function TGPStringFormat.GetHotkeyPrefix: THotkeyPrefix;
  1938.   var HotkeyPrefix: Integer;
  1939.   begin
  1940.     SetStatus(GdipGetStringFormatHotkeyPrefix(nativeFormat, HotkeyPrefix));
  1941.     result := THotkeyPrefix(HotkeyPrefix);
  1942.   end;
  1943.  
  1944.   function TGPStringFormat.SetTabStops(firstTabOffset: Single; count: Integer; tabStops: PSingle): TStatus;
  1945.   begin
  1946.     result := SetStatus(GdipSetStringFormatTabStops(nativeFormat, firstTabOffset, count, tabStops));
  1947.   end;
  1948.  
  1949.   function TGPStringFormat.GetTabStopCount: Integer;
  1950.   begin
  1951.     SetStatus(GdipGetStringFormatTabStopCount(nativeFormat, result));
  1952.   end;
  1953.  
  1954.   function TGPStringFormat.GetTabStops(count: Integer; firstTabOffset, tabStops: PSingle): TStatus;
  1955.   begin
  1956.     result := SetStatus(GdipGetStringFormatTabStops(nativeFormat, count, firstTabOffset, tabStops));
  1957.   end;
  1958.  
  1959.   function TGPStringFormat.SetDigitSubstitution(language: LANGID; substitute: TStringDigitSubstitute): TStatus;
  1960.   begin
  1961.     result := SetStatus(GdipSetStringFormatDigitSubstitution(nativeFormat, language, substitute));
  1962.   end;
  1963.  
  1964.   function TGPStringFormat.GetDigitSubstitutionLanguage: LANGID;
  1965.   begin
  1966.     SetStatus(GdipGetStringFormatDigitSubstitution(nativeFormat, @result, nil));
  1967.   end;
  1968.  
  1969.   function TGPStringFormat.GetDigitSubstitutionMethod: TStringDigitSubstitute;
  1970.   begin
  1971.     SetStatus(GdipGetStringFormatDigitSubstitution(nativeFormat, nil, @result));
  1972.   end;
  1973.  
  1974.   function TGPStringFormat.SetTrimming(trimming: TStringTrimming): TStatus;
  1975.   begin
  1976.     result := SetStatus(GdipSetStringFormatTrimming(nativeFormat, trimming));
  1977.   end;
  1978.  
  1979.   function TGPStringFormat.GetTrimming: TStringTrimming;
  1980.   begin
  1981.     SetStatus(GdipGetStringFormatTrimming(nativeFormat, result));
  1982.   end;
  1983.  
  1984.   function TGPStringFormat.SetMeasurableCharacterRanges(rangeCount: Integer;
  1985.     ranges: PCharacterRange): TStatus;
  1986.   begin
  1987.     result := SetStatus(GdipSetStringFormatMeasurableCharacterRanges(nativeFormat,
  1988.       rangeCount, ranges));
  1989.   end;
  1990.  
  1991.   function TGPStringFormat.GetMeasurableCharacterRangeCount: Integer;
  1992.   begin
  1993.     SetStatus(GdipGetStringFormatMeasurableCharacterRangeCount(nativeFormat, result));
  1994.   end;
  1995.  
  1996.   function TGPStringFormat.GetLastStatus: TStatus;
  1997.   begin
  1998.     result := lastError;
  1999.     lastError := Ok;
  2000.   end;
  2001.  
  2002.   function TGPStringFormat.SetStatus(newStatus: GpStatus): TStatus;
  2003.   begin
  2004.     if (newStatus <> Ok) then lastError := newStatus;
  2005.     result := newStatus;
  2006.   end;
  2007.  
  2008.   // operator =
  2009.   procedure TGPStringFormat.Assign(source: TGPStringFormat);
  2010.   begin
  2011.     assert(assigned(source));
  2012.     GdipDeleteStringFormat(nativeFormat);
  2013.     lastError := GdipCloneStringFormat(source.nativeFormat, nativeFormat);
  2014.   end;
  2015.  
  2016.   constructor TGPStringFormat.Create(clonedStringFormat: GpStringFormat; status: TStatus);
  2017.   begin
  2018.     lastError := status;
  2019.     nativeFormat := clonedStringFormat;
  2020.   end;
  2021.  
  2022.  
  2023.  
  2024.   // ---------------------------------------------------------------------------
  2025.   //  TAdjustableArrowCap
  2026.   // ---------------------------------------------------------------------------
  2027.  
  2028.   constructor TGPAdjustableArrowCap.Create(height, width: Single; isFilled: Bool = TRUE);
  2029.   var cap: GpAdjustableArrowCap;
  2030.   begin
  2031.     cap := nil;
  2032.     lastResult := GdipCreateAdjustableArrowCap(height, width, isFilled, cap);
  2033.     SetNativeCap(cap);
  2034.   end;
  2035.  
  2036.   function TGPAdjustableArrowCap.SetHeight(height: Single): TStatus;
  2037.   begin
  2038.     result := SetStatus(GdipSetAdjustableArrowCapHeight(GpAdjustableArrowCap(nativeCap), height));
  2039.   end;
  2040.  
  2041.   function TGPAdjustableArrowCap.GetHeight: Single;
  2042.   begin
  2043.     SetStatus(GdipGetAdjustableArrowCapHeight(GpAdjustableArrowCap(nativeCap), result));
  2044.   end;
  2045.  
  2046.   function TGPAdjustableArrowCap.SetWidth(width: Single): TStatus;
  2047.   begin
  2048.     result := SetStatus(GdipSetAdjustableArrowCapWidth(GpAdjustableArrowCap(nativeCap), width));
  2049.   end;
  2050.  
  2051.   function TGPAdjustableArrowCap.GetWidth: Single;
  2052.   begin
  2053.     SetStatus(GdipGetAdjustableArrowCapWidth(GpAdjustableArrowCap(nativeCap), result));
  2054.   end;
  2055.  
  2056.   function TGPAdjustableArrowCap.SetMiddleInset(middleInset: Single): TStatus;
  2057.   begin
  2058.     result := SetStatus(GdipSetAdjustableArrowCapMiddleInset(GpAdjustableArrowCap(nativeCap), middleInset));
  2059.   end;
  2060.  
  2061.   function TGPAdjustableArrowCap.GetMiddleInset: Single;
  2062.   begin
  2063.     SetStatus(GdipGetAdjustableArrowCapMiddleInset(
  2064.       GpAdjustableArrowCap(nativeCap), result));
  2065.   end;
  2066.  
  2067.   function TGPAdjustableArrowCap.SetFillState(isFilled: Bool): TStatus;
  2068.   begin
  2069.     result := SetStatus(GdipSetAdjustableArrowCapFillState(
  2070.       GpAdjustableArrowCap(nativeCap), isFilled));
  2071.   end;
  2072.  
  2073.   function TGPAdjustableArrowCap.IsFilled: BOOL;
  2074.   begin
  2075.     SetStatus(GdipGetAdjustableArrowCapFillState(
  2076.       GpAdjustableArrowCap(nativeCap), result));
  2077.   end;
  2078.  
  2079. (**************************************************************************\
  2080. *
  2081. *   GDI+ Metafile class
  2082. *
  2083. \**************************************************************************)
  2084.  
  2085.     // Playback a metafile from a HMETAFILE
  2086.     // If deleteWmf is TRUE, then when the metafile is deleted,
  2087.     // the hWmf will also be deleted.  Otherwise, it won't be.
  2088.  
  2089.   constructor TGPMetafile.Create(hWmf: HMETAFILE;
  2090.     var wmfPlaceableFileHeader: TWmfPlaceableFileHeader; deleteWmf: BOOL = FALSE);
  2091.   var
  2092.     metafile: GpMetafile;
  2093.   begin
  2094.     metafile := nil;
  2095.     lastResult := GdipCreateMetafileFromWmf(hWmf, deleteWmf, @wmfPlaceableFileHeader, metafile);
  2096.     SetNativeImage(metafile);
  2097.   end;
  2098.  
  2099.     // Playback a metafile from a HENHMETAFILE
  2100.     // If deleteEmf is TRUE, then when the metafile is deleted,
  2101.     // the hEmf will also be deleted.  Otherwise, it won't be.
  2102.  
  2103.   constructor TGPMetafile.Create(hEmf: HENHMETAFILE; deleteEmf: BOOL = FALSE);
  2104.   var
  2105.     metafile: GpMetafile;
  2106.   begin
  2107.     metafile := nil;
  2108.     lastResult := GdipCreateMetafileFromEmf(hEmf, deleteEmf, metafile);
  2109.     SetNativeImage(metafile);
  2110.   end;
  2111.  
  2112.   constructor TGPMetafile.Create(filename: WideString);
  2113.   var
  2114.     metafile: GpMetafile;
  2115.   begin
  2116.     metafile := nil;
  2117.     lastResult := GdipCreateMetafileFromFile(PWideChar(filename), metafile);
  2118.     SetNativeImage(metafile);
  2119.   end;
  2120.  
  2121.     // Playback a WMF metafile from a file.
  2122.  
  2123.   constructor TGPMetafile.Create(filename: Widestring; var wmfPlaceableFileHeader: TWmfPlaceableFileHeader);
  2124.   var
  2125.     metafile: GpMetafile;
  2126.   begin
  2127.     metafile := nil;
  2128.     lastResult := GdipCreateMetafileFromWmfFile(PWideChar(filename), @wmfPlaceableFileHeader, metafile);
  2129.     SetNativeImage(metafile);
  2130.   end;
  2131.  
  2132.   constructor TGPMetafile.Create(stream: IStream);
  2133.   var
  2134.     metafile: GpMetafile;
  2135.   begin
  2136.     metafile := nil;
  2137.     lastResult := GdipCreateMetafileFromStream(stream, metafile);
  2138.     SetNativeImage(metafile);
  2139.   end;
  2140.  
  2141.     // Record a metafile to memory.
  2142.  
  2143.   constructor TGPMetafile.Create(referenceHdc: HDC; type_: TEmfType = EmfTypeEmfPlusDual;
  2144.     description: PWCHAR = nil);
  2145.   var
  2146.     metafile: GpMetafile;
  2147.   begin
  2148.     metafile := nil;
  2149.     lastResult := GdipRecordMetafile(referenceHdc, type_, nil, MetafileFrameUnitGdi,
  2150.        description, metafile);
  2151.     SetNativeImage(metafile);
  2152.   end;
  2153.  
  2154.     // Record a metafile to memory.
  2155.  
  2156.   constructor TGPMetafile.Create(referenceHdc: HDC; frameRect: TGPRectF;
  2157.      frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi;
  2158.      type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil);
  2159.   var metafile: GpMetafile;
  2160.   begin
  2161.     metafile := nil;
  2162.     lastResult := GdipRecordMetafile(referenceHdc, type_, @frameRect, frameUnit,
  2163.       description, metafile);
  2164.     SetNativeImage(metafile);
  2165.   end;
  2166.  
  2167.     // Record a metafile to memory.
  2168.  
  2169.   constructor TGPMetafile.Create(referenceHdc: HDC; frameRect: TGPRect;
  2170.     frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi;
  2171.     type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil);
  2172.   var
  2173.     metafile: GpMetafile;
  2174.   begin
  2175.     metafile := nil;
  2176.     lastResult := GdipRecordMetafileI(referenceHdc, type_, @frameRect, frameUnit,
  2177.       description, metafile);
  2178.     SetNativeImage(metafile);
  2179.   end;
  2180.  
  2181.   constructor TGPMetafile.Create(fileName: WideString; referenceHdc: HDC;
  2182.     type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil);
  2183.   var
  2184.     metafile: GpMetafile;
  2185.   begin
  2186.     metafile := nil;
  2187.     lastResult := GdipRecordMetafileFileName(PWideChar(fileName),
  2188.       referenceHdc, type_, nil, MetafileFrameUnitGdi, description, metafile);
  2189.     SetNativeImage(metafile);
  2190.   end;
  2191.  
  2192.   constructor TGPMetafile.Create(fileName: WideString; referenceHdc: HDC; frameRect: TGPRectF;
  2193.     frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi; type_: TEmfType = EmfTypeEmfPlusDual;
  2194.     description: PWCHAR = nil);
  2195.   var
  2196.     metafile: GpMetafile;
  2197.   begin
  2198.     metafile := nil;
  2199.     lastResult := GdipRecordMetafileFileName(PWideChar(fileName), referenceHdc,
  2200.       type_, @frameRect, frameUnit, description, metafile);
  2201.     SetNativeImage(metafile);
  2202.   end;
  2203.  
  2204.   constructor TGPMetafile.Create(fileName: WideString; referenceHdc: HDC; frameRect: TGPRect;
  2205.     frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi; type_: TEmfType = EmfTypeEmfPlusDual;
  2206.     description: PWCHAR = nil);
  2207.   var
  2208.     metafile: GpMetafile;
  2209.   begin
  2210.     metafile := nil;
  2211.     lastResult := GdipRecordMetafileFileNameI(PWideChar(fileName),
  2212.       referenceHdc, type_, @frameRect, frameUnit, description, metafile);
  2213.     SetNativeImage(metafile);
  2214.   end;
  2215.  
  2216.   constructor TGPMetafile.Create(stream: IStream; referenceHdc: HDC;
  2217.     type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil);
  2218.   var
  2219.     metafile: GpMetafile;
  2220.   begin
  2221.     metafile := nil;
  2222.     lastResult := GdipRecordMetafileStream(stream, referenceHdc, type_, nil,
  2223.       MetafileFrameUnitGdi, description, metafile);
  2224.     SetNativeImage(metafile);
  2225.   end;
  2226.  
  2227.   constructor TGPMetafile.Create(stream: IStream; referenceHdc: HDC; frameRect: TGPRectF;
  2228.     frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi; type_: TEmfType = EmfTypeEmfPlusDual;
  2229.     description: PWCHAR = nil);
  2230.   var
  2231.     metafile: GpMetafile;
  2232.   begin
  2233.     metafile := nil;
  2234.     lastResult := GdipRecordMetafileStream(stream, referenceHdc, type_,
  2235.       @frameRect, frameUnit, description, metafile);
  2236.     SetNativeImage(metafile);
  2237.   end;
  2238.  
  2239.   constructor TGPMetafile.Create(stream : IStream; referenceHdc : HDC; frameRect : TGPRect;
  2240.     frameUnit : TMetafileFrameUnit = MetafileFrameUnitGdi; type_ : TEmfType = EmfTypeEmfPlusDual;
  2241.     description : PWCHAR = nil);
  2242.   var
  2243.     metafile: GpMetafile;
  2244.   begin
  2245.     metafile := nil;
  2246.     lastResult := GdipRecordMetafileStreamI(stream, referenceHdc, type_,
  2247.       @frameRect, frameUnit, description, metafile);
  2248.     SetNativeImage(metafile);
  2249.   end;
  2250.  
  2251.   function TGPMetafile.GetMetafileHeader(hWmf: HMETAFILE;
  2252.     var wmfPlaceableFileHeader: TWmfPlaceableFileHeader; header: TMetafileHeader): TStatus;
  2253.   begin
  2254.     result := GdipGetMetafileHeaderFromWmf(hWmf, @wmfPlaceableFileHeader, @header.Type_);
  2255.   end;
  2256.  
  2257.   function TGPMetafile.GetMetafileHeader(hEmf: HENHMETAFILE; header: TMetafileHeader): TStatus;
  2258.   begin
  2259.     result := GdipGetMetafileHeaderFromEmf(hEmf, @header.Type_);
  2260.   end;
  2261.  
  2262.   function TGPMetafile.GetMetafileHeader(filename: WideString; header: TMetafileHeader): TStatus;
  2263.   begin
  2264.     result := GdipGetMetafileHeaderFromFile(PWideChar(filename), @header.Type_);
  2265.   end;
  2266.  
  2267.   function TGPMetafile.GetMetafileHeader(stream: IStream; header: TMetafileHeader): TStatus;
  2268.   begin
  2269.     result := GdipGetMetafileHeaderFromStream(stream, @header.Type_);
  2270.   end;
  2271.  
  2272.   function TGPMetafile.GetMetafileHeader(header: TMetafileHeader): TStatus;
  2273.   begin
  2274.     result := SetStatus(GdipGetMetafileHeaderFromMetafile(GpMetafile(nativeImage),
  2275.       @header.Type_));
  2276.   end;
  2277.  
  2278.     // Once this method is called, the Metafile object is in an invalid state
  2279.     // and can no longer be used.  It is the responsiblity of the caller to
  2280.     // invoke DeleteEnhMetaFile to delete this hEmf.
  2281.  
  2282.   function TGPMetafile.GetHENHMETAFILE: HENHMETAFILE;
  2283.   begin
  2284.     SetStatus(GdipGetHemfFromMetafile(GpMetafile(nativeImage), result));
  2285.   end;
  2286.  
  2287.     // Used in conjuction with Graphics::EnumerateMetafile to play an EMF+
  2288.     // The data must be DWORD aligned if it's an EMF or EMF+.  It must be
  2289.     // WORD aligned if it's a WMF.
  2290.  
  2291.   function TGPMetafile.PlayRecord(recordType: TEmfPlusRecordType; flags, dataSize: UINT;
  2292.     data: PBYTE): TStatus;
  2293.   begin
  2294.     result := SetStatus(GdipPlayMetafileRecord(GpMetafile(nativeImage),
  2295.       recordType, flags, dataSize, data));
  2296.   end;
  2297.  
  2298.     // If you're using a printer HDC for the metafile, but you want the
  2299.     // metafile rasterized at screen resolution, then use this API to set
  2300.     // the rasterization dpi of the metafile to the screen resolution,
  2301.     // e.g. 96 dpi or 120 dpi.
  2302.  
  2303.   function TGPMetafile.SetDownLevelRasterizationLimit(metafileRasterizationLimitDpi: UINT): TStatus;
  2304.   begin
  2305.     result := SetStatus(GdipSetMetafileDownLevelRasterizationLimit(
  2306.       GpMetafile(nativeImage), metafileRasterizationLimitDpi));
  2307.   end;
  2308.  
  2309.   function TGPMetafile.GetDownLevelRasterizationLimit: UINT;
  2310.   var metafileRasterizationLimitDpi: UINT;
  2311.   begin
  2312.     metafileRasterizationLimitDpi := 0;
  2313.     SetStatus(GdipGetMetafileDownLevelRasterizationLimit(
  2314.       GpMetafile(nativeImage), metafileRasterizationLimitDpi));
  2315.     result := metafileRasterizationLimitDpi;
  2316.   end;
  2317.  
  2318.   function TGPMetafile.EmfToWmfBits(hemf: HENHMETAFILE; cbData16: UINT; pData16: PBYTE;
  2319.     iMapMode: Integer = MM_ANISOTROPIC; eFlags: TEmfToWmfBitsFlags = EmfToWmfBitsFlagsDefault): UINT;
  2320.   begin
  2321.     result := GdipEmfToWmfBits(hemf, cbData16, pData16, iMapMode, Integer(eFlags));
  2322.   end;
  2323.  
  2324.   constructor TGPMetafile.Create;
  2325.   begin
  2326.     SetNativeImage(nil);
  2327.     lastResult := Ok;
  2328.   end;
  2329.  
  2330. (**************************************************************************\
  2331. *
  2332. *   GDI+ Codec Image APIs
  2333. *
  2334. \**************************************************************************)
  2335.  
  2336. //--------------------------------------------------------------------------
  2337. // Codec Management APIs
  2338. //--------------------------------------------------------------------------
  2339.  
  2340.   function GetImageDecodersSize(out numDecoders, size: UINT): TStatus;
  2341.   begin
  2342.     result := GdipGetImageDecodersSize(numDecoders, size);
  2343.   end;
  2344.  
  2345.   function GetImageDecoders(numDecoders, size: UINT;
  2346.      decoders: PImageCodecInfo): TStatus;
  2347.   begin
  2348.     result := GdipGetImageDecoders(numDecoders, size, decoders);
  2349.   end;
  2350.  
  2351.  
  2352.   function GetImageEncodersSize(out numEncoders, size: UINT): TStatus;
  2353.   begin
  2354.     result := GdipGetImageEncodersSize(numEncoders, size);
  2355.   end;
  2356.  
  2357.   function GetImageEncoders(numEncoders, size: UINT;
  2358.      encoders: PImageCodecInfo): TStatus;
  2359.   begin
  2360.     result := GdipGetImageEncoders(numEncoders, size, encoders);
  2361.   end;
  2362.  
  2363. (**************************************************************************\
  2364. *
  2365. *   GDI+ Region class implementation
  2366. *
  2367. \**************************************************************************)
  2368.  
  2369.   constructor TGPRegion.Create;
  2370.   var
  2371.     region: GpRegion;
  2372.   begin
  2373.     region := nil;
  2374.     lastResult := GdipCreateRegion(region);
  2375.     SetNativeRegion(region);
  2376.   end;
  2377.  
  2378.   constructor TGPRegion.Create(rect: TGPRectF);
  2379.   var
  2380.     region: GpRegion;
  2381.   begin
  2382.     region := nil;
  2383.     lastResult := GdipCreateRegionRect(@rect, region);
  2384.     SetNativeRegion(region);
  2385.   end;
  2386.  
  2387.   constructor TGPRegion.Create(rect: TGPRect);
  2388.   var
  2389.     region: GpRegion;
  2390.   begin
  2391.     region := nil;
  2392.     lastResult := GdipCreateRegionRectI(@rect, region);
  2393.     SetNativeRegion(region);
  2394.   end;
  2395.  
  2396.   constructor TGPRegion.Create(path: TGPGraphicsPath);
  2397.   var
  2398.     region: GpRegion;
  2399.   begin
  2400.     region := nil;
  2401.     lastResult := GdipCreateRegionPath(path.nativePath, region);
  2402.     SetNativeRegion(region);
  2403.   end;
  2404.  
  2405.   constructor TGPRegion.Create(regionData: PBYTE; size: Integer);
  2406.   var
  2407.     region: GpRegion;
  2408.   begin
  2409.     region := nil;
  2410.     lastResult := GdipCreateRegionRgnData(regionData, size, region);
  2411.     SetNativeRegion(region);
  2412.   end;
  2413.  
  2414.   constructor TGPRegion.Create(hRgn: HRGN);
  2415.   var
  2416.     region: GpRegion;
  2417.   begin
  2418.     region := nil;
  2419.     lastResult := GdipCreateRegionHrgn(hRgn, region);
  2420.     SetNativeRegion(region);
  2421.   end;
  2422.  
  2423.   function TGPRegion.FromHRGN(hRgn: HRGN): TGPRegion;
  2424.   var
  2425.     region: GpRegion;
  2426.   begin
  2427.     region := nil;
  2428.     if (GdipCreateRegionHrgn(hRgn, region) = Ok) then
  2429.     begin
  2430.         result := TGPRegion.Create(region);
  2431.         if (result = nil) then
  2432.             GdipDeleteRegion(region);
  2433.         exit;
  2434.     end
  2435.     else
  2436.       result := nil;
  2437.   end;
  2438.  
  2439.   destructor TGPRegion.Destroy;
  2440.   begin
  2441.     GdipDeleteRegion(nativeRegion);
  2442.   end;
  2443.  
  2444.   function TGPRegion.Clone: TGPRegion;
  2445.   var region: GpRegion;
  2446.   begin
  2447.     region := nil;
  2448.     SetStatus(GdipCloneRegion(nativeRegion, region));
  2449.     result := TGPRegion.Create(region);
  2450.   end;
  2451.  
  2452.   function TGPRegion.MakeInfinite: TStatus;
  2453.   begin
  2454.     result := SetStatus(GdipSetInfinite(nativeRegion));
  2455.   end;
  2456.  
  2457.   function TGPRegion.MakeEmpty: TStatus;
  2458.   begin
  2459.     result := SetStatus(GdipSetEmpty(nativeRegion));
  2460.   end;
  2461.  
  2462.   // Get the size of the buffer needed for the GetData method
  2463.   function TGPRegion.GetDataSize: UINT;
  2464.   var bufferSize: UINT;
  2465.   begin
  2466.     bufferSize := 0;
  2467.     SetStatus(GdipGetRegionDataSize(nativeRegion, bufferSize));
  2468.     result := bufferSize;
  2469.   end;
  2470.  
  2471.  
  2472.     // buffer     - where to put the data
  2473.     // bufferSize - how big the buffer is (should be at least as big as GetDataSize())
  2474.     // sizeFilled - if not nil, this is an OUT param that says how many bytes
  2475.     //              of data were written to the buffer.
  2476.  
  2477.   function TGPRegion.GetData(buffer: PBYTE; bufferSize: UINT; sizeFilled: PUINT = nil): TStatus;
  2478.   begin
  2479.     result := SetStatus(GdipGetRegionData(nativeRegion, buffer, bufferSize, sizeFilled));
  2480.   end;
  2481.  
  2482.   function TGPRegion.Intersect(const rect: TGPRect): TStatus;
  2483.   begin
  2484.     result := SetStatus(GdipCombineRegionRectI(nativeRegion, @rect, CombineModeIntersect));
  2485.   end;
  2486.  
  2487.   function TGPRegion.Intersect(const rect: TGPRectF): TStatus;
  2488.   begin
  2489.     result := SetStatus(GdipCombineRegionRect(nativeRegion, @rect, CombineModeIntersect));
  2490.   end;
  2491.  
  2492.   function TGPRegion.Intersect(path: TGPGraphicsPath): TStatus;
  2493.   begin
  2494.     result := SetStatus(GdipCombineRegionPath(nativeRegion, path.nativePath,
  2495.       CombineModeIntersect));
  2496.   end;
  2497.  
  2498.   function TGPRegion.Intersect(region: TGPRegion): TStatus;
  2499.   begin
  2500.     result := SetStatus(GdipCombineRegionRegion(nativeRegion, region.nativeRegion,
  2501.       CombineModeIntersect));
  2502.   end;
  2503.  
  2504.   function TGPRegion.Union(const rect: TGPRect): TStatus;
  2505.   begin
  2506.     result := SetStatus(GdipCombineRegionRectI(nativeRegion, @rect, CombineModeUnion));
  2507.   end;
  2508.  
  2509.   function TGPRegion.Union(const rect: TGPRectF): TStatus;
  2510.   begin
  2511.     result := SetStatus(GdipCombineRegionRect(nativeRegion, @rect, CombineModeUnion));
  2512.   end;
  2513.  
  2514.   function TGPRegion.Union(path: TGPGraphicsPath): TStatus;
  2515.   begin
  2516.     result := SetStatus(GdipCombineRegionPath(nativeRegion, path.nativePath, CombineModeUnion));
  2517.   end;
  2518.  
  2519.   function TGPRegion.Union(region: TGPRegion): TStatus;
  2520.   begin
  2521.     result := SetStatus(GdipCombineRegionRegion(nativeRegion, region.nativeRegion,
  2522.       CombineModeUnion));
  2523.   end;
  2524.  
  2525.   function TGPRegion.Xor_(const rect: TGPRect): TStatus;
  2526.   begin
  2527.     result := SetStatus(GdipCombineRegionRectI(nativeRegion, @rect, CombineModeXor));
  2528.   end;
  2529.  
  2530.   function TGPRegion.Xor_(const rect: TGPRectF): TStatus;
  2531.   begin
  2532.     result := SetStatus(GdipCombineRegionRect(nativeRegion, @rect, CombineModeXor));
  2533.   end;
  2534.  
  2535.   function TGPRegion.Xor_(path: TGPGraphicsPath): TStatus;
  2536.   begin
  2537.     result := SetStatus(GdipCombineRegionPath(nativeRegion, path.nativePath, CombineModeXor));
  2538.   end;
  2539.  
  2540.   function TGPRegion.Xor_(region: TGPRegion): TStatus;
  2541.   begin
  2542.     result := SetStatus(GdipCombineRegionRegion(nativeRegion, region.nativeRegion,
  2543.       CombineModeXor));
  2544.   end;
  2545.  
  2546.   function TGPRegion.Exclude(const rect: TGPRect): TStatus;
  2547.   begin
  2548.      result := SetStatus(GdipCombineRegionRectI(nativeRegion, @rect, CombineModeExclude));
  2549.   end;
  2550.  
  2551.   function TGPRegion.Exclude(const rect: TGPRectF): TStatus;
  2552.   begin
  2553.     result := SetStatus(GdipCombineRegionRect(nativeRegion, @rect, CombineModeExclude));
  2554.   end;
  2555.  
  2556.   function TGPRegion.Exclude(path: TGPGraphicsPath): TStatus;
  2557.   begin
  2558.     result := SetStatus(GdipCombineRegionPath(nativeRegion, path.nativePath, CombineModeExclude));
  2559.   end;
  2560.  
  2561.   function TGPRegion.Exclude(region: TGPRegion): TStatus;
  2562.   begin
  2563.     result := SetStatus(GdipCombineRegionRegion(nativeRegion,
  2564.                                                region.nativeRegion,
  2565.                                                          CombineModeExclude));
  2566.   end;
  2567.  
  2568.   function TGPRegion.Complement(const rect: TGPRect): TStatus;
  2569.   begin
  2570.     result := SetStatus(GdipCombineRegionRectI(nativeRegion, @rect,
  2571.                                                         CombineModeComplement));
  2572.   end;
  2573.  
  2574.   function TGPRegion.Complement(const rect: TGPRectF): TStatus;
  2575.   begin
  2576.     result := SetStatus(GdipCombineRegionRect(nativeRegion, @rect,
  2577.                                                        CombineModeComplement));
  2578.   end;
  2579.  
  2580.   function TGPRegion.Complement(path: TGPGraphicsPath): TStatus;
  2581.   begin
  2582.     result := SetStatus(GdipCombineRegionPath(nativeRegion,
  2583.                                                 path.nativePath,
  2584.                                                 CombineModeComplement));
  2585.   end;
  2586.  
  2587.   function TGPRegion.Complement(region: TGPRegion): TStatus;
  2588.   begin
  2589.     result := SetStatus(GdipCombineRegionRegion(nativeRegion,
  2590.                                                   region.nativeRegion,
  2591.                                                          CombineModeComplement));
  2592.   end;
  2593.  
  2594.   function TGPRegion.Translate(dx, dy: Single): TStatus;
  2595.   begin
  2596.     result := SetStatus(GdipTranslateRegion(nativeRegion, dx, dy));
  2597.   end;
  2598.  
  2599.   function TGPRegion.Translate(dx, dy: Integer): TStatus;
  2600.   begin
  2601.     result := SetStatus(GdipTranslateRegionI(nativeRegion, dx, dy));
  2602.   end;
  2603.  
  2604.   function TGPRegion.Transform(matrix: TGPMatrix): TStatus;
  2605.   begin
  2606.     result := SetStatus(GdipTransformRegion(nativeRegion,
  2607.                                                      matrix.nativeMatrix));
  2608.   end;
  2609.  
  2610.   function TGPRegion.GetBounds(out rect: TGPRect; g: TGPGraphics): TStatus;
  2611.   begin
  2612.     result := SetStatus(GdipGetRegionBoundsI(nativeRegion,
  2613.                                                 g.nativeGraphics,
  2614.                                                 @rect));
  2615.   end;
  2616.  
  2617.   function TGPRegion.GetBounds(out rect: TGPRectF; g: TGPGraphics): TStatus;
  2618.   begin
  2619.     result := SetStatus(GdipGetRegionBounds(nativeRegion,
  2620.                                                 g.nativeGraphics,
  2621.                                                 @rect));
  2622.   end;
  2623.  
  2624.   function TGPRegion.GetHRGN(g: TGPGraphics): HRGN;
  2625.   begin
  2626.     SetStatus(GdipGetRegionHRgn(nativeRegion, g.nativeGraphics, result));
  2627.   end;
  2628.  
  2629.   function TGPRegion.IsEmpty(g: TGPGraphics): BOOL;
  2630.   var booln: BOOL;
  2631.   begin
  2632.     booln := FALSE;
  2633.     SetStatus(GdipIsEmptyRegion(nativeRegion, g.nativeGraphics, booln));
  2634.     result := booln;
  2635.   end;
  2636.  
  2637.   function TGPRegion.IsInfinite(g: TGPGraphics): BOOL ;
  2638.   var booln: BOOL;
  2639.   begin
  2640.     booln := FALSE;
  2641.     SetStatus(GdipIsInfiniteRegion(nativeRegion, g.nativeGraphics, booln));
  2642.     result := booln;
  2643.   end;
  2644.  
  2645.   function TGPRegion.IsVisible(x, y: Integer; g: TGPGraphics = nil): BOOL;
  2646.   var
  2647.     booln: BOOL;
  2648.     GPX: GpGraphics;
  2649.   begin
  2650.     booln := FALSE;
  2651.     if assigned(g) then gpx := g.nativeGraphics else gpx := nil;
  2652.     SetStatus(GdipIsVisibleRegionPointI(nativeRegion, X, Y, gpx, booln));
  2653.     result := booln;
  2654.   end;
  2655.  
  2656.   function TGPRegion.IsVisible(const point: TGPPoint; g: TGPGraphics = nil): BOOL;
  2657.   var
  2658.     booln: BOOL;
  2659.     GPX: GpGraphics;
  2660.   begin
  2661.     booln := FALSE;
  2662.     if assigned(g) then gpx := g.nativeGraphics else gpx := nil;
  2663.     SetStatus(GdipIsVisibleRegionPointI(nativeRegion, point.X, point.Y, gpx, booln));
  2664.     result := booln;
  2665.   end;
  2666.  
  2667.   function TGPRegion.IsVisible(x, y: Single; g: TGPGraphics = nil): BOOL;
  2668.   var
  2669.     booln: BOOL;
  2670.     GPX: GpGraphics;
  2671.   begin
  2672.     booln := FALSE;
  2673.     if assigned(g) then gpx := g.nativeGraphics else gpx := nil;
  2674.     SetStatus(GdipIsVisibleRegionPoint(nativeRegion, X, Y, gpx, booln));
  2675.     result := booln;
  2676.   end;
  2677.  
  2678.   function TGPRegion.IsVisible(const point: TGPPointF; g: TGPGraphics = nil): BOOL;
  2679.   var
  2680.     booln: BOOL;
  2681.     GPX: GpGraphics;
  2682.   begin
  2683.     booln := FALSE;
  2684.     if assigned(g) then gpx := g.nativeGraphics else gpx := nil;
  2685.     SetStatus(GdipIsVisibleRegionPoint(nativeRegion, point.X, point.Y, gpx, booln));
  2686.     result := booln;
  2687.   end;
  2688.  
  2689.   function TGPRegion.IsVisible(x, y, width, height: Integer; g: TGPGraphics): BOOL;
  2690.   var
  2691.     booln: BOOL;
  2692.     GPX: GpGraphics;
  2693.   begin
  2694.     booln := FALSE;
  2695.     if assigned(g) then gpx := g.nativeGraphics else gpx := nil;
  2696.     SetStatus(GdipIsVisibleRegionRectI(nativeRegion,
  2697.                                                   X,
  2698.                                                   Y,
  2699.                                                   Width,
  2700.                                                   Height,
  2701.                                                   gpx,
  2702.                                                   booln));
  2703.     result := booln;
  2704.   end;
  2705.  
  2706.   function TGPRegion.IsVisible(const rect: TGPRect; g: TGPGraphics = nil): BOOL;
  2707.   var
  2708.     booln: BOOL;
  2709.     GPX: GpGraphics;
  2710.   begin
  2711.     booln := FALSE;
  2712.     if assigned(g) then gpx := g.nativeGraphics else gpx := nil;
  2713.     SetStatus(GdipIsVisibleRegionRectI(nativeRegion,
  2714.                                                   rect.X,
  2715.                                                   rect.Y,
  2716.                                                   rect.Width,
  2717.                                                   rect.Height,
  2718.                                                   gpx,
  2719.                                                   booln));
  2720.     result := booln;
  2721.   end;
  2722.  
  2723.   function TGPRegion.IsVisible(x, y, width, height: Single; g: TGPGraphics = nil): BOOL;
  2724.   var
  2725.     booln: BOOL;
  2726.     GPX: GpGraphics;
  2727.   begin
  2728.     booln := FALSE;
  2729.     if assigned(g) then gpx := g.nativeGraphics else gpx := nil;
  2730.     SetStatus(GdipIsVisibleRegionRect(nativeRegion, X,
  2731.                                                     Y, Width,
  2732.                                                     Height,
  2733.                                                     gpx,
  2734.                                                     booln));
  2735.     result := booln;
  2736.   end;
  2737.  
  2738.   function TGPRegion.IsVisible(const rect: TGPRectF; g: TGPGraphics = nil): BOOL;
  2739.   var
  2740.     booln: BOOL;
  2741.     GPX: GpGraphics;
  2742.   begin
  2743.     booln := FALSE;
  2744.     if assigned(g) then gpx := g.nativeGraphics else gpx := nil;
  2745.     SetStatus(GdipIsVisibleRegionRect(nativeRegion, rect.X,
  2746.                                                     rect.Y, rect.Width,
  2747.                                                     rect.Height,
  2748.                                                     gpx,
  2749.                                                     booln));
  2750.     result := booln;
  2751.   end;
  2752.  
  2753.   function TGPRegion.Equals(region: TGPRegion; g: TGPGraphics): BOOL;
  2754.   var
  2755.     booln: BOOL;
  2756.   begin
  2757.     booln := FALSE;
  2758.     SetStatus(GdipIsEqualRegion(nativeRegion,
  2759.                                               region.nativeRegion,
  2760.                                               g.nativeGraphics,
  2761.                                               booln));
  2762.     result := booln;
  2763.   end;
  2764.  
  2765.   function TGPRegion.GetRegionScansCount(matrix: TGPMatrix): UINT;
  2766.   var Count: UINT;
  2767.   begin
  2768.     count := 0;
  2769.     SetStatus(GdipGetRegionScansCount(nativeRegion, count, matrix.nativeMatrix));
  2770.     result := count;
  2771.   end;
  2772.  
  2773.   // If rects is nil, result := the count of rects in the region.
  2774.   // Otherwise, assume rects is big enough to hold all the region rects
  2775.   // and fill them in and result := the number of rects filled in.
  2776.   // The rects are result :=ed in the units specified by the matrix
  2777.   // (which is typically a world-to-device transform).
  2778.   // Note that the number of rects result :=ed can vary, depending on the
  2779.   // matrix that is used.
  2780.  
  2781.   function TGPRegion.GetRegionScans(matrix: TGPMatrix; rects: PGPRectF; out count: Integer): TStatus;
  2782.   begin
  2783.     result := SetStatus(GdipGetRegionScans(nativeRegion,
  2784.                                           rects,
  2785.                                           count,
  2786.                                           matrix.nativeMatrix));
  2787.   end;
  2788.  
  2789.   function TGPRegion.GetRegionScans(matrix: TGPMatrix; rects: PGPRect; out count: Integer): TStatus;
  2790.   begin
  2791.     result := SetStatus(GdipGetRegionScansI(nativeRegion,
  2792.                                           rects,
  2793.                                           count,
  2794.                                           matrix.nativeMatrix));
  2795.   end;
  2796.  
  2797.   function TGPRegion.GetLastStatus: TStatus;
  2798.   begin
  2799.     result := lastResult;
  2800.     lastResult := Ok;
  2801.   end;
  2802.  
  2803.   function TGPRegion.SetStatus(status: TStatus): TStatus;
  2804.   begin
  2805.     if (status <> Ok) then lastResult := status;
  2806.     result := status;
  2807.   end;
  2808.  
  2809.   constructor TGPRegion.Create(nativeRegion: GpRegion);
  2810.   begin
  2811.     SetNativeRegion(nativeRegion);
  2812.   end;
  2813.  
  2814.   procedure TGPRegion.SetNativeRegion(nativeRegion: GpRegion);
  2815.   begin
  2816.     self.nativeRegion := nativeRegion;
  2817.   end;
  2818.  
  2819. (**************************************************************************\
  2820. *
  2821. *   GDI+ CustomLineCap APIs
  2822. *
  2823. \**************************************************************************)
  2824.  
  2825.   constructor TGPCustomLineCap.Create(fillPath, strokePath: TGPGraphicsPath;
  2826.                   baseCap: TLineCap = LineCapFlat; baseInset: Single = 0);
  2827.   var nativeFillPath, nativeStrokePath: GpPath;
  2828.   begin
  2829.     nativeCap := nil;
  2830.     nativeFillPath := nil;
  2831.     nativeStrokePath := nil;
  2832.  
  2833.     if assigned(fillPath) then nativeFillPath := fillPath.nativePath;
  2834.     if assigned(strokePath) then nativeStrokePath := strokePath.nativePath;
  2835.  
  2836.     lastResult := GdipCreateCustomLineCap(nativeFillPath, nativeStrokePath,
  2837.                     baseCap, baseInset, nativeCap);
  2838.   end;
  2839.  
  2840.   destructor TGPCustomLineCap.Destroy;
  2841.   begin
  2842.     GdipDeleteCustomLineCap(nativeCap);
  2843.   end;
  2844.  
  2845.   function TGPCustomLineCap.Clone: TGPCustomLineCap;
  2846.   var newNativeLineCap: GpCustomLineCap;
  2847.   begin
  2848.     newNativeLineCap := nil;
  2849.     SetStatus(GdipCloneCustomLineCap(nativeCap, newNativeLineCap));
  2850.     if (lastResult = Ok) then
  2851.     begin
  2852.       result := TGPCustomLineCap.Create(newNativeLineCap, lastResult);
  2853.       if (result = nil) then
  2854.          SetStatus(GdipDeleteCustomLineCap(newNativeLineCap));
  2855.     end
  2856.     else
  2857.       result := nil;
  2858.   end;
  2859.  
  2860.   // This changes both the start and end cap.
  2861.   function TGPCustomLineCap.SetStrokeCap(strokeCap: TLineCap): TStatus;
  2862.   begin
  2863.     result := SetStrokeCaps(strokeCap, strokeCap);
  2864.   end;
  2865.  
  2866.   function TGPCustomLineCap.SetStrokeCaps(startCap, endCap: TLineCap): TStatus;
  2867.   begin
  2868.     result := SetStatus(GdipSetCustomLineCapStrokeCaps(nativeCap, startCap, endCap));
  2869.   end;
  2870.  
  2871.   function TGPCustomLineCap.GetStrokeCaps(out startCap, endCap: TLineCap): TStatus;
  2872.   begin
  2873.     result := SetStatus(GdipGetCustomLineCapStrokeCaps(nativeCap, startCap, endCap));
  2874.   end;
  2875.  
  2876.   function TGPCustomLineCap.SetStrokeJoin(lineJoin: TLineJoin): TStatus;
  2877.   begin
  2878.     result := SetStatus(GdipSetCustomLineCapStrokeJoin(nativeCap, lineJoin));
  2879.   end;
  2880.  
  2881.   function TGPCustomLineCap.GetStrokeJoin: TLineJoin;
  2882.   begin
  2883.     SetStatus(GdipGetCustomLineCapStrokeJoin(nativeCap, result));
  2884.   end;
  2885.  
  2886.   function TGPCustomLineCap.SetBaseCap(baseCap: TLineCap): TStatus;
  2887.   begin
  2888.     result := SetStatus(GdipSetCustomLineCapBaseCap(nativeCap, baseCap));
  2889.   end;
  2890.  
  2891.   function TGPCustomLineCap.GetBaseCap: TLineCap;
  2892.   begin
  2893.     SetStatus(GdipGetCustomLineCapBaseCap(nativeCap, result));
  2894.   end;
  2895.  
  2896.   function TGPCustomLineCap.SetBaseInset(inset: Single): TStatus;
  2897.   begin
  2898.     result := SetStatus(GdipSetCustomLineCapBaseInset(nativeCap, inset));
  2899.   end;
  2900.  
  2901.   function TGPCustomLineCap.GetBaseInset: Single;
  2902.   begin
  2903.     SetStatus(GdipGetCustomLineCapBaseInset(nativeCap, result));
  2904.   end;
  2905.  
  2906.   function TGPCustomLineCap.SetWidthScale(widthScale: Single): TStatus;
  2907.   begin
  2908.     result := SetStatus(GdipSetCustomLineCapWidthScale(nativeCap, widthScale));
  2909.   end;
  2910.  
  2911.   function TGPCustomLineCap.GetWidthScale: Single;
  2912.   begin
  2913.     SetStatus(GdipGetCustomLineCapWidthScale(nativeCap, result));
  2914.   end;
  2915.  
  2916.   function TGPCustomLineCap.GetLastStatus: TStatus;
  2917.   begin
  2918.     result := lastResult;
  2919.     lastResult := Ok;
  2920.   end;
  2921.  
  2922.   constructor TGPCustomLineCap.Create;
  2923.   begin
  2924.     nativeCap := nil;
  2925.     lastResult := Ok;
  2926.   end;
  2927.  
  2928.   constructor TGPCustomLineCap.Create(nativeCap: GpCustomLineCap; status: TStatus);
  2929.   begin
  2930.     lastResult := status;
  2931.     SetNativeCap(nativeCap);
  2932.   end;
  2933.  
  2934.   procedure TGPCustomLineCap.SetNativeCap(nativeCap: GpCustomLineCap);
  2935.   begin
  2936.     self.nativeCap := nativeCap;
  2937.   end;
  2938.  
  2939.   function TGPCustomLineCap.SetStatus(status: TStatus): TStatus;
  2940.   begin
  2941.     if (status <> Ok) then lastResult := status;
  2942.     result := status;
  2943.   end;
  2944.  
  2945. (**************************************************************************
  2946. *
  2947. * CachedBitmap class definition
  2948. *
  2949. *   GDI+ CachedBitmap is a representation of an accelerated drawing
  2950. *   that has restrictions on what operations are allowed in order
  2951. *   to accelerate the drawing to the destination.
  2952. *
  2953. **************************************************************************)
  2954.  
  2955.   constructor TGPCachedBitmap.Create(bitmap: TGPBitmap; graphics: TGPGraphics);
  2956.   begin
  2957.     nativeCachedBitmap := nil;
  2958.     lastResult := GdipCreateCachedBitmap(
  2959.         GpBitmap(bitmap.nativeImage),
  2960.         graphics.nativeGraphics,
  2961.         nativeCachedBitmap);
  2962.   end;
  2963.  
  2964.   destructor TGPCachedBitmap.Destroy;
  2965.   begin
  2966.     GdipDeleteCachedBitmap(nativeCachedBitmap);
  2967.   end;
  2968.  
  2969.   function TGPCachedBitmap.GetLastStatus: TStatus;
  2970.   begin
  2971.     result := lastResult;
  2972.     lastResult := Ok;
  2973.   end;
  2974.  
  2975. (**************************************************************************\
  2976. *
  2977. *   GDI+ Pen class
  2978. *
  2979. \**************************************************************************)
  2980.  
  2981.   //--------------------------------------------------------------------------
  2982.   // Pen class
  2983.   //--------------------------------------------------------------------------
  2984.  
  2985.   constructor TGPPen.Create(color: TGPColor; width: Single = 1.0);
  2986.   var unit_: TUnit;
  2987.   begin
  2988.     unit_ := UnitWorld;
  2989.     nativePen := nil;
  2990.     lastResult := GdipCreatePen1(color, width, unit_, nativePen);
  2991.   end;
  2992.  
  2993.   constructor TGPPen.Create(brush: TGPBrush; width: Single = 1.0);
  2994.   var unit_: TUnit;
  2995.   begin
  2996.     unit_ := UnitWorld;
  2997.     nativePen := nil;
  2998.     lastResult := GdipCreatePen2(brush.nativeBrush, width, unit_, nativePen);
  2999.   end;
  3000.  
  3001.   destructor TGPPen.Destroy;
  3002.   begin
  3003.     GdipDeletePen(nativePen);
  3004.   end;
  3005.  
  3006.   function TGPPen.Clone: TGPPen;
  3007.   var clonePen: GpPen;
  3008.   begin
  3009.     clonePen := nil;
  3010.     lastResult := GdipClonePen(nativePen, clonePen);
  3011.     result := TGPPen.Create(clonePen, lastResult);
  3012.   end;
  3013.  
  3014.   function TGPPen.SetWidth(width: Single): TStatus;
  3015.   begin
  3016.     result := SetStatus(GdipSetPenWidth(nativePen, width));
  3017.   end;
  3018.  
  3019.   function TGPPen.GetWidth: Single;
  3020.   begin
  3021.     SetStatus(GdipGetPenWidth(nativePen, result));
  3022.   end;
  3023.     
  3024.   // Set/get line caps: start, end, and dash
  3025.   // Line cap and join APIs by using LineCap and LineJoin enums.
  3026.  
  3027.   function TGPPen.SetLineCap(startCap, endCap: TLineCap; dashCap: TDashCap): TStatus;
  3028.   begin
  3029.     result := SetStatus(GdipSetPenLineCap197819(nativePen, startCap, endCap, dashCap));
  3030.   end;
  3031.  
  3032.   function TGPPen.SetStartCap(startCap: TLineCap): TStatus;
  3033.   begin
  3034.     result := SetStatus(GdipSetPenStartCap(nativePen, startCap));
  3035.   end;
  3036.  
  3037.   function TGPPen.SetEndCap(endCap: TLineCap): TStatus;
  3038.   begin
  3039.     result := SetStatus(GdipSetPenEndCap(nativePen, endCap));
  3040.   end;
  3041.  
  3042.   function TGPPen.SetDashCap(dashCap: TDashCap): TStatus;
  3043.   begin
  3044.     result := SetStatus(GdipSetPenDashCap197819(nativePen, dashCap));
  3045.   end;
  3046.  
  3047.   function TGPPen.GetStartCap: TLineCap;
  3048.   begin
  3049.     SetStatus(GdipGetPenStartCap(nativePen, result));
  3050.   end;
  3051.  
  3052.   function TGPPen.GetEndCap: TLineCap;
  3053.   begin
  3054.     SetStatus(GdipGetPenEndCap(nativePen, result));
  3055.   end;
  3056.  
  3057.   function TGPPen.GetDashCap: TDashCap;
  3058.   begin
  3059.     SetStatus(GdipGetPenDashCap197819(nativePen, result));
  3060.   end;
  3061.  
  3062.   function TGPPen.SetLineJoin(lineJoin: TLineJoin): TStatus;
  3063.   begin
  3064.     result := SetStatus(GdipSetPenLineJoin(nativePen, lineJoin));
  3065.   end;
  3066.  
  3067.   function TGPPen.GetLineJoin: TLineJoin;
  3068.   begin
  3069.     SetStatus(GdipGetPenLineJoin(nativePen, result));
  3070.   end;
  3071.  
  3072.   function TGPPen.SetCustomStartCap(customCap: TGPCustomLineCap): TStatus;
  3073.   var nativeCap: GpCustomLineCap;
  3074.   begin
  3075.     nativeCap := nil;
  3076.     if assigned(customCap) then nativeCap := customCap.nativeCap;
  3077.     result := SetStatus(GdipSetPenCustomStartCap(nativePen, nativeCap));
  3078.   end;
  3079.  
  3080.   function TGPPen.GetCustomStartCap(customCap: TGPCustomLineCap): TStatus;
  3081.   begin
  3082.     if(customCap = nil) then
  3083.       result := SetStatus(InvalidParameter)
  3084.     else
  3085.       result := SetStatus(GdipGetPenCustomStartCap(nativePen, customCap.nativeCap));
  3086.   end;
  3087.  
  3088.   function TGPPen.SetCustomEndCap(customCap: TGPCustomLineCap): TStatus;
  3089.   var nativeCap: GpCustomLineCap;
  3090.   begin
  3091.     nativeCap := nil;
  3092.     if assigned(customCap) then nativeCap := customCap.nativeCap;
  3093.     result := SetStatus(GdipSetPenCustomEndCap(nativePen, nativeCap));
  3094.   end;
  3095.  
  3096.   function TGPPen.GetCustomEndCap(customCap: TGPCustomLineCap): TStatus;
  3097.   begin
  3098.     if(customCap = nil) then
  3099.       result := SetStatus(InvalidParameter)
  3100.     else
  3101.       result := SetStatus(GdipGetPenCustomEndCap(nativePen, customCap.nativeCap));
  3102.   end;
  3103.  
  3104.   function TGPPen.SetMiterLimit(miterLimit: Single): TStatus;
  3105.   begin
  3106.     result := SetStatus(GdipSetPenMiterLimit(nativePen, miterLimit));
  3107.   end;
  3108.  
  3109.   function TGPPen.GetMiterLimit: Single;
  3110.   begin
  3111.     SetStatus(GdipGetPenMiterLimit(nativePen, result));
  3112.   end;
  3113.  
  3114.   function TGPPen.SetAlignment(penAlignment: TPenAlignment): TStatus;
  3115.   begin
  3116.     result := SetStatus(GdipSetPenMode(nativePen, penAlignment));
  3117.   end;
  3118.  
  3119.   function TGPPen.GetAlignment: TPenAlignment;
  3120.   begin
  3121.     SetStatus(GdipGetPenMode(nativePen, result));
  3122.   end;
  3123.  
  3124.   function TGPPen.SetTransform(matrix: TGPMatrix): TStatus;
  3125.   begin
  3126.     result := SetStatus(GdipSetPenTransform(nativePen, matrix.nativeMatrix));
  3127.   end;
  3128.  
  3129.   function TGPPen.GetTransform(matrix: TGPMatrix): TStatus;
  3130.   begin
  3131.     result := SetStatus(GdipGetPenTransform(nativePen, matrix.nativeMatrix));
  3132.   end;
  3133.  
  3134.   function TGPPen.ResetTransform: TStatus;
  3135.   begin
  3136.     result := SetStatus(GdipResetPenTransform(nativePen));
  3137.   end;
  3138.  
  3139.   function TGPPen.MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  3140.   begin
  3141.     result := SetStatus(GdipMultiplyPenTransform(nativePen, matrix.nativeMatrix, order));
  3142.   end;
  3143.  
  3144.   function TGPPen.TranslateTransform(dx, dy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  3145.   begin
  3146.     result := SetStatus(GdipTranslatePenTransform(nativePen, dx, dy, order));
  3147.   end;
  3148.  
  3149.   function TGPPen.ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  3150.   begin
  3151.     result := SetStatus(GdipScalePenTransform(nativePen, sx, sy, order));
  3152.   end;
  3153.  
  3154.   function TGPPen.RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  3155.   begin
  3156.     result := SetStatus(GdipRotatePenTransform(nativePen, angle, order));
  3157.   end;
  3158.  
  3159.   function TGPPen.GetPenType: TPenType;
  3160.   begin
  3161.     SetStatus(GdipGetPenFillType(nativePen, result));
  3162.   end;
  3163.  
  3164.   function TGPPen.SetColor(color: TGPColor): TStatus;
  3165.   begin
  3166.     result := SetStatus(GdipSetPenColor(nativePen, color));
  3167.   end;
  3168.  
  3169.   function TGPPen.SetBrush(brush: TGPBrush): TStatus;
  3170.   begin
  3171.     result := SetStatus(GdipSetPenBrushFill(nativePen, brush.nativeBrush));
  3172.   end;
  3173.  
  3174.   function TGPPen.GetColor(out Color: TGPColor): TStatus;
  3175.   var
  3176.     type_: TPenType;
  3177.     argb: DWORD;
  3178.   begin
  3179.     type_ := GetPenType;
  3180.  
  3181.     if (type_ <> PenTypeSolidColor) then
  3182.     begin
  3183.       result := WrongState;
  3184.       exit;
  3185.     end;
  3186.  
  3187.     SetStatus(GdipGetPenColor(nativePen, argb));
  3188.     if (lastResult = Ok) then color := argb;
  3189.     result := lastResult;
  3190.   end;
  3191.  
  3192.   function TGPPen.GetBrush: TGPBrush;
  3193.   var
  3194.     type_: TPenType;
  3195.     Brush: TGPBrush;
  3196.     nativeBrush: GpBrush;
  3197.   begin
  3198.     type_ := GetPenType;
  3199.     brush := nil;
  3200.  
  3201.     case type_ of
  3202.        PenTypeSolidColor     : brush := TGPSolidBrush.Create;
  3203.        PenTypeHatchFill      : brush := TGPHatchBrush.Create;
  3204.        PenTypeTextureFill    : brush := TGPTextureBrush.Create;
  3205.        PenTypePathGradient   : brush := TGPBrush.Create;
  3206.        PenTypeLinearGradient : brush := TGPLinearGradientBrush.Create;
  3207.      end;
  3208.  
  3209.      if (brush <> nil) then
  3210.      begin
  3211.        SetStatus(GdipGetPenBrushFill(nativePen, nativeBrush));
  3212.        brush.SetNativeBrush(nativeBrush);
  3213.      end;
  3214.  
  3215.      result := brush;
  3216.   end;
  3217.  
  3218.   function TGPPen.GetDashStyle: TDashStyle;
  3219.   begin
  3220.     SetStatus(GdipGetPenDashStyle(nativePen, result));
  3221.   end;
  3222.  
  3223.   function TGPPen.SetDashStyle(dashStyle: TDashStyle): TStatus;
  3224.   begin
  3225.     result := SetStatus(GdipSetPenDashStyle(nativePen, dashStyle));
  3226.   end;
  3227.  
  3228.   function TGPPen.GetDashOffset: Single;
  3229.   begin
  3230.     SetStatus(GdipGetPenDashOffset(nativePen, result));
  3231.   end;
  3232.  
  3233.   function TGPPen.SetDashOffset(dashOffset: Single): TStatus;
  3234.   begin
  3235.     result := SetStatus(GdipSetPenDashOffset(nativePen, dashOffset));
  3236.   end;
  3237.     
  3238.   function TGPPen.SetDashPattern(dashArray: PSingle; count: Integer): TStatus;
  3239.   begin
  3240.     result := SetStatus(GdipSetPenDashArray(nativePen, dashArray, count));
  3241.   end;
  3242.  
  3243.   function TGPPen.GetDashPatternCount: Integer;
  3244.   begin
  3245.     SetStatus(GdipGetPenDashCount(nativePen, result));
  3246.   end;
  3247.  
  3248.   function TGPPen.GetDashPattern(dashArray: PSingle; count: Integer): TStatus;
  3249.   begin
  3250.     result := SetStatus(GdipGetPenDashArray(nativePen, dashArray, count));
  3251.   end;
  3252.  
  3253.   function TGPPen.SetCompoundArray(compoundArray: PSingle; count: Integer): TStatus;
  3254.   begin
  3255.     result := SetStatus(GdipSetPenCompoundArray(nativePen, compoundArray, count));
  3256.   end;
  3257.  
  3258.   function TGPPen.GetCompoundArrayCount: Integer;
  3259.   begin
  3260.     SetStatus(GdipGetPenCompoundCount(nativePen, result));
  3261.   end;
  3262.  
  3263.   function TGPPen.GetCompoundArray(compoundArray: PSingle; count: Integer): TStatus;
  3264.   begin
  3265.     if (count <= 0) then
  3266.       result := SetStatus(InvalidParameter)
  3267.     else
  3268.       result := SetStatus(GdipGetPenCompoundArray(nativePen, compoundArray, count));
  3269.   end;
  3270.  
  3271.   function TGPPen.GetLastStatus: TStatus;
  3272.   begin
  3273.     result := lastResult;
  3274.     lastResult := Ok;
  3275.   end;
  3276.  
  3277.   constructor TGPPen.Create(nativePen: GpPen; status: TStatus);
  3278.   begin
  3279.     lastResult := status;
  3280.     SetNativePen(nativePen);
  3281.   end;
  3282.  
  3283.   procedure TGPPen.SetNativePen(nativePen: GpPen);
  3284.   begin
  3285.     self.nativePen := nativePen;
  3286.   end;
  3287.  
  3288.   function TGPPen.SetStatus(status: TStatus): TStatus;
  3289.   begin
  3290.     if (status <> Ok) then lastResult := status;
  3291.     result := status;
  3292.   end;
  3293.  
  3294. (**************************************************************************\
  3295. *
  3296. *   GDI+ Brush class
  3297. *
  3298. \**************************************************************************)
  3299.  
  3300. //--------------------------------------------------------------------------
  3301. // Abstract base class for various brush types
  3302. //--------------------------------------------------------------------------
  3303.  
  3304.   destructor TGPBrush.Destroy;
  3305.   begin
  3306.     GdipDeleteBrush(nativeBrush);
  3307.   end;
  3308.  
  3309.   function TGPBrush.Clone: TGPBrush;
  3310.   var
  3311.     brush: GpBrush;
  3312.     newBrush: TGPBrush;
  3313.   begin
  3314.     brush := nil;
  3315.     SetStatus(GdipCloneBrush(nativeBrush, brush));
  3316.     newBrush := TGPBrush.Create(brush, lastResult);
  3317.     if (newBrush = nil) then
  3318.       GdipDeleteBrush(brush);
  3319.     result := newBrush;
  3320.   end;
  3321.  
  3322.   function TGPBrush.GetType: TBrushType;
  3323.   var type_: TBrushType;
  3324.   begin
  3325.     type_ := TBrushType(-1);
  3326.     SetStatus(GdipGetBrushType(nativeBrush, type_));
  3327.     result := type_;
  3328.   end;
  3329.  
  3330.   function TGPBrush.GetLastStatus: TStatus;
  3331.   begin
  3332.     result := lastResult;
  3333.     lastResult := Ok;
  3334.   end;
  3335.  
  3336.   constructor TGPBrush.Create;
  3337.   begin
  3338.     SetStatus(NotImplemented);
  3339.   end;
  3340.  
  3341.   constructor TGPBrush.Create(nativeBrush: GpBrush; status: TStatus);
  3342.   begin
  3343.     lastResult := status;
  3344.     SetNativeBrush(nativeBrush);
  3345.   end;
  3346.  
  3347.   procedure TGPBrush.SetNativeBrush(nativeBrush: GpBrush);
  3348.   begin
  3349.     self.nativeBrush := nativeBrush;
  3350.   end;
  3351.  
  3352.   function TGPBrush.SetStatus(status: TStatus): TStatus;
  3353.   begin
  3354.     if (status <> Ok) then lastResult := status;
  3355.     result := status;
  3356.   end;
  3357.  
  3358. //--------------------------------------------------------------------------
  3359. // Solid Fill Brush Object
  3360. //--------------------------------------------------------------------------
  3361.  
  3362.   constructor TGPSolidBrush.Create(color: TGPColor);
  3363.   var
  3364.     brush: GpSolidFill;
  3365.   begin
  3366.     brush := nil;
  3367.     lastResult := GdipCreateSolidFill(color, brush);
  3368.     SetNativeBrush(brush);
  3369.   end;
  3370.  
  3371.   function TGPSolidBrush.GetColor(out color: TGPColor): TStatus;
  3372.   begin
  3373.     SetStatus(GdipGetSolidFillColor(GPSOLIDFILL(nativeBrush), color));
  3374.     result := lastResult;
  3375.   end;
  3376.  
  3377.   function TGPSolidBrush.SetColor(color: TGPColor): TStatus;
  3378.   begin
  3379.     result := SetStatus(GdipSetSolidFillColor(GpSolidFill(nativeBrush),
  3380.                 color));
  3381.   end;
  3382.  
  3383.   constructor TGPSolidBrush.Create;
  3384.   begin
  3385.     // hide parent function
  3386.   end;
  3387.  
  3388. //--------------------------------------------------------------------------
  3389. // Texture Brush Fill Object
  3390. //--------------------------------------------------------------------------
  3391.  
  3392.   constructor TGPTextureBrush.Create(image: TGPImage; wrapMode: TWrapMode = WrapModeTile);
  3393.   var texture: GpTexture;
  3394.   begin
  3395.     //texture := nil;
  3396.     lastResult := GdipCreateTexture(image.nativeImage, wrapMode, texture);
  3397.     SetNativeBrush(texture);
  3398.   end;
  3399.  
  3400.   // When creating a texture brush from a metafile image, the dstRect
  3401.   // is used to specify the size that the metafile image should be
  3402.   // rendered at in the device units of the destination graphics.
  3403.   // It is NOT used to crop the metafile image, so only the width
  3404.   // and height values matter for metafiles.
  3405.  
  3406.   constructor TGPTextureBrush.Create(image: TGPImage; wrapMode: TWrapMode; dstRect: TGPRectF);
  3407.   var texture: GpTexture;
  3408.   begin
  3409.     texture := nil;
  3410.     lastResult := GdipCreateTexture2(image.nativeImage, wrapMode, dstRect.X,
  3411.                     dstRect.Y, dstRect.Width, dstRect.Height, texture);
  3412.     SetNativeBrush(texture);
  3413.   end;
  3414.  
  3415.   constructor TGPTextureBrush.Create(image: TGPImage; dstRect: TGPRectF; imageAttributes: TGPImageAttributes = nil);
  3416.   var texture: GpTexture;
  3417.       ImgAtt: GpImageAttributes;
  3418.   begin
  3419.     texture := nil;
  3420.     if assigned(imageAttributes) then ImgAtt := imageAttributes.nativeImageAttr
  3421.                                  else ImgAtt := nil;
  3422.  
  3423.     lastResult := GdipCreateTextureIA(image.nativeImage, ImgAtt, dstRect.X,
  3424.                     dstRect.Y, dstRect.Width, dstRect.Height, texture);
  3425.     SetNativeBrush(texture);
  3426.   end;
  3427.  
  3428.   constructor TGPTextureBrush.Create(image: TGPImage; dstRect: TGPRect; imageAttributes: TGPImageAttributes = nil);
  3429.   var texture: GpTexture;
  3430.       ImgAtt: GpImageAttributes;
  3431.   begin
  3432.     texture := nil;
  3433.     if assigned(imageAttributes) then ImgAtt := imageAttributes.nativeImageAttr
  3434.                                  else ImgAtt := nil;
  3435.     lastResult := GdipCreateTextureIAI(image.nativeImage, ImgAtt, dstRect.X,
  3436.                     dstRect.Y, dstRect.Width, dstRect.Height, texture);
  3437.      SetNativeBrush(texture);
  3438.   end;
  3439.  
  3440.   constructor TGPTextureBrush.Create(image: TGPImage; wrapMode: TWrapMode; dstRect: TGPRect);
  3441.   var texture: GpTexture;
  3442.   begin
  3443.     texture := nil;
  3444.     lastResult := GdipCreateTexture2I(image.nativeImage, wrapMode, dstRect.X,
  3445.                     dstRect.Y, dstRect.Width, dstRect.Height, texture);
  3446.     SetNativeBrush(texture);
  3447.   end;
  3448.  
  3449.   constructor TGPTextureBrush.Create(image: TGPImage; wrapMode: TWrapMode; dstX, dstY, dstWidth, dstHeight: Single);
  3450.   var texture: GpTexture;
  3451.   begin
  3452.     texture := nil;
  3453.     lastResult := GdipCreateTexture2(image.nativeImage, wrapMode, dstX, dstY,
  3454.                     dstWidth, dstHeight, texture);
  3455.     SetNativeBrush(texture);
  3456.   end;
  3457.  
  3458.   constructor TGPTextureBrush.Create(image: TGPImage; wrapMode: TWrapMode; dstX, dstY, dstWidth, dstHeight: Integer);
  3459.   var texture: GpTexture;
  3460.   begin
  3461.     texture := nil;
  3462.     lastResult := GdipCreateTexture2I(image.nativeImage, wrapMode, dstX, dstY,
  3463.                     dstWidth, dstHeight, texture);
  3464.     SetNativeBrush(texture);
  3465.   end;
  3466.  
  3467.   function TGPTextureBrush.SetTransform(matrix: TGPMatrix): TStatus;
  3468.   begin
  3469.     result := SetStatus(GdipSetTextureTransform(GpTexture(nativeBrush),
  3470.                 matrix.nativeMatrix));
  3471.   end;
  3472.  
  3473.   function TGPTextureBrush.GetTransform(matrix: TGPMatrix): TStatus;
  3474.   begin
  3475.     result := SetStatus(GdipGetTextureTransform(GpTexture(nativeBrush),
  3476.                 matrix.nativeMatrix));
  3477.   end;
  3478.  
  3479.   function TGPTextureBrush.ResetTransform: TStatus;
  3480.   begin
  3481.     result := SetStatus(GdipResetTextureTransform(GpTexture(nativeBrush)));
  3482.   end;
  3483.  
  3484.   function TGPTextureBrush.MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  3485.   begin
  3486.     result := SetStatus(GdipMultiplyTextureTransform(GpTexture(nativeBrush),
  3487.                 matrix.nativeMatrix, order));
  3488.   end;
  3489.  
  3490.   function TGPTextureBrush.TranslateTransform(dx, dy: Single; order: MatrixOrder = MatrixOrderPrepend): TStatus;
  3491.   begin
  3492.     result := SetStatus(GdipTranslateTextureTransform(GpTexture(nativeBrush),
  3493.                 dx, dy, order));
  3494.   end;
  3495.  
  3496.   function TGPTextureBrush.ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  3497.   begin
  3498.     result := SetStatus(GdipScaleTextureTransform(GpTexture(nativeBrush),
  3499.                  sx, sy, order));
  3500.   end;
  3501.  
  3502.   function TGPTextureBrush.RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  3503.   begin
  3504.     result := SetStatus(GdipRotateTextureTransform(GpTexture(nativeBrush),
  3505.                                                               angle, order));
  3506.   end;
  3507.  
  3508.   function TGPTextureBrush.SetWrapMode(wrapMode: TWrapMode): TStatus;
  3509.   begin
  3510.     result := SetStatus(GdipSetTextureWrapMode(GpTexture(nativeBrush), wrapMode));
  3511.   end;
  3512.  
  3513.   function TGPTextureBrush.GetWrapMode: TWrapMode;
  3514.   begin
  3515.     SetStatus(GdipGetTextureWrapMode(GpTexture(nativeBrush), result));
  3516.   end;
  3517.  
  3518.   function TGPTextureBrush.GetImage: TGPImage;
  3519.   var image: GpImage;
  3520.   begin
  3521.     SetStatus(GdipGetTextureImage(GpTexture(nativeBrush), image));
  3522.     result := TGPImage.Create(image, lastResult);
  3523.     if (result = nil) then
  3524.       GdipDisposeImage(image);
  3525.   end;
  3526.  
  3527.   constructor TGPTextureBrush.Create;
  3528.   begin
  3529.     // hide parent function
  3530.   end;
  3531.  
  3532. //--------------------------------------------------------------------------
  3533. // Linear Gradient Brush Object
  3534. //--------------------------------------------------------------------------
  3535.  
  3536.   constructor TGPLinearGradientBrush.Create(const point1, point2: TGPPointF; color1, color2: TGPColor);
  3537.   var brush: GpLineGradient;
  3538.   begin
  3539.     brush := nil;
  3540.     lastResult := GdipCreateLineBrush(@point1, @point2, color1, color2, WrapModeTile, brush);
  3541.     SetNativeBrush(brush);
  3542.   end;
  3543.  
  3544.   constructor TGPLinearGradientBrush.Create(const point1, point2: TGPPoint; color1, color2: TGPColor);
  3545.   var brush: GpLineGradient;
  3546.   begin
  3547.     brush := nil;
  3548.     lastResult := GdipCreateLineBrushI(@point1, @point2, color1,
  3549.                     color2, WrapModeTile, brush);
  3550.     SetNativeBrush(brush);
  3551.   end;
  3552.  
  3553.   constructor TGPLinearGradientBrush.Create(rect: TGPRectF; color1, color2: TGPColor; mode: TLinearGradientMode);
  3554.   var brush: GpLineGradient;
  3555.   begin
  3556.     brush := nil;
  3557.     lastResult := GdipCreateLineBrushFromRect(@rect, color1,
  3558.                     color2, mode, WrapModeTile, brush);
  3559.     SetNativeBrush(brush);
  3560.   end;
  3561.  
  3562.   constructor TGPLinearGradientBrush.Create(rect: TGPRect; color1, color2: TGPColor; mode: TLinearGradientMode);
  3563.   var brush: GpLineGradient;
  3564.   begin
  3565.     brush := nil;
  3566.     lastResult := GdipCreateLineBrushFromRectI(@rect, color1,
  3567.                     color2, mode, WrapModeTile, brush);
  3568.     SetNativeBrush(brush);
  3569.   end;
  3570.  
  3571.   constructor TGPLinearGradientBrush.Create(rect: TGPRectF; color1, color2: TGPColor; angle: Single; isAngleScalable: BOOL = FALSE);
  3572.   var brush: GpLineGradient;
  3573.   begin
  3574.     brush := nil;
  3575.     lastResult := GdipCreateLineBrushFromRectWithAngle(@rect, color1,
  3576.                     color2, angle, isAngleScalable, WrapModeTile, brush);
  3577.     SetNativeBrush(brush);
  3578.   end;
  3579.  
  3580.   constructor TGPLinearGradientBrush.Create(rect: TGPRect; color1, color2: TGPColor; angle: Single; isAngleScalable: BOOL = FALSE);
  3581.   var brush: GpLineGradient;
  3582.   begin
  3583.     brush := nil;
  3584.     lastResult := GdipCreateLineBrushFromRectWithAngleI(@rect, color1,
  3585.                     color2, angle, isAngleScalable, WrapModeTile, brush);
  3586.     SetNativeBrush(brush);
  3587.   end;
  3588.  
  3589.   function TGPLinearGradientBrush.SetLinearColors(color1, color2: TGPColor): TStatus;
  3590.   begin
  3591.     result := SetStatus(GdipSetLineColors(GpLineGradient(nativeBrush),
  3592.                 color1, color2));
  3593.   end;
  3594.  
  3595.   function TGPLinearGradientBrush.GetLinearColors(out color1, color2: TGPColor): TStatus;
  3596.   var colors: array[0..1] of TGPColor;
  3597.   begin
  3598.     SetStatus(GdipGetLineColors(GpLineGradient(nativeBrush), @colors));
  3599.     if (lastResult = Ok) then
  3600.     begin
  3601.       color1 := colors[0];
  3602.       color2 := colors[1];
  3603.     end;
  3604.     result := lastResult;
  3605.   end;
  3606.  
  3607.   function TGPLinearGradientBrush.GetRectangle(out rect: TGPRectF): TStatus;
  3608.   begin
  3609.     result := SetStatus(GdipGetLineRect(GpLineGradient(nativeBrush), @rect));
  3610.   end;
  3611.  
  3612.   function TGPLinearGradientBrush.GetRectangle(out rect: TGPRect): TStatus;
  3613.   begin
  3614.     result := SetStatus(GdipGetLineRectI(GpLineGradient(nativeBrush), @rect));
  3615.   end;
  3616.  
  3617.   function TGPLinearGradientBrush.SetGammaCorrection(useGammaCorrection: BOOL): TStatus;
  3618.   begin
  3619.     result := SetStatus(GdipSetLineGammaCorrection(GpLineGradient(nativeBrush),
  3620.                 useGammaCorrection));
  3621.   end;
  3622.     
  3623.   function TGPLinearGradientBrush.GetGammaCorrection: BOOL;
  3624.   var useGammaCorrection: BOOL;
  3625.   begin
  3626.     SetStatus(GdipGetLineGammaCorrection(GpLineGradient(nativeBrush),
  3627.                 useGammaCorrection));
  3628.     result := useGammaCorrection;
  3629.   end;
  3630.  
  3631.   function TGPLinearGradientBrush.GetBlendCount: Integer;
  3632.   var count: Integer;
  3633.   begin
  3634.     count := 0;
  3635.     SetStatus(GdipGetLineBlendCount(GpLineGradient(nativeBrush), count));
  3636.     result := count;
  3637.   end;
  3638.  
  3639.   function TGPLinearGradientBrush.SetBlend(blendFactors, blendPositions: PSingle; count: Integer): TStatus;
  3640.   begin
  3641.     result := SetStatus(GdipSetLineBlend(GpLineGradient(nativeBrush),
  3642.                           blendFactors, blendPositions, count));
  3643.   end;
  3644.  
  3645.   function TGPLinearGradientBrush.GetBlend(blendFactors, blendPositions: PSingle; count: Integer): TStatus;
  3646.   begin
  3647.     if ((count <= 0) or (blendFactors = nil) or (blendPositions = nil)) then
  3648.       result := SetStatus(InvalidParameter)
  3649.     else
  3650.       result := SetStatus(GdipGetLineBlend(GpLineGradient(nativeBrush), blendFactors,
  3651.         blendPositions, count));
  3652.   end;
  3653.  
  3654.   function TGPLinearGradientBrush.GetInterpolationColorCount: Integer;
  3655.   var count: Integer;
  3656.   begin
  3657.     count := 0;
  3658.     SetStatus(GdipGetLinePresetBlendCount(GpLineGradient(nativeBrush), count));
  3659.     result := count;
  3660.   end;
  3661.  
  3662.   function TGPLinearGradientBrush.SetInterpolationColors(presetColors: PGPColor;
  3663.     blendPositions: PSingle; count: Integer): TStatus;
  3664.   begin
  3665.     if (count <= 0)  then
  3666.       result := SetStatus(InvalidParameter)
  3667.     else
  3668.       result := SetStatus(GdipSetLinePresetBlend(GpLineGradient(nativeBrush),
  3669.         PARGB(presetColors), blendPositions, count));
  3670.   end;
  3671.  
  3672.   function TGPLinearGradientBrush.GetInterpolationColors(presetColors: PGPColor; blendPositions: PSingle; count: Integer): TStatus;
  3673.   begin
  3674.     if (count <= 0) then
  3675.       result := SetStatus(InvalidParameter)
  3676.     else
  3677.       result := SetStatus(GdipGetLinePresetBlend(GpLineGradient(nativeBrush),
  3678.                           PARGB(presetColors), blendPositions, count));
  3679.   end;
  3680.  
  3681.   function TGPLinearGradientBrush.SetBlendBellShape(focus: Single; scale: Single = 1.0): TStatus;
  3682.   begin
  3683.     result := SetStatus(GdipSetLineSigmaBlend(GpLineGradient(nativeBrush), focus, scale));
  3684.   end;
  3685.  
  3686.   function TGPLinearGradientBrush.SetBlendTriangularShape(focus: Single; scale: Single = 1.0): TStatus;
  3687.   begin
  3688.     result := SetStatus(GdipSetLineLinearBlend(GpLineGradient(nativeBrush), focus, scale));
  3689.   end;
  3690.  
  3691.   function TGPLinearGradientBrush.SetTransform(matrix: TGPMatrix): TStatus;
  3692.   begin
  3693.     result := SetStatus(GdipSetLineTransform(GpLineGradient(nativeBrush),
  3694.                                                           matrix.nativeMatrix));
  3695.   end;
  3696.  
  3697.   function TGPLinearGradientBrush.GetTransform(matrix: TGPMatrix): TStatus;
  3698.   begin
  3699.     result := SetStatus(GdipGetLineTransform(GpLineGradient(nativeBrush),
  3700.                                                      matrix.nativeMatrix));
  3701.   end;
  3702.  
  3703.   function TGPLinearGradientBrush.ResetTransform: TStatus;
  3704.   begin
  3705.     result := SetStatus(GdipResetLineTransform(GpLineGradient(nativeBrush)));
  3706.   end;
  3707.  
  3708.   function TGPLinearGradientBrush.MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  3709.   begin
  3710.     result := SetStatus(GdipMultiplyLineTransform(GpLineGradient(nativeBrush),
  3711.                                                                 matrix.nativeMatrix,
  3712.                                                                 order));
  3713.   end;
  3714.  
  3715.   function TGPLinearGradientBrush.TranslateTransform(dx, dy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  3716.   begin
  3717.     result := SetStatus(GdipTranslateLineTransform(GpLineGradient(nativeBrush),
  3718.                                                                dx, dy, order));
  3719.   end;
  3720.  
  3721.   function TGPLinearGradientBrush.ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  3722.   begin
  3723.     result := SetStatus(GdipScaleLineTransform(GpLineGradient(nativeBrush),
  3724.                                                              sx, sy, order));
  3725.   end;
  3726.  
  3727.   function TGPLinearGradientBrush.RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  3728.   begin
  3729.     result := SetStatus(GdipRotateLineTransform(GpLineGradient(nativeBrush),
  3730.                                                               angle, order));
  3731.   end;
  3732.  
  3733.   function TGPLinearGradientBrush.SetWrapMode(wrapMode: TWrapMode): TStatus;
  3734.   begin
  3735.     result := SetStatus(GdipSetLineWrapMode(GpLineGradient(nativeBrush), wrapMode));
  3736.   end;
  3737.  
  3738.   function TGPLinearGradientBrush.GetWrapMode: TWrapMode;
  3739.   begin
  3740.      SetStatus(GdipGetLineWrapMode(GpLineGradient(nativeBrush), result));
  3741.   end;
  3742.  
  3743.   constructor TGPLinearGradientBrush.Create;
  3744.   begin
  3745.     // hide parent function
  3746.   end;
  3747.  
  3748. //--------------------------------------------------------------------------
  3749. // Hatch Brush Object
  3750. //--------------------------------------------------------------------------
  3751.  
  3752.   constructor TGPHatchBrush.Create(hatchStyle: THatchStyle; foreColor: TGPColor; backColor: TGPColor = aclBlack);
  3753.   var
  3754.     brush: GpHatch;
  3755.   begin
  3756.     brush := nil;
  3757.     lastResult := GdipCreateHatchBrush(Integer(hatchStyle), foreColor, backColor, brush);
  3758.     SetNativeBrush(brush);
  3759.   end;
  3760.  
  3761.   function TGPHatchBrush.GetHatchStyle: THatchStyle;
  3762.   begin
  3763.     SetStatus(GdipGetHatchStyle(GpHatch(nativeBrush), result));
  3764.   end;
  3765.  
  3766.   function TGPHatchBrush.GetForegroundColor(out color: TGPColor): TStatus;
  3767.   begin
  3768.     result := SetStatus(GdipGetHatchForegroundColor(GpHatch(nativeBrush), color));
  3769.   end;
  3770.  
  3771.   function TGPHatchBrush.GetBackgroundColor(out color: TGPColor): TStatus;
  3772.   begin
  3773.     result := SetStatus(GdipGetHatchBackgroundColor(GpHatch(nativeBrush), color));
  3774.   end;
  3775.  
  3776.   constructor TGPHatchBrush.Create;
  3777.   begin
  3778.   end;
  3779.  
  3780.   constructor TGPImage.Create(filename: WideString;
  3781.                   useEmbeddedColorManagement: BOOL = FALSE);
  3782.   begin
  3783.     nativeImage := nil;
  3784.     if(useEmbeddedColorManagement) then
  3785.     begin
  3786.         lastResult := GdipLoadImageFromFileICM(
  3787.             PWideChar(filename),
  3788.             nativeImage
  3789.         );
  3790.     end
  3791.     else
  3792.     begin
  3793.         lastResult := GdipLoadImageFromFile(
  3794.             PWideChar(filename),
  3795.             nativeImage
  3796.         );
  3797.     end;
  3798.   end;
  3799.  
  3800.   constructor TGPImage.Create(stream: IStream;
  3801.                   useEmbeddedColorManagement: BOOL  = FALSE);
  3802.   begin
  3803.     nativeImage := nil;
  3804.     if(useEmbeddedColorManagement) then
  3805.          lastResult := GdipLoadImageFromStreamICM(stream, nativeImage)
  3806.     else lastResult := GdipLoadImageFromStream(stream, nativeImage);
  3807.   end;
  3808.  
  3809.   function TGPImage.FromFile(filename: WideString;
  3810.                useEmbeddedColorManagement: BOOL = FALSE): TGPImage;
  3811.   begin
  3812.     result := TGPImage.Create(
  3813.         PWideChar(filename),
  3814.         useEmbeddedColorManagement
  3815.     );
  3816.   end;
  3817.  
  3818.   function TGPImage.FromStream(stream: IStream;
  3819.                useEmbeddedColorManagement: BOOL = FALSE): TGPImage;
  3820.   begin
  3821.     result := TGPImage.Create(
  3822.         stream,
  3823.         useEmbeddedColorManagement
  3824.     );
  3825.   end;
  3826.  
  3827.   destructor TGPImage.destroy;
  3828.   begin
  3829.     GdipDisposeImage(nativeImage);
  3830.   end;
  3831.  
  3832.   function TGPImage.Clone: TGPImage;
  3833.   var cloneimage: GpImage;
  3834.   begin
  3835.     cloneimage := nil;
  3836.     SetStatus(GdipCloneImage(nativeImage, cloneimage));
  3837.     result := TGPImage.Create(cloneimage, lastResult);
  3838.   end;
  3839.  
  3840.   function TGPImage.Save(filename: WideString; const clsidEncoder: TGUID;
  3841.                encoderParams: PEncoderParameters = nil): TStatus;
  3842.   begin
  3843.     result := SetStatus(GdipSaveImageToFile(nativeImage,
  3844.                                                      PWideChar(filename),
  3845.                                                      @clsidEncoder,
  3846.                                                      encoderParams));
  3847.   end;
  3848.  
  3849.   function TGPImage.Save(stream: IStream; const clsidEncoder: TGUID;
  3850.                encoderParams: PEncoderParameters  = nil): TStatus;
  3851.   begin
  3852.     result := SetStatus(GdipSaveImageToStream(nativeImage,
  3853.                                                        stream,
  3854.                                                        @clsidEncoder,
  3855.                                                        encoderParams));
  3856.   end;
  3857.  
  3858.   function TGPImage.SaveAdd(encoderParams: PEncoderParameters): TStatus;
  3859.   begin
  3860.     result := SetStatus(GdipSaveAdd(nativeImage,
  3861.                                              encoderParams));
  3862.   end;
  3863.  
  3864.   function TGPImage.SaveAdd(newImage: TGPImage;
  3865.                encoderParams: PEncoderParameters): TStatus;
  3866.   begin
  3867.     if (newImage = nil) then
  3868.     begin
  3869.       result := SetStatus(InvalidParameter);
  3870.       exit;
  3871.     end;
  3872.     result := SetStatus(GdipSaveAddImage(nativeImage,
  3873.                                                   newImage.nativeImage,
  3874.                                                   encoderParams));
  3875.   end;
  3876.  
  3877.   function TGPImage.GetType: TImageType;
  3878.   begin
  3879.     SetStatus(GdipGetImageType(nativeImage, result));
  3880.   end;
  3881.  
  3882.   function TGPImage.GetPhysicalDimension(out size: TGPSizeF): TStatus;
  3883.   var
  3884.     width, height: Single;
  3885.     status: TStatus;
  3886.   begin
  3887.     status := SetStatus(GdipGetImageDimension(nativeImage, width, height));
  3888.     size.Width  := width;
  3889.     size.Height := height;
  3890.     result := status;
  3891.   end;
  3892.  
  3893.   function TGPImage.GetBounds(out srcRect: TGPRectF; out srcUnit: TUnit): TStatus;
  3894.   begin
  3895.     result := SetStatus(GdipGetImageBounds(nativeImage, @srcRect, srcUnit));
  3896.   end;
  3897.  
  3898.   function TGPImage.GetWidth: UINT;
  3899.   var width: UINT;
  3900.   begin
  3901.     width := 0;
  3902.     SetStatus(GdipGetImageWidth(nativeImage, width));
  3903.     result := width;
  3904.   end;
  3905.  
  3906.   function TGPImage.GetHeight: UINT;
  3907.   var height: UINT;
  3908.   begin
  3909.     height := 0;
  3910.     SetStatus(GdipGetImageHeight(nativeImage, height));
  3911.     result := height;
  3912.   end;
  3913.  
  3914.   function TGPImage.GetHorizontalResolution: Single;
  3915.   var resolution: Single;
  3916.   begin
  3917.     resolution := 0.0;
  3918.     SetStatus(GdipGetImageHorizontalResolution(nativeImage, resolution));
  3919.     result := resolution;
  3920.   end;
  3921.  
  3922.   function TGPImage.GetVerticalResolution: Single;
  3923.   var resolution: Single;
  3924.   begin
  3925.     resolution := 0.0;
  3926.     SetStatus(GdipGetImageVerticalResolution(nativeImage, resolution));
  3927.     result := resolution;
  3928.   end;
  3929.  
  3930.   function TGPImage.GetFlags: UINT;
  3931.   var flags: UINT;
  3932.   begin
  3933.     flags := 0;
  3934.     SetStatus(GdipGetImageFlags(nativeImage, flags));
  3935.     result := flags;
  3936.   end;
  3937.  
  3938.   function TGPImage.GetRawFormat(out format: TGUID): TStatus;
  3939.   begin
  3940.     result := SetStatus(GdipGetImageRawFormat(nativeImage, @format));
  3941.   end;
  3942.  
  3943.   function TGPImage.GetPixelFormat: TPixelFormat;
  3944.   begin
  3945.     SetStatus(GdipGetImagePixelFormat(nativeImage, result));
  3946.   end;
  3947.  
  3948.   function TGPImage.GetPaletteSize: Integer;
  3949.   var size: Integer;
  3950.   begin
  3951.     size := 0;
  3952.     SetStatus(GdipGetImagePaletteSize(nativeImage, size));
  3953.     result := size;
  3954.   end;
  3955.  
  3956.   function TGPImage.GetPalette(palette: PColorPalette; size: Integer): TStatus;
  3957.   begin
  3958.     result := SetStatus(GdipGetImagePalette(nativeImage, palette, size));
  3959.   end;
  3960.  
  3961.   function TGPImage.SetPalette(palette: PColorPalette): TStatus;
  3962.   begin
  3963.     result := SetStatus(GdipSetImagePalette(nativeImage, palette));
  3964.   end;
  3965.  
  3966.   function TGPImage.GetThumbnailImage(thumbWidth, thumbHeight: UINT;
  3967.                 callback: GetThumbnailImageAbort = nil;
  3968.                 callbackData: pointer = nil): TGPImage;
  3969.   var
  3970.     thumbimage: GpImage;
  3971.     newImage: TGPImage;
  3972.   begin
  3973.     thumbimage := nil;
  3974.     SetStatus(GdipGetImageThumbnail(nativeImage,
  3975.                                                 thumbWidth, thumbHeight,
  3976.                                                 thumbimage,
  3977.                                                 callback, callbackData));
  3978.  
  3979.     newImage := TGPImage.Create(thumbimage, lastResult);
  3980.     if (newImage = nil) then
  3981.         GdipDisposeImage(thumbimage);
  3982.  
  3983.     result := newImage;
  3984.   end;
  3985.  
  3986.   function TGPImage.GetFrameDimensionsCount: UINT;
  3987.   var count: UINT;
  3988.   begin
  3989.     count := 0;
  3990.     SetStatus(GdipImageGetFrameDimensionsCount(nativeImage, count));
  3991.     result := count;
  3992.   end;
  3993.  
  3994.   function TGPImage.GetFrameDimensionsList(dimensionIDs: PGUID; count: UINT): TStatus;
  3995.   begin
  3996.     result := SetStatus(GdipImageGetFrameDimensionsList(nativeImage, dimensionIDs, count));
  3997.   end;
  3998.  
  3999.   function TGPImage.GetFrameCount(const dimensionID: TGUID): UINT;
  4000.   var count: UINT;
  4001.   begin
  4002.     count := 0;
  4003.     SetStatus(GdipImageGetFrameCount(nativeImage, @dimensionID, count));
  4004.     result := count;
  4005.   end;
  4006.  
  4007.   function TGPImage.SelectActiveFrame(const dimensionID: TGUID; frameIndex: UINT): TStatus;
  4008.   begin
  4009.     result := SetStatus(GdipImageSelectActiveFrame(nativeImage,
  4010.                                                             @dimensionID,
  4011.                                                             frameIndex));
  4012.   end;
  4013.  
  4014.   function TGPImage.RotateFlip(rotateFlipType: TRotateFlipType): TStatus;
  4015.   begin
  4016.     result := SetStatus(GdipImageRotateFlip(nativeImage,
  4017.                                                      rotateFlipType));
  4018.   end;
  4019.  
  4020.   function TGPImage.GetPropertyCount: UINT;
  4021.   var numProperty: UINT;
  4022.   begin
  4023.     numProperty := 0;
  4024.     SetStatus(GdipGetPropertyCount(nativeImage, numProperty));
  4025.     result := numProperty;
  4026.   end;
  4027.  
  4028.   function TGPImage.GetPropertyIdList(numOfProperty: UINT; list: PPropID): TStatus;
  4029.   begin
  4030.     result := SetStatus(GdipGetPropertyIdList(nativeImage, numOfProperty, list));
  4031.   end;
  4032.  
  4033.   function TGPImage.GetPropertyItemSize(propId: PROPID): UINT;
  4034.   var size: UINT;
  4035.   begin
  4036.     size := 0;
  4037.     SetStatus(GdipGetPropertyItemSize(nativeImage, propId, size));
  4038.     result := size;
  4039.   end;
  4040.  
  4041.   function TGPImage.GetPropertyItem(propId: PROPID; propSize: UINT;
  4042.                buffer: PPropertyItem): TStatus;
  4043.   begin
  4044.     result := SetStatus(GdipGetPropertyItem(nativeImage,
  4045.                                                      propId, propSize, buffer));
  4046.   end;
  4047.  
  4048.   function TGPImage.GetPropertySize(out totalBufferSize, numProperties : UINT): TStatus;
  4049.   begin
  4050.     result := SetStatus(GdipGetPropertySize(nativeImage,
  4051.                                                      totalBufferSize,
  4052.                                                      numProperties));
  4053.   end;
  4054.  
  4055.   function TGPImage.GetAllPropertyItems(totalBufferSize, numProperties: UINT;
  4056.                allItems: PPROPERTYITEM): TStatus;
  4057.   begin
  4058.     result := SetStatus(GdipGetAllPropertyItems(nativeImage,
  4059.                                                          totalBufferSize,
  4060.                                                          numProperties,
  4061.                                                          allItems));
  4062.   end;
  4063.  
  4064.   function TGPImage.RemovePropertyItem(propId: TPROPID): TStatus;
  4065.   begin
  4066.     result := SetStatus(GdipRemovePropertyItem(nativeImage, propId));
  4067.   end;
  4068.  
  4069.   function TGPImage.SetPropertyItem(const item: TPropertyItem): TStatus;
  4070.   begin
  4071.     result := SetStatus(GdipSetPropertyItem(nativeImage, @item));
  4072.   end;
  4073.  
  4074.   function TGPImage.GetEncoderParameterListSize(const clsidEncoder: TGUID): UINT;
  4075.   var size: UINT;
  4076.   begin
  4077.     size := 0;
  4078.     SetStatus(GdipGetEncoderParameterListSize(nativeImage, @clsidEncoder, size));
  4079.     result := size;
  4080.   end;
  4081.  
  4082.   function TGPImage.GetEncoderParameterList(const clsidEncoder: TGUID; size: UINT;
  4083.                buffer: PEncoderParameters): TStatus;
  4084.   begin
  4085.     result := SetStatus(GdipGetEncoderParameterList(nativeImage,
  4086.                                                              @clsidEncoder,
  4087.                                                              size,
  4088.                                                              buffer));
  4089.   end;
  4090.  
  4091.   function TGPImage.GetLastStatus: TStatus;
  4092.   begin
  4093.     result := lastResult;
  4094.     lastResult := Ok;
  4095.   end;
  4096.  
  4097.   constructor TGPImage.Create(nativeImage: GpImage; status: TStatus);
  4098.   begin
  4099.     SetNativeImage(nativeImage);
  4100.     lastResult := status;
  4101.   end;
  4102.  
  4103.   procedure TGPImage.SetNativeImage(nativeImage: GpImage);
  4104.   begin
  4105.     self.nativeImage := nativeImage;
  4106.   end;
  4107.  
  4108.   function TGPImage.SetStatus(status: TStatus): TStatus;
  4109.   begin
  4110.     if (status <> Ok) then lastResult := status;
  4111.     result := status;
  4112.   end;
  4113.  
  4114.   // TGPBitmap
  4115.  
  4116.   constructor TGPBitmap.Create(filename: WideString; useEmbeddedColorManagement: BOOL = FALSE);
  4117.   var bitmap: GpBitmap;
  4118.   begin
  4119.     bitmap := nil;
  4120.     if(useEmbeddedColorManagement) then
  4121.       lastResult := GdipCreateBitmapFromFileICM(PWideChar(filename), bitmap)
  4122.     else
  4123.         lastResult := GdipCreateBitmapFromFile(PWideChar(filename), bitmap);
  4124.     SetNativeImage(bitmap);
  4125.   end;
  4126.  
  4127.   constructor TGPBitmap.Create(stream: IStream; useEmbeddedColorManagement: BOOL = FALSE);
  4128.   var bitmap: GpBitmap;
  4129.   begin
  4130.     bitmap := nil;
  4131.     if(useEmbeddedColorManagement) then
  4132.       lastResult := GdipCreateBitmapFromStreamICM(stream, bitmap)
  4133.     else
  4134.         lastResult := GdipCreateBitmapFromStream(stream, bitmap);
  4135.     SetNativeImage(bitmap);
  4136.   end;
  4137.  
  4138.   function TGPBitmap.FromFile(filename: WideString; useEmbeddedColorManagement: BOOL = FALSE): TGPBitmap;
  4139.   begin
  4140.     result := TGPBitmap.Create(
  4141.         PWideChar(filename),
  4142.         useEmbeddedColorManagement
  4143.     );
  4144.   end;
  4145.  
  4146.   function TGPBitmap.FromStream(stream: IStream; useEmbeddedColorManagement: BOOL = FALSE): TGPBitmap;
  4147.   begin
  4148.     result := TGPBitmap.Create(
  4149.         stream,
  4150.         useEmbeddedColorManagement
  4151.     );
  4152.   end;
  4153.  
  4154.   constructor TGPBitmap.Create(width, height, stride: Integer; format: TPixelFormat; scan0: PBYTE);
  4155.   var bitmap: GpBitmap;
  4156.   begin
  4157.     bitmap := nil;
  4158.     lastResult := GdipCreateBitmapFromScan0(width,
  4159.                                                        height,
  4160.                                                        stride,
  4161.                                                        format,
  4162.                                                        scan0,
  4163.                                                        bitmap);
  4164.  
  4165.     SetNativeImage(bitmap);
  4166.   end;
  4167.  
  4168.   constructor TGPBitmap.Create(width, height: Integer; format: TPixelFormat = PixelFormat32bppARGB);
  4169.   var bitmap: GpBitmap;
  4170.   begin
  4171.     bitmap := nil;
  4172.     lastResult := GdipCreateBitmapFromScan0(width,
  4173.                                                        height,
  4174.                                                        0,
  4175.                                                        format,
  4176.                                                        nil,
  4177.                                                        bitmap);
  4178.  
  4179.     SetNativeImage(bitmap);
  4180.   end;
  4181.  
  4182.   constructor TGPBitmap.Create(width, height: Integer; target: TGPGraphics);
  4183.   var bitmap: GpBitmap;
  4184.   begin
  4185.     bitmap := nil;
  4186.     lastResult := GdipCreateBitmapFromGraphics(width,
  4187.                                                           height,
  4188.                                                           target.nativeGraphics,
  4189.                                                           bitmap);
  4190.  
  4191.     SetNativeImage(bitmap);
  4192.   end;
  4193.  
  4194.   function TGPBitmap.Clone(rect: TGPRect; format: TPixelFormat): TGPBitmap;
  4195.   begin
  4196.     result := Clone(rect.X, rect.Y, rect.Width, rect.Height, format);
  4197.   end;
  4198.  
  4199.   function TGPBitmap.Clone(x, y, width, height: Integer; format: TPixelFormat): TGPBitmap;
  4200.   var
  4201.     bitmap: TGPBitmap;
  4202.     gpdstBitmap: GpBitmap;
  4203.   begin
  4204.     gpdstBitmap := nil;
  4205.     lastResult := GdipCloneBitmapAreaI(
  4206.                                x,
  4207.                                y,
  4208.                                width,
  4209.                                height,
  4210.                                format,
  4211.                                GpBitmap(nativeImage),
  4212.                                gpdstBitmap);
  4213.  
  4214.     if (lastResult = Ok) then
  4215.     begin
  4216.        bitmap := TGPBitmap.Create(gpdstBitmap);
  4217.        if (bitmap = nil) then
  4218.          GdipDisposeImage(gpdstBitmap);
  4219.        result := bitmap;
  4220.        exit;
  4221.     end
  4222.     else
  4223.        result := nil;
  4224.   end;
  4225.  
  4226.   function TGPBitmap.Clone(rect: TGPRectF; format: TPixelFormat): TGPBitmap;
  4227.   begin
  4228.     result := Clone(rect.X, rect.Y, rect.Width, rect.Height, format);
  4229.   end;
  4230.  
  4231.   function TGPBitmap.Clone(x, y, width, height: Single; format: TPixelFormat): TGPBitmap;
  4232.   var
  4233.     bitmap: TGPBitmap;
  4234.     gpdstBitmap: GpBitmap;
  4235.   begin
  4236.     gpdstBitmap := nil;
  4237.     SetStatus(GdipCloneBitmapArea(
  4238.                                x,
  4239.                                y,
  4240.                                width,
  4241.                                height,
  4242.                                format,
  4243.                                GpBitmap(nativeImage),
  4244.                                gpdstBitmap));
  4245.  
  4246.    if (lastResult = Ok) then
  4247.    begin
  4248.      bitmap := TGPBitmap.Create(gpdstBitmap);
  4249.      if (bitmap = nil) then
  4250.        GdipDisposeImage(gpdstBitmap);
  4251.        result := bitmap;
  4252.    end
  4253.    else
  4254.        result := nil;
  4255.   end;
  4256.  
  4257.   function TGPBitmap.LockBits(rect: TGPRect; flags: UINT; format: TPixelFormat;
  4258.                out lockedBitmapData: TBitmapData): TStatus;
  4259.   begin
  4260.     result := SetStatus(GdipBitmapLockBits(
  4261.                                     GpBitmap(nativeImage),
  4262.                                     @rect,
  4263.                                     flags,
  4264.                                     format,
  4265.                                     @lockedBitmapData));
  4266.   end;
  4267.  
  4268.   function TGPBitmap.UnlockBits(var lockedBitmapData: TBitmapData): TStatus;
  4269.   begin
  4270.     result := SetStatus(GdipBitmapUnlockBits(
  4271.                                     GpBitmap(nativeImage),
  4272.                                     @lockedBitmapData));
  4273.   end;
  4274.  
  4275.   function TGPBitmap.GetPixel(x, y: Integer; out color: TGPColor): TStatus;
  4276.   begin
  4277.     result := SetStatus(GdipBitmapGetPixel(GpBitmap(nativeImage), x, y, color));
  4278.   end;
  4279.  
  4280.   function TGPBitmap.SetPixel(x, y: Integer; color: TGPColor): TStatus;
  4281.   begin
  4282.     result := SetStatus(GdipBitmapSetPixel(
  4283.         GpBitmap(nativeImage),
  4284.         x, y,
  4285.         color));
  4286.   end;
  4287.  
  4288.   function TGPBitmap.SetResolution(xdpi, ydpi: Single): TStatus;
  4289.   begin
  4290.     result := SetStatus(GdipBitmapSetResolution(
  4291.         GpBitmap(nativeImage),
  4292.         xdpi, ydpi));
  4293.   end;
  4294.  
  4295.   constructor TGPBitmap.Create(surface: IDirectDrawSurface7);
  4296.   var bitmap: GpBitmap;
  4297.   begin
  4298.     bitmap := nil;
  4299.     lastResult := GdipCreateBitmapFromDirectDrawSurface(surface, bitmap);
  4300.     SetNativeImage(bitmap);
  4301.   end;
  4302.  
  4303.   constructor TGPBitmap.Create(var gdiBitmapInfo: TBITMAPINFO; gdiBitmapData: Pointer);
  4304.   var bitmap: GpBitmap;
  4305.   begin
  4306.     bitmap := nil;
  4307.     lastResult := GdipCreateBitmapFromGdiDib(@gdiBitmapInfo, gdiBitmapData, bitmap);
  4308.     SetNativeImage(bitmap);
  4309.   end;
  4310.  
  4311.   constructor TGPBitmap.Create(hbm: HBITMAP; hpal: HPALETTE);
  4312.   var bitmap: GpBitmap;
  4313.   begin
  4314.     bitmap := nil;
  4315.     lastResult := GdipCreateBitmapFromHBITMAP(hbm, hpal, bitmap);
  4316.     SetNativeImage(bitmap);
  4317.   end;
  4318.  
  4319.   constructor TGPBitmap.Create(hicon: HICON);
  4320.   var bitmap: GpBitmap;
  4321.   begin
  4322.     bitmap := nil;
  4323.     lastResult := GdipCreateBitmapFromHICON(hicon, bitmap);
  4324.     SetNativeImage(bitmap);
  4325.   end;
  4326.  
  4327.   constructor TGPBitmap.Create(hInstance: HMODULE; bitmapName: WideString);
  4328.   var bitmap: GpBitmap;
  4329.   begin
  4330.     bitmap := nil;
  4331.     lastResult := GdipCreateBitmapFromResource(hInstance, PWideChar(bitmapName), bitmap);
  4332.     SetNativeImage(bitmap);
  4333.   end;
  4334.  
  4335.   function TGPBitmap.FromDirectDrawSurface7(surface: IDirectDrawSurface7): TGPBitmap;
  4336.   begin
  4337.     result := TGPBitmap.Create(surface);
  4338.   end;
  4339.  
  4340.   function TGPBitmap.FromBITMAPINFO(var gdiBitmapInfo: TBITMAPINFO; gdiBitmapData: Pointer): TGPBitmap;
  4341.   begin
  4342.     result := TGPBitmap.Create(gdiBitmapInfo, gdiBitmapData);
  4343.   end;
  4344.  
  4345.   function TGPBitmap.FromHBITMAP(hbm: HBITMAP; hpal: HPALETTE): TGPBitmap;
  4346.   begin
  4347.     result := TGPBitmap.Create(hbm, hpal);
  4348.   end;
  4349.  
  4350.   function TGPBitmap.FromHICON(hicon: HICON): TGPBitmap;
  4351.   begin
  4352.     result := TGPBitmap.Create(hicon);
  4353.   end;
  4354.  
  4355.   function TGPBitmap.FromResource(hInstance: HMODULE; bitmapName: WideString): TGPBitmap;
  4356.   begin
  4357.     result := TGPBitmap.Create(hInstance, PWideChar(bitmapName));
  4358.   end;
  4359.  
  4360.   function TGPBitmap.GetHBITMAP(colorBackground: TGPColor; out hbmreturn: HBITMAP): TStatus;
  4361.   begin
  4362.     result := SetStatus(GdipCreateHBITMAPFromBitmap(
  4363.                                         GpBitmap(nativeImage),
  4364.                                         hbmreturn,
  4365.                                         colorBackground));
  4366.   end;
  4367.  
  4368.   function TGPBitmap.GetHICON(out hicon: HICON): TStatus;
  4369.   begin
  4370.     result := SetStatus(GdipCreateHICONFromBitmap(
  4371.                                         GpBitmap(nativeImage),
  4372.                                         hicon));
  4373.   end;
  4374.  
  4375.   constructor TGPBitmap.Create(nativeBitmap: GpBitmap);
  4376.   begin
  4377.     lastResult := Ok;
  4378.     SetNativeImage(nativeBitmap);
  4379.   end;
  4380.  
  4381. (**************************************************************************\
  4382. *
  4383. *   GDI+ Graphics Object
  4384. *
  4385. \**************************************************************************)
  4386.  
  4387.   function TGPGraphics.FromHDC(hdc: HDC): TGPGraphics;
  4388.   begin
  4389.     result := TGPGraphics.Create(hdc);
  4390.   end;
  4391.  
  4392.   function TGPGraphics.FromHDC(hdc: HDC; hdevice: THANDLE): TGPGraphics;
  4393.   begin
  4394.     result := TGPGraphics.Create(hdc, hdevice);
  4395.   end;
  4396.  
  4397.   function TGPGraphics.FromHWND(hwnd: HWND; icm: BOOL = FALSE): TGPGraphics;
  4398.   begin
  4399.     result := TGPGraphics.Create(hwnd, icm);
  4400.   end;
  4401.  
  4402.   function TGPGraphics.FromImage(image: TGPImage): TGPGraphics;
  4403.   begin
  4404.     result := TGPGraphics.Create(image);
  4405.   end;
  4406.  
  4407.   constructor TGPGraphics.Create(hdc: HDC);
  4408.   var graphics: GpGraphics;
  4409.   begin
  4410.     graphics:= nil;
  4411.     lastResult := GdipCreateFromHDC(hdc, graphics);
  4412.     SetNativeGraphics(graphics);
  4413.   end;
  4414.  
  4415.   constructor TGPGraphics.Create(hdc: HDC; hdevice: THANDLE);
  4416.   var graphics: GpGraphics;
  4417.   begin
  4418.     graphics:= nil;
  4419.     lastResult := GdipCreateFromHDC2(hdc, hdevice, graphics);
  4420.     SetNativeGraphics(graphics);
  4421.   end;
  4422.  
  4423.   constructor TGPGraphics.Create(hwnd: HWND; icm: BOOL{ = FALSE});
  4424.   var graphics: GpGraphics;
  4425.   begin
  4426.     graphics:= nil;
  4427.     if icm then lastResult := GdipCreateFromHWNDICM(hwnd, graphics)
  4428.            else lastResult := GdipCreateFromHWND(hwnd, graphics);
  4429.     SetNativeGraphics(graphics);
  4430.   end;
  4431.  
  4432.   constructor TGPGraphics.Create(image: TGPImage);
  4433.   var graphics: GpGraphics;
  4434.   begin
  4435.     graphics:= nil;
  4436.     if (image <> nil) then
  4437.       lastResult := GdipGetImageGraphicsContext(image.nativeImage, graphics);
  4438.     SetNativeGraphics(graphics);
  4439.   end;
  4440.  
  4441.   destructor TGPGraphics.destroy;
  4442.   begin
  4443.     GdipDeleteGraphics(nativeGraphics);
  4444.   end;
  4445.  
  4446.   procedure TGPGraphics.Flush(intention: TFlushIntention = FlushIntentionFlush);
  4447.   begin
  4448.     GdipFlush(nativeGraphics, intention);
  4449.   end;
  4450.  
  4451.     //------------------------------------------------------------------------
  4452.     // GDI Interop methods
  4453.     //------------------------------------------------------------------------
  4454.  
  4455.     // Locks the graphics until ReleaseDC is called
  4456.  
  4457.   function TGPGraphics.GetHDC: HDC;
  4458.   begin
  4459.     SetStatus(GdipGetDC(nativeGraphics, result));
  4460.   end;
  4461.  
  4462.   procedure TGPGraphics.ReleaseHDC(hdc: HDC);
  4463.   begin
  4464.     SetStatus(GdipReleaseDC(nativeGraphics, hdc));
  4465.   end;
  4466.  
  4467.     //------------------------------------------------------------------------
  4468.     // Rendering modes
  4469.     //------------------------------------------------------------------------
  4470.  
  4471.   function TGPGraphics.SetRenderingOrigin(x, y: Integer): TStatus;
  4472.   begin
  4473.     result := SetStatus(GdipSetRenderingOrigin(nativeGraphics, x, y));
  4474.   end;
  4475.  
  4476.   function TGPGraphics.GetRenderingOrigin(out x, y: Integer): TStatus;
  4477.   begin
  4478.     result := SetStatus(GdipGetRenderingOrigin(nativeGraphics, x, y));
  4479.   end;
  4480.  
  4481.   function TGPGraphics.SetCompositingMode(compositingMode: TCompositingMode): TStatus;
  4482.   begin
  4483.     result := SetStatus(GdipSetCompositingMode(nativeGraphics,
  4484.                                 compositingMode));
  4485.   end;
  4486.  
  4487.   function TGPGraphics.GetCompositingMode: TCompositingMode;
  4488.   begin
  4489.     SetStatus(GdipGetCompositingMode(nativeGraphics, result));
  4490.   end;
  4491.  
  4492.   function TGPGraphics.SetCompositingQuality(compositingQuality: TCompositingQuality): TStatus;
  4493.   begin
  4494.     result := SetStatus(GdipSetCompositingQuality( nativeGraphics, compositingQuality));
  4495.   end;
  4496.  
  4497.   function TGPGraphics.GetCompositingQuality: TCompositingQuality;
  4498.   begin
  4499.     SetStatus(GdipGetCompositingQuality(nativeGraphics, result));
  4500.   end;
  4501.  
  4502.   function TGPGraphics.SetTextRenderingHint(newMode: TTextRenderingHint): TStatus;
  4503.   begin
  4504.     result := SetStatus(GdipSetTextRenderingHint(nativeGraphics, newMode));
  4505.   end;
  4506.  
  4507.   function TGPGraphics.GetTextRenderingHint: TTextRenderingHint;
  4508.   begin
  4509.     SetStatus(GdipGetTextRenderingHint(nativeGraphics, result));
  4510.   end;
  4511.  
  4512.   function TGPGraphics.SetTextContrast(contrast: UINT): TStatus;
  4513.   begin
  4514.     result := SetStatus(GdipSetTextContrast(nativeGraphics, contrast));
  4515.   end;
  4516.  
  4517.   function TGPGraphics.GetTextContrast: UINT;
  4518.   begin
  4519.     SetStatus(GdipGetTextContrast(nativeGraphics, result));
  4520.   end;
  4521.  
  4522.   function TGPGraphics.GetInterpolationMode: TInterpolationMode;
  4523.   var mode: TInterpolationMode;
  4524.   begin
  4525.     mode := InterpolationModeInvalid;
  4526.     SetStatus(GdipGetInterpolationMode(nativeGraphics, mode));
  4527.     result := mode;
  4528.   end;
  4529.  
  4530.   function TGPGraphics.SetInterpolationMode(interpolationMode: TInterpolationMode): TStatus;
  4531.   begin
  4532.     result := SetStatus(GdipSetInterpolationMode(nativeGraphics,
  4533.                                interpolationMode));
  4534.   end;
  4535.  
  4536.   function TGPGraphics.GetSmoothingMode: TSmoothingMode;
  4537.   var smoothingMode: TSmoothingMode;
  4538.   begin
  4539.     smoothingMode := SmoothingModeInvalid;
  4540.     SetStatus(GdipGetSmoothingMode(nativeGraphics,  smoothingMode));
  4541.     result := smoothingMode;
  4542.   end;
  4543.  
  4544.   function TGPGraphics.SetSmoothingMode(smoothingMode: TSmoothingMode): TStatus;
  4545.   begin
  4546.     result := SetStatus(GdipSetSmoothingMode(nativeGraphics, smoothingMode));
  4547.   end;
  4548.  
  4549.   function TGPGraphics.GetPixelOffsetMode: TPixelOffsetMode;
  4550.   var pixelOffsetMode: TPixelOffsetMode;
  4551.   begin
  4552.     pixelOffsetMode := PixelOffsetModeInvalid;
  4553.     SetStatus(GdipGetPixelOffsetMode(nativeGraphics, pixelOffsetMode));
  4554.     result := pixelOffsetMode;
  4555.   end;
  4556.  
  4557.   function TGPGraphics.SetPixelOffsetMode(pixelOffsetMode: TPixelOffsetMode): TStatus;
  4558.   begin
  4559.     result := SetStatus(GdipSetPixelOffsetMode(nativeGraphics, pixelOffsetMode));
  4560.   end;
  4561.  
  4562.     //------------------------------------------------------------------------
  4563.     // Manipulate current world transform
  4564.     //------------------------------------------------------------------------
  4565.  
  4566.   function TGPGraphics.SetTransform(matrix: TGPMatrix): TStatus;
  4567.   begin
  4568.     result := SetStatus(GdipSetWorldTransform(nativeGraphics, matrix.nativeMatrix));
  4569.   end;
  4570.  
  4571.   function TGPGraphics.ResetTransform: TStatus;
  4572.   begin
  4573.     result := SetStatus(GdipResetWorldTransform(nativeGraphics));
  4574.   end;
  4575.  
  4576.   function TGPGraphics.MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  4577.   begin
  4578.     result := SetStatus(GdipMultiplyWorldTransform(nativeGraphics,
  4579.                                 matrix.nativeMatrix,
  4580.                                 order));
  4581.   end;
  4582.  
  4583.   function TGPGraphics.TranslateTransform(dx, dy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  4584.   begin
  4585.     result := SetStatus(GdipTranslateWorldTransform(nativeGraphics,
  4586.                                    dx, dy, order));
  4587.   end;
  4588.  
  4589.   function TGPGraphics.ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  4590.   begin
  4591.     result := SetStatus(GdipScaleWorldTransform(nativeGraphics,
  4592.                                  sx, sy, order));
  4593.   end;
  4594.  
  4595.   function TGPGraphics.RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  4596.   begin
  4597.     result := SetStatus(GdipRotateWorldTransform(nativeGraphics,
  4598.                                   angle, order));
  4599.   end;
  4600.  
  4601.   function TGPGraphics.GetTransform(matrix: TGPMatrix): TStatus;
  4602.   begin
  4603.     result := SetStatus(GdipGetWorldTransform(nativeGraphics,
  4604.                                matrix.nativeMatrix));
  4605.   end;
  4606.  
  4607.   function TGPGraphics.SetPageUnit(unit_: TUnit): TStatus;
  4608.   begin
  4609.     result := SetStatus(GdipSetPageUnit(nativeGraphics,
  4610.                              unit_));
  4611.   end;
  4612.  
  4613.   function TGPGraphics.SetPageScale(scale: Single): TStatus;
  4614.   begin
  4615.     result := SetStatus(GdipSetPageScale(nativeGraphics,
  4616.                               scale));
  4617.   end;
  4618.  
  4619.   function TGPGraphics.GetPageUnit: TUnit;
  4620.   begin
  4621.     SetStatus(GdipGetPageUnit(nativeGraphics, result));
  4622.   end;
  4623.  
  4624.   function TGPGraphics.GetPageScale: Single;
  4625.   begin
  4626.     SetStatus(GdipGetPageScale(nativeGraphics, result));
  4627.   end;
  4628.  
  4629.   function TGPGraphics.GetDpiX: Single;
  4630.   begin
  4631.     SetStatus(GdipGetDpiX(nativeGraphics, result));
  4632.   end;
  4633.  
  4634.   function TGPGraphics.GetDpiY: Single;
  4635.   begin
  4636.     SetStatus(GdipGetDpiY(nativeGraphics, result));
  4637.   end;
  4638.  
  4639.   function TGPGraphics.TransformPoints(destSpace: TCoordinateSpace;
  4640.                srcSpace: TCoordinateSpace;
  4641.                pts: PGPPointF;
  4642.                count: Integer): TStatus;
  4643.   begin
  4644.     result := SetStatus(GdipTransformPoints(nativeGraphics,
  4645.                              destSpace,
  4646.                              srcSpace,
  4647.                              pts,
  4648.                              count));
  4649.   end;
  4650.  
  4651.   function TGPGraphics.TransformPoints(destSpace: TCoordinateSpace;
  4652.                srcSpace: TCoordinateSpace;
  4653.                pts: PGPPoint;
  4654.                count: Integer): TStatus;
  4655.   begin
  4656.  
  4657.     result := SetStatus(GdipTransformPointsI(nativeGraphics,
  4658.                               destSpace,
  4659.                               srcSpace,
  4660.                               pts,
  4661.                               count));
  4662.   end;
  4663.  
  4664.     //------------------------------------------------------------------------
  4665.     // GetNearestColor (for <= 8bpp surfaces).  Note: Alpha is ignored.
  4666.     //------------------------------------------------------------------------
  4667.  
  4668.   function TGPGraphics.GetNearestColor(var color: TGPColor): TStatus;
  4669.   begin
  4670.     result := SetStatus(GdipGetNearestColor(nativeGraphics, @color));
  4671.   end;
  4672.  
  4673.   function TGPGraphics.DrawLine(pen: TGPPen; x1, y1, x2, y2: Single): TStatus;
  4674.   begin
  4675.     result := SetStatus(GdipDrawLine(nativeGraphics,
  4676.                           pen.nativePen, x1, y1, x2,
  4677.                           y2));
  4678.   end;
  4679.  
  4680.   function TGPGraphics.DrawLine(pen: TGPPen; const pt1, pt2: TGPPointF): TStatus;
  4681.   begin
  4682.     result := DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y);
  4683.   end;
  4684.  
  4685.   function TGPGraphics.DrawLines(pen: TGPPen; points: PGPPointF; count: Integer): TStatus;
  4686.   begin
  4687.     result := SetStatus(GdipDrawLines(nativeGraphics,
  4688.                            pen.nativePen,
  4689.                            points, count));
  4690.   end;
  4691.  
  4692.   function TGPGraphics.DrawLine(pen: TGPPen; x1, y1, x2, y2: Integer): TStatus;
  4693.   begin
  4694.     result := SetStatus(GdipDrawLineI(nativeGraphics,
  4695.                            pen.nativePen,
  4696.                            x1,
  4697.                            y1,
  4698.                            x2,
  4699.                            y2));
  4700.   end;
  4701.  
  4702.   function TGPGraphics.DrawLine(pen: TGPPen; const pt1, pt2: TGPPoint): TStatus;
  4703.   begin
  4704.     result := DrawLine(pen,
  4705.             pt1.X,
  4706.             pt1.Y,
  4707.             pt2.X,
  4708.             pt2.Y);
  4709.   end;
  4710.  
  4711.   function TGPGraphics.DrawLines(pen: TGPPen; points: PGPPoint; count: Integer): TStatus;
  4712.   begin
  4713.     result := SetStatus(GdipDrawLinesI(nativeGraphics,
  4714.                             pen.nativePen,
  4715.                             points,
  4716.                             count));
  4717.   end;
  4718.  
  4719.   function TGPGraphics.DrawArc(pen: TGPPen; x, y, width, height, startAngle, sweepAngle: Single): TStatus;
  4720.   begin
  4721.     result := SetStatus(GdipDrawArc(nativeGraphics,
  4722.                          pen.nativePen,
  4723.                          x,
  4724.                          y,
  4725.                          width,
  4726.                          height,
  4727.                          startAngle,
  4728.                          sweepAngle));
  4729.   end;
  4730.  
  4731.   function TGPGraphics.DrawArc(pen: TGPPen; const rect: TGPRectF; startAngle, sweepAngle: Single): TStatus;
  4732.   begin
  4733.     result := DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height,
  4734.                startAngle, sweepAngle);
  4735.   end;
  4736.  
  4737.   function TGPGraphics.DrawArc(pen: TGPPen; x, y, width, height: Integer; startAngle,
  4738.            sweepAngle: Single): TStatus; 
  4739.   begin
  4740.     result := SetStatus(GdipDrawArcI(nativeGraphics,
  4741.                           pen.nativePen,
  4742.                           x,
  4743.                           y,
  4744.                           width,
  4745.                           height,
  4746.                           startAngle,
  4747.                           sweepAngle));
  4748.   end;
  4749.  
  4750.  
  4751.   function TGPGraphics.DrawArc(pen: TGPPen; const rect: TGPRect; startAngle, sweepAngle: Single): TStatus;
  4752.   begin
  4753.     result := DrawArc(pen,
  4754.                rect.X,
  4755.                rect.Y,
  4756.                rect.Width,
  4757.                rect.Height,
  4758.                startAngle,
  4759.                sweepAngle);
  4760.   end;
  4761.  
  4762.   function TGPGraphics.DrawBezier(pen: TGPPen; x1, y1, x2, y2, x3, y3, x4, y4: Single): TStatus;
  4763.   begin
  4764.     result := SetStatus(GdipDrawBezier(nativeGraphics,
  4765.                             pen.nativePen, x1, y1,
  4766.                             x2, y2, x3, y3, x4, y4));
  4767.   end;
  4768.  
  4769.   function TGPGraphics.DrawBezier(pen: TGPPen; const pt1, pt2, pt3, pt4: TGPPointF): TStatus;
  4770.   begin
  4771.     result := DrawBezier(pen,
  4772.               pt1.X,
  4773.               pt1.Y,
  4774.               pt2.X,
  4775.               pt2.Y,
  4776.               pt3.X,
  4777.               pt3.Y,
  4778.               pt4.X,
  4779.               pt4.Y);
  4780.   end;
  4781.  
  4782.   function TGPGraphics.DrawBeziers(pen: TGPPen; points: PGPPointF; count: Integer): TStatus;
  4783.   begin
  4784.     result := SetStatus(GdipDrawBeziers(nativeGraphics,
  4785.                              pen.nativePen,
  4786.                              points,
  4787.                              count));
  4788.   end;
  4789.  
  4790.   function TGPGraphics.DrawBezier(pen: TGPPen; x1, y1, x2, y2, x3, y3, x4, y4: Integer): TStatus;
  4791.   begin
  4792.     result := SetStatus(GdipDrawBezierI(nativeGraphics,
  4793.                              pen.nativePen,
  4794.                              x1,
  4795.                              y1,
  4796.                              x2,
  4797.                              y2,
  4798.                              x3,
  4799.                              y3,
  4800.                              x4,
  4801.                              y4));
  4802.   end;
  4803.  
  4804.   function TGPGraphics.DrawBezier(pen: TGPPen; const pt1, pt2, pt3, pt4: TGPPoint): TStatus;
  4805.   begin
  4806.     result := DrawBezier(pen,
  4807.               pt1.X,
  4808.               pt1.Y,
  4809.               pt2.X,
  4810.               pt2.Y,
  4811.               pt3.X,
  4812.               pt3.Y,
  4813.               pt4.X,
  4814.               pt4.Y);
  4815.   end;
  4816.  
  4817.   function TGPGraphics.DrawBeziers(pen: TGPPen; points: PGPPoint; count: Integer): TStatus;
  4818.   begin
  4819.     result := SetStatus(GdipDrawBeziersI(nativeGraphics,
  4820.                               pen.nativePen,
  4821.                               points,
  4822.                               count));
  4823.   end;
  4824.  
  4825.   function TGPGraphics.DrawRectangle(pen: TGPPen; const rect: TGPRectF): TStatus;
  4826.   begin
  4827.     result := DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height);
  4828.   end;
  4829.  
  4830.   function TGPGraphics.DrawRectangle(pen: TGPPen; x, y, width, height: Single): TStatus;
  4831.   begin
  4832.     result := SetStatus(GdipDrawRectangle(nativeGraphics,
  4833.                                pen.nativePen, x, y,
  4834.                                width, height));
  4835.   end;
  4836.  
  4837.   function TGPGraphics.DrawRectangles(pen: TGPPen;  rects: PGPRectF; count: Integer): TStatus;
  4838.   begin
  4839.     result := SetStatus(GdipDrawRectangles(nativeGraphics,
  4840.                             pen.nativePen,
  4841.                             rects, count));
  4842.   end;
  4843.  
  4844.   function TGPGraphics.DrawRectangle(pen: TGPPen; const rect: TGPRect): TStatus;
  4845.   begin
  4846.     result := DrawRectangle(pen,
  4847.                  rect.X,
  4848.                  rect.Y,
  4849.                  rect.Width,
  4850.                  rect.Height);
  4851.   end;
  4852.  
  4853.   function TGPGraphics.DrawRectangle(pen: TGPPen; x, y, width, height: Integer): TStatus;
  4854.   begin
  4855.     result := SetStatus(GdipDrawRectangleI(nativeGraphics,
  4856.                             pen.nativePen,
  4857.                             x,
  4858.                             y,
  4859.                             width,
  4860.                             height));
  4861.   end;
  4862.  
  4863.   function TGPGraphics.DrawRectangles(pen: TGPPen; rects: PGPRect; count: Integer): TStatus;
  4864.   begin
  4865.     result := SetStatus(GdipDrawRectanglesI(nativeGraphics,
  4866.                              pen.nativePen,
  4867.                              rects,
  4868.                              count));
  4869.   end;
  4870.  
  4871.   function TGPGraphics.DrawEllipse(pen: TGPPen; const rect: TGPRectF): TStatus;
  4872.   begin
  4873.     result := DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height);
  4874.   end;
  4875.  
  4876.   function TGPGraphics.DrawEllipse(pen: TGPPen; x, y, width, height: Single): TStatus;
  4877.   begin
  4878.     result := SetStatus(GdipDrawEllipse(nativeGraphics,
  4879.                              pen.nativePen,
  4880.                              x,
  4881.                              y,
  4882.                              width,
  4883.                              height));
  4884.   end;
  4885.  
  4886.   function TGPGraphics.DrawEllipse(pen: TGPPen; const rect: TGPRect): TStatus;
  4887.   begin
  4888.     result := DrawEllipse(pen,
  4889.                rect.X,
  4890.                rect.Y,
  4891.                rect.Width,
  4892.                rect.Height);
  4893.   end;
  4894.  
  4895.   function TGPGraphics.DrawEllipse(pen: TGPPen; x, y, width, height: Integer): TStatus;
  4896.   begin
  4897.     result := SetStatus(GdipDrawEllipseI(nativeGraphics,
  4898.                               pen.nativePen,
  4899.                               x,
  4900.                               y,
  4901.                               width,
  4902.                               height));
  4903.   end;
  4904.  
  4905.   function TGPGraphics.DrawPie(pen: TGPPen; const rect: TGPRectF; startAngle, sweepAngle: Single): TStatus;
  4906.   begin
  4907.     result := DrawPie(pen,
  4908.                rect.X,
  4909.                rect.Y,
  4910.                rect.Width,
  4911.                rect.Height,
  4912.                startAngle,
  4913.                sweepAngle);
  4914.   end;
  4915.  
  4916.   function TGPGraphics.DrawPie(pen: TGPPen; x, y, width, height, startAngle, sweepAngle: Single): TStatus;
  4917.   begin
  4918.     result := SetStatus(GdipDrawPie(nativeGraphics,
  4919.                          pen.nativePen,
  4920.                          x,
  4921.                          y,
  4922.                          width,
  4923.                          height,
  4924.                          startAngle,
  4925.                          sweepAngle));
  4926.   end;
  4927.  
  4928.   function TGPGraphics.DrawPie(pen: TGPPen; const rect: TGPRect; startAngle, sweepAngle: Single): TStatus;
  4929.   begin
  4930.     result := DrawPie(pen,
  4931.                rect.X,
  4932.                rect.Y,
  4933.                rect.Width,
  4934.                rect.Height,
  4935.                startAngle,
  4936.                sweepAngle);
  4937.   end;
  4938.  
  4939.   function TGPGraphics.DrawPie(pen: TGPPen; x, y, width, height: Integer;
  4940.                  startAngle, sweepAngle: Single): TStatus;
  4941.   begin
  4942.     result := SetStatus(GdipDrawPieI(nativeGraphics,
  4943.                           pen.nativePen,
  4944.                           x,
  4945.                           y,
  4946.                           width,
  4947.                           height,
  4948.                           startAngle,
  4949.                           sweepAngle));
  4950.   end;
  4951.  
  4952.   function TGPGraphics.DrawPolygon(pen: TGPPen; points: PGPPointF; count: Integer): TStatus;
  4953.   begin
  4954.     result := SetStatus(GdipDrawPolygon(nativeGraphics,
  4955.                              pen.nativePen,
  4956.                              points,
  4957.                              count));
  4958.   end;
  4959.  
  4960.   function TGPGraphics.DrawPolygon(pen: TGPPen; points: PGPPoint; count: Integer): TStatus;
  4961.   begin
  4962.     result := SetStatus(GdipDrawPolygonI(nativeGraphics,
  4963.                               pen.nativePen,
  4964.                               points,
  4965.                               count));
  4966.   end;
  4967.  
  4968.   function TGPGraphics.DrawPath(pen: TGPPen; path: TGPGraphicsPath): TStatus;
  4969.   var
  4970.     nPen: GpPen;
  4971.     nPath: GpPath;
  4972.   begin
  4973.     if assigned(pen) then nPen := pen.nativePen else nPen  := nil;
  4974.     if assigned(path) then nPath := path.nativePath else nPath := nil;
  4975.     result := SetStatus(GdipDrawPath(nativeGraphics, nPen, nPath));
  4976.   end;
  4977.  
  4978.   function TGPGraphics.DrawCurve(pen: TGPPen; points: PGPPointF; count: Integer): TStatus;
  4979.   begin
  4980.     result := SetStatus(GdipDrawCurve(nativeGraphics,
  4981.                            pen.nativePen, points,
  4982.                            count));
  4983.   end;
  4984.  
  4985.   function TGPGraphics.DrawCurve(pen: TGPPen; points: PGPPointF; count: Integer; tension: Single): TStatus;
  4986.   begin
  4987.     result := SetStatus(GdipDrawCurve2(nativeGraphics,
  4988.                             pen.nativePen, points,
  4989.                             count, tension));
  4990.   end;
  4991.  
  4992.   function TGPGraphics.DrawCurve(pen: TGPPen; points: PGPPointF; count, offset,
  4993.            numberOfSegments: Integer; tension: Single = 0.5): TStatus;
  4994.   begin
  4995.     result := SetStatus(GdipDrawCurve3(nativeGraphics,
  4996.                             pen.nativePen, points,
  4997.                             count, offset,
  4998.                             numberOfSegments, tension));
  4999.   end;
  5000.  
  5001.   function TGPGraphics.DrawCurve(pen: TGPPen; points: PGPPoint; count: Integer): TStatus;
  5002.   begin
  5003.     result := SetStatus(GdipDrawCurveI(nativeGraphics,
  5004.                             pen.nativePen,
  5005.                             points,
  5006.                             count));
  5007.   end;
  5008.  
  5009.   function TGPGraphics.DrawCurve(pen: TGPPen; points: PGPPoint; count: Integer; tension: Single): TStatus;
  5010.   begin
  5011.     result := SetStatus(GdipDrawCurve2I(nativeGraphics,
  5012.                              pen.nativePen,
  5013.                              points,
  5014.                              count,
  5015.                              tension));
  5016.   end;
  5017.  
  5018.   function TGPGraphics.DrawCurve(pen: TGPPen; points: PGPPoint; count, offset,
  5019.            numberOfSegments: Integer; tension: Single = 0.5): TStatus; 
  5020.   begin
  5021.     result := SetStatus(GdipDrawCurve3I(nativeGraphics,
  5022.                              pen.nativePen,
  5023.                              points,
  5024.                              count,
  5025.                              offset,
  5026.                              numberOfSegments,
  5027.                              tension));
  5028.   end;
  5029.  
  5030.   function TGPGraphics.DrawClosedCurve(pen: TGPPen; points: PGPPointF; count: Integer): TStatus;
  5031.   begin
  5032.     result := SetStatus(GdipDrawClosedCurve(nativeGraphics,
  5033.                              pen.nativePen,
  5034.                              points, count));
  5035.   end;
  5036.  
  5037.   function TGPGraphics.DrawClosedCurve(pen: TGPPen; points: PGPPointF; count: Integer;
  5038.            tension: Single): TStatus;
  5039.   begin
  5040.     result := SetStatus(GdipDrawClosedCurve2(nativeGraphics,
  5041.                               pen.nativePen,
  5042.                               points, count,
  5043.                               tension));
  5044.   end;
  5045.  
  5046.   function TGPGraphics.DrawClosedCurve(pen: TGPPen; points: PGPPoint; count: Integer): TStatus;
  5047.   begin
  5048.     result := SetStatus(GdipDrawClosedCurveI(nativeGraphics,
  5049.                               pen.nativePen,
  5050.                               points,
  5051.                               count));
  5052.   end;
  5053.  
  5054.   function TGPGraphics.DrawClosedCurve(pen: TGPPen; points: PGPPoint;
  5055.            count: Integer; tension: Single): TStatus; 
  5056.   begin
  5057.     result := SetStatus(GdipDrawClosedCurve2I(nativeGraphics,
  5058.                                pen.nativePen,
  5059.                                points,
  5060.                                count,
  5061.                                tension));
  5062.   end;
  5063.  
  5064.   function TGPGraphics.Clear(color: TGPColor): TStatus;
  5065.   begin
  5066.     result := SetStatus(GdipGraphicsClear(
  5067.         nativeGraphics,
  5068.         color));
  5069.   end;
  5070.  
  5071.   function TGPGraphics.FillRectangle(brush: TGPBrush; const rect: TGPRectF): TStatus;
  5072.   begin
  5073.     result := FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height);
  5074.   end;
  5075.  
  5076.   function TGPGraphics.FillRectangle(brush: TGPBrush; x, y, width, height: Single): TStatus;
  5077.   begin
  5078.     result := SetStatus(GdipFillRectangle(nativeGraphics,
  5079.                                brush.nativeBrush, x, y,
  5080.                                width, height));
  5081.   end;
  5082.  
  5083.   function TGPGraphics.FillRectangles(brush: TGPBrush; rects: PGPRectF; count: Integer): TStatus;
  5084.   begin
  5085.     result := SetStatus(GdipFillRectangles(nativeGraphics,
  5086.                             brush.nativeBrush,
  5087.                             rects, count));
  5088.   end;
  5089.  
  5090.   function TGPGraphics.FillRectangle(brush: TGPBrush; const rect: TGPRect): TStatus;
  5091.   begin
  5092.     result := FillRectangle(brush,
  5093.                  rect.X,
  5094.                  rect.Y,
  5095.                  rect.Width,
  5096.                  rect.Height);
  5097.   end;
  5098.  
  5099.   function TGPGraphics.FillRectangle(brush: TGPBrush; x, y, width, height: Integer): TStatus;
  5100.   begin
  5101.     result := SetStatus(GdipFillRectangleI(nativeGraphics,
  5102.                             brush.nativeBrush,
  5103.                             x,
  5104.                             y,
  5105.                             width,
  5106.                             height));
  5107.   end;
  5108.  
  5109.   function TGPGraphics.FillRectangles(brush: TGPBrush; rects: PGPRect; count: Integer): TStatus;
  5110.   begin
  5111.     result := SetStatus(GdipFillRectanglesI(nativeGraphics,
  5112.                              brush.nativeBrush,
  5113.                              rects,
  5114.                              count));
  5115.   end;
  5116.  
  5117.   function TGPGraphics.FillPolygon(brush: TGPBrush; points: PGPPointF; count: Integer): TStatus;
  5118.   begin
  5119.     result := FillPolygon(brush, points, count, FillModeAlternate);
  5120.   end;
  5121.  
  5122.   function TGPGraphics.FillPolygon(brush: TGPBrush; points: PGPPointF; count: Integer;
  5123.                fillMode: TFillMode): TStatus;
  5124.   begin
  5125.     result := SetStatus(GdipFillPolygon(nativeGraphics,
  5126.                              brush.nativeBrush,
  5127.                              points, count, fillMode));
  5128.   end;
  5129.  
  5130.   function TGPGraphics.FillPolygon(brush: TGPBrush; points: PGPPoint; count: Integer): TStatus;
  5131.   begin
  5132.     result := FillPolygon(brush, points, count, FillModeAlternate);
  5133.   end;
  5134.  
  5135.   function TGPGraphics.FillPolygon(brush: TGPBrush; points: PGPPoint; count: Integer;
  5136.                fillMode: TFillMode): TStatus;
  5137.   begin
  5138.     result := SetStatus(GdipFillPolygonI(nativeGraphics,
  5139.                               brush.nativeBrush,
  5140.                               points, count,
  5141.                               fillMode));
  5142.   end;
  5143.  
  5144.   function TGPGraphics.FillEllipse(brush: TGPBrush; const rect: TGPRectF): TStatus;
  5145.   begin
  5146.     result := FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height);
  5147.   end;
  5148.  
  5149.   function TGPGraphics.FillEllipse(brush: TGPBrush; x, y, width, height: Single): TStatus;
  5150.   begin
  5151.     result := SetStatus(GdipFillEllipse(nativeGraphics,
  5152.                              brush.nativeBrush, x, y,
  5153.                              width, height));
  5154.   end;
  5155.  
  5156.   function TGPGraphics.FillEllipse(brush: TGPBrush; const rect: TGPRect): TStatus;
  5157.   begin
  5158.     result := FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height);
  5159.   end;
  5160.  
  5161.   function TGPGraphics.FillEllipse(brush: TGPBrush; x, y, width, height: Integer): TStatus;
  5162.   begin
  5163.     result := SetStatus(GdipFillEllipseI(nativeGraphics,
  5164.                               brush.nativeBrush,
  5165.                               x,
  5166.                               y,
  5167.                               width,
  5168.                               height));
  5169.   end;
  5170.  
  5171.   function TGPGraphics.FillPie(brush: TGPBrush; const rect: TGPRectF; startAngle, sweepAngle: Single): TStatus;
  5172.   begin
  5173.     result := FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height,
  5174.                startAngle, sweepAngle);
  5175.   end;
  5176.  
  5177.   function TGPGraphics.FillPie(brush: TGPBrush; x, y, width, height, startAngle, sweepAngle: Single): TStatus;
  5178.   begin
  5179.     result := SetStatus(GdipFillPie(nativeGraphics,
  5180.                          brush.nativeBrush, x, y,
  5181.                          width, height, startAngle,
  5182.                          sweepAngle));
  5183.   end;
  5184.  
  5185.   function TGPGraphics.FillPie(brush: TGPBrush; const rect: TGPRect; startAngle, sweepAngle: Single): TStatus;
  5186.   begin
  5187.     result := FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height,
  5188.                startAngle, sweepAngle);
  5189.   end;
  5190.  
  5191.   function TGPGraphics.FillPie(brush: TGPBrush; x, y, width, height: Integer; startAngle,
  5192.            sweepAngle: Single): TStatus; 
  5193.   begin
  5194.     result := SetStatus(GdipFillPieI(nativeGraphics,
  5195.                           brush.nativeBrush,
  5196.                           x,
  5197.                           y,
  5198.                           width,
  5199.                           height,
  5200.                           startAngle,
  5201.                           sweepAngle));
  5202.   end;
  5203.  
  5204.   function TGPGraphics.FillPath(brush: TGPBrush; path: TGPGraphicsPath): TStatus;
  5205.   begin
  5206.     result := SetStatus(GdipFillPath(nativeGraphics,
  5207.                           brush.nativeBrush,
  5208.                           path.nativePath));
  5209.   end;
  5210.  
  5211.   function TGPGraphics.FillClosedCurve(brush: TGPBrush; points: PGPPointF; count: Integer): TStatus;
  5212.   begin
  5213.     result := SetStatus(GdipFillClosedCurve(nativeGraphics,
  5214.                              brush.nativeBrush,
  5215.                              points, count));
  5216.  
  5217.   end;
  5218.  
  5219.   function TGPGraphics.FillClosedCurve(brush: TGPBrush; points: PGPPointF; count: Integer;
  5220.                fillMode: TFillMode; tension: Single = 0.5): TStatus;
  5221.   begin
  5222.     result := SetStatus(GdipFillClosedCurve2(nativeGraphics,
  5223.                               brush.nativeBrush,
  5224.                               points, count,
  5225.                               tension, fillMode));
  5226.   end;
  5227.  
  5228.   function TGPGraphics.FillClosedCurve(brush: TGPBrush; points:  PGPPoint; count: Integer): TStatus;
  5229.   begin
  5230.     result := SetStatus(GdipFillClosedCurveI(nativeGraphics,
  5231.                               brush.nativeBrush,
  5232.                               points,
  5233.                               count));
  5234.   end;
  5235.  
  5236.   function TGPGraphics.FillClosedCurve(brush: TGPBrush; points: PGPPoint;
  5237.            count: Integer; fillMode: TFillMode; tension: Single = 0.5): TStatus;
  5238.   begin
  5239.     result := SetStatus(GdipFillClosedCurve2I(nativeGraphics,
  5240.                                brush.nativeBrush,
  5241.                                points, count,
  5242.                                tension, fillMode));
  5243.   end;
  5244.  
  5245.   function TGPGraphics.FillRegion(brush: TGPBrush; region: TGPRegion): TStatus;
  5246.   begin
  5247.     result := SetStatus(GdipFillRegion(nativeGraphics,
  5248.                             brush.nativeBrush,
  5249.                             region.nativeRegion));
  5250.   end;
  5251.  
  5252.  
  5253.   function TGPGraphics.DrawString( string_: WideString; length: Integer; font: TGPFont;
  5254.      const layoutRect: TGPRectF; stringFormat: TGPStringFormat; brush: TGPBrush): TStatus;
  5255.   var
  5256.     nFont: GpFont;
  5257.     nStringFormat: GpStringFormat;
  5258.     nBrush: GpBrush;
  5259.   begin
  5260.     if assigned(font) then nfont := font.nativeFont else nfont := nil;
  5261.     if assigned(stringFormat) then nstringFormat := stringFormat.nativeFormat else nstringFormat := nil;
  5262.     if assigned(brush) then nbrush := brush.nativeBrush else nbrush := nil;
  5263.     result := SetStatus(GdipDrawString(
  5264.         nativeGraphics,
  5265.         PWideChar(string_),
  5266.         length,
  5267.         nfont,
  5268.         @layoutRect,
  5269.         nstringFormat,
  5270.         nbrush));
  5271.   end;
  5272.  
  5273.   function TGPGraphics.DrawString(string_: WideString; length: Integer; font: TGPFont;
  5274.            const origin: TGPPointF; brush: TGPBrush): TStatus;
  5275.   var
  5276.     rect: TGPRectF;
  5277.     nfont: Gpfont;
  5278.     nBrush: GpBrush;
  5279.   begin
  5280.     rect.X := origin.X;
  5281.     rect.Y := origin.Y;
  5282.     rect.Width := 0.0;
  5283.     rect.Height := 0.0;
  5284.     if assigned(font) then nfont := font.nativeFont else nfont := nil;
  5285.     if assigned(Brush) then nBrush := Brush.nativeBrush else nBrush := nil;
  5286.     result := SetStatus(GdipDrawString(
  5287.         nativeGraphics,
  5288.         PWideChar(string_),
  5289.         length,
  5290.         nfont,
  5291.         @rect,
  5292.         nil,
  5293.         nbrush));
  5294.   end;
  5295.  
  5296.   function TGPGraphics.DrawString(string_: WideString; length: Integer; font: TGPFont;
  5297.       const origin: TGPPointF; stringFormat: TGPStringFormat; brush: TGPBrush): TStatus;
  5298.   var
  5299.     rect: TGPRectF;
  5300.     nFont: GpFont;
  5301.     nStringFormat: GpStringFormat;
  5302.     nBrush: GpBrush;
  5303.   begin
  5304.     rect.X := origin.X;
  5305.     rect.Y := origin.Y;
  5306.     rect.Width := 0.0;
  5307.     rect.Height := 0.0;
  5308.     if assigned(font) then nfont := font.nativeFont else nfont := nil;
  5309.     if assigned(stringFormat) then nstringFormat := stringFormat.nativeFormat else nstringFormat := nil;
  5310.     if assigned(brush) then nbrush := brush.nativeBrush else nbrush := nil;
  5311.     result := SetStatus(GdipDrawString(
  5312.         nativeGraphics,
  5313.         PWideChar(string_),
  5314.         length,
  5315.         nfont,
  5316.         @rect,
  5317.         nstringFormat,
  5318.         nbrush));
  5319.   end;
  5320.  
  5321.  
  5322.   function TGPGraphics.MeasureString(string_: WideString; length: Integer; font: TGPFont;
  5323.        const layoutRect: TGPRectF; stringFormat: TGPStringFormat; out boundingBox: TGPRectF;
  5324.        codepointsFitted: PInteger = nil; linesFilled: PInteger = nil): TStatus;
  5325.   var
  5326.     nFont: GpFont;
  5327.     nStringFormat: GpStringFormat;
  5328.   begin
  5329.     if assigned(font) then nfont := font.nativeFont else nfont := nil;
  5330.     if assigned(stringFormat) then nstringFormat := stringFormat.nativeFormat else nstringFormat := nil;
  5331.     result := SetStatus(GdipMeasureString(
  5332.         nativeGraphics,
  5333.         PWideChar(string_),
  5334.         length,
  5335.         nfont,
  5336.         @layoutRect,
  5337.         nstringFormat,
  5338.         @boundingBox,
  5339.         codepointsFitted,
  5340.         linesFilled
  5341.     ));
  5342.   end;
  5343.  
  5344.  
  5345.   function TGPGraphics.MeasureString(string_: WideString; length: Integer; font: TGPFont;
  5346.        const layoutRectSize: TGPSizeF; stringFormat: TGPStringFormat; out size: TGPSizeF;
  5347.        codepointsFitted: PInteger = nil; linesFilled: PInteger = nil): TStatus;
  5348.   var
  5349.     layoutRect, boundingBox: TGPRectF;
  5350.     status: TStatus;
  5351.     nFont: GpFont;
  5352.     nStringFormat: GpStringFormat;
  5353.   begin
  5354.     layoutRect.X := 0;
  5355.     layoutRect.Y := 0;
  5356.     layoutRect.Width := layoutRectSize.Width;
  5357.     layoutRect.Height := layoutRectSize.Height;
  5358.  
  5359.     if assigned(font) then nfont := font.nativeFont else nfont := nil;
  5360.     if assigned(stringFormat) then nstringFormat := stringFormat.nativeFormat else nstringFormat := nil;
  5361.  
  5362.     status := SetStatus(GdipMeasureString(
  5363.         nativeGraphics,
  5364.         PWideChar(string_),
  5365.         length,
  5366.         nfont,
  5367.         @layoutRect,
  5368.         nstringFormat,
  5369.         @boundingBox,
  5370.         codepointsFitted,
  5371.         linesFilled
  5372.     ));
  5373.  
  5374.     if (status = Ok) then
  5375.     begin
  5376.       size.Width  := boundingBox.Width;
  5377.       size.Height := boundingBox.Height;
  5378.     end;
  5379.     result := status;
  5380.   end;
  5381.  
  5382.     
  5383.   function TGPGraphics.MeasureString(string_: WideString ; length: Integer; font: TGPFont;
  5384.        const origin: TGPPointF; stringFormat: TGPStringFormat; out boundingBox: TGPRectF): TStatus;
  5385.   var
  5386.     rect: TGPRectF;
  5387.     nFont: GpFont;
  5388.     nstringFormat: GpstringFormat;
  5389.   begin
  5390.     rect.X := origin.X;
  5391.     rect.Y := origin.Y;
  5392.     rect.Width := 0.0;
  5393.     rect.Height := 0.0;
  5394.  
  5395.     if assigned(font) then nfont := font.nativeFont else nfont := nil;
  5396.     if assigned(stringFormat) then nstringFormat := stringFormat.nativeFormat else nstringFormat := nil;
  5397.  
  5398.     result := SetStatus(GdipMeasureString(
  5399.         nativeGraphics,
  5400.         PWideChar(string_),
  5401.         length,
  5402.         nfont,
  5403.         @rect,
  5404.         nstringFormat,
  5405.         @boundingBox,
  5406.         nil,
  5407.         nil
  5408.     ));
  5409.   end;
  5410.  
  5411.     
  5412.   function TGPGraphics.MeasureString(string_: WideString; length: Integer; font: TGPFont;
  5413.        const layoutRect: TGPRectF; out boundingBox: TGPRectF): TStatus;
  5414.   var
  5415.     nFont: GpFont;
  5416.   begin
  5417.     if assigned(font) then nfont := font.nativeFont else nfont := nil;
  5418.     result := SetStatus(GdipMeasureString(
  5419.         nativeGraphics,
  5420.         PWideChar(string_),
  5421.         length,
  5422.         nfont,
  5423.         @layoutRect,
  5424.         nil,
  5425.         @boundingBox,
  5426.         nil,
  5427.         nil
  5428.     ));
  5429.   end;
  5430.  
  5431.     
  5432.   function TGPGraphics.MeasureString(string_: WideString; length: Integer; font: TGPFont;
  5433.        const origin: TGPPointF; out boundingBox: TGPRectF): TStatus;
  5434.   var
  5435.     nFont: GpFont;
  5436.     rect: TGPRectF;
  5437.   begin
  5438.     if assigned(font) then nfont := font.nativeFont else nfont := nil;
  5439.     rect.X := origin.X;
  5440.     rect.Y := origin.Y;
  5441.     rect.Width := 0.0;
  5442.     rect.Height := 0.0;
  5443.  
  5444.     result := SetStatus(GdipMeasureString(
  5445.         nativeGraphics,
  5446.         PWideChar(string_),
  5447.         length,
  5448.         nfont,
  5449.         @rect,
  5450.         nil,
  5451.         @boundingBox,
  5452.         nil,
  5453.         nil
  5454.     ));
  5455.   end;
  5456.  
  5457.  
  5458.  
  5459.   function TGPGraphics.MeasureCharacterRanges(string_: WideString; length: Integer; font: TGPFont;
  5460.        const layoutRect: TGPRectF; stringFormat: TGPStringFormat; regionCount: Integer;
  5461.        const regions: array of TGPRegion): TStatus;
  5462.   var
  5463.     nativeRegions: Pointer;
  5464.     i: Integer;
  5465.     Status: TStatus;
  5466.     nFont: GpFont;
  5467.     nstringFormat: GpstringFormat;
  5468.   type
  5469.     TArrayGpRegion = array of GpRegion;
  5470.   begin
  5471.     if assigned(font) then nfont := font.nativeFont else nfont := nil;
  5472.     if assigned(stringFormat) then nstringFormat := stringFormat.nativeFormat else nstringFormat := nil;
  5473.  
  5474.     if (regionCount <= 0) then
  5475.     begin
  5476.       result := InvalidParameter;
  5477.       exit;
  5478.     end;
  5479.  
  5480.     getmem(nativeRegions, Sizeof(GpRegion)* regionCount);
  5481.  
  5482.     for i := 0 to regionCount - 1 do
  5483.       TArrayGpRegion(nativeRegions)[i] := regions[i].nativeRegion;
  5484.  
  5485.     status := SetStatus(GdipMeasureCharacterRanges(
  5486.         nativeGraphics,
  5487.         PWideChar(string_),
  5488.         length,
  5489.         nfont,
  5490.         @layoutRect,
  5491.         nstringFormat,
  5492.         regionCount,
  5493.         nativeRegions
  5494.     ));
  5495.  
  5496.     freemem(nativeRegions, Sizeof(GpRegion)* regionCount);
  5497.     result := status;
  5498.   end;
  5499.  
  5500.   function TGPGraphics.DrawDriverString(text: PUINT16; length: Integer; font: TGPFont
  5501.        ; brush: TGPBrush; positions: PGPPointF; flags: Integer
  5502.        ; matrix: TGPMatrix): TStatus;
  5503.   var
  5504.     nfont: Gpfont;
  5505.     nbrush: Gpbrush;
  5506.     nmatrix: Gpmatrix;
  5507.   begin
  5508.     if assigned(font) then nfont := font.nativeFont else nfont := nil;
  5509.     if assigned(brush) then nbrush := brush.nativeBrush else nbrush := nil;
  5510.     if assigned(matrix) then nmatrix := matrix.nativeMatrix else nmatrix := nil;
  5511.  
  5512.     result := SetStatus(GdipDrawDriverString(
  5513.         nativeGraphics,
  5514.         text,
  5515.         length,
  5516.         nfont,
  5517.         nbrush,
  5518.         positions,
  5519.         flags,
  5520.         nmatrix));
  5521.   end;
  5522.  
  5523.   function TGPGraphics.MeasureDriverString(text: PUINT16; length: Integer; font: TGPFont;
  5524.        positions: PGPPointF; flags: Integer; matrix: TGPMatrix;
  5525.        out boundingBox: TGPRectF): TStatus;
  5526.   var
  5527.     nfont: Gpfont;
  5528.     nmatrix: Gpmatrix;
  5529.   begin
  5530.     if assigned(font) then nfont := font.nativeFont else nfont := nil;
  5531.     if assigned(matrix) then nmatrix := matrix.nativeMatrix else nmatrix := nil;
  5532.  
  5533.     result := SetStatus(GdipMeasureDriverString(
  5534.         nativeGraphics,
  5535.         text,
  5536.         length,
  5537.         nfont,
  5538.         positions,
  5539.         flags,
  5540.         nmatrix,
  5541.         @boundingBox
  5542.     ));
  5543.   end;
  5544.  
  5545.     // Draw a cached bitmap on this graphics destination offset by
  5546.     // x, y. Note this will fail with WrongState if the CachedBitmap
  5547.     // native format differs from this Graphics.
  5548.  
  5549.   function TGPGraphics.DrawCachedBitmap(cb: TGPCachedBitmap;  x, y: Integer): TStatus;
  5550.   begin
  5551.     result := SetStatus(GdipDrawCachedBitmap(
  5552.         nativeGraphics,
  5553.         cb.nativeCachedBitmap,
  5554.         x, y
  5555.     ));
  5556.   end;
  5557.  
  5558.   function TGPGraphics.DrawImage(image: TGPImage; const point: TGPPointF): TStatus;
  5559.   begin
  5560.     result := DrawImage(image, point.X, point.Y);
  5561.   end;
  5562.  
  5563.   function TGPGraphics.DrawImage(image: TGPImage; x, y: Single): TStatus;
  5564.   var
  5565.    nImage: GpImage;
  5566.   begin
  5567.     if assigned(Image) then nImage := Image.nativeImage else nImage := nil;
  5568.     result := SetStatus(GdipDrawImage(nativeGraphics, nImage, x, y));
  5569.   end;
  5570.  
  5571.   function TGPGraphics.DrawImage(image: TGPImage; const rect: TGPRectF): TStatus;
  5572.   begin
  5573.     result := DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height);
  5574.   end;
  5575.  
  5576.   function TGPGraphics.DrawImage(image: TGPImage; x, y, width, height: Single): TStatus;
  5577.   var
  5578.    nImage: GpImage;
  5579.   begin
  5580.     if assigned(Image) then nImage := Image.nativeImage else nImage := nil;
  5581.     result := SetStatus(GdipDrawImageRect(nativeGraphics,
  5582.                                nimage,
  5583.                                x,
  5584.                                y,
  5585.                                width,
  5586.                                height));
  5587.   end;
  5588.  
  5589.   function TGPGraphics.DrawImage(image: TGPImage; const point: TGPPoint): TStatus;
  5590.   begin
  5591.     result := DrawImage(image, point.X, point.Y);
  5592.   end;
  5593.  
  5594.   function TGPGraphics.DrawImage(image: TGPImage; x, y: Integer): TStatus;
  5595.   var
  5596.    nImage: GpImage;
  5597.   begin
  5598.     if assigned(Image) then nImage := Image.nativeImage else nImage := nil;
  5599.     result := SetStatus(GdipDrawImageI(nativeGraphics,
  5600.                             nimage,
  5601.                             x,
  5602.                             y));
  5603.   end;
  5604.  
  5605.   function TGPGraphics.DrawImage(image: TGPImage; const rect: TGPRect): TStatus;
  5606.   begin
  5607.     result := DrawImage(image,
  5608.              rect.X,
  5609.              rect.Y,
  5610.              rect.Width,
  5611.              rect.Height);
  5612.   end;
  5613.  
  5614.   function TGPGraphics.DrawImage(image: TGPImage; x, y, width, height: Integer): TStatus;
  5615.   var
  5616.    nImage: GpImage;
  5617.   begin
  5618.     if assigned(Image) then nImage := Image.nativeImage else nImage := nil;
  5619.     result := SetStatus(GdipDrawImageRectI(nativeGraphics,
  5620.                             nimage,
  5621.                             x,
  5622.                             y,
  5623.                             width,
  5624.                             height));
  5625.   end;
  5626.  
  5627.  
  5628.     // Affine Draw Image
  5629.     // destPoints.length = 3: rect => parallelogram
  5630.     //     destPoints[0] <=> top-left corner of the source rectangle
  5631.     //     destPoints[1] <=> top-right corner
  5632.     //     destPoints[2] <=> bottom-left corner
  5633.     // destPoints.length = 4: rect => quad
  5634.     //     destPoints[3] <=> bottom-right corner
  5635.  
  5636.   function TGPGraphics.DrawImage(image: TGPImage; destPoints: PGPPointF; count: Integer): TStatus;
  5637.   var
  5638.    nImage: GpImage;
  5639.   begin
  5640.     if (((count <> 3) and (count <> 4)) or (destPoints = nil)) then
  5641.     begin
  5642.       result := SetStatus(InvalidParameter);
  5643.       exit;
  5644.     end;
  5645.     if assigned(Image) then nImage := Image.nativeImage else nImage := nil;
  5646.     result := SetStatus(GdipDrawImagePoints(nativeGraphics,
  5647.                              nimage,
  5648.                              destPoints, count));
  5649.   end;
  5650.  
  5651.   function TGPGraphics.DrawImage(image: TGPImage; destPoints: PGPPoint; count: Integer): TStatus;
  5652.   var
  5653.    nImage: GpImage;
  5654.   begin
  5655.     if (((count <> 3) and (count <> 4))or (destPoints = nil)) then
  5656.     begin
  5657.       result := SetStatus(InvalidParameter);
  5658.       exit;
  5659.     end;
  5660.  
  5661.     if assigned(Image) then nImage := Image.nativeImage else nImage := nil;
  5662.     result := SetStatus(GdipDrawImagePointsI(nativeGraphics,
  5663.                               nimage,
  5664.                               destPoints,
  5665.                               count));
  5666.   end;
  5667.  
  5668.   function TGPGraphics.DrawImage(image: TGPImage; x, y, srcx, srcy, srcwidth, srcheight: Single;
  5669.         srcUnit: TUnit): TStatus;
  5670.   var
  5671.     nImage: GpImage;
  5672.   begin
  5673.     if assigned(Image) then nImage := Image.nativeImage else nImage := nil;
  5674.     result := SetStatus(GdipDrawImagePointRect(nativeGraphics,
  5675.                                 nimage,
  5676.                                 x, y,
  5677.                                 srcx, srcy,
  5678.                                 srcwidth, srcheight, srcUnit));
  5679.   end;
  5680.  
  5681.   function TGPGraphics.DrawImage(image: TGPImage; const destRect: TGPRectF; srcx, srcy, srcwidth, srcheight: Single;
  5682.        srcUnit: TUnit; imageAttributes: TGPImageAttributes = nil; callback: DrawImageAbort = nil;
  5683.        callbackData: Pointer = nil): TStatus;
  5684.   var
  5685.     nImage: GpImage;
  5686.     nimageAttributes: GpimageAttributes;
  5687.   begin
  5688.     if assigned(Image) then nImage := Image.nativeImage else nImage := nil;
  5689.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  5690.     result := SetStatus(GdipDrawImageRectRect(nativeGraphics,
  5691.                                nimage,
  5692.                                destRect.X,
  5693.                                destRect.Y,
  5694.                                destRect.Width,
  5695.                                destRect.Height,
  5696.                                srcx, srcy,
  5697.                                srcwidth, srcheight,
  5698.                                srcUnit,
  5699.                                nimageAttributes,
  5700.                                callback,
  5701.                                callbackData));
  5702.   end;
  5703.  
  5704.   function TGPGraphics.DrawImage(image: TGPImage; destPoints: PGPPointF; count: Integer;
  5705.        srcx, srcy, srcwidth, srcheight: Single; srcUnit: TUnit;
  5706.        imageAttributes: TGPImageAttributes = nil; callback: DrawImageAbort = nil;
  5707.        callbackData: Pointer = nil): TStatus;
  5708.   var
  5709.     nImage: GpImage;
  5710.     nimageAttributes: GpimageAttributes;
  5711.   begin
  5712.     if assigned(Image) then nImage := Image.nativeImage else nImage := nil;
  5713.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  5714.     result := SetStatus(GdipDrawImagePointsRect(nativeGraphics,
  5715.                                  nimage,
  5716.                                  destPoints, count,
  5717.                                  srcx, srcy,
  5718.                                  srcwidth,
  5719.                                  srcheight,
  5720.                                  srcUnit,
  5721.                                  nimageAttributes,
  5722.                                  callback,
  5723.                                  callbackData));
  5724.   end;
  5725.  
  5726.   function TGPGraphics.DrawImage(image: TGPImage; x, y, srcx, srcy, srcwidth, srcheight: Integer;
  5727.        srcUnit: TUnit): TStatus;
  5728.   var
  5729.     nImage: GpImage;
  5730.   begin
  5731.     if assigned(Image) then nImage := Image.nativeImage else nImage := nil;
  5732.     result := SetStatus(GdipDrawImagePointRectI(nativeGraphics,
  5733.                                  nimage,
  5734.                                  x,
  5735.                                  y,
  5736.                                  srcx,
  5737.                                  srcy,
  5738.                                  srcwidth,
  5739.                                  srcheight,
  5740.                                  srcUnit));
  5741.   end;
  5742.  
  5743.   function TGPGraphics.DrawImage(image: TGPImage; const destRect: TGPRect; srcx, srcy, srcwidth,
  5744.        srcheight: Integer; srcUnit: TUnit; imageAttributes: TGPImageAttributes = nil;
  5745.        callback: DrawImageAbort = nil; callbackData: Pointer = nil): TStatus;
  5746.   var
  5747.     nImage: GpImage;
  5748.     nimageAttributes: GpimageAttributes;
  5749.   begin
  5750.     if assigned(Image) then nImage := Image.nativeImage else nImage := nil;
  5751.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  5752.     result := SetStatus(GdipDrawImageRectRectI(nativeGraphics,
  5753.                                 nimage,
  5754.                                 destRect.X,
  5755.                                 destRect.Y,
  5756.                                 destRect.Width,
  5757.                                 destRect.Height,
  5758.                                 srcx,
  5759.                                 srcy,
  5760.                                 srcwidth,
  5761.                                 srcheight,
  5762.                                 srcUnit,
  5763.                                 nimageAttributes,
  5764.                                 callback,
  5765.                                 callbackData));
  5766.   end;
  5767.  
  5768.   function TGPGraphics.DrawImage(image: TGPImage; destPoints: PGPPoint;
  5769.        count, srcx, srcy, srcwidth, srcheight: Integer; srcUnit: TUnit;
  5770.        imageAttributes: TGPImageAttributes = nil; callback: DrawImageAbort = nil;
  5771.        callbackData: Pointer = nil): TStatus;
  5772.   var
  5773.     nImage: GpImage;
  5774.     nimageAttributes: GpimageAttributes;
  5775.   begin
  5776.     if assigned(Image) then nImage := Image.nativeImage else nImage := nil;
  5777.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  5778.  
  5779.     result := SetStatus(GdipDrawImagePointsRectI(nativeGraphics,
  5780.                                   nimage,
  5781.                                   destPoints,
  5782.                                   count,
  5783.                                   srcx,
  5784.                                   srcy,
  5785.                                   srcwidth,
  5786.                                   srcheight,
  5787.                                   srcUnit,
  5788.                                   nimageAttributes,
  5789.                                   callback,
  5790.                                   callbackData));
  5791.   end;
  5792.  
  5793.     // The following methods are for playing an EMF+ to a graphics
  5794.     // via the enumeration interface.  Each record of the EMF+ is
  5795.     // sent to the callback (along with the callbackData).  Then
  5796.     // the callback can invoke the Metafile::PlayRecord method
  5797.     // to play the particular record.
  5798.  
  5799.     
  5800.   function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; const destPoint: TGPPointF;
  5801.       callback: EnumerateMetafileProc; callbackData: Pointer = nil;
  5802.       imageAttributes: TGPImageAttributes = nil): TStatus;
  5803.   var
  5804.     nMetafile: GpMetafile;
  5805.     nimageAttributes: GpimageAttributes;
  5806.   begin
  5807.     if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil;
  5808.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  5809.     result := SetStatus(GdipEnumerateMetafileDestPoint(
  5810.             nativeGraphics,
  5811.             nmetafile,
  5812.             @destPoint,
  5813.             callback,
  5814.             callbackData,
  5815.             nimageAttributes));
  5816.   end;
  5817.  
  5818.     
  5819.   function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; const destPoint: TGPPoint;
  5820.        callback: EnumerateMetafileProc; callbackData: pointer = nil;
  5821.        imageAttributes: TGPImageAttributes = nil): TStatus;
  5822.   var
  5823.     nMetafile: GpMetafile;
  5824.     nimageAttributes: GpimageAttributes;
  5825.   begin
  5826.     if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil;
  5827.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  5828.     result := SetStatus(GdipEnumerateMetafileDestPointI(
  5829.             nativeGraphics,
  5830.             nmetafile,
  5831.             @destPoint,
  5832.             callback,
  5833.             callbackData,
  5834.             nimageAttributes));
  5835.   end;
  5836.  
  5837.  
  5838.   function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; const destRect: TGPRectF;
  5839.        callback: EnumerateMetafileProc; callbackData: Pointer = nil;
  5840.        imageAttributes: TGPImageAttributes = nil): TStatus;
  5841.   var
  5842.     nMetafile: GpMetafile;
  5843.     nimageAttributes: GpimageAttributes;
  5844.   begin
  5845.     if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil;
  5846.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  5847.     result := SetStatus(GdipEnumerateMetafileDestRect(
  5848.             nativeGraphics,
  5849.             nmetafile,
  5850.             @destRect,
  5851.             callback,
  5852.             callbackData,
  5853.             nimageAttributes));
  5854.   end;
  5855.  
  5856.  
  5857.   function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; const destRect: TGPRect;
  5858.        callback: EnumerateMetafileProc; callbackData: Pointer = nil;
  5859.        imageAttributes: TGPImageAttributes = nil): TStatus;
  5860.   var
  5861.     nMetafile: GpMetafile;
  5862.     nimageAttributes: GpimageAttributes;
  5863.   begin
  5864.     if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil;
  5865.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  5866.     result := SetStatus(GdipEnumerateMetafileDestRectI(
  5867.             nativeGraphics,
  5868.             nmetafile,
  5869.             @destRect,
  5870.             callback,
  5871.             callbackData,
  5872.             nimageAttributes));
  5873.   end;
  5874.  
  5875.  
  5876.   function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; destPoints: PGPPointF;
  5877.        count: Integer; callback: EnumerateMetafileProc; callbackData: Pointer = nil;
  5878.        imageAttributes: TGPImageAttributes = nil): TStatus;
  5879.   var
  5880.     nMetafile: GpMetafile;
  5881.     nimageAttributes: GpimageAttributes;
  5882.   begin
  5883.     if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil;
  5884.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  5885.     result := SetStatus(GdipEnumerateMetafileDestPoints(
  5886.             nativeGraphics,
  5887.             nmetafile,
  5888.             destPoints,
  5889.             count,
  5890.             callback,
  5891.             callbackData,
  5892.             nimageAttributes));
  5893.   end;
  5894.  
  5895.     
  5896.   function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; destPoints: PGPPoint;
  5897.        count: Integer; callback: EnumerateMetafileProc; callbackData: Pointer = nil;
  5898.        imageAttributes: TGPImageAttributes = nil): TStatus;
  5899.   var
  5900.     nMetafile: GpMetafile;
  5901.     nimageAttributes: GpimageAttributes;
  5902.   begin
  5903.     if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil;
  5904.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  5905.     result := SetStatus(GdipEnumerateMetafileDestPointsI(
  5906.             nativeGraphics,
  5907.             nmetafile,
  5908.             destPoints,
  5909.             count,
  5910.             callback,
  5911.             callbackData,
  5912.             nimageAttributes));
  5913.   end;
  5914.  
  5915.     
  5916.   function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; const destPoint: TGPPointF;
  5917.        const srcRect: TGPRectF; srcUnit: TUnit; callback: EnumerateMetafileProc;
  5918.        callbackData: pointer = nil; imageAttributes: TGPImageAttributes = nil): TStatus;
  5919.   var
  5920.     nMetafile: GpMetafile;
  5921.     nimageAttributes: GpimageAttributes;
  5922.   begin
  5923.     if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil;
  5924.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  5925.     result := SetStatus(GdipEnumerateMetafileSrcRectDestPoint(
  5926.             nativeGraphics,
  5927.             nmetafile,
  5928.             @destPoint,
  5929.             @srcRect,
  5930.             srcUnit,
  5931.             callback,
  5932.             callbackData,
  5933.             nimageAttributes));
  5934.   end;
  5935.  
  5936.     
  5937.   function TGPGraphics.EnumerateMetafile(metafile : TGPMetafile; const destPoint : TGPPoint;
  5938.        const srcRect : TGPRect; srcUnit : TUnit; callback : EnumerateMetafileProc;
  5939.        callbackData : Pointer = nil; imageAttributes : TGPImageAttributes = nil): TStatus;
  5940.   var
  5941.     nMetafile: GpMetafile;
  5942.     nimageAttributes: GpimageAttributes;
  5943.   begin
  5944.     if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil;
  5945.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  5946.     result := SetStatus(GdipEnumerateMetafileSrcRectDestPointI(
  5947.             nativeGraphics,
  5948.             nmetafile,
  5949.             @destPoint,
  5950.             @srcRect,
  5951.             srcUnit,
  5952.             callback,
  5953.             callbackData,
  5954.             nimageAttributes));
  5955.   end;
  5956.  
  5957.  
  5958.   function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; const destRect: TGPRectF;
  5959.        const srcRect: TGPRectF; srcUnit: TUnit; callback: EnumerateMetafileProc;
  5960.        callbackData: Pointer = nil; imageAttributes: TGPImageAttributes = nil): TStatus;
  5961.   var
  5962.     nMetafile: GpMetafile;
  5963.     nimageAttributes: GpimageAttributes;
  5964.   begin
  5965.     if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil;
  5966.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  5967.     result := SetStatus(GdipEnumerateMetafileSrcRectDestRect(
  5968.             nativeGraphics,
  5969.             nmetafile,
  5970.             @destRect,
  5971.             @srcRect,
  5972.             srcUnit,
  5973.             callback,
  5974.             callbackData,
  5975.             nimageAttributes));
  5976.   end;
  5977.  
  5978.  
  5979.   function TGPGraphics.EnumerateMetafile(metafile : TGPMetafile; const destRect, srcRect: TGPRect;
  5980.        srcUnit : TUnit; callback : EnumerateMetafileProc; callbackData : Pointer = nil;
  5981.        imageAttributes : TGPImageAttributes = nil): TStatus;
  5982.   var
  5983.     nMetafile: GpMetafile;
  5984.     nimageAttributes: GpimageAttributes;
  5985.   begin
  5986.     if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil;
  5987.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  5988.     result := SetStatus(GdipEnumerateMetafileSrcRectDestRectI(
  5989.             nativeGraphics,
  5990.             nmetafile,
  5991.             @destRect,
  5992.             @srcRect,
  5993.             srcUnit,
  5994.             callback,
  5995.             callbackData,
  5996.             nimageAttributes));
  5997.   end;
  5998.  
  5999.     
  6000.   function TGPGraphics.EnumerateMetafile( metafile: TGPMetafile; destPoints: PGPPointF;
  6001.     count: Integer; const srcRect: TGPRectF; srcUnit: TUnit; callback: EnumerateMetafileProc;
  6002.     callbackData: Pointer = nil; imageAttributes: TGPImageAttributes = nil): TStatus;
  6003.   var
  6004.     nMetafile: GpMetafile;
  6005.     nimageAttributes: GpimageAttributes;
  6006.   begin
  6007.     if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil;
  6008.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  6009.     result := SetStatus(GdipEnumerateMetafileSrcRectDestPoints(
  6010.             nativeGraphics,
  6011.             nmetafile,
  6012.             destPoints,
  6013.             count,
  6014.             @srcRect,
  6015.             srcUnit,
  6016.             callback,
  6017.             callbackData,
  6018.             nimageAttributes));
  6019.   end;
  6020.  
  6021.  
  6022.   function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; destPoints: PGPPoint;
  6023.     count: Integer; const srcRect: TGPRect; srcUnit: TUnit; callback: EnumerateMetafileProc;
  6024.     callbackData: Pointer = nil; imageAttributes: TGPImageAttributes = nil): TStatus;
  6025.   var
  6026.     nMetafile: GpMetafile;
  6027.     nimageAttributes: GpimageAttributes;
  6028.   begin
  6029.     if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil;
  6030.     if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil;
  6031.     result := SetStatus(GdipEnumerateMetafileSrcRectDestPointsI(
  6032.             nativeGraphics,
  6033.             nmetafile,
  6034.             destPoints,
  6035.             count,
  6036.             @srcRect,
  6037.             srcUnit,
  6038.             callback,
  6039.             callbackData,
  6040.             nimageAttributes));
  6041.   end;
  6042.     
  6043.   function TGPGraphics.SetClip(g: TGPGraphics; combineMode: TCombineMode = CombineModeReplace): TStatus;
  6044.   begin
  6045.     result := SetStatus(GdipSetClipGraphics(nativeGraphics,
  6046.                              g.nativeGraphics,
  6047.                              combineMode));
  6048.   end;
  6049.  
  6050.   function TGPGraphics.SetClip(rect: TGPRectF; combineMode: TCombineMode = CombineModeReplace): TStatus;
  6051.   begin
  6052.     result := SetStatus(GdipSetClipRect(nativeGraphics,
  6053.                              rect.X, rect.Y,
  6054.                              rect.Width, rect.Height,
  6055.                              combineMode));
  6056.   end;
  6057.  
  6058.   function TGPGraphics.SetClip(rect: TGPRect; combineMode: TCombineMode = CombineModeReplace): TStatus;
  6059.   begin
  6060.     result := SetStatus(GdipSetClipRectI(nativeGraphics,
  6061.                               rect.X, rect.Y,
  6062.                               rect.Width, rect.Height,
  6063.                               combineMode));
  6064.   end;
  6065.  
  6066.   function TGPGraphics.SetClip(path: TGPGraphicsPath; combineMode: TCombineMode = CombineModeReplace): TStatus;
  6067.   begin
  6068.     result := SetStatus(GdipSetClipPath(nativeGraphics,
  6069.                              path.nativePath,
  6070.                              combineMode));
  6071.   end;
  6072.  
  6073.   function TGPGraphics.SetClip(region: TGPRegion; combineMode: TCombineMode = CombineModeReplace): TStatus;
  6074.   begin
  6075.     result := SetStatus(GdipSetClipRegion(nativeGraphics,
  6076.                                region.nativeRegion,
  6077.                                combineMode));
  6078.   end;
  6079.  
  6080.     // This is different than the other SetClip methods because it assumes
  6081.     // that the HRGN is already in device units, so it doesn't transform
  6082.     // the coordinates in the HRGN.
  6083.     
  6084.   function TGPGraphics.SetClip(hRgn: HRGN; combineMode: TCombineMode = CombineModeReplace): TStatus;
  6085.   begin
  6086.     result := SetStatus(GdipSetClipHrgn(nativeGraphics, hRgn,
  6087.                              combineMode));
  6088.   end;
  6089.  
  6090.   function TGPGraphics.IntersectClip(const rect: TGPRectF): TStatus;
  6091.   begin
  6092.     result := SetStatus(GdipSetClipRect(nativeGraphics,
  6093.                              rect.X, rect.Y,
  6094.                              rect.Width, rect.Height,
  6095.                              CombineModeIntersect));
  6096.   end;
  6097.  
  6098.   function TGPGraphics.IntersectClip(const rect: TGPRect): TStatus;
  6099.   begin
  6100.     result := SetStatus(GdipSetClipRectI(nativeGraphics,
  6101.                               rect.X, rect.Y,
  6102.                               rect.Width, rect.Height,
  6103.                               CombineModeIntersect));
  6104.   end;
  6105.  
  6106.   function TGPGraphics.IntersectClip(region: TGPRegion): TStatus;
  6107.   begin
  6108.     result := SetStatus(GdipSetClipRegion(nativeGraphics,
  6109.                                region.nativeRegion,
  6110.                                CombineModeIntersect));
  6111.   end;
  6112.  
  6113.   function TGPGraphics.ExcludeClip(const rect: TGPRectF): TStatus;
  6114.   begin
  6115.     result := SetStatus(GdipSetClipRect(nativeGraphics,
  6116.                              rect.X, rect.Y,
  6117.                              rect.Width, rect.Height,
  6118.                              CombineModeExclude));
  6119.   end;
  6120.  
  6121.   function TGPGraphics.ExcludeClip(const rect: TGPRect): TStatus;
  6122.   begin
  6123.     result := SetStatus(GdipSetClipRectI(nativeGraphics,
  6124.                               rect.X, rect.Y,
  6125.                               rect.Width, rect.Height,
  6126.                               CombineModeExclude));
  6127.   end;
  6128.  
  6129.   function TGPGraphics.ExcludeClip(region: TGPRegion): TStatus;
  6130.   begin
  6131.     result := SetStatus(GdipSetClipRegion(nativeGraphics,
  6132.                                region.nativeRegion,
  6133.                                CombineModeExclude));
  6134.   end;
  6135.  
  6136.   function TGPGraphics.ResetClip: TStatus;
  6137.   begin
  6138.     result := SetStatus(GdipResetClip(nativeGraphics));
  6139.   end;
  6140.  
  6141.   function TGPGraphics.TranslateClip(dx, dy: Single): TStatus;
  6142.   begin
  6143.     result := SetStatus(GdipTranslateClip(nativeGraphics, dx, dy));
  6144.   end;
  6145.  
  6146.   function TGPGraphics.TranslateClip(dx, dy: Integer): TStatus;
  6147.   begin
  6148.     result := SetStatus(GdipTranslateClipI(nativeGraphics,
  6149.                             dx, dy));
  6150.   end;
  6151.  
  6152.   function TGPGraphics.GetClip(region: TGPRegion): TStatus;
  6153.   begin
  6154.     result := SetStatus(GdipGetClip(nativeGraphics,
  6155.                          region.nativeRegion));
  6156.   end;
  6157.  
  6158.   function TGPGraphics.GetClipBounds(out rect: TGPRectF): TStatus;
  6159.   begin
  6160.     result := SetStatus(GdipGetClipBounds(nativeGraphics, @rect));
  6161.   end;
  6162.  
  6163.   function TGPGraphics.GetClipBounds(out rect: TGPRect): TStatus;
  6164.   begin
  6165.     result := SetStatus(GdipGetClipBoundsI(nativeGraphics, @rect));
  6166.   end;
  6167.  
  6168.   function TGPGraphics.IsClipEmpty: Bool;
  6169.   var booln: BOOL;
  6170.   begin
  6171.     booln := FALSE;
  6172.     SetStatus(GdipIsClipEmpty(nativeGraphics, @booln));
  6173.     result := booln;
  6174.   end;
  6175.  
  6176.   function TGPGraphics.GetVisibleClipBounds(out rect: TGPRectF): TStatus;
  6177.   begin
  6178.     result := SetStatus(GdipGetVisibleClipBounds(nativeGraphics, @rect));
  6179.   end;
  6180.  
  6181.   function TGPGraphics.GetVisibleClipBounds(out rect: TGPRect): TStatus;
  6182.   begin
  6183.     result := SetStatus(GdipGetVisibleClipBoundsI(nativeGraphics, @rect));
  6184.   end;
  6185.  
  6186.   function TGPGraphics.IsVisibleClipEmpty: BOOL;
  6187.   var booln: BOOL;
  6188.   begin
  6189.     booln := FALSE;
  6190.     SetStatus(GdipIsVisibleClipEmpty(nativeGraphics, booln));
  6191.     result := booln;
  6192.   end;
  6193.  
  6194.   function TGPGraphics.IsVisible(x, y: Integer): BOOL;
  6195.   var pt: TGPPoint;
  6196.   begin
  6197.     pt.X := x; pt.Y := y;
  6198.     result := IsVisible(pt);
  6199.   end;
  6200.  
  6201.   function TGPGraphics.IsVisible(const point: TGPPoint): BOOL;
  6202.   var booln: BOOL;
  6203.   begin
  6204.     booln := FALSE;
  6205.     SetStatus(GdipIsVisiblePointI(nativeGraphics,
  6206.                           point.X,
  6207.                           point.Y,
  6208.                           booln));
  6209.     result := booln;
  6210.   end;
  6211.  
  6212.   function TGPGraphics.IsVisible(x, y, width, height: Integer): BOOL;
  6213.   var booln: BOOL;
  6214.   begin
  6215.     booln := TRUE;
  6216.     SetStatus(GdipIsVisibleRectI(nativeGraphics,
  6217.                          X,
  6218.                          Y,
  6219.                          Width,
  6220.                          Height,
  6221.                          booln));
  6222.     result := booln;
  6223.   end;
  6224.  
  6225.   function TGPGraphics.IsVisible(const rect: TGPRect): BOOL;
  6226.   var booln: BOOL;
  6227.   begin
  6228.     booln := TRUE;
  6229.     SetStatus(GdipIsVisibleRectI(nativeGraphics,
  6230.                          rect.X,
  6231.                          rect.Y,
  6232.                          rect.Width,
  6233.                          rect.Height,
  6234.                          booln));
  6235.     result := booln;
  6236.   end;
  6237.  
  6238.   function TGPGraphics.IsVisible(x, y: Single): BOOL;
  6239.   var booln: BOOL;
  6240.   begin
  6241.     booln := FALSE;
  6242.     SetStatus(GdipIsVisiblePoint(nativeGraphics,
  6243.                          X,
  6244.                          Y,
  6245.                          booln));
  6246.  
  6247.     result := booln;
  6248.   end;
  6249.  
  6250.   function TGPGraphics.IsVisible(const point: TGPPointF): BOOL;
  6251.   var booln: BOOL;
  6252.   begin
  6253.     booln := FALSE;
  6254.     SetStatus(GdipIsVisiblePoint(nativeGraphics,
  6255.                          point.X,
  6256.                          point.Y,
  6257.                          booln));
  6258.  
  6259.     result := booln;
  6260.   end;
  6261.  
  6262.   function TGPGraphics.IsVisible(x, y, width, height: Single): BOOL;
  6263.   var booln: BOOL;
  6264.   begin
  6265.     booln := TRUE;
  6266.     SetStatus(GdipIsVisibleRect(nativeGraphics,
  6267.                         X,
  6268.                         Y,
  6269.                         Width,
  6270.                         Height,
  6271.                         booln));
  6272.     result := booln;
  6273.   end;
  6274.  
  6275.   function TGPGraphics.IsVisible(const rect: TGPRectF): BOOL;
  6276.   var booln: BOOL;
  6277.   begin
  6278.     booln := TRUE;
  6279.     SetStatus(GdipIsVisibleRect(nativeGraphics,
  6280.                         rect.X,
  6281.                         rect.Y,
  6282.                         rect.Width,
  6283.                         rect.Height,
  6284.                         booln));
  6285.     result := booln;
  6286.   end;
  6287.  
  6288.   function TGPGraphics.Save: GraphicsState;
  6289.   begin
  6290.     SetStatus(GdipSaveGraphics(nativeGraphics, result));
  6291.   end;
  6292.  
  6293.   function TGPGraphics.Restore(gstate: GraphicsState): TStatus;
  6294.   begin
  6295.     result := SetStatus(GdipRestoreGraphics(nativeGraphics,
  6296.                              gstate));
  6297.   end;
  6298.  
  6299.   function TGPGraphics.BeginContainer(const dstrect,srcrect: TGPRectF; unit_: TUnit): GraphicsContainer;
  6300.   begin
  6301.     SetStatus(GdipBeginContainer(nativeGraphics, @dstrect,
  6302.                          @srcrect, unit_, result));
  6303.   end;
  6304.  
  6305.   function TGPGraphics.BeginContainer(const dstrect, srcrect: TGPRect; unit_: TUnit): GraphicsContainer;
  6306.   begin
  6307.     SetStatus(GdipBeginContainerI(nativeGraphics, @dstrect,
  6308.                           @srcrect, unit_, result));
  6309.   end;
  6310.  
  6311.   function TGPGraphics.BeginContainer: GraphicsContainer;
  6312.   begin
  6313.     SetStatus(GdipBeginContainer2(nativeGraphics, result));
  6314.   end;
  6315.  
  6316.   function TGPGraphics.EndContainer(state: GraphicsContainer): TStatus;
  6317.   begin
  6318.     result := SetStatus(GdipEndContainer(nativeGraphics, state));
  6319.   end;
  6320.  
  6321.     // Only valid when recording metafiles.
  6322.  
  6323.   function TGPGraphics.AddMetafileComment(data: PBYTE; sizeData: UINT): TStatus;
  6324.   begin
  6325.     result := SetStatus(GdipComment(nativeGraphics, sizeData, data));
  6326.   end;
  6327.  
  6328.   function TGPGraphics.GetHalftonePalette: HPALETTE;
  6329.   begin
  6330.     result := GdipCreateHalftonePalette;
  6331.   end;
  6332.  
  6333.   function TGPGraphics.GetLastStatus: TStatus;
  6334.   begin
  6335.     result := lastResult;
  6336.     lastResult := Ok;
  6337.   end;
  6338.  
  6339.   constructor TGPGraphics.Create(graphics: GpGraphics);
  6340.   begin
  6341.     lastResult := Ok;
  6342.     SetNativeGraphics(graphics);
  6343.   end;
  6344.  
  6345.   procedure TGPGraphics.SetNativeGraphics(graphics: GpGraphics);
  6346.   begin
  6347.     self.nativeGraphics := graphics;
  6348.   end;
  6349.  
  6350.   function TGPGraphics.SetStatus(status: TStatus): TStatus;
  6351.   begin
  6352.     if (status <> Ok) then lastResult := status;
  6353.     result := status;
  6354.   end;
  6355.  
  6356.   function TGPGraphics.GetNativeGraphics: GpGraphics;
  6357.   begin
  6358.     result := self.nativeGraphics;
  6359.   end;
  6360.  
  6361.   function TGPGraphics.GetNativePen(pen: TGPPen): GpPen;
  6362.   begin
  6363.     result := pen.nativePen;
  6364.   end;
  6365.  
  6366. (**************************************************************************\
  6367. *
  6368. *   GDI+ Font Family class
  6369. *
  6370. \**************************************************************************)
  6371.  
  6372.   constructor TGPFontFamily.Create;
  6373.   begin
  6374.     nativeFamily := nil;
  6375.     lastResult   := Ok;
  6376.   end;
  6377.  
  6378.   constructor TGPFontFamily.Create(name: WideString; fontCollection: TGPFontCollection = nil);
  6379.   var nfontCollection: GpfontCollection;
  6380.   begin
  6381.     nativeFamily := nil;
  6382.     if assigned(fontCollection) then nfontCollection := fontCollection.nativeFontCollection else nfontCollection := nil;
  6383.     lastResult := GdipCreateFontFamilyFromName(PWideChar(name), nfontCollection, nativeFamily);
  6384.   end;
  6385.  
  6386.   destructor TGPFontFamily.Destroy;
  6387.   begin
  6388.     GdipDeleteFontFamily (nativeFamily);
  6389.   end;
  6390.  
  6391.   class function TGPFontFamily.GenericSansSerif: TGPFontFamily;
  6392.   var
  6393.     nFontFamily: GpFontFamily;
  6394.   begin
  6395.     if (GenericSansSerifFontFamily <> nil) then
  6396.     begin
  6397.       result := GenericSansSerifFontFamily;
  6398.       exit;
  6399.     end;
  6400.     GenericSansSerifFontFamily := TGPFontFamily.Create;
  6401.     GenericSansSerifFontFamily.lastResult := GdipGetGenericFontFamilySansSerif(nFontFamily);
  6402.     GenericSansSerifFontFamily.nativeFamily := nFontFamily;
  6403.     result := GenericSansSerifFontFamily;
  6404.   end;
  6405.  
  6406.   class function TGPFontFamily.GenericSerif: TGPFontFamily;
  6407.   var nFontFamily: GpFontFamily;
  6408.   begin
  6409.     if (GenericSerifFontFamily <> nil) then
  6410.     begin
  6411.       result := GenericSerifFontFamily;
  6412.       exit;
  6413.     end;
  6414.  
  6415.     GenericSerifFontFamily := TGPFontFamily.Create;// (GenericSerifFontFamilyBuffer);
  6416.     GenericSerifFontFamily.lastResult := GdipGetGenericFontFamilySerif(nFontFamily);
  6417.     GenericSerifFontFamily.nativeFamily := nFontFamily;
  6418.     result := GenericSerifFontFamily;
  6419.   end;
  6420.  
  6421.   class function TGPFontFamily.GenericMonospace: TGPFontFamily;
  6422.   var nFontFamily: GpFontFamily;
  6423.   begin
  6424.     if (GenericMonospaceFontFamily <> nil) then
  6425.     begin
  6426.       result := GenericMonospaceFontFamily;
  6427.       exit;
  6428.     end;
  6429.     GenericMonospaceFontFamily := TGPFontFamily.Create;// (GenericMonospaceFontFamilyBuffer);
  6430.     GenericMonospaceFontFamily.lastResult := GdipGetGenericFontFamilyMonospace(nFontFamily);
  6431.     GenericMonospaceFontFamily.nativeFamily := nFontFamily;
  6432.     result := GenericMonospaceFontFamily;
  6433.   end;
  6434.  
  6435.   function TGPFontFamily.GetFamilyName(out name: string; language: LANGID = 0): TStatus;
  6436.   var str: array[0..LF_FACESIZE - 1] of WideChar;
  6437.   begin
  6438.     result := SetStatus(GdipGetFamilyName(nativeFamily, @str, language));
  6439.     name := str;
  6440.   end;
  6441.  
  6442.   function TGPFontFamily.Clone: TGPFontFamily;
  6443.   var
  6444.     clonedFamily: GpFontFamily;
  6445.   begin
  6446.     clonedFamily := nil;
  6447.     SetStatus(GdipCloneFontFamily (nativeFamily, clonedFamily));
  6448.     result := TGPFontFamily.Create(clonedFamily, lastResult);
  6449.   end;
  6450.  
  6451.   function TGPFontFamily.IsAvailable: BOOL;
  6452.   begin
  6453.     result := (nativeFamily <> nil);
  6454.   end;
  6455.  
  6456.   function TGPFontFamily.IsStyleAvailable(style: Integer): BOOL;
  6457.   var
  6458.     StyleAvailable: BOOL;
  6459.     status: TStatus;
  6460.   begin
  6461.     status := SetStatus(GdipIsStyleAvailable(nativeFamily, style, StyleAvailable));
  6462.     if (status <> Ok) then StyleAvailable := FALSE;
  6463.     result := StyleAvailable;
  6464.   end;
  6465.  
  6466.   function TGPFontFamily.GetEmHeight(style: Integer): UINT16;
  6467.   begin
  6468.     SetStatus(GdipGetEmHeight(nativeFamily, style, result));
  6469.   end;
  6470.  
  6471.   function TGPFontFamily.GetCellAscent(style: Integer): UINT16;
  6472.   begin
  6473.     SetStatus(GdipGetCellAscent(nativeFamily, style, result));
  6474.   end;
  6475.  
  6476.   function TGPFontFamily.GetCellDescent(style: Integer): UINT16;
  6477.   begin
  6478.     SetStatus(GdipGetCellDescent(nativeFamily, style, result));
  6479.   end;
  6480.  
  6481.   function TGPFontFamily.GetLineSpacing(style: Integer): UINT16;
  6482.   begin
  6483.     SetStatus(GdipGetLineSpacing(nativeFamily, style, result));
  6484.   end;
  6485.  
  6486.   function TGPFontFamily.GetLastStatus: TStatus;
  6487.   begin
  6488.     result := lastResult;
  6489.     lastResult := Ok;
  6490.   end;
  6491.  
  6492.   function TGPFontFamily.SetStatus(status: TStatus): TStatus;
  6493.   begin
  6494.     if (status <> Ok) then lastResult := status;
  6495.     result := status;
  6496.   end;
  6497.  
  6498.   constructor TGPFontFamily.Create(nativeOrig: GpFontFamily; status: TStatus);
  6499.   begin
  6500.     lastResult  := status;
  6501.     nativeFamily := nativeOrig;
  6502.   end;
  6503.  
  6504. (**************************************************************************\
  6505. *
  6506. *   GDI+ Font class
  6507. *
  6508. \**************************************************************************)
  6509.  
  6510.   constructor TGPFont.Create(hdc: HDC);
  6511.   var font: GpFont;
  6512.   begin
  6513.     font := nil;
  6514.     lastResult := GdipCreateFontFromDC(hdc, font);
  6515.     SetNativeFont(font);
  6516.   end;
  6517.  
  6518.   constructor TGPFont.Create(hdc: HDC; logfont: PLogFontA);
  6519.   var font: GpFont;
  6520.   begin
  6521.     font := nil;
  6522.     if assigned(logfont) then
  6523.       lastResult := GdipCreateFontFromLogfontA(hdc, logfont, font)
  6524.     else
  6525.       lastResult := GdipCreateFontFromDC(hdc, font);
  6526.     SetNativeFont(font);
  6527.   end;
  6528.  
  6529.   constructor TGPFont.Create(hdc: HDC; logfont: PLogFontW);
  6530.   var font: GpFont;
  6531.   begin
  6532.     font := nil;
  6533.     if assigned(logfont) then
  6534.       lastResult := GdipCreateFontFromLogfontW(hdc, logfont, font)
  6535.     else
  6536.       lastResult := GdipCreateFontFromDC(hdc, font);
  6537.     SetNativeFont(font);
  6538.   end;
  6539.  
  6540.   constructor TGPFont.Create(hdc: HDC; hfont: HFONT);
  6541.   var
  6542.     font: GpFont;
  6543.     lf: LOGFONTA;
  6544.   begin
  6545.     font := nil;
  6546.     if BOOL(hfont) then
  6547.     begin
  6548.       if( BOOL(GetObjectA(hfont, sizeof(LOGFONTA), @lf))) then
  6549.             lastResult := GdipCreateFontFromLogfontA(hdc, @lf, font)
  6550.         else
  6551.             lastResult := GdipCreateFontFromDC(hdc, font);
  6552.     end
  6553.     else
  6554.       lastResult := GdipCreateFontFromDC(hdc, font);
  6555.     SetNativeFont(font);
  6556.   end;
  6557.  
  6558.   constructor TGPFont.Create(family: TGPFontFamily; emSize: Single;
  6559.       style: TFontStyle = FontStyleRegular; unit_: TUnit = UnitPoint);
  6560.   var
  6561.     font: GpFont;
  6562.     nFontFamily: GpFontFamily;
  6563.   begin
  6564.     font := nil;
  6565.     if assigned(Family) then nFontFamily := Family.nativeFamily else nFontFamily := nil;
  6566.     lastResult := GdipCreateFont(nFontFamily, emSize, Integer(style), Integer(unit_), font);
  6567.     SetNativeFont(font);
  6568.   end;
  6569.  
  6570.   constructor TGPFont.Create(familyName: WideString; emSize: Single;
  6571.       style: TFontStyle = FontStyleRegular; unit_: TUnit = UnitPoint;
  6572.       fontCollection: TGPFontCollection = nil);
  6573.   var
  6574.     family: TGPFontFamily;
  6575.     nativeFamily: GpFontFamily;
  6576.   begin
  6577.     nativeFont := nil;
  6578.     family := TGPFontFamily.Create(familyName, fontCollection);
  6579.     nativeFamily := family.nativeFamily;
  6580.     lastResult := family.GetLastStatus;
  6581.     if (lastResult <> Ok) then
  6582.     begin
  6583.       nativeFamily := TGPFontFamily.GenericSansSerif.nativeFamily;
  6584.       lastResult := TGPFontFamily.GenericSansSerif.lastResult;
  6585.       if (lastResult <> Ok) then
  6586.       begin
  6587.         family.Free;
  6588.         exit;
  6589.       end;
  6590.     end;
  6591.  
  6592.     lastResult := GdipCreateFont(nativeFamily,
  6593.                             emSize,
  6594.                             integer(style),
  6595.                             integer(unit_),
  6596.                             nativeFont);
  6597.  
  6598.     if (lastResult <> Ok) then
  6599.       begin
  6600.         nativeFamily := TGPFontFamily.GenericSansSerif.nativeFamily;
  6601.         lastResult := TGPFontFamily.GenericSansSerif.lastResult;
  6602.         if (lastResult <> Ok) then
  6603.         begin
  6604.           family.Free;
  6605.           exit;
  6606.         end;
  6607.  
  6608.         lastResult := GdipCreateFont(
  6609.             nativeFamily,
  6610.             emSize,
  6611.             Integer(style),
  6612.             Integer(unit_),
  6613.             nativeFont);
  6614.       end;
  6615.       family.Free;
  6616.   end;
  6617.  
  6618.   function TGPFont.GetLogFontA(g: TGPGraphics; out logfontA: TLogFontA): TStatus;
  6619.   var nGraphics: GpGraphics;
  6620.   begin
  6621.     if assigned(g) then nGraphics := g.nativeGraphics else nGraphics := nil;
  6622.     result := SetStatus(GdipGetLogFontA(nativeFont, nGraphics, logfontA));
  6623.   end;
  6624.  
  6625.   function TGPFont.GetLogFontW(g: TGPGraphics; out logfontW: TLogFontW): TStatus;
  6626.   var nGraphics: GpGraphics;
  6627.   begin
  6628.     if assigned(g) then nGraphics := g.nativeGraphics else nGraphics := nil;
  6629.     result := SetStatus(GdipGetLogFontW(nativeFont, nGraphics, logfontW));
  6630.   end;
  6631.  
  6632.   function TGPFont.Clone: TGPFont;
  6633.   var cloneFont: GpFont;
  6634.   begin
  6635.     cloneFont := nil;
  6636.     SetStatus(GdipCloneFont(nativeFont, cloneFont));
  6637.     result := TGPFont.Create(cloneFont, lastResult);
  6638.   end;
  6639.  
  6640.   destructor TGPFont.Destroy;
  6641.   begin
  6642.     GdipDeleteFont(nativeFont);
  6643.   end;
  6644.  
  6645.   function TGPFont.IsAvailable: BOOL;
  6646.   begin
  6647.     result := (nativeFont <> nil);
  6648.   end;
  6649.  
  6650.   function TGPFont.GetStyle: Integer;
  6651.   begin
  6652.     SetStatus(GdipGetFontStyle(nativeFont, result));
  6653.   end;
  6654.  
  6655.   function TGPFont.GetSize: Single;
  6656.   begin
  6657.     SetStatus(GdipGetFontSize(nativeFont, result));
  6658.   end;
  6659.  
  6660.   function TGPFont.GetUnit: TUnit;
  6661.   begin
  6662.     SetStatus(GdipGetFontUnit(nativeFont, result));
  6663.   end;
  6664.  
  6665.   function TGPFont.GetLastStatus: TStatus;
  6666.   begin
  6667.     result := lastResult;
  6668.   end;
  6669.  
  6670.   function TGPFont.GetHeight(graphics: TGPGraphics): Single;
  6671.   var ngraphics: Gpgraphics;
  6672.   begin
  6673.     if assigned(graphics) then ngraphics := graphics.nativeGraphics else ngraphics := nil;
  6674.     SetStatus(GdipGetFontHeight(nativeFont, ngraphics, result));
  6675.   end;
  6676.  
  6677.   function TGPFont.GetHeight(dpi: Single): Single;
  6678.   begin
  6679.     SetStatus(GdipGetFontHeightGivenDPI(nativeFont, dpi, result));
  6680.   end;
  6681.  
  6682.   function TGPFont.GetFamily(family: TGPFontFamily): TStatus;
  6683.   var
  6684.     status: TStatus;
  6685.     nFamily: GpFontFamily;
  6686.   begin
  6687.     if (family = nil) then
  6688.     begin
  6689.       result := SetStatus(InvalidParameter);
  6690.       exit;
  6691.     end;
  6692.  
  6693.     status := GdipGetFamily(nativeFont, nFamily);
  6694.     family.nativeFamily := nFamily;
  6695.     family.SetStatus(status);
  6696.     result := SetStatus(status);
  6697.   end;
  6698.  
  6699.   constructor TGPFont.Create(font: GpFont; status: TStatus);
  6700.   begin
  6701.     lastResult := status;
  6702.     SetNativeFont(font);
  6703.   end;
  6704.  
  6705.   procedure TGPFont.SetNativeFont(Font: GpFont);
  6706.   begin
  6707.     nativeFont := Font;
  6708.   end;
  6709.  
  6710.   function TGPFont.SetStatus(status: TStatus): TStatus;
  6711.   begin
  6712.     if (status <> Ok) then lastResult := status;
  6713.     result := status;
  6714.   end;
  6715.  
  6716. (**************************************************************************\
  6717. *
  6718. *   Font collections (Installed and Private)
  6719. *
  6720. \**************************************************************************)
  6721.  
  6722.   constructor TGPFontCollection.Create;
  6723.   begin
  6724.     nativeFontCollection := nil;
  6725.   end;
  6726.  
  6727.   destructor TGPFontCollection.Destroy;
  6728.   begin
  6729.     inherited Destroy;
  6730.   end;
  6731.  
  6732.   function TGPFontCollection.GetFamilyCount: Integer;
  6733.   var
  6734.     numFound: Integer;
  6735.   begin
  6736.     numFound := 0;
  6737.     lastResult := GdipGetFontCollectionFamilyCount(nativeFontCollection, numFound);
  6738.     result := numFound;
  6739.   end;
  6740.  
  6741.   function TGPFontCollection.GetFamilies(numSought: Integer; out gpfamilies: array of TGPFontFamily;
  6742.       out numFound: Integer): TStatus;
  6743.   var
  6744.     nativeFamilyList: Pointer;
  6745.     Status: TStatus;
  6746.     i: Integer;
  6747.   type
  6748.     ArrGpFontFamily = array of GpFontFamily;
  6749.   begin
  6750.     if ((numSought <= 0) or (length(gpfamilies) = 0)) then
  6751.     begin
  6752.       result := SetStatus(InvalidParameter);
  6753.       exit;
  6754.     end;
  6755.     numFound := 0;
  6756.  
  6757.     getMem(nativeFamilyList, numSought * SizeOf(GpFontFamily));
  6758.     if nativeFamilyList = nil then
  6759.     begin
  6760.       result := SetStatus(OutOfMemory);
  6761.       exit;
  6762.     end;
  6763.  
  6764.     status := SetStatus(GdipGetFontCollectionFamilyList(
  6765.         nativeFontCollection,
  6766.         numSought,
  6767.         nativeFamilyList,
  6768.         numFound
  6769.     ));
  6770.     
  6771.     if (status = Ok) then
  6772.       for i := 0 to numFound - 1 do
  6773.          GdipCloneFontFamily(ArrGpFontFamily(nativeFamilyList)[i], gpfamilies[i].nativeFamily);
  6774.     Freemem(nativeFamilyList, numSought * SizeOf(GpFontFamily));
  6775.     result := status;
  6776.   end;
  6777.  
  6778.   function TGPFontCollection.GetLastStatus: TStatus;
  6779.   begin
  6780.     result := lastResult;
  6781.   end;
  6782.  
  6783.   function TGPFontCollection.SetStatus(status: TStatus): TStatus;
  6784.   begin
  6785.     lastResult := status;
  6786.     result := lastResult;
  6787.   end;
  6788.  
  6789.  
  6790.   constructor TGPInstalledFontCollection.Create;
  6791.   begin
  6792.     nativeFontCollection := nil;
  6793.     lastResult := GdipNewInstalledFontCollection(nativeFontCollection);
  6794.   end;
  6795.  
  6796.   destructor TGPInstalledFontCollection.Destroy;
  6797.   begin
  6798.     inherited Destroy;
  6799.   end;
  6800.  
  6801.   constructor TGPPrivateFontCollection.Create;
  6802.   begin
  6803.     nativeFontCollection := nil;
  6804.     lastResult := GdipNewPrivateFontCollection(nativeFontCollection);
  6805.   end;
  6806.  
  6807.   destructor TGPPrivateFontCollection.destroy;
  6808.   begin
  6809.     GdipDeletePrivateFontCollection(nativeFontCollection);
  6810.     inherited Destroy;
  6811.   end;
  6812.  
  6813.   function TGPPrivateFontCollection.AddFontFile(filename: WideString): TStatus;
  6814.   begin
  6815.     result := SetStatus(GdipPrivateAddFontFile(nativeFontCollection, PWideChar(filename)));
  6816.   end;
  6817.  
  6818.   function TGPPrivateFontCollection.AddMemoryFont(memory: Pointer; length: Integer): TStatus;
  6819.   begin
  6820.     result := SetStatus(GdipPrivateAddMemoryFont(
  6821.         nativeFontCollection,
  6822.         memory,
  6823.         length));
  6824.   end;
  6825.  
  6826. (**************************************************************************\
  6827. *
  6828. *   GDI+ Graphics Path class
  6829. *
  6830. \**************************************************************************)
  6831.  
  6832.   constructor TGPGraphicsPath.Create(fillMode: TFillMode = FillModeAlternate);
  6833.   begin
  6834.     nativePath := nil;
  6835.     lastResult := GdipCreatePath(fillMode, nativePath);
  6836.   end;
  6837.  
  6838.   constructor TGPGraphicsPath.Create(points: PGPPointF; types: PBYTE; count: Integer;
  6839.               fillMode: TFillMode = FillModeAlternate);
  6840.   begin
  6841.     nativePath := nil;
  6842.     lastResult := GdipCreatePath2(points, types, count, fillMode, nativePath);
  6843.   end;
  6844.  
  6845.   constructor TGPGraphicsPath.Create(points: PGPPoint; types: PBYTE; count: Integer;
  6846.               fillMode: TFillMode = FillModeAlternate);
  6847.   begin
  6848.       nativePath := nil;
  6849.       lastResult := GdipCreatePath2I(points, types, count, fillMode, nativePath);
  6850.   end;
  6851.  
  6852.   destructor TGPGraphicsPath.destroy;
  6853.   begin
  6854.     GdipDeletePath(nativePath);
  6855.   end;
  6856.  
  6857.   function TGPGraphicsPath.Clone: TGPGraphicsPath;
  6858.   var
  6859.     clonepath: GpPath;
  6860.   begin
  6861.     clonepath := nil;
  6862.     SetStatus(GdipClonePath(nativePath, clonepath));
  6863.     result := TGPGraphicsPath.Create(clonepath);
  6864.   end;
  6865.  
  6866.     // Reset the path object to empty (and fill mode to FillModeAlternate)
  6867.  
  6868.   function TGPGraphicsPath.Reset: TStatus;
  6869.   begin
  6870.     result := SetStatus(GdipResetPath(nativePath));
  6871.   end;
  6872.  
  6873.   function TGPGraphicsPath.GetFillMode: TFillMode;
  6874.   var FMode: TFillMode;
  6875.   begin
  6876.     FMode := FillModeAlternate;
  6877.     SetStatus(GdipGetPathFillMode(nativePath, result));
  6878.     result := FMode;
  6879.   end;
  6880.  
  6881.   function TGPGraphicsPath.SetFillMode(fillmode: TFillMode): TStatus;
  6882.   begin
  6883.     result := SetStatus(GdipSetPathFillMode(nativePath, fillmode));
  6884.   end;
  6885.  
  6886.   function TGPGraphicsPath.GetPathData(pathData: TPathData): TStatus;
  6887.   var
  6888.     count: Integer;
  6889.   begin
  6890.     count := GetPointCount;
  6891.     if ((count <= 0) or ((pathData.Count > 0) and (pathData.Count < Count))) then
  6892.     begin
  6893.       pathData.Count := 0;
  6894.       if assigned(pathData.Points) then
  6895.       begin
  6896.         FreeMem(pathData.Points);
  6897.         pathData.Points := nil;
  6898.       end;
  6899.       if assigned(pathData.Types) then
  6900.       begin
  6901.         freemem(pathData.Types);
  6902.         pathData.Types := nil;
  6903.       end;
  6904.       if (count <= 0) then
  6905.       begin
  6906.         result := lastResult;
  6907.         exit;
  6908.       end;
  6909.     end;
  6910.  
  6911.     if (pathData.Count = 0) then
  6912.     begin
  6913.       getmem(pathData.Points, SizeOf(TGPPointF) * count);
  6914.       if (pathData.Points = nil) then
  6915.       begin
  6916.         result := SetStatus(OutOfMemory);
  6917.         exit;
  6918.       end;
  6919.       Getmem(pathData.Types, count);
  6920.       if (pathData.Types = nil) then
  6921.       begin
  6922.         freemem(pathData.Points);
  6923.         pathData.Points := nil;
  6924.         result := SetStatus(OutOfMemory);
  6925.         exit;
  6926.       end;
  6927.       pathData.Count := count;
  6928.     end;
  6929.  
  6930.     result := SetStatus(GdipGetPathData(nativePath, @pathData.Count));
  6931.   end;
  6932.  
  6933.   function TGPGraphicsPath.StartFigure: TStatus;
  6934.   begin
  6935.     result := SetStatus(GdipStartPathFigure(nativePath));
  6936.   end;
  6937.  
  6938.   function TGPGraphicsPath.CloseFigure: TStatus;
  6939.   begin
  6940.     result := SetStatus(GdipClosePathFigure(nativePath));
  6941.   end;
  6942.  
  6943.   function TGPGraphicsPath.CloseAllFigures: TStatus;
  6944.   begin
  6945.     result := SetStatus(GdipClosePathFigures(nativePath));
  6946.   end;
  6947.  
  6948.   function TGPGraphicsPath.SetMarker: TStatus;
  6949.   begin
  6950.     result := SetStatus(GdipSetPathMarker(nativePath));
  6951.   end;
  6952.  
  6953.   function TGPGraphicsPath.ClearMarkers: TStatus;
  6954.   begin
  6955.     result := SetStatus(GdipClearPathMarkers(nativePath));
  6956.   end;
  6957.  
  6958.   function TGPGraphicsPath.Reverse: TStatus;
  6959.   begin
  6960.     result := SetStatus(GdipReversePath(nativePath));
  6961.   end;
  6962.  
  6963.   function TGPGraphicsPath.GetLastPoint(out lastPoint: TGPPointF): TStatus;
  6964.   begin
  6965.     result := SetStatus(GdipGetPathLastPoint(nativePath,
  6966.                                             @lastPoint));
  6967.   end;
  6968.  
  6969.   function TGPGraphicsPath.AddLine(const pt1, pt2: TGPPointF): TStatus;
  6970.   begin
  6971.     result := AddLine(pt1.X, pt1.Y, pt2.X, pt2.Y);
  6972.   end;
  6973.  
  6974.   function TGPGraphicsPath.AddLine(x1, y1, x2, y2: Single): TStatus;
  6975.   begin
  6976.     result := SetStatus(GdipAddPathLine(nativePath, x1, y1,
  6977.                                          x2, y2));
  6978.   end;
  6979.  
  6980.   function TGPGraphicsPath.AddLines(points: PGPPointF; count: Integer): TStatus;
  6981.   begin
  6982.     result := SetStatus(GdipAddPathLine2(nativePath, points, count));
  6983.   end;
  6984.  
  6985.   function TGPGraphicsPath.AddLine(const pt1, pt2: TGPPoint): TStatus;
  6986.   begin
  6987.     result := AddLine(pt1.X, pt1.Y, pt2.X, pt2.Y);
  6988.   end;
  6989.  
  6990.   function TGPGraphicsPath.AddLine(x1, y1, x2, y2: Integer): TStatus;
  6991.   begin
  6992.     result := SetStatus(GdipAddPathLineI(nativePath, x1, y1, x2, y2));
  6993.   end;
  6994.  
  6995.   function TGPGraphicsPath.AddLines(points: PGPPoint; count: Integer): TStatus;
  6996.   begin
  6997.     result := SetStatus(GdipAddPathLine2I(nativePath, points, count));
  6998.   end;
  6999.  
  7000.   function TGPGraphicsPath.AddArc(rect: TGPRectF; startAngle, sweepAngle: Single): TStatus;
  7001.   begin
  7002.     result := AddArc(rect.X, rect.Y, rect.Width, rect.Height,
  7003.                   startAngle, sweepAngle);
  7004.   end;
  7005.  
  7006.   function TGPGraphicsPath.AddArc(x, y, width, height, startAngle, sweepAngle: Single): TStatus;
  7007.   begin
  7008.     result := SetStatus(GdipAddPathArc(nativePath, x, y, width, height, startAngle, sweepAngle));
  7009.   end;
  7010.  
  7011.   function TGPGraphicsPath.AddArc(rect: TGPRect; startAngle, sweepAngle: Single): TStatus;
  7012.   begin
  7013.     result := AddArc(rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle);
  7014.   end;
  7015.  
  7016.   function TGPGraphicsPath.AddArc(x, y, width, height: Integer; startAngle, sweepAngle: Single): TStatus;
  7017.   begin
  7018.     result := SetStatus(GdipAddPathArcI(nativePath, x, y, width, height, startAngle, sweepAngle));
  7019.   end;
  7020.  
  7021.   function TGPGraphicsPath.AddBezier(pt1, pt2, pt3, pt4: TGPPointF): TStatus;
  7022.   begin
  7023.     result := AddBezier(pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
  7024.   end;
  7025.  
  7026.   function TGPGraphicsPath.AddBezier(x1, y1, x2, y2, x3, y3, x4, y4: Single): TStatus;
  7027.   begin
  7028.     result := SetStatus(GdipAddPathBezier(nativePath, x1, y1, x2, y2, x3, y3, x4, y4));
  7029.   end;
  7030.  
  7031.   function TGPGraphicsPath.AddBeziers(points: PGPPointF; count: Integer): TStatus;
  7032.   begin
  7033.     result := SetStatus(GdipAddPathBeziers(nativePath, points, count));
  7034.   end;
  7035.  
  7036.   function TGPGraphicsPath.AddBezier(pt1, pt2, pt3, pt4: TGPPoint): TStatus;
  7037.   begin
  7038.     result := AddBezier(pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y);
  7039.   end;
  7040.  
  7041.   function TGPGraphicsPath.AddBezier(x1, y1, x2, y2, x3, y3, x4, y4: Integer): TStatus;
  7042.   begin
  7043.        result := SetStatus(GdipAddPathBezierI(nativePath, x1, y1, x2, y2, x3, y3, x4, y4));
  7044.   end;
  7045.  
  7046.   function TGPGraphicsPath.AddBeziers(points: PGPPoint; count: Integer): TStatus;
  7047.   begin
  7048.        result := SetStatus(GdipAddPathBeziersI(nativePath, points, count));
  7049.   end;
  7050.  
  7051.   function TGPGraphicsPath.AddCurve(points: PGPPointF; count: Integer): TStatus;
  7052.   begin
  7053.     result := SetStatus(GdipAddPathCurve(nativePath, points, count));
  7054.   end;
  7055.  
  7056.   function TGPGraphicsPath.AddCurve(points: PGPPointF; count: Integer;
  7057.     tension: Single): TStatus;
  7058.   begin
  7059.     result := SetStatus(GdipAddPathCurve2(nativePath, points, count, tension));
  7060.   end;
  7061.  
  7062.   function TGPGraphicsPath.AddCurve(points: PGPPointF; count, offset,
  7063.     numberOfSegments: Integer; tension: Single): TStatus;
  7064.   begin
  7065.     result := SetStatus(GdipAddPathCurve3(nativePath, points, count, offset,
  7066.                           numberOfSegments, tension));
  7067.   end;
  7068.  
  7069.   function TGPGraphicsPath.AddCurve(points: PGPPoint; count: Integer): TStatus;
  7070.   begin
  7071.     result := SetStatus(GdipAddPathCurveI(nativePath, points, count));
  7072.   end;
  7073.  
  7074.   function TGPGraphicsPath.AddCurve(points: PGPPoint; count: Integer; tension: Single): TStatus;
  7075.   begin
  7076.     result := SetStatus(GdipAddPathCurve2I(nativePath, points, count, tension));
  7077.   end;
  7078.  
  7079.   function TGPGraphicsPath.AddCurve(points: PGPPoint; count, offset,
  7080.     numberOfSegments: Integer; tension: Single): TStatus;
  7081.   begin
  7082.     result := SetStatus(GdipAddPathCurve3I(nativePath, points, count, offset,
  7083.      numberOfSegments, tension));
  7084.   end;
  7085.  
  7086.   function TGPGraphicsPath.AddClosedCurve(points: PGPPointF; count: Integer): TStatus;
  7087.   begin
  7088.     result := SetStatus(GdipAddPathClosedCurve(nativePath, points, count));
  7089.   end;
  7090.  
  7091.   function TGPGraphicsPath.AddClosedCurve(points: PGPPointF; count: Integer; tension: Single): TStatus;
  7092.   begin
  7093.     result := SetStatus(GdipAddPathClosedCurve2(nativePath, points, count, tension));
  7094.   end;
  7095.  
  7096.   function TGPGraphicsPath.AddClosedCurve(points: PGPPoint; count: Integer): TStatus;
  7097.   begin
  7098.     result := SetStatus(GdipAddPathClosedCurveI(nativePath, points, count));
  7099.   end;
  7100.  
  7101.  
  7102.   function TGPGraphicsPath.AddClosedCurve(points: PGPPoint; count: Integer; tension: Single): TStatus;
  7103.   begin
  7104.        result := SetStatus(GdipAddPathClosedCurve2I(nativePath, points, count, tension));
  7105.   end;
  7106.  
  7107.   function TGPGraphicsPath.AddRectangle(rect: TGPRectF): TStatus;
  7108.   begin
  7109.     result := SetStatus(GdipAddPathRectangle(nativePath,
  7110.                                             rect.X,
  7111.                                             rect.Y,
  7112.                                             rect.Width,
  7113.                                             rect.Height));
  7114.   end;
  7115.  
  7116.   function TGPGraphicsPath.AddRectangles(rects: PGPRectF; count: Integer): TStatus;
  7117.   begin
  7118.     result := SetStatus(GdipAddPathRectangles(nativePath,
  7119.                                              rects,
  7120.                                              count));
  7121.   end;
  7122.  
  7123.   function TGPGraphicsPath.AddRectangle(rect: TGPRect): TStatus;
  7124.   begin
  7125.     result := SetStatus(GdipAddPathRectangleI(nativePath,
  7126.                                             rect.X,
  7127.                                             rect.Y,
  7128.                                             rect.Width,
  7129.                                             rect.Height));
  7130.   end;
  7131.  
  7132.   function TGPGraphicsPath.AddRectangles(rects: PGPRect; count: Integer): TStatus;
  7133.   begin
  7134.     result := SetStatus(GdipAddPathRectanglesI(nativePath,
  7135.                                              rects,
  7136.                                              count));
  7137.   end;
  7138.  
  7139.   function TGPGraphicsPath.AddEllipse(rect: TGPRectF): TStatus;
  7140.   begin
  7141.     result := AddEllipse(rect.X, rect.Y, rect.Width, rect.Height);
  7142.   end;
  7143.  
  7144.   function TGPGraphicsPath.AddEllipse(x, y, width, height: Single): TStatus;
  7145.   begin
  7146.     result := SetStatus(GdipAddPathEllipse(nativePath,
  7147.                                           x,
  7148.                                           y,
  7149.                                           width,
  7150.                                           height));
  7151.   end;
  7152.  
  7153.   function TGPGraphicsPath.AddEllipse(rect: TGPRect): TStatus;
  7154.   begin
  7155.     result := AddEllipse(rect.X, rect.Y, rect.Width, rect.Height);
  7156.   end;
  7157.  
  7158.   function TGPGraphicsPath.AddEllipse(x, y, width, height: Integer): TStatus;
  7159.   begin
  7160.     result := SetStatus(GdipAddPathEllipseI(nativePath,
  7161.                                           x,
  7162.                                           y,
  7163.                                           width,
  7164.                                           height));
  7165.   end;
  7166.  
  7167.   function TGPGraphicsPath.AddPie(rect: TGPRectF; startAngle, sweepAngle: Single): TStatus;
  7168.   begin
  7169.     result := AddPie(rect.X, rect.Y, rect.Width, rect.Height, startAngle,
  7170.                   sweepAngle);
  7171.   end;
  7172.  
  7173.   function TGPGraphicsPath.AddPie(x, y, width, height, startAngle, sweepAngle: Single): TStatus;
  7174.   begin
  7175.     result := SetStatus(GdipAddPathPie(nativePath, x, y, width,
  7176.                                         height, startAngle,
  7177.                                         sweepAngle));
  7178.   end;
  7179.  
  7180.   function TGPGraphicsPath.AddPie(rect: TGPRect; startAngle, sweepAngle: Single): TStatus;
  7181.   begin
  7182.     result := AddPie(rect.X,
  7183.                   rect.Y,
  7184.                   rect.Width,
  7185.                   rect.Height,
  7186.                   startAngle,
  7187.                   sweepAngle);
  7188.   end;
  7189.  
  7190.   function TGPGraphicsPath.AddPie(x, y, width, height: Integer; startAngle, sweepAngle: Single): TStatus;
  7191.   begin
  7192.     result := SetStatus(GdipAddPathPieI(nativePath,
  7193.                                         x,
  7194.                                         y,
  7195.                                         width,
  7196.                                         height,
  7197.                                         startAngle,
  7198.                                         sweepAngle));
  7199.   end;
  7200.  
  7201.   function TGPGraphicsPath.AddPolygon(points: PGPPointF; count: Integer): TStatus;
  7202.   begin
  7203.     result := SetStatus(GdipAddPathPolygon(nativePath, points, count));
  7204.   end;
  7205.  
  7206.   function TGPGraphicsPath.AddPolygon(points: PGPPoint; count: Integer): TStatus;
  7207.   begin
  7208.        result := SetStatus(GdipAddPathPolygonI(nativePath, points,
  7209.                                           count));
  7210.   end;
  7211.  
  7212.   function TGPGraphicsPath.AddPath(addingPath: TGPGraphicsPath; connect: Bool): TStatus;
  7213.   var
  7214.     nativePath2: GpPath;
  7215.   begin
  7216.     nativePath2 := nil;
  7217.     if assigned(addingPath) then nativePath2 := addingPath.nativePath;
  7218.     result := SetStatus(GdipAddPathPath(nativePath, nativePath2, connect));
  7219.   end;
  7220.  
  7221.   function TGPGraphicsPath.AddString(
  7222.       string_: WideString; length: Integer;
  7223.       family : TGPFontFamily;
  7224.       style  : Integer;
  7225.       emSize : Single;  // World units
  7226.       origin : TGPPointF;
  7227.       format : TGPStringFormat): TStatus;
  7228.   var
  7229.     rect : TGPRectF;
  7230.     gpff : GPFONTFAMILY;
  7231.     gpsf : GPSTRINGFORMAT;
  7232.   begin
  7233.     rect.X := origin.X;
  7234.     rect.Y := origin.Y;
  7235.     rect.Width := 0.0;
  7236.     rect.Height := 0.0;
  7237.  
  7238.     gpff := nil;
  7239.     gpsf := nil;
  7240.     if assigned(family) then gpff := family.nativeFamily;
  7241.     if assigned(format) then gpsf := format.nativeFormat;
  7242.     result := SetStatus(GdipAddPathString(nativePath, PWideChar(string_), length, gpff,
  7243.           style, emSize, @rect, gpsf));
  7244.   end;
  7245.  
  7246.   function TGPGraphicsPath.AddString(
  7247.       string_: WideString;
  7248.       length : Integer;
  7249.       family : TGPFontFamily;
  7250.       style  : Integer;
  7251.       emSize : Single;  // World units
  7252.       layoutRect: TGPRectF;
  7253.       format : TGPStringFormat): TStatus;
  7254.   var
  7255.     gpff : GPFONTFAMILY;
  7256.     gpsf : GPSTRINGFORMAT;
  7257.   begin
  7258.     gpff := nil;
  7259.     gpsf := nil;
  7260.     if assigned(family) then gpff := family.nativeFamily;
  7261.     if assigned(format) then gpsf := format.nativeFormat;
  7262.     result := SetStatus(GdipAddPathString( nativePath, PWideChar(string_), length, gpff,
  7263.           style, emSize, @layoutRect, gpsf));
  7264.   end;
  7265.  
  7266.   function TGPGraphicsPath.AddString(
  7267.       string_: WideString;
  7268.       length : Integer;
  7269.       family : TGPFontFamily;
  7270.       style  : Integer;
  7271.       emSize : Single;  // World units
  7272.       origin : TGPPoint;
  7273.       format : TGPStringFormat): TStatus;
  7274.   var
  7275.     rect : TGPRect;
  7276.     gpff : GPFONTFAMILY;
  7277.     gpsf : GPSTRINGFORMAT;
  7278.   begin
  7279.     rect.X := origin.X;
  7280.     rect.Y := origin.Y;
  7281.     rect.Width := 0;
  7282.     rect.Height := 0;
  7283.     gpff := nil;
  7284.     gpsf := nil;
  7285.     if assigned(family) then gpff := family.nativeFamily;
  7286.     if assigned(format) then gpsf := format.nativeFormat;
  7287.     result := SetStatus(GdipAddPathStringI(nativePath, PWideChar(string_), length, gpff,
  7288.           style, emSize, @rect, gpsf));
  7289.   end;
  7290.  
  7291.   function TGPGraphicsPath.AddString(
  7292.       string_: WideString;
  7293.       length : Integer;
  7294.       family : TGPFontFamily;
  7295.       style  : Integer;
  7296.       emSize : Single;  // World units
  7297.       layoutRect: TGPRect;
  7298.       format : TGPStringFormat): TStatus;
  7299.   var
  7300.     gpff : GPFONTFAMILY;
  7301.     gpsf : GPSTRINGFORMAT;
  7302.   begin
  7303.     gpff := nil;
  7304.     gpsf := nil;
  7305.     if assigned(family) then gpff := family.nativeFamily;
  7306.     if assigned(format) then gpsf := format.nativeFormat;
  7307.     result := SetStatus(GdipAddPathStringI( nativePath, PWideChar(string_), length, gpff,
  7308.           style, emSize, @layoutRect, gpsf));
  7309.   end;
  7310.  
  7311.   function TGPGraphicsPath.Transform(matrix: TGPMatrix): TStatus;
  7312.   begin
  7313.       if assigned(matrix) then
  7314.         result := SetStatus(GdipTransformPath(nativePath, matrix.nativeMatrix))
  7315.       else
  7316.         result := Ok;
  7317.   end;
  7318.  
  7319.     // This is not always the tightest bounds.
  7320.  
  7321.   function TGPGraphicsPath.GetBounds(out bounds: TGPRectF; matrix: TGPMatrix = nil; pen: TGPPen = nil): TStatus;
  7322.   var
  7323.     nativeMatrix: GpMatrix;
  7324.     nativePen: GpPen;
  7325.   begin
  7326.     nativeMatrix := nil;
  7327.     nativePen    := nil;
  7328.     if assigned(matrix) then nativeMatrix := matrix.nativeMatrix;
  7329.     if assigned(pen) then nativePen := pen.nativePen;
  7330.  
  7331.     result := SetStatus(GdipGetPathWorldBounds(nativePath, @bounds, nativeMatrix, nativePen));
  7332.   end;
  7333.  
  7334.   function TGPGraphicsPath.GetBounds(out bounds: TGPRect; matrix: TGPMatrix = nil; pen: TGPPen = nil): TStatus;
  7335.   var
  7336.     nativeMatrix: GpMatrix;
  7337.     nativePen: GpPen;
  7338.   begin
  7339.     nativeMatrix := nil;
  7340.     nativePen    := nil;
  7341.     if assigned(matrix) then nativeMatrix := matrix.nativeMatrix;
  7342.     if assigned(pen) then nativePen := pen.nativePen;
  7343.  
  7344.     result := SetStatus(GdipGetPathWorldBoundsI(nativePath, @bounds, nativeMatrix, nativePen));
  7345.   end;
  7346.  
  7347.     // Once flattened, the resultant path is made of line segments and
  7348.     // the original path information is lost.  When matrix is nil the
  7349.     // identity matrix is assumed.
  7350.  
  7351.   function TGPGraphicsPath.Flatten(matrix: TGPMatrix = nil; flatness: Single = FlatnessDefault): TStatus;
  7352.   var nativeMatrix: GpMatrix;
  7353.   begin
  7354.     nativeMatrix := nil;
  7355.     if assigned(matrix) then nativeMatrix := matrix.nativeMatrix;
  7356.     result := SetStatus(GdipFlattenPath(nativePath, nativeMatrix, flatness));
  7357.   end;
  7358.  
  7359.   function TGPGraphicsPath.Widen(pen: TGPPen; matrix: TGPMatrix = nil; flatness: Single = FlatnessDefault): TStatus;
  7360.   var nativeMatrix: GpMatrix;
  7361.   begin
  7362.     nativeMatrix := nil;
  7363.     if assigned(matrix) then nativeMatrix := matrix.nativeMatrix;
  7364.     result := SetStatus(GdipWidenPath(nativePath, pen.nativePen, nativeMatrix, flatness));
  7365.   end;
  7366.  
  7367.   function TGPGraphicsPath.Outline(matrix: TGPMatrix = nil; flatness: Single = FlatnessDefault): TStatus;
  7368.   var nativeMatrix: GpMatrix;
  7369.   begin
  7370.     nativeMatrix := nil;
  7371.     if assigned(matrix) then nativeMatrix := matrix.nativeMatrix;
  7372.     result := SetStatus(GdipWindingModeOutline(nativePath, nativeMatrix, flatness));
  7373.   end;
  7374.  
  7375.     // Once this is called, the resultant path is made of line segments and
  7376.     // the original path information is lost.  When matrix is nil, the
  7377.     // identity matrix is assumed.
  7378.  
  7379.   function TGPGraphicsPath.Warp(destPoints: PGPPointF; count: Integer; srcRect: TGPRectF;
  7380.             matrix: TGPMatrix = nil; warpMode: TWarpMode = WarpModePerspective;
  7381.             flatness: Single = FlatnessDefault): TStatus;
  7382.   var nativeMatrix: GpMatrix;
  7383.   begin
  7384.     nativeMatrix := nil;
  7385.     if assigned(matrix) then nativeMatrix := matrix.nativeMatrix;
  7386.     result := SetStatus(GdipWarpPath(nativePath, nativeMatrix, destPoints,
  7387.                 count, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height,
  7388.                 warpMode, flatness));
  7389.   end;
  7390.  
  7391.   function TGPGraphicsPath.GetPointCount: Integer;
  7392.   var count: Integer;
  7393.   begin
  7394.     count := 0;
  7395.     SetStatus(GdipGetPointCount(nativePath, count));
  7396.     result := count;
  7397.   end;
  7398.  
  7399.   function TGPGraphicsPath.GetPathTypes(types: PBYTE; count: Integer): TStatus;
  7400.   begin
  7401.     result := SetStatus(GdipGetPathTypes(nativePath, types, count));
  7402.   end;
  7403.  
  7404.   function TGPGraphicsPath.GetPathPoints(points: PGPPointF; count: Integer): TStatus;
  7405.   begin
  7406.     result := SetStatus(GdipGetPathPoints(nativePath, points, count));
  7407.   end;
  7408.  
  7409.   function TGPGraphicsPath.GetPathPoints(points: PGPPoint; count: Integer): TStatus;
  7410.   begin
  7411.     result := SetStatus(GdipGetPathPointsI(nativePath, points, count));
  7412.   end;
  7413.  
  7414.   function TGPGraphicsPath.GetLastStatus: TStatus;
  7415.   begin
  7416.     result := lastResult;
  7417.     lastResult := Ok;
  7418.   end;
  7419.  
  7420.   function TGPGraphicsPath.IsVisible(point: TGPPointF; g: TGPGraphics = nil): BOOL;
  7421.   begin
  7422.     result := IsVisible(point.X, point.Y, g);
  7423.   end;
  7424.  
  7425.   function TGPGraphicsPath.IsVisible(x, y: Single; g: TGPGraphics = nil): BOOL;
  7426.   var
  7427.     booln: BOOL;
  7428.     nativeGraphics: GpGraphics;
  7429.   begin
  7430.     booln := FALSE;
  7431.     nativeGraphics := nil;
  7432.     if assigned(g) then nativeGraphics := g.nativeGraphics;
  7433.     SetStatus(GdipIsVisiblePathPoint(nativePath, x, y, nativeGraphics, booln));
  7434.     result := booln;
  7435.   end;
  7436.  
  7437.   function TGPGraphicsPath.IsVisible(point: TGPPoint; g : TGPGraphics = nil): BOOL;
  7438.   begin
  7439.     result := IsVisible(point.X, point.Y, g);
  7440.   end;
  7441.  
  7442.   function TGPGraphicsPath.IsVisible(x, y: Integer; g: TGPGraphics = nil): BOOL;
  7443.   var
  7444.     booln: BOOL;
  7445.     nativeGraphics: GpGraphics;
  7446.   begin
  7447.     booln := FALSE;
  7448.     nativeGraphics := nil;
  7449.     if assigned(g) then nativeGraphics := g.nativeGraphics;
  7450.     SetStatus(GdipIsVisiblePathPointI(nativePath, x, y, nativeGraphics, booln));
  7451.     result := booln;
  7452.   end;
  7453.  
  7454.   function TGPGraphicsPath.IsOutlineVisible(point: TGPPointF; pen: TGPPen; g: TGPGraphics = nil): BOOL;
  7455.   begin
  7456.     result := IsOutlineVisible(point.X, point.Y, pen, g);
  7457.   end;
  7458.  
  7459.   function TGPGraphicsPath.IsOutlineVisible(x, y: Single; pen: TGPPen; g: TGPGraphics = nil): BOOL;
  7460.   var
  7461.     booln: BOOL;
  7462.     nativeGraphics: GpGraphics;
  7463.     nativePen: GpPen;
  7464.   begin
  7465.     booln := FALSE;
  7466.     nativeGraphics := nil;
  7467.     nativePen := nil;
  7468.     if assigned(g) then nativeGraphics := g.nativeGraphics;
  7469.     if assigned(pen) then nativePen := pen.nativePen;
  7470.     SetStatus(GdipIsOutlineVisiblePathPoint(nativePath, x, y, nativePen,
  7471.         nativeGraphics, booln));
  7472.     result := booln;
  7473.   end;
  7474.  
  7475.   function TGPGraphicsPath.IsOutlineVisible(point: TGPPoint; pen: TGPPen; g: TGPGraphics = nil): BOOL;
  7476.   begin
  7477.     result := IsOutlineVisible(point.X, point.Y, pen, g);
  7478.   end;
  7479.  
  7480.   function TGPGraphicsPath.IsOutlineVisible(x, y: Integer; pen: TGPPen; g: TGPGraphics = nil): BOOL;
  7481.   var
  7482.     booln: BOOL;
  7483.     nativeGraphics: GpGraphics;
  7484.     nativePen: GpPen;
  7485.   begin
  7486.     booln := FALSE;
  7487.     nativeGraphics := nil;
  7488.     nativePen := nil;
  7489.     if assigned(g) then nativeGraphics := g.nativeGraphics;
  7490.     if assigned(pen) then nativePen := pen.nativePen;
  7491.     SetStatus(GdipIsOutlineVisiblePathPointI(nativePath, x, y, nativePen,
  7492.        nativeGraphics, booln));
  7493.     result := booln;
  7494.   end;
  7495.  
  7496.   constructor TGPGraphicsPath.Create(path: TGPGraphicsPath);
  7497.   var clonepath: GpPath;
  7498.   begin
  7499.     clonepath := nil;
  7500.     SetStatus(GdipClonePath(path.nativePath, clonepath));
  7501.     SetNativePath(clonepath);
  7502.   end;
  7503.  
  7504.   constructor TGPGraphicsPath.Create(nativePath: GpPath);
  7505.   begin
  7506.     lastResult := Ok;
  7507.     SetNativePath(nativePath);
  7508.   end;
  7509.  
  7510.   procedure TGPGraphicsPath.SetNativePath(nativePath: GpPath);
  7511.   begin
  7512.     self.nativePath := nativePath;
  7513.   end;
  7514.  
  7515.   function TGPGraphicsPath.SetStatus(status: TStatus): TStatus;
  7516.   begin
  7517.     if (status <> Ok) then LastResult := status;
  7518.     result := status;
  7519.   end;
  7520.  
  7521. //--------------------------------------------------------------------------
  7522. // GraphisPathIterator class
  7523. //--------------------------------------------------------------------------
  7524.  
  7525.   constructor TGPGraphicsPathIterator.Create(path: TGPGraphicsPath);
  7526.   var
  7527.     nativePath: GpPath;
  7528.     iter: GpPathIterator;
  7529.   begin
  7530.     nativePath := nil;
  7531.     if assigned(path) then nativePath := path.nativePath;
  7532.     iter := nil;
  7533.     lastResult := GdipCreatePathIter(iter, nativePath);
  7534.     SetNativeIterator(iter);
  7535.   end;
  7536.  
  7537.   destructor TGPGraphicsPathIterator.Destroy;
  7538.   begin
  7539.     GdipDeletePathIter(nativeIterator);
  7540.   end;
  7541.  
  7542.  
  7543.   function TGPGraphicsPathIterator.NextSubpath(out startIndex, endIndex: Integer; out isClosed: bool): Integer;
  7544.   begin
  7545.     SetStatus(GdipPathIterNextSubpath(nativeIterator, result, startIndex, endIndex, isClosed));
  7546.   end;
  7547.  
  7548.   function TGPGraphicsPathIterator.NextSubpath(path: TGPGraphicsPath; out isClosed: BOOL): Integer;
  7549.   var
  7550.     nativePath: GpPath;
  7551.     resultCount: Integer;
  7552.   begin
  7553.     nativePath := nil;
  7554.     if assigned(path) then nativePath := path.nativePath;
  7555.     SetStatus(GdipPathIterNextSubpathPath(nativeIterator, resultCount,
  7556.       nativePath, isClosed));
  7557.     result := resultCount;
  7558.   end;
  7559.  
  7560.   function TGPGraphicsPathIterator.NextPathType(out pathType: TPathPointType; out startIndex, endIndex: Integer): Integer;
  7561.   var
  7562.     resultCount: Integer;
  7563.   begin
  7564.     SetStatus(GdipPathIterNextPathType(nativeIterator, resultCount, @pathType,
  7565.        startIndex, endIndex));
  7566.     result := resultCount;
  7567.   end;
  7568.  
  7569.   function TGPGraphicsPathIterator.NextMarker(out startIndex, endIndex: Integer): Integer;
  7570.   begin
  7571.     SetStatus(GdipPathIterNextMarker(nativeIterator, result, startIndex, endIndex));
  7572.   end;
  7573.  
  7574.   function TGPGraphicsPathIterator.NextMarker(path: TGPGraphicsPath): Integer;
  7575.   var nativePath: GpPath;
  7576.   begin
  7577.     nativePath := nil;
  7578.     if assigned(path) then nativePath := path.nativePath;
  7579.     SetStatus(GdipPathIterNextMarkerPath(nativeIterator, result, nativePath));
  7580.   end;
  7581.  
  7582.   function TGPGraphicsPathIterator.GetCount: Integer;
  7583.   begin
  7584.     SetStatus(GdipPathIterGetCount(nativeIterator, result));
  7585.   end;
  7586.  
  7587.   function TGPGraphicsPathIterator.GetSubpathCount: Integer;
  7588.   begin
  7589.     SetStatus(GdipPathIterGetSubpathCount(nativeIterator, result));
  7590.   end;
  7591.  
  7592.   function TGPGraphicsPathIterator.HasCurve: BOOL;
  7593.   begin
  7594.     SetStatus(GdipPathIterHasCurve(nativeIterator, result));
  7595.   end;
  7596.  
  7597.   procedure TGPGraphicsPathIterator.Rewind;
  7598.   begin
  7599.     SetStatus(GdipPathIterRewind(nativeIterator));
  7600.   end;
  7601.  
  7602.   function TGPGraphicsPathIterator.Enumerate(points: PGPPointF; types: PBYTE;
  7603.     count: Integer): Integer;
  7604.   begin
  7605.     SetStatus(GdipPathIterEnumerate(nativeIterator, result, points, types, count));
  7606.   end;
  7607.  
  7608.   function TGPGraphicsPathIterator.CopyData(points: PGPPointF; types: PBYTE;
  7609.     startIndex, endIndex: Integer): Integer;
  7610.   begin
  7611.     SetStatus(GdipPathIterCopyData(nativeIterator, result, points, types,
  7612.       startIndex, endIndex));
  7613.   end;
  7614.  
  7615.   function TGPGraphicsPathIterator.GetLastStatus: TStatus;
  7616.   begin
  7617.     result := lastResult;
  7618.     lastResult := Ok;
  7619.   end;
  7620.  
  7621.   procedure TGPGraphicsPathIterator.SetNativeIterator(nativeIterator: GpPathIterator);
  7622.   begin
  7623.     self.nativeIterator := nativeIterator;
  7624.   end;
  7625.  
  7626.   function TGPGraphicsPathIterator.SetStatus(status: TStatus): TStatus;
  7627.   begin
  7628.     if (status <> Ok) then lastResult := status;
  7629.     result := status;
  7630.   end;
  7631.  
  7632. //--------------------------------------------------------------------------
  7633. // Path Gradient Brush
  7634. //--------------------------------------------------------------------------
  7635.  
  7636.   constructor TGPPathGradientBrush.Create(points: PGPPointF; count: Integer; wrapMode: TWrapMode = WrapModeClamp);
  7637.   var brush: GpPathGradient;
  7638.   begin
  7639.     brush := nil;
  7640.     lastResult := GdipCreatePathGradient(points, count, wrapMode, brush);
  7641.     SetNativeBrush(brush);
  7642.   end;
  7643.  
  7644.   constructor TGPPathGradientBrush.Create(points: PGPPoint; count: Integer; wrapMode: TWrapMode = WrapModeClamp);
  7645.   var brush: GpPathGradient;
  7646.   begin
  7647.     brush := nil;
  7648.     lastResult := GdipCreatePathGradientI(points, count, wrapMode, brush);
  7649.     SetNativeBrush(brush);
  7650.   end;
  7651.  
  7652.   constructor TGPPathGradientBrush.Create(path: TGPGraphicsPath);
  7653.   var brush: GpPathGradient;
  7654.   begin
  7655.     brush := nil;
  7656.     lastResult := GdipCreatePathGradientFromPath(path.nativePath, brush);
  7657.     SetNativeBrush(brush);
  7658.   end;
  7659.  
  7660.   function TGPPathGradientBrush.GetCenterColor(out Color: TGPColor): TStatus;
  7661.   begin
  7662.     SetStatus(GdipGetPathGradientCenterColor(GpPathGradient(nativeBrush), Color));
  7663.     result := lastResult;
  7664.   end;
  7665.  
  7666.   function TGPPathGradientBrush.SetCenterColor(color: TGPColor): TStatus;
  7667.   begin
  7668.     SetStatus(GdipSetPathGradientCenterColor(GpPathGradient(nativeBrush),color));
  7669.     result := lastResult;
  7670.   end;
  7671.  
  7672.   function TGPPathGradientBrush.GetPointCount: Integer;
  7673.   begin
  7674.     SetStatus(GdipGetPathGradientPointCount(GpPathGradient(nativeBrush), result));
  7675.   end;
  7676.  
  7677.   function TGPPathGradientBrush.GetSurroundColorCount: Integer;
  7678.   begin
  7679.     SetStatus(GdipGetPathGradientSurroundColorCount(GpPathGradient(nativeBrush), result));
  7680.   end;
  7681.  
  7682.   function TGPPathGradientBrush.GetSurroundColors(colors: PARGB; var count: Integer): TStatus;
  7683.   var
  7684.     count1: Integer;
  7685.   begin
  7686.     if not assigned(colors) then
  7687.     begin
  7688.       result := SetStatus(InvalidParameter);
  7689.       exit;
  7690.     end;
  7691.  
  7692.     SetStatus(GdipGetPathGradientSurroundColorCount(GpPathGradient(nativeBrush), count1));
  7693.  
  7694.     if(lastResult <> Ok) then
  7695.     begin
  7696.       result := lastResult;
  7697.       exit;
  7698.     end;
  7699.  
  7700.     if((count < count1) or (count1 <= 0)) then
  7701.     begin
  7702.       result := SetStatus(InsufficientBuffer);
  7703.       exit;
  7704.     end;
  7705.  
  7706.     SetStatus(GdipGetPathGradientSurroundColorsWithCount(GpPathGradient(nativeBrush), colors, count1));
  7707.     if(lastResult = Ok) then
  7708.       count := count1;
  7709.  
  7710.     result := lastResult;
  7711.   end;
  7712.  
  7713.   function TGPPathGradientBrush.SetSurroundColors(colors: PARGB; var count: Integer): TStatus;
  7714.   var
  7715.     count1: Integer;
  7716.   type
  7717.     TDynArrDWORD = array of DWORD;
  7718.   begin
  7719.     if (colors = nil) then
  7720.     begin
  7721.       result := SetStatus(InvalidParameter);
  7722.       exit;
  7723.     end;
  7724.  
  7725.     count1 := GetPointCount;
  7726.  
  7727.     if((count > count1) or (count1 <= 0)) then
  7728.     begin
  7729.       result := SetStatus(InvalidParameter);
  7730.       exit;
  7731.     end;
  7732.  
  7733.     count1 := count;
  7734.  
  7735.     SetStatus(GdipSetPathGradientSurroundColorsWithCount(
  7736.                 GpPathGradient(nativeBrush), colors, count1));
  7737.  
  7738.     if(lastResult = Ok) then count := count1;
  7739.     result := lastResult;
  7740.   end;
  7741.  
  7742.   function TGPPathGradientBrush.GetGraphicsPath(path: TGPGraphicsPath): TStatus;
  7743.   begin
  7744.     if(path = nil) then
  7745.     begin
  7746.       result := SetStatus(InvalidParameter);
  7747.       exit;
  7748.     end;
  7749.     result := SetStatus(GdipGetPathGradientPath(GpPathGradient(nativeBrush), path.nativePath));
  7750.   end;
  7751.  
  7752.   function TGPPathGradientBrush.SetGraphicsPath(path: TGPGraphicsPath): TStatus;
  7753.   begin
  7754.     if(path = nil) then
  7755.     begin
  7756.       result := SetStatus(InvalidParameter);
  7757.       exit;
  7758.     end;
  7759.     result := SetStatus(GdipSetPathGradientPath(GpPathGradient(nativeBrush), path.nativePath));
  7760.   end;
  7761.  
  7762.   function TGPPathGradientBrush.GetCenterPoint(out point: TGPPointF): TStatus;
  7763.   begin
  7764.     result := SetStatus(GdipGetPathGradientCenterPoint(GpPathGradient(nativeBrush), @point));
  7765.   end;
  7766.  
  7767.   function TGPPathGradientBrush.GetCenterPoint(out point: TGPPoint): TStatus;
  7768.   begin
  7769.     result := SetStatus(GdipGetPathGradientCenterPointI(GpPathGradient(nativeBrush), @point));
  7770.   end;
  7771.  
  7772.   function TGPPathGradientBrush.SetCenterPoint(point: TGPPointF): TStatus;
  7773.   begin
  7774.     result := SetStatus(GdipSetPathGradientCenterPoint(GpPathGradient(nativeBrush), @point));
  7775.   end;
  7776.  
  7777.   function TGPPathGradientBrush.SetCenterPoint(point: TGPPoint): TStatus;
  7778.   begin
  7779.     result := SetStatus(GdipSetPathGradientCenterPointI(GpPathGradient(nativeBrush), @point));
  7780.   end;
  7781.  
  7782.   function TGPPathGradientBrush.GetRectangle(out rect: TGPRectF): TStatus;
  7783.   begin
  7784.     result := SetStatus(GdipGetPathGradientRect(GpPathGradient(nativeBrush), @rect));
  7785.   end;
  7786.  
  7787.   function TGPPathGradientBrush.GetRectangle(out rect: TGPRect): TStatus;
  7788.   begin
  7789.     result := SetStatus(GdipGetPathGradientRectI(GpPathGradient(nativeBrush), @rect));
  7790.   end;
  7791.  
  7792.   function TGPPathGradientBrush.SetGammaCorrection(useGammaCorrection: BOOL): TStatus;
  7793.   begin
  7794.     result := SetStatus(GdipSetPathGradientGammaCorrection(GpPathGradient(nativeBrush),
  7795.       useGammaCorrection));
  7796.   end;
  7797.  
  7798.   function TGPPathGradientBrush.GetGammaCorrection: BOOL;
  7799.   begin
  7800.     SetStatus(GdipGetPathGradientGammaCorrection(GpPathGradient(nativeBrush), result));
  7801.   end;
  7802.  
  7803.   function TGPPathGradientBrush.GetBlendCount: Integer;
  7804.   var count: Integer;
  7805.   begin
  7806.     count := 0;
  7807.     SetStatus(GdipGetPathGradientBlendCount(GpPathGradient(nativeBrush), count));
  7808.     result := count;
  7809.   end;
  7810.  
  7811.   function TGPPathGradientBrush.GetBlend(blendFactors, blendPositions:PSingle; count: Integer): TStatus;
  7812.   begin
  7813.     result := SetStatus(GdipGetPathGradientBlend(
  7814.                       GpPathGradient(nativeBrush),
  7815.                       blendFactors, blendPositions, count));
  7816.   end;
  7817.  
  7818.   function TGPPathGradientBrush.SetBlend(blendFactors, blendPositions: PSingle; count: Integer): TStatus;
  7819.   begin
  7820.     result := SetStatus(GdipSetPathGradientBlend(
  7821.                       GpPathGradient(nativeBrush),
  7822.                       blendFactors, blendPositions, count));
  7823.   end;
  7824.  
  7825.   function TGPPathGradientBrush.GetInterpolationColorCount: Integer;
  7826.   var count: Integer;
  7827.   begin
  7828.     count := 0;
  7829.     SetStatus(GdipGetPathGradientPresetBlendCount(GpPathGradient(nativeBrush), count));
  7830.     result := count;
  7831.   end;
  7832.  
  7833.   function TGPPathGradientBrush.SetInterpolationColors(presetColors: PARGB;
  7834.     blendPositions: PSingle; count: Integer): TStatus;
  7835.   var
  7836.     status: TStatus;
  7837.   begin
  7838.     if ((count <= 0) or (presetColors = nil)) then
  7839.     begin
  7840.       result := SetStatus(InvalidParameter);
  7841.       exit;
  7842.     end;
  7843.  
  7844.     status := SetStatus(GdipSetPathGradientPresetBlend(GpPathGradient(nativeBrush),
  7845.                           presetColors, blendPositions, count));
  7846.     result := status;
  7847.   end;
  7848.  
  7849.   function TGPPathGradientBrush.GetInterpolationColors(presetColors: PARGB;
  7850.     blendPositions: PSingle; count: Integer): TStatus;
  7851.   var
  7852.     status: GpStatus;
  7853.     i: Integer;
  7854.     argbs: PARGB;
  7855.   begin
  7856.         if ((count <= 0) or (presetColors = nil)) then
  7857.         begin
  7858.           result := SetStatus(InvalidParameter);
  7859.           exit;
  7860.         end;
  7861.         getmem(argbs, count*SizeOf(ARGB));
  7862.         if (argbs = nil) then
  7863.         begin
  7864.           result := SetStatus(OutOfMemory);
  7865.           exit;
  7866.         end;
  7867.  
  7868.         status := SetStatus(GdipGetPathGradientPresetBlend(nativeBrush, argbs,
  7869.                      blendPositions, count));
  7870.  
  7871.         for i := 0 to count - 1 do
  7872.           TColorDynArray(presetColors)[i] := TColorDynArray(argbs)[i];
  7873.  
  7874.         freemem(argbs);
  7875.  
  7876.         result := status;
  7877.   end;
  7878.  
  7879.   function TGPPathGradientBrush.SetBlendBellShape(focus: Single; scale: Single = 1.0): TStatus;
  7880.   begin
  7881.     result := SetStatus(GdipSetPathGradientSigmaBlend(GpPathGradient(nativeBrush), focus, scale));
  7882.   end;
  7883.  
  7884.   function TGPPathGradientBrush.SetBlendTriangularShape(focus: Single; scale: Single = 1.0): TStatus;
  7885.   begin
  7886.     result := SetStatus(GdipSetPathGradientLinearBlend(GpPathGradient(nativeBrush), focus, scale));
  7887.   end;
  7888.  
  7889.   function TGPPathGradientBrush.GetTransform(matrix: TGPMatrix): TStatus;
  7890.   begin
  7891.     result := SetStatus(GdipGetPathGradientTransform(GpPathGradient(nativeBrush),
  7892.                       matrix.nativeMatrix));
  7893.   end;
  7894.  
  7895.   function TGPPathGradientBrush.SetTransform(matrix: TGPMatrix): TStatus;
  7896.   begin
  7897.     result := SetStatus(GdipSetPathGradientTransform(
  7898.                       GpPathGradient(nativeBrush),
  7899.                       matrix.nativeMatrix));
  7900.   end;
  7901.  
  7902.   function TGPPathGradientBrush.ResetTransform: TStatus;
  7903.   begin
  7904.     result := SetStatus(GdipResetPathGradientTransform(
  7905.                       GpPathGradient(nativeBrush)));
  7906.   end;
  7907.  
  7908.   function TGPPathGradientBrush.MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  7909.   begin
  7910.     result := SetStatus(GdipMultiplyPathGradientTransform(
  7911.                       GpPathGradient(nativeBrush),
  7912.                       matrix.nativeMatrix,
  7913.                       order));
  7914.   end;
  7915.  
  7916.   function TGPPathGradientBrush.TranslateTransform(dx, dy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  7917.   begin
  7918.     result := SetStatus(GdipTranslatePathGradientTransform(
  7919.                       GpPathGradient(nativeBrush),
  7920.                       dx, dy, order));
  7921.   end;
  7922.  
  7923.   function TGPPathGradientBrush.ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  7924.   begin
  7925.     result := SetStatus(GdipScalePathGradientTransform(
  7926.                       GpPathGradient(nativeBrush),
  7927.                       sx, sy, order));
  7928.   end;
  7929.  
  7930.   function TGPPathGradientBrush.RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus;
  7931.   begin
  7932.     result := SetStatus(GdipRotatePathGradientTransform(
  7933.                       GpPathGradient(nativeBrush),
  7934.                       angle, order));
  7935.   end;
  7936.  
  7937.   function TGPPathGradientBrush.GetFocusScales(out xScale, yScale: Single): TStatus;
  7938.   begin
  7939.     result := SetStatus(GdipGetPathGradientFocusScales(
  7940.                       GpPathGradient(nativeBrush), xScale, yScale));
  7941.   end;
  7942.  
  7943.   function TGPPathGradientBrush.SetFocusScales(xScale, yScale: Single): TStatus;
  7944.   begin
  7945.     result := SetStatus(GdipSetPathGradientFocusScales(
  7946.                       GpPathGradient(nativeBrush), xScale, yScale));
  7947.   end;
  7948.  
  7949.   function TGPPathGradientBrush.GetWrapMode: TWrapMode;
  7950.   begin
  7951.     SetStatus(GdipGetPathGradientWrapMode(GpPathGradient(nativeBrush), result));
  7952.   end;
  7953.  
  7954.   function TGPPathGradientBrush.SetWrapMode(wrapMode: TWrapMode): TStatus;
  7955.   begin
  7956.     result := SetStatus(GdipSetPathGradientWrapMode(
  7957.                       GpPathGradient(nativeBrush), wrapMode));
  7958.   end;
  7959.  
  7960.   constructor TGPPathGradientBrush.Create;
  7961.   begin
  7962.      // Î˜crase la fonction parent
  7963.   end;
  7964.  
  7965. initialization
  7966. begin
  7967.   // Initialize StartupInput structure
  7968.   StartupInput.DebugEventCallback := nil;
  7969.   StartupInput.SuppressBackgroundThread := False;
  7970.   StartupInput.SuppressExternalCodecs   := False;
  7971.   StartupInput.GdiplusVersion := 1;
  7972.   // Initialize GDI+
  7973.   GdiplusStartup(gdiplusToken, @StartupInput, nil);
  7974.  
  7975. end;
  7976.  
  7977. finalization
  7978. begin
  7979.  
  7980.   if assigned(GenericSansSerifFontFamily) then GenericSansSerifFontFamily.Free;
  7981.   if assigned(GenericSerifFontFamily) then GenericSerifFontFamily.Free;
  7982.   if assigned(GenericMonospaceFontFamily) then GenericMonospaceFontFamily.Free;
  7983.  
  7984.   if assigned(GenericTypographicStringFormatBuffer) then GenericTypographicStringFormatBuffer.free;
  7985.   if assigned(GenericDefaultStringFormatBuffer) then GenericDefaultStringFormatBuffer.Free;
  7986.  
  7987.   // Close GDI +
  7988.   GdiplusShutdown(gdiplusToken);
  7989. end;
  7990.  
  7991. end.
  7992.