📄 gdipobj.pas
字号:
{******************************************************************}
{ GDI+ Class }
{ }
{ home page : http://www.progdigy.com }
{ email : hgourvest@progdigy.com }
{ }
{ date : 15-02-2002 }
{ }
{ The contents of this file are used with permission, subject to }
{ the Mozilla Public License Version 1.1 (the "License"); you may }
{ not use this file except in compliance with the License. You may }
{ obtain a copy of the License at }
{ http://www.mozilla.org/MPL/MPL-1.1.html }
{ }
{ Software distributed under the License is distributed on an }
{ "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or }
{ implied. See the License for the specific language governing }
{ rights and limitations under the License. }
{ }
{ *****************************************************************}
unit GDIPOBJ;
interface
uses
Windows,
ActiveX,
DirectDraw,
GDIPAPI;
(**************************************************************************\
*
* GDI+ Codec Image APIs
*
\**************************************************************************)
//--------------------------------------------------------------------------
// Codec Management APIs
//--------------------------------------------------------------------------
function GetImageDecodersSize(out numDecoders, size: UINT): TStatus;
function GetImageDecoders(numDecoders, size: UINT;
decoders: PImageCodecInfo): TStatus;
function GetImageEncodersSize(out numEncoders, size: UINT): TStatus;
function GetImageEncoders(numEncoders, size: UINT;
encoders: PImageCodecInfo): TStatus;
(**************************************************************************\
*
* Private GDI+ header file.
*
\**************************************************************************)
//---------------------------------------------------------------------------
// GDI+ classes for forward reference
//---------------------------------------------------------------------------
type
TGPGraphics = class;
TGPPen = class;
TGPBrush = class;
TGPMatrix = class;
TGPBitmap = class;
TGPMetafile = class;
TGPFontFamily = class;
TGPGraphicsPath = class;
TGPRegion = class;
TGPImage = class;
TGPHatchBrush = class;
TGPSolidBrush = class;
TGPLinearGradientBrush = class;
TGPPathGradientBrush = class;
TGPFont = class;
TGPFontCollection = class;
TGPInstalledFontCollection = class;
TGPPrivateFontCollection = class;
TGPImageAttributes = class;
TGPCachedBitmap = class;
(**************************************************************************\
*
* GDI+ Region, Font, Image, CustomLineCap class definitions.
*
\**************************************************************************)
TGPRegion = class(TGdiplusBase)
protected
nativeRegion: GpRegion;
lastResult: TStatus;
function SetStatus(status: TStatus): TStatus;
procedure SetNativeRegion(nativeRegion: GpRegion);
constructor Create(nativeRegion: GpRegion); reintroduce; overload;
public
constructor Create; reintroduce; overload;
constructor Create(rect: TGPRectF); reintroduce; overload;
constructor Create(rect: TGPRect); reintroduce; overload;
constructor Create(path: TGPGraphicsPath); reintroduce; overload;
constructor Create(regionData: PBYTE; size: Integer); reintroduce; overload;
constructor Create(hRgn: HRGN); reintroduce; overload;
function FromHRGN(hRgn: HRGN): TGPRegion;
destructor Destroy; override;
function Clone: TGPRegion;
function MakeInfinite: TStatus;
function MakeEmpty: TStatus;
function GetDataSize: UINT;
// buffer - where to put the data
// bufferSize - how big the buffer is (should be at least as big as GetDataSize())
// sizeFilled - if not NULL, this is an OUT param that says how many bytes
// of data were written to the buffer.
function GetData(buffer: PBYTE; bufferSize: UINT;
sizeFilled: PUINT = nil): TStatus;
function Intersect(const rect: TGPRect): TStatus; overload;
function Intersect(const rect: TGPRectF): TStatus; overload;
function Intersect(path: TGPGraphicsPath): TStatus; overload;
function Intersect(region: TGPRegion): TStatus; overload;
function Union(const rect: TGPRect): TStatus; overload;
function Union(const rect: TGPRectF): TStatus; overload;
function Union(path: TGPGraphicsPath): TStatus; overload;
function Union(region: TGPRegion): TStatus; overload;
function Xor_(const rect: TGPRect): TStatus; overload;
function Xor_(const rect: TGPRectF): TStatus; overload;
function Xor_(path: TGPGraphicsPath): TStatus; overload;
function Xor_(region: TGPRegion): TStatus; overload;
function Exclude(const rect: TGPRect): TStatus; overload;
function Exclude(const rect: TGPRectF): TStatus; overload;
function Exclude(path: TGPGraphicsPath): TStatus; overload;
function Exclude(region: TGPRegion): TStatus; overload;
function Complement(const rect: TGPRect): TStatus; overload;
function Complement(const rect: TGPRectF): TStatus; overload;
function Complement(path: TGPGraphicsPath): TStatus; overload;
function Complement(region: TGPRegion): TStatus; overload;
function Translate(dx, dy: Single): TStatus; overload;
function Translate(dx, dy: Integer): TStatus; overload;
function Transform(matrix: TGPMatrix): TStatus;
function GetBounds(out rect: TGPRect; g: TGPGraphics): TStatus; overload;
function GetBounds(out rect: TGPRectF; g: TGPGraphics): TStatus; overload;
function GetHRGN(g: TGPGraphics): HRGN;
function IsEmpty(g: TGPGraphics): BOOL;
function IsInfinite(g: TGPGraphics): BOOL ;
function IsVisible(x, y: Integer; g: TGPGraphics = nil): BOOL; overload;
function IsVisible(const point: TGPPoint; g: TGPGraphics = nil): BOOL; overload;
function IsVisible(x, y: Single; g: TGPGraphics = nil): BOOL; overload;
function IsVisible(const point: TGPPointF; g: TGPGraphics = nil): BOOL; overload;
function IsVisible(x, y, width, height: Integer; g: TGPGraphics): BOOL; overload;
function IsVisible(const rect: TGPRect; g: TGPGraphics = nil): BOOL; overload;
function IsVisible(x, y, width, height: Single; g: TGPGraphics = nil): BOOL; overload;
function IsVisible(const rect: TGPRectF; g: TGPGraphics = nil): BOOL; overload;
function Equals(region: TGPRegion; g: TGPGraphics): BOOL;
function GetRegionScansCount(matrix: TGPMatrix): UINT;
function GetRegionScans(matrix: TGPMatrix ;rects: PGPRectF; out count: Integer): TStatus; overload;
function GetRegionScans(matrix: TGPMatrix; rects: PGPRect; out count: Integer): TStatus; overload;
function GetLastStatus: TStatus;
end;
//--------------------------------------------------------------------------
// FontFamily
//--------------------------------------------------------------------------
TGPFontFamily = class(TGdiplusBase)
protected
nativeFamily: GpFontFamily;
lastResult: TStatus;
function SetStatus(status: TStatus): TStatus;
constructor Create(nativeOrig: GpFontFamily;
status: TStatus); reintroduce; overload;
public
constructor Create; reintroduce; overload;
constructor Create(name: WideString; fontCollection: TGPFontCollection = nil); reintroduce; overload;
destructor Destroy; override;
class function GenericSansSerif: TGPFontFamily;
class function GenericSerif: TGPFontFamily;
class function GenericMonospace: TGPFontFamily;
function GetFamilyName(out name: String; language: LANGID = 0): TStatus;
function Clone: TGPFontFamily;
function IsAvailable: BOOL;
function IsStyleAvailable(style: Integer): BOOL;
function GetEmHeight(style: Integer): UINT16;
function GetCellAscent(style: Integer): UINT16;
function GetCellDescent(style: Integer): UINT16;
function GetLineSpacing(style: Integer): UINT16;
function GetLastStatus: TStatus;
end;
//--------------------------------------------------------------------------
// Font Collection
//--------------------------------------------------------------------------
TGPFontCollection = class(TGdiplusBase)
protected
nativeFontCollection: GpFontCollection;
lastResult: TStatus;
function SetStatus(status: TStatus): TStatus;
public
constructor Create;
destructor Destroy; override;
function GetFamilyCount: Integer;
function GetFamilies(numSought: Integer; out gpfamilies: array of TGPFontFamily;
out numFound: Integer): TStatus;
function GetLastStatus: TStatus;
end;
TGPInstalledFontCollection = class(TGPFontCollection)
public
constructor Create; reintroduce;
destructor Destroy; override;
end;
TGPPrivateFontCollection = class(TGPFontCollection)
public
constructor Create; reintroduce;
destructor destroy; override;
function AddFontFile(filename: WideString): TStatus;
function AddMemoryFont(memory: Pointer; length: Integer): TStatus;
end;
//--------------------------------------------------------------------------
// TFont
//--------------------------------------------------------------------------
TGPFont = class(TGdiplusBase)
protected
nativeFont: GpFont;
lastResult: TStatus;
procedure SetNativeFont(Font: GpFont);
function SetStatus(status: TStatus): TStatus;
constructor Create(font: GpFont; status: TStatus); overload;
public
constructor Create(hdc: HDC); reintroduce; overload;
constructor Create(hdc: HDC; logfont: PLogFontA); reintroduce; overload;
constructor Create(hdc: HDC; logfont: PLogFontW); reintroduce; overload;
constructor Create(hdc: HDC; hfont: HFONT); reintroduce; overload;
constructor Create(family: TGPFontFamily; emSize: Single;
style: TFontStyle = FontStyleRegular;
unit_: TUnit = UnitPoint); reintroduce; overload;
constructor Create(familyName: WideString; emSize: Single;
style: TFontStyle = FontStyleRegular; unit_: TUnit = UnitPoint;
fontCollection: TGPFontCollection = nil); reintroduce; overload;
function GetLogFontA(g: TGPGraphics; out logfontA: TLogFontA): TStatus;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -