diff --git a/.gitignore b/.gitignore index e3ea8f1..6e4e47a 100644 --- a/.gitignore +++ b/.gitignore @@ -73,3 +73,4 @@ OtherStuff thirdparty prevcode WinXHelper +*.ini diff --git a/ICON_1.res b/ICON_1.res new file mode 100644 index 0000000..673ac03 Binary files /dev/null and b/ICON_1.res differ diff --git a/ICON_2.res b/ICON_2.res new file mode 100644 index 0000000..bf08ada Binary files /dev/null and b/ICON_2.res differ diff --git a/ICON_3.res b/ICON_3.res new file mode 100644 index 0000000..4c152c7 Binary files /dev/null and b/ICON_3.res differ diff --git a/Manifest1.res b/Manifest1.res new file mode 100644 index 0000000..9b6b273 Binary files /dev/null and b/Manifest1.res differ diff --git a/PNGIMAGE_1.res b/PNGIMAGE_1.res new file mode 100644 index 0000000..2f8f844 Binary files /dev/null and b/PNGIMAGE_1.res differ diff --git a/PNGIMAGE_2.res b/PNGIMAGE_2.res new file mode 100644 index 0000000..ea10d65 Binary files /dev/null and b/PNGIMAGE_2.res differ diff --git a/WinXCorners.bdsproj b/WinXCorners.bdsproj new file mode 100644 index 0000000..a3bd942 --- /dev/null +++ b/WinXCorners.bdsproj @@ -0,0 +1,175 @@ + + + + + + + + + + + + WinXCorners.dpr + + + 7.0 + + + 8 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + True + True + WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; + + False + + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + False + False + False + True + True + True + True + True + True + + + + 0 + 0 + False + 1 + False + False + False + 16384 + 1048576 + 4194304 + + + + + + + + + vcl;rtl;vclx;dbrtl;vcldb;adortl;dbxcds;dbexpress;xmlrtl;vclie;inet;inetdbbde;inetdbxpress;VclSmp;dsnap;bdertl;teeui;teedb;tee;vcldbx;vclactnband + + + False + + + + + + False + + + True + False + + + + $00000000 + + + + True + False + 1 + 3 + 0 + 0 + False + False + False + False + False + 1033 + 1252 + + + + + 1.3.0.0 + + + + + + 1.0.0.0 + + + + diff --git a/WinXCorners.dpr b/WinXCorners.dpr index c4d59d8..2f0b6f1 100644 --- a/WinXCorners.dpr +++ b/WinXCorners.dpr @@ -1,42 +1,25 @@ program WinXCorners; - - - - - - - - - - - - - - - - - - - - - -{$R *.dres} +{.$R *.dres} uses - madExcept, - madLinkDisAsm, - madListHardware, - madListProcesses, - madListModules, - Vcl.Forms, - Winapi.Windows, + Forms, + Windows, Main in 'Main.pas' {frmMain}, frmSettings in 'frmSettings.pas' {frmTrayPopup}, XCombobox in 'XCombobox.pas', osdgui in 'osdgui.pas' {frmOSD}, - frmAdvanced in 'frmAdvanced.pas' {frmAdvSettings}; + frmAdvanced in 'frmAdvanced.pas' {frmAdvSettings}, + functions in 'functions.pas'; {$R *.res} +{$R PNGIMAGE_1.res} +{$R PNGIMAGE_2.res} +{$R ICON_1.res} +{$R ICON_2.res} +{$R ICON_3.res} +{$ifdef ver360} +{$R Manifest1.res} +{$endif} var AppHandle: HWND; @@ -50,7 +33,7 @@ begin Application.Initialize; Application.ShowMainForm := False; - Application.MainFormOnTaskbar := False; +// Application.MainFormOnTaskbar := False; Application.Title := 'WinXCorners'; Application.CreateForm(TfrmMain, frmMain); Application.CreateForm(TfrmTrayPopup, frmTrayPopup); diff --git a/WinXCorners.dproj b/WinXCorners.dproj index 34ed40a..a3c6c7f 100644 --- a/WinXCorners.dproj +++ b/WinXCorners.dproj @@ -1,7 +1,7 @@  {F8C9BBB6-7EFC-4526-9D5E-53B8277C8413} - 18.6 + 20.1 VCL WinXCorners.dpr True @@ -18,6 +18,11 @@ Base true + + true + Base + true + true Base @@ -29,6 +34,12 @@ true true + + true + Cfg_1 + true + true + true Base @@ -40,6 +51,12 @@ true true + + true + Cfg_2 + true + true + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 3082 @@ -53,6 +70,8 @@ false false false + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png WinXCorners_Icon3.ico @@ -64,6 +83,14 @@ $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png $(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png + + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + Debug + true + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + 1033 + $(BDS)\bin\default_app.manifest + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 3082 @@ -86,6 +113,9 @@ madExcept;$(DCC_Define) 3 + + PerMonitorV2 + CompanyName=;FileDescription=;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=;ProductVersion=1.0.0.0;Comments= 3082 @@ -95,10 +125,9 @@ 0 - otherstuff\aaaab.ico + WinXCorners_Icon3.ico true 1033 - true Debug PerMonitor madExcept;$(DCC_Define) @@ -106,6 +135,9 @@ 2 true + + PerMonitorV2 + MainSource @@ -126,6 +158,7 @@
frmAdvSettings
dfm + ICON Icon_1 @@ -146,10 +179,6 @@ ICON Icon_3 - - Cfg_2 - Base - Base @@ -157,6 +186,10 @@ Cfg_1 Base + + Cfg_2 + Base +
Delphi.Personality.12 @@ -167,77 +200,101 @@ WinXCorners.dpr - Microsoft Office 2000 Sample Automation Server Wrapper Components - Microsoft Office XP Sample Automation Server Wrapper Components + Embarcadero C++Builder Office 2000 Servers Package + Embarcadero C++Builder Office XP Servers Package + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + Ethea IconFontsImageList FMX components + Drag and Drop Component Suite + Delphi Tag Editor + TurboPack DOSCommand Designtime Package for Delphi + JCL Package containing common units for JCL Experts + JCL Debug IDE extension + JCL Project Analyzer + JCL Open and Save IDE dialogs with favorite folders + JCL Package containing repository wizards + JCL Debug Window of XMM registers + JCL Stack Trace Viewer + Mustangpeak Common Library Delphi DesignTime Package + Graphics32 Design Time Package + Png components for Delphi designtime + HGM Components + Delphi4Python - Export forms for Python + Python4Delphi - Design-time Engine Package + Python4Delphi - Design-Time Engine Package for VCL + Python4Delphi - Design-time Engine Package for FMX + P4D - Python Environments Project Menu Extension + P4D - Python Environments + Ethea IconFontsImageList VCL components + P4D AI&ML extension for Python packages + P4D Data Sciences - RemBG + P4D Data Sciences - PyQT5 + P4D Data Sciences - PSUtil + P4D Data Sciences - Pillow + P4D Data Sciences - MoviePy + P4D Data Sciences - H5Py + P4D Data Sciences - Boto3 + THtmlViewer, TFrameViewer, and TFrameBrowser + GLScene Engine + GLScene GPU Computing + CEF4Delphi + Internet Embedded Web Browser Components + File C:\Users\vhanl\Documents\Skia4Delphi\Library\RAD Studio 11 Alexandria\Win32\Release\Bpl\Skia.Package.FMX280.bpl not found + File C:\Users\vhanl\Documents\Skia4Delphi\Library\RAD Studio 11 Alexandria\Win32\Release\Bpl\Skia.Package.VCL280.bpl not found + File C:\Users\vhanl\Documents\Skia4Delphi\Library\RAD Studio 11 Alexandria\Win32\Release\Bpl\Skia.Package.FMX.Designtime280.bpl not found + File C:\Users\vhanl\Documents\Skia4Delphi\Library\RAD Studio 11 Alexandria\Win32\Release\Bpl\Skia.Package.VCL.Designtime280.bpl not found + KControls Development Suite - design time package + Vue Design Components for Firemonkey + priyatna.org - NiceGrid + P4D Data Sciences - MatplotLib + P4D Data Sciences - NLTK + P4D Data Sciences - ONNXRuntime + P4D Data Sciences - SciPy + P4D Data Sciences - NumPy + P4D Data Sciences - Scikit-Learn + P4D Data Sciences - PyTorch + P4D Data Sciences - OpenCV + P4D Data Sciences - TensorFlow + P4D Data Sciences - Pandas + P4D Data Sciences - Keras + P4D Data Sciences - PyAnime4k + DelphiWebScript Runtime + JVEsoft Cross Platform Infrastructure Component Suite + Alcinoe + Zeos Database Components + TFrameStand and TFormStand Designtime Package + Overbyte ICS FMX Design-Time Package for Delphi 11.0 + Chrome Tabs + ATTabs - lite OS-independant tabs + DCPcrypt cryptographic component library v2 BETA 3 + TTextEditor control package - designtime + Winsoft PDFium Component Suite + TurboPack SynEdit Delphi designtime package + zControls + MustangPeak EasyListview Designtime Package + VirtualTreeView Controls + Virtual Shell Tools Delphi Designtime Package + Toolbar2000 Design Package (Jordan Russell) + Toolbar2000 -- SpTBXLib Design Package + Ethea SVGIconImageList VCL components + Ethea SVGIconImageList FMX components + MWK - SVG + MWK - SVG-Unterstützung Designtime + SynWeb component suite - - - - .\ - true - - - - - .\ - true - - - - - .\ - true - - - - - .\ - true - - - - - .\ - true - - - - - WinXCorners.exe - true - - - - - .\ - true - - - - - .\ - true - - - - - WinXCorners.exe - true - - - - - .\ - true - - - - - .\ - true - - + + + + + + + + + + + + 1 @@ -250,10 +307,14 @@ 0 - + classes - 1 + 64 + + + classes + 64 @@ -261,10 +322,8 @@ res\xml 1 - - - - library\lib\armeabi-v7a + + res\xml 1 @@ -273,97 +332,382 @@ library\lib\armeabi 1 + + library\lib\armeabi + 1 + + + + + library\lib\armeabi-v7a + 1 + library\lib\mips 1 + + library\lib\mips + 1 + - library\lib\armeabi-v7a 1 + + library\lib\arm64-v8a + 1 + + + + + library\lib\armeabi-v7a + 1 + res\drawable 1 + + res\drawable + 1 + + + + + res\drawable-anydpi-v21 + 1 + + + res\drawable-anydpi-v21 + 1 + res\values 1 + + res\values + 1 + res\values-v21 1 + + res\values-v21 + 1 + + + + + res\values-v31 + 1 + + + res\values-v31 + 1 + + + + + res\drawable-anydpi-v26 + 1 + + + res\drawable-anydpi-v26 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-anydpi-v33 + 1 + + + res\drawable-anydpi-v33 + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\values-night-v21 + 1 + + + res\values-night-v21 + 1 + res\drawable 1 + + res\drawable + 1 + res\drawable-xxhdpi 1 + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + res\drawable-ldpi 1 + + res\drawable-ldpi + 1 + res\drawable-mdpi 1 + + res\drawable-mdpi + 1 + res\drawable-hdpi 1 + + res\drawable-hdpi + 1 + res\drawable-xhdpi 1 + + res\drawable-xhdpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + res\drawable-small 1 + + res\drawable-small + 1 + res\drawable-normal 1 + + res\drawable-normal + 1 + res\drawable-large 1 + + res\drawable-large + 1 + res\drawable-xlarge 1 + + res\drawable-xlarge + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\drawable-anydpi-v24 + 1 + + + res\drawable-anydpi-v24 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-night-anydpi-v21 + 1 + + + res\drawable-night-anydpi-v21 + 1 + + + + + res\drawable-anydpi-v31 + 1 + + + res\drawable-anydpi-v31 + 1 + + + + + res\drawable-night-anydpi-v31 + 1 + + + res\drawable-night-anydpi-v31 + 1 + @@ -388,6 +732,11 @@ 1 .framework + + Contents\MacOS + 1 + .framework + 0 @@ -401,7 +750,7 @@ 1 .dylib - + 1 .dylib @@ -415,6 +764,11 @@ 1 .dylib + + Contents\MacOS + 1 + .dylib + 0 .dll;.bpl @@ -429,7 +783,7 @@ 1 .dylib - + 1 .dylib @@ -443,6 +797,11 @@ 1 .dylib + + Contents\MacOS + 1 + .dylib + 0 .bpl @@ -452,13 +811,16 @@ 0 + + 0 + 0 0 - + 0 @@ -469,247 +831,421 @@ Contents\Resources\StartUp\ 0 + + Contents\Resources\StartUp\ + 0 + 0 - - + + 1 - + 1 - + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 - - + + + ..\ 1 - + + ..\ 1 - + + ..\ + 1 + + + + + Contents + 1 + + + Contents + 1 + + + Contents 1 - + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + 1 1 - + + 1 + + + 1 + + + Contents\MacOS + 1 + + + Contents\MacOS + 1 + + + Contents\MacOS + 1 + + + 0 + + + + + library\lib\armeabi-v7a + 1 + + + + + 1 + + 1 - + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 - + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF 1 - + + ..\ 1 + ..\ 1 - + + ..\ 1 - + 1 1 - + 1 - + + + ..\$(PROJECTNAME).launchscreen + 64 + + + ..\$(PROJECTNAME).launchscreen + 64 + + + 1 1 - + 1 - - + + + Assets + 1 + + + Assets 1 - - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + + + Assets + 1 + + + Assets 1 + + - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - ..\ + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 + + - ..\ + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - ..\ + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - ..\ + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - Contents + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - Contents + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - Contents\Resources + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - Contents\Resources + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - - - library\lib\armeabi-v7a + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - Contents\MacOS + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - Contents\MacOS + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - 0 + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 - - + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - Assets + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - Assets + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - - Assets + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - Assets + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset 1 - - + + - + + + - - + + + True + False False diff --git a/WinXCorners.res b/WinXCorners.res index e718720..c122fee 100644 Binary files a/WinXCorners.res and b/WinXCorners.res differ diff --git a/WinXHelper.bdsproj b/WinXHelper.bdsproj new file mode 100644 index 0000000..0b870bd --- /dev/null +++ b/WinXHelper.bdsproj @@ -0,0 +1,175 @@ + + + + + + + + + + + + WinXHelper.dpr + + + 7.0 + + + 8 + 0 + 1 + 1 + 0 + 0 + 1 + 1 + 1 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + 0 + 0 + 0 + 0 + 0 + 1 + 0 + 1 + 1 + 1 + True + True + WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE; + + False + + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + True + False + False + False + True + True + True + True + True + True + + + + 0 + 0 + False + 1 + False + False + False + 16384 + 1048576 + 4194304 + + + + + + + + + + + + False + + + + + + False + + + True + False + + + + $00000000 + + + + False + False + 1 + 0 + 0 + 0 + False + False + False + False + False + 2058 + 1252 + + + + + 1.0.0.0 + + + + + + 1.0.0.0 + + + + diff --git a/WinXHelper.dpr b/WinXHelper.dpr index 362f4c9..8a34a2e 100644 --- a/WinXHelper.dpr +++ b/WinXHelper.dpr @@ -35,6 +35,7 @@ var TargetWnd: THandle; Msg: PCopyDataStruct; // MsgStr: String; + aNil: Cardinal; begin //if Code < 0 then if (Code < 0) or (Code = HC_NOREMOVE) then @@ -61,7 +62,8 @@ begin Msg^.cbData := SizeOf(TMouseHookStruct) + 1; Msg^.lpData := PMouseHookStruct(lParam); //PostMessage(TargetWnd, WM_COPYDATA, CurWnd, Integer(Msg)); - SendMessageTimeout(TargetWnd, WM_COPYDATA, 0, Integer(Msg), SMTO_ABORTIFHUNG, 50, nil); + aNil := 0; + SendMessageTimeout(TargetWnd, WM_COPYDATA, 0, Integer(Msg), SMTO_ABORTIFHUNG, 50, aNil); Dispose(Msg); end; end; @@ -98,6 +100,8 @@ begin end; procedure RunHook; stdcall; +const + WH_MOUSE_LL = 14; begin GlobalData^.HookHandle := SetWindowsHookEx(WH_MOUSE_LL, @HookProc, HInstance, 0); if GlobalData^.HookHandle = INVALID_HANDLE_VALUE then diff --git a/WinXHelper.res b/WinXHelper.res index 59bd1db..e726929 100644 Binary files a/WinXHelper.res and b/WinXHelper.res differ diff --git a/compile.cmd b/compile.cmd index c46a03c..6eec8a7 100644 --- a/compile.cmd +++ b/compile.cmd @@ -1,12 +1,13 @@ @echo off -SET MSBUILD="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" -SET RSVARS="C:\Program Files (x86)\Embarcadero\Studio\20.0\bin\rsvars.bat" +rem SET MSBUILD="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe" +SET MSBUILD="c:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin\MSBuild.exe" +SET RSVARS="C:\Program Files (x86)\Embarcadero\Studio\23.0\bin\rsvars.bat" SET PROJECT=WinXCorners.dproj call %RSVARS% -%MSBUILD% %PROJECT% "/t:Clean,Make" "/p:config=Debug" "/verbosity:minimal" +%MSBUILD% %PROJECT% "/t:Clean,Make" "/p:config=Release" "/verbosity:minimal" if %ERRORLEVEL% NEQ 0 GOTO END diff --git a/functions.pas b/functions.pas index 444b93f..9b6bbe6 100644 --- a/functions.pas +++ b/functions.pas @@ -17,8 +17,7 @@ interface uses -Windows, Classes, TlHelp32, PsAPI, SysUtils, Registry, Graphics, DWMApi, PNGImage{, -UXTHeme, Themes} {uxtheme and themes for rendering text on glass }, +Windows, Classes, TlHelp32, PsAPI, SysUtils, Registry, Graphics, DWMApi, PNGImage, OleAcc, Variants, DirectDraw, ActiveX; const diff --git a/obj/JCAPIMIN.OBJ b/obj/JCAPIMIN.OBJ new file mode 100644 index 0000000..c0dbacc Binary files /dev/null and b/obj/JCAPIMIN.OBJ differ diff --git a/obj/JCAPISTD.OBJ b/obj/JCAPISTD.OBJ new file mode 100644 index 0000000..3e5b62d Binary files /dev/null and b/obj/JCAPISTD.OBJ differ diff --git a/obj/JCCOEFCT.OBJ b/obj/JCCOEFCT.OBJ new file mode 100644 index 0000000..6f1038d Binary files /dev/null and b/obj/JCCOEFCT.OBJ differ diff --git a/obj/JCCOLOR.OBJ b/obj/JCCOLOR.OBJ new file mode 100644 index 0000000..417440e Binary files /dev/null and b/obj/JCCOLOR.OBJ differ diff --git a/obj/JCDCTMGR.OBJ b/obj/JCDCTMGR.OBJ new file mode 100644 index 0000000..d799844 Binary files /dev/null and b/obj/JCDCTMGR.OBJ differ diff --git a/obj/JCHUFF.OBJ b/obj/JCHUFF.OBJ new file mode 100644 index 0000000..8052ab0 Binary files /dev/null and b/obj/JCHUFF.OBJ differ diff --git a/obj/JCINIT.OBJ b/obj/JCINIT.OBJ new file mode 100644 index 0000000..4cf70af Binary files /dev/null and b/obj/JCINIT.OBJ differ diff --git a/obj/JCMAINCT.OBJ b/obj/JCMAINCT.OBJ new file mode 100644 index 0000000..43971d2 Binary files /dev/null and b/obj/JCMAINCT.OBJ differ diff --git a/obj/JCMARKER.OBJ b/obj/JCMARKER.OBJ new file mode 100644 index 0000000..e0de11d Binary files /dev/null and b/obj/JCMARKER.OBJ differ diff --git a/obj/JCMASTER.OBJ b/obj/JCMASTER.OBJ new file mode 100644 index 0000000..917b384 Binary files /dev/null and b/obj/JCMASTER.OBJ differ diff --git a/obj/JCOMAPI.OBJ b/obj/JCOMAPI.OBJ new file mode 100644 index 0000000..e779ea5 Binary files /dev/null and b/obj/JCOMAPI.OBJ differ diff --git a/obj/JCPARAM.OBJ b/obj/JCPARAM.OBJ new file mode 100644 index 0000000..7a69214 Binary files /dev/null and b/obj/JCPARAM.OBJ differ diff --git a/obj/JCPHUFF.OBJ b/obj/JCPHUFF.OBJ new file mode 100644 index 0000000..65de058 Binary files /dev/null and b/obj/JCPHUFF.OBJ differ diff --git a/obj/JCPREPCT.OBJ b/obj/JCPREPCT.OBJ new file mode 100644 index 0000000..7080e3e Binary files /dev/null and b/obj/JCPREPCT.OBJ differ diff --git a/obj/JCSAMPLE.OBJ b/obj/JCSAMPLE.OBJ new file mode 100644 index 0000000..5c38fad Binary files /dev/null and b/obj/JCSAMPLE.OBJ differ diff --git a/obj/JCTRANS.OBJ b/obj/JCTRANS.OBJ new file mode 100644 index 0000000..123d555 Binary files /dev/null and b/obj/JCTRANS.OBJ differ diff --git a/obj/JDAPIMIN.OBJ b/obj/JDAPIMIN.OBJ new file mode 100644 index 0000000..7c6f029 Binary files /dev/null and b/obj/JDAPIMIN.OBJ differ diff --git a/obj/JDAPISTD.OBJ b/obj/JDAPISTD.OBJ new file mode 100644 index 0000000..a191de9 Binary files /dev/null and b/obj/JDAPISTD.OBJ differ diff --git a/obj/JDATADST.OBJ b/obj/JDATADST.OBJ new file mode 100644 index 0000000..dd68c05 Binary files /dev/null and b/obj/JDATADST.OBJ differ diff --git a/obj/JDATASRC.OBJ b/obj/JDATASRC.OBJ new file mode 100644 index 0000000..423fa02 Binary files /dev/null and b/obj/JDATASRC.OBJ differ diff --git a/obj/JDCOEFCT.OBJ b/obj/JDCOEFCT.OBJ new file mode 100644 index 0000000..e0ee8d8 Binary files /dev/null and b/obj/JDCOEFCT.OBJ differ diff --git a/obj/JDCOLOR.OBJ b/obj/JDCOLOR.OBJ new file mode 100644 index 0000000..bd24056 Binary files /dev/null and b/obj/JDCOLOR.OBJ differ diff --git a/obj/JDDCTMGR.OBJ b/obj/JDDCTMGR.OBJ new file mode 100644 index 0000000..80e98dd Binary files /dev/null and b/obj/JDDCTMGR.OBJ differ diff --git a/obj/JDHUFF.OBJ b/obj/JDHUFF.OBJ new file mode 100644 index 0000000..2b88232 Binary files /dev/null and b/obj/JDHUFF.OBJ differ diff --git a/obj/JDINPUT.OBJ b/obj/JDINPUT.OBJ new file mode 100644 index 0000000..8b82bc9 Binary files /dev/null and b/obj/JDINPUT.OBJ differ diff --git a/obj/JDMAINCT.OBJ b/obj/JDMAINCT.OBJ new file mode 100644 index 0000000..a38a441 Binary files /dev/null and b/obj/JDMAINCT.OBJ differ diff --git a/obj/JDMARKER.OBJ b/obj/JDMARKER.OBJ new file mode 100644 index 0000000..96507b0 Binary files /dev/null and b/obj/JDMARKER.OBJ differ diff --git a/obj/JDMASTER.OBJ b/obj/JDMASTER.OBJ new file mode 100644 index 0000000..799b24d Binary files /dev/null and b/obj/JDMASTER.OBJ differ diff --git a/obj/JDMERGE.OBJ b/obj/JDMERGE.OBJ new file mode 100644 index 0000000..7ce7138 Binary files /dev/null and b/obj/JDMERGE.OBJ differ diff --git a/obj/JDPHUFF.OBJ b/obj/JDPHUFF.OBJ new file mode 100644 index 0000000..b6ca34c Binary files /dev/null and b/obj/JDPHUFF.OBJ differ diff --git a/obj/JDPOSTCT.OBJ b/obj/JDPOSTCT.OBJ new file mode 100644 index 0000000..683b320 Binary files /dev/null and b/obj/JDPOSTCT.OBJ differ diff --git a/obj/JDSAMPLE.OBJ b/obj/JDSAMPLE.OBJ new file mode 100644 index 0000000..aaeede5 Binary files /dev/null and b/obj/JDSAMPLE.OBJ differ diff --git a/obj/JDTRANS.OBJ b/obj/JDTRANS.OBJ new file mode 100644 index 0000000..527086f Binary files /dev/null and b/obj/JDTRANS.OBJ differ diff --git a/obj/JERROR.OBJ b/obj/JERROR.OBJ new file mode 100644 index 0000000..4f9dc6c Binary files /dev/null and b/obj/JERROR.OBJ differ diff --git a/obj/JFDCTFLT.OBJ b/obj/JFDCTFLT.OBJ new file mode 100644 index 0000000..9602a23 Binary files /dev/null and b/obj/JFDCTFLT.OBJ differ diff --git a/obj/JFDCTFST.OBJ b/obj/JFDCTFST.OBJ new file mode 100644 index 0000000..ea3366a Binary files /dev/null and b/obj/JFDCTFST.OBJ differ diff --git a/obj/JFDCTINT.OBJ b/obj/JFDCTINT.OBJ new file mode 100644 index 0000000..8a2ec8c Binary files /dev/null and b/obj/JFDCTINT.OBJ differ diff --git a/obj/JIDCTFLT.OBJ b/obj/JIDCTFLT.OBJ new file mode 100644 index 0000000..46bd522 Binary files /dev/null and b/obj/JIDCTFLT.OBJ differ diff --git a/obj/JIDCTFST.OBJ b/obj/JIDCTFST.OBJ new file mode 100644 index 0000000..1e37f84 Binary files /dev/null and b/obj/JIDCTFST.OBJ differ diff --git a/obj/JIDCTINT.OBJ b/obj/JIDCTINT.OBJ new file mode 100644 index 0000000..e6e8c2d Binary files /dev/null and b/obj/JIDCTINT.OBJ differ diff --git a/obj/JIDCTRED.OBJ b/obj/JIDCTRED.OBJ new file mode 100644 index 0000000..6403cd5 Binary files /dev/null and b/obj/JIDCTRED.OBJ differ diff --git a/obj/JMEMMGR.OBJ b/obj/JMEMMGR.OBJ new file mode 100644 index 0000000..90a844a Binary files /dev/null and b/obj/JMEMMGR.OBJ differ diff --git a/obj/JMEMNOBS.OBJ b/obj/JMEMNOBS.OBJ new file mode 100644 index 0000000..112175c Binary files /dev/null and b/obj/JMEMNOBS.OBJ differ diff --git a/obj/JPEGTRAN.OBJ b/obj/JPEGTRAN.OBJ new file mode 100644 index 0000000..0a4cbb0 Binary files /dev/null and b/obj/JPEGTRAN.OBJ differ diff --git a/obj/JQUANT1.OBJ b/obj/JQUANT1.OBJ new file mode 100644 index 0000000..7476dff Binary files /dev/null and b/obj/JQUANT1.OBJ differ diff --git a/obj/JQUANT2.OBJ b/obj/JQUANT2.OBJ new file mode 100644 index 0000000..7500711 Binary files /dev/null and b/obj/JQUANT2.OBJ differ diff --git a/obj/JUTILS.OBJ b/obj/JUTILS.OBJ new file mode 100644 index 0000000..69d4102 Binary files /dev/null and b/obj/JUTILS.OBJ differ diff --git a/obj/adler32.obj b/obj/adler32.obj new file mode 100644 index 0000000..84d2850 Binary files /dev/null and b/obj/adler32.obj differ diff --git a/obj/compress.obj b/obj/compress.obj new file mode 100644 index 0000000..90cf74f Binary files /dev/null and b/obj/compress.obj differ diff --git a/obj/crc32.obj b/obj/crc32.obj new file mode 100644 index 0000000..ea14153 Binary files /dev/null and b/obj/crc32.obj differ diff --git a/obj/deflate.obj b/obj/deflate.obj new file mode 100644 index 0000000..3ffc8bc Binary files /dev/null and b/obj/deflate.obj differ diff --git a/obj/gzio.obj b/obj/gzio.obj new file mode 100644 index 0000000..ff94037 Binary files /dev/null and b/obj/gzio.obj differ diff --git a/obj/infback.obj b/obj/infback.obj new file mode 100644 index 0000000..2114f10 Binary files /dev/null and b/obj/infback.obj differ diff --git a/obj/inffast.obj b/obj/inffast.obj new file mode 100644 index 0000000..c8f5b1f Binary files /dev/null and b/obj/inffast.obj differ diff --git a/obj/inflate.obj b/obj/inflate.obj new file mode 100644 index 0000000..4c53c01 Binary files /dev/null and b/obj/inflate.obj differ diff --git a/obj/inftrees.obj b/obj/inftrees.obj new file mode 100644 index 0000000..c37455e Binary files /dev/null and b/obj/inftrees.obj differ diff --git a/obj/trees.obj b/obj/trees.obj new file mode 100644 index 0000000..98a6110 Binary files /dev/null and b/obj/trees.obj differ diff --git a/obj/uncompr.obj b/obj/uncompr.obj new file mode 100644 index 0000000..12cd70b Binary files /dev/null and b/obj/uncompr.obj differ diff --git a/obj/zutil.obj b/obj/zutil.obj new file mode 100644 index 0000000..9395409 Binary files /dev/null and b/obj/zutil.obj differ diff --git a/AnimateEasing.pas b/thirparty/AnimateEasing.pas similarity index 100% rename from AnimateEasing.pas rename to thirparty/AnimateEasing.pas diff --git a/thirparty/DirectDraw.pas b/thirparty/DirectDraw.pas new file mode 100644 index 0000000..bb21c26 --- /dev/null +++ b/thirparty/DirectDraw.pas @@ -0,0 +1,7161 @@ +{******************************************************************************} +{* *} +{* Copyright (C) Microsoft Corporation. All Rights Reserved. *} +{* *} +{* Files: ddraw.h dvp.h *} +{* Content: DirectDraw and DirectDrawVideoPort include files *} +{* *} +{* DirectX 9.0 Delphi adaptation by Alexey Barkovoy *} +{* E-Mail: clootie@reactor.ru *} +{* *} +{* Modified: 20-Dec-2002 *} +{* *} +{* Based upon : *} +{* DirectX 7.0 Object Pascal adaptation by *} +{* Erik Unger, e-Mail: DelphiDirectX@next-reality.com *} +{* *} +{* Latest version can be downloaded from: *} +{* http://clootie.narod.ru/delphi/ *} +{* *} +{******************************************************************************} +{ } +{ Obtained through: Joint Endeavour of Delphi Innovators (Project JEDI) } +{ } +{ 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. } +{ } +{ Alternatively, the contents of this file may be used under the terms of the } +{ GNU Lesser General Public License (the "LGPL License"), in which case the } +{ provisions of the LGPL License are applicable instead of those above. } +{ If you wish to allow use of your version of this file only under the terms } +{ of the LGPL License and not to allow others to use your version of this file } +{ under the MPL, indicate your decision by deleting the provisions above and } +{ replace them with the notice and other provisions required by the LGPL } +{ License. If you do not delete the provisions above, a recipient may use } +{ your version of this file under either the MPL or the LGPL License. } +{ } +{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html } +{ } +{******************************************************************************} + +/////////////////////////////////////////////////////////////////////////////// +// Notes: +//---------------------------------------------------------------------------- +// Possible input defines for this file, mapped to original C values: +// DIRECTDRAW_VERSION_7 : DIRECTDRAW_VERSION = 0x0700, +// DIRECTDRAW_VERSION_6 : DIRECTDRAW_VERSION = 0x0600, +// DIRECTDRAW_VERSION_5 : DIRECTDRAW_VERSION = 0x0500, +// DIRECTDRAW_VERSION_3 : DIRECTDRAW_VERSION = 0x0300, +// DIRECTDRAW_VERSION_LESS_3 : DIRECTDRAW_VERSION < 0x0300, +// +// By default DIRECTDRAW_VERSION_7 (DIRECTDRAW_VERSION = 0x0700) is assumed +// +// Also you can use generic DIRECTXx defines, so: +// DIRECTX7 equal to DIRECTDRAW_VERSION_7; +// DIRECTX6 equal to DIRECTDRAW_VERSION_6; +// DIRECTX5 equal to DIRECTDRAW_VERSION_5; +// DIRECTX3 equal to DIRECTDRAW_VERSION_3 +/////////////////////////////////////////////////////////////////////////////// + +unit DirectDraw; + +interface + +{$I DirectX.inc} + +//////////////////////////////////////////////////////////////////////// +// Global level dynamic loading support +{$IFDEF DYNAMIC_LINK_ALL} + {$DEFINE DIRECTDRAW_DYNAMIC_LINK} +{$ENDIF} +{$IFDEF DYNAMIC_LINK_EXPLICIT_ALL} + {$DEFINE DIRECTDRAW_DYNAMIC_LINK_EXPLICIT} +{$ENDIF} + +// Remove "dots" below to force some kind of dynamic linking +{.$DEFINE DIRECTDRAW_DYNAMIC_LINK} +{.$DEFINE DIRECTDRAW_DYNAMIC_LINK_EXPLICIT} + +//////////////////////////////////////////////////////////////////////// +// Assume for what DirectDraw version we will compile headers +{$IFDEF DIRECTX7} + {$DEFINE DIRECTDRAW_VERSION_7} +{$ENDIF} +{$IFDEF DIRECTX6} + {$DEFINE DIRECTDRAW_VERSION_6} +{$ENDIF} +{$IFDEF DIRECTX5} + {$DEFINE DIRECTDRAW_VERSION_5} +{$ENDIF} +{$IFDEF DIRECTX3} + {$DEFINE DIRECTDRAW_VERSION_3} +{$ENDIF} + +{$IFNDEF DIRECTDRAW_VERSION_7} + {$IFNDEF DIRECTDRAW_VERSION_6} + {$IFNDEF DIRECTDRAW_VERSION_5} + {$IFNDEF DIRECTDRAW_VERSION_3} + {$IFNDEF DIRECTDRAW_VERSION_LESS_3} + {$DEFINE DIRECTDRAW_VERSION_7} // Compiling for DirectDraw7 by default + {$ENDIF} + {$ENDIF} + {$ENDIF} + {$ENDIF} +{$ENDIF} + +//////////////////////////////////////////////////////////////////////// +// Emit conditionals to C++Builder compiler +{$IFDEF DIRECTDRAW_VERSION_LESS_3} + {$HPPEMIT '#define DIRECTDRAW_VERSION 0x0100'} +{$ENDIF} +{$IFDEF DIRECTDRAW_VERSION_3} + {$HPPEMIT '#define DIRECTDRAW_VERSION 0x0300'} +{$ENDIF} +{$IFDEF DIRECTDRAW_VERSION_5} + {$HPPEMIT '#define DIRECTDRAW_VERSION 0x0500'} +{$ENDIF} +{$IFDEF DIRECTDRAW_VERSION_6} + {$HPPEMIT '#define DIRECTDRAW_VERSION 0x0600'} +{$ENDIF} +{$IFDEF DIRECTDRAW_VERSION_7} + {$HPPEMIT '#define DIRECTDRAW_VERSION 0x0700'} +{$ENDIF} + +//////////////////////////////////////////////////////////////////////// +// Define symbols for '<=' comparision +{$IFDEF DIRECTDRAW_VERSION_7} + {$DEFINE DIRECTDRAW_VERSION_6} +{$ENDIF} +{$IFDEF DIRECTDRAW_VERSION_6} + {$DEFINE DIRECTDRAW_VERSION_5} +{$ENDIF} +{$IFDEF DIRECTDRAW_VERSION_5} + {$DEFINE DIRECTDRAW_VERSION_3} +{$ENDIF} +{$IFDEF DIRECTDRAW_VERSION_3} + {$DEFINE DIRECTDRAW_VERSION_LESS_3} +{$ENDIF} + +(*$HPPEMIT '#include "ddraw.h"' *) +(*$HPPEMIT '#include "dvp.h"' *) + +uses + Windows; + + +(*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: ddraw.h + * Content: DirectDraw include file + * + ***************************************************************************) + +function MAKEFOURCC(ch0, ch1, ch2, ch3: Char): DWORD; +{$EXTERNALSYM MAKEFOURCC} + +(* + * FOURCC codes for DX compressed-texture pixel formats + *) +const + //#define FOURCC_DXT1 (MAKEFOURCC('D','X','T','1')) + FOURCC_DXT1 = DWORD(Byte('D') or (Byte('X') shl 8) or (Byte('T') shl 16) or (Byte('1') shl 24)); + {$EXTERNALSYM FOURCC_DXT1} + //#define FOURCC_DXT2 (MAKEFOURCC('D','X','T','2')) + FOURCC_DXT2 = DWORD(Byte('D') or (Byte('X') shl 8) or (Byte('T') shl 16) or (Byte('2') shl 24)); + {$EXTERNALSYM FOURCC_DXT2} + //#define FOURCC_DXT3 (MAKEFOURCC('D','X','T','3')) + FOURCC_DXT3 = DWORD(Byte('D') or (Byte('X') shl 8) or (Byte('T') shl 16) or (Byte('3') shl 24)); + {$EXTERNALSYM FOURCC_DXT3} + //#define FOURCC_DXT4 (MAKEFOURCC('D','X','T','4')) + FOURCC_DXT4 = DWORD(Byte('D') or (Byte('X') shl 8) or (Byte('T') shl 16) or (Byte('4') shl 24)); + {$EXTERNALSYM FOURCC_DXT4} + //#define FOURCC_DXT5 (MAKEFOURCC('D','X','T','5')) + FOURCC_DXT5 = DWORD(Byte('D') or (Byte('X') shl 8) or (Byte('T') shl 16) or (Byte('5') shl 24)); + {$EXTERNALSYM FOURCC_DXT5} + +(* + * GUIDS used by DirectDraw objects + *) +const + CLSID_DirectDraw: TGUID = '{D7B70EE0-4340-11CF-B063-0020AFC2CD35}'; + {$EXTERNALSYM CLSID_DirectDraw} + CLSID_DirectDraw7: TGUID = '{3c305196-50db-11d3-9cfe-00c04fd930c5}'; + {$EXTERNALSYM CLSID_DirectDraw7} + CLSID_DirectDrawClipper: TGUID = '{593817A0-7DB3-11CF-A2DE-00AA00b93356}'; + {$EXTERNALSYM CLSID_DirectDrawClipper} + (* These GUID's defined later by typedefing to Delphi interfaces + DEFINE_GUID( IID_IDirectDraw, 0x6C14DB80,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); + DEFINE_GUID( IID_IDirectDraw2, 0xB3A6F3E0,0x2B43,0x11CF,0xA2,0xDE,0x00,0xAA,0x00,0xB9,0x33,0x56 ); + DEFINE_GUID( IID_IDirectDraw4, 0x9c59509a,0x39bd,0x11d1,0x8c,0x4a,0x00,0xc0,0x4f,0xd9,0x30,0xc5 ); + DEFINE_GUID( IID_IDirectDraw7, 0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b ); + DEFINE_GUID( IID_IDirectDrawSurface, 0x6C14DB81,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); + DEFINE_GUID( IID_IDirectDrawSurface2, 0x57805885,0x6eec,0x11cf,0x94,0x41,0xa8,0x23,0x03,0xc1,0x0e,0x27 ); + DEFINE_GUID( IID_IDirectDrawSurface3, 0xDA044E00,0x69B2,0x11D0,0xA1,0xD5,0x00,0xAA,0x00,0xB8,0xDF,0xBB ); + DEFINE_GUID( IID_IDirectDrawSurface4, 0x0B2B8630,0xAD35,0x11D0,0x8E,0xA6,0x00,0x60,0x97,0x97,0xEA,0x5B ); + DEFINE_GUID( IID_IDirectDrawSurface7, 0x06675a80,0x3b9b,0x11d2,0xb9,0x2f,0x00,0x60,0x97,0x97,0xea,0x5b ); + DEFINE_GUID( IID_IDirectDrawPalette, 0x6C14DB84,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); + DEFINE_GUID( IID_IDirectDrawClipper, 0x6C14DB85,0xA733,0x11CE,0xA5,0x21,0x00,0x20,0xAF,0x0B,0xE5,0x60 ); + DEFINE_GUID( IID_IDirectDrawColorControl, 0x4B9F0EE0,0x0D7E,0x11D0,0x9B,0x06,0x00,0xA0,0xC9,0x03,0xA3,0xB8 ); + DEFINE_GUID( IID_IDirectDrawGammaControl, 0x69C11C3E,0xB46B,0x11D1,0xAD,0x7A,0x00,0xC0,0x4F,0xC2,0x9B,0x4E ); + *) + +const + DD_ROP_SPACE = (256 div 32); // space required to store ROP array + {$EXTERNALSYM DD_ROP_SPACE} + + MAX_DDDEVICEID_STRING = 512; + {$EXTERNALSYM MAX_DDDEVICEID_STRING} + + +(*============================================================================ + * + * DirectDraw Structures + * + * Various structures used to invoke DirectDraw. + * + *==========================================================================*) + +var + NilGUID : TGUID = '{00000000-0000-0000-0000-000000000000}'; + + +type + //Clootie: This was originally in Erik Unger headers - don't know why, so leave it alone + TRefGUID = packed record + case Integer of + 1: (guid : PGUID); + 2: (dwFlags : DWORD); + end; + + REFGUID = PGUID; + {$EXTERNALSYM REFGUID} + + {$HPPEMIT 'typedef System::DelphiInterface _di_IDirectDraw;'} + {$HPPEMIT 'typedef System::DelphiInterface _di_IDirectDraw2;'} + {$HPPEMIT 'typedef System::DelphiInterface _di_IDirectDraw4;'} + {$HPPEMIT 'typedef System::DelphiInterface _di_IDirectDraw7;'} + {$HPPEMIT 'typedef System::DelphiInterface _di_IDirectDrawSurface;'} + {$HPPEMIT 'typedef System::DelphiInterface _di_IDirectDrawSurface2;'} + {$HPPEMIT 'typedef System::DelphiInterface _di_IDirectDrawSurface3;'} + {$HPPEMIT 'typedef System::DelphiInterface _di_IDirectDrawSurface4;'} + {$HPPEMIT 'typedef System::DelphiInterface _di_IDirectDrawSurface7;'} + {$HPPEMIT 'typedef System::DelphiInterface _di_IDirectDrawPalette;'} + {$HPPEMIT 'typedef System::DelphiInterface _di_IDirectDrawClipper;'} + {$HPPEMIT 'typedef System::DelphiInterface _di_IDirectDrawColorControl;'} + {$HPPEMIT 'typedef System::DelphiInterface _di_IDirectDrawGammaControl;'} + IDirectDraw = interface; + {$EXTERNALSYM IDirectDraw} + IDirectDraw2 = interface; + {$EXTERNALSYM IDirectDraw2} + IDirectDraw4 = interface; + {$EXTERNALSYM IDirectDraw4} + IDirectDraw7 = interface; + {$EXTERNALSYM IDirectDraw7} + IDirectDrawSurface = interface; + {$EXTERNALSYM IDirectDrawSurface} + IDirectDrawSurface2 = interface; + {$EXTERNALSYM IDirectDrawSurface2} + IDirectDrawSurface3 = interface; + {$EXTERNALSYM IDirectDrawSurface3} + IDirectDrawSurface4 = interface; + {$EXTERNALSYM IDirectDrawSurface4} + IDirectDrawSurface7 = interface; + {$EXTERNALSYM IDirectDrawSurface7} + + IDirectDrawPalette = interface; + {$EXTERNALSYM IDirectDrawPalette} + IDirectDrawClipper = interface; + {$EXTERNALSYM IDirectDrawClipper} + IDirectDrawColorControl = interface; + {$EXTERNALSYM IDirectDrawColorControl} + IDirectDrawGammaControl = interface; + {$EXTERNALSYM IDirectDrawGammaControl} + +(* + * Generic pixel format with 8-bit RGB and alpha components + *) + PDDARGB = ^TDDARGB; + _DDARGB = packed record + blue: Byte; + green: Byte; + red: Byte; + alpha: Byte; + end; + {$EXTERNALSYM _DDARGB} + DDARGB = _DDARGB; + {$EXTERNALSYM DDARGB} + TDDARGB = _DDARGB; + +(* + * This version of the structure remains for backwards source compatibility. + * The DDARGB structure is the one that should be used for all DirectDraw APIs. + *) + PDDRGBA = ^TDDRGBA; + _DDRGBA = packed record + red : Byte; + green : Byte; + blue : Byte; + alpha : Byte; + end; + {$EXTERNALSYM _DDRGBA} + DDRGBA = _DDRGBA; + {$EXTERNALSYM DDRGBA} + TDDRGBA = _DDRGBA; + +(* + * TDDColorKey + *) + PDDColorKey = ^TDDColorKey; + _DDCOLORKEY = packed record + dwColorSpaceLowValue: DWORD; // low boundary of color space that is to + // be treated as Color Key, inclusive + dwColorSpaceHighValue: DWORD; // high boundary of color space that is + // to be treated as Color Key, inclusive + end; + {$EXTERNALSYM _DDCOLORKEY} + DDCOLORKEY = _DDCOLORKEY; + {$EXTERNALSYM DDCOLORKEY} + TDDColorKey = _DDCOLORKEY; + +// Delphi 5 and up don't allow interfaces in variant records +// so we have to use pointers instead (which can be type-casted into interfaces): + +{$IFDEF COMPILER5_UP} + PDirectDrawSurface = Pointer; +{$ELSE} + PDirectDrawSurface = IDirectDrawSurface; +{$ENDIF} + +(* + * TDDBltFX + * Used to pass override information to the DIRECTDRAWSURFACE callback Blt. + *) + PDDBltFX = ^TDDBltFX; + _DDBLTFX = packed record + dwSize : DWORD; // size of structure + dwDDFX : DWORD; // FX operations + dwROP : DWORD; // Win32 raster operations + dwDDROP : DWORD; // Raster operations new for DirectDraw + dwRotationAngle : DWORD; // Rotation angle for blt + dwZBufferOpCode : DWORD; // ZBuffer compares + dwZBufferLow : DWORD; // Low limit of Z buffer + dwZBufferHigh : DWORD; // High limit of Z buffer + dwZBufferBaseDest : DWORD; // Destination base value + dwZDestConstBitDepth : DWORD; // Bit depth used to specify Z constant for destination + case Integer of + 0: ( + dwZDestConst : DWORD // Constant to use as Z buffer for dest + ); + 1: ( + lpDDSZBufferDest : ^PDirectDrawSurface; // Surface to use as Z buffer for dest + dwZSrcConstBitDepth : DWORD; // Bit depth used to specify Z constant for source + case integer of + 0: ( + dwZSrcConst : DWORD; // Constant to use as Z buffer for src + ); + 1: ( + lpDDSZBufferSrc : ^PDirectDrawSurface; // Surface to use as Z buffer for src + dwAlphaEdgeBlendBitDepth : DWORD; // Bit depth used to specify constant for alpha edge blend + dwAlphaEdgeBlend : DWORD; // Alpha for edge blending + dwReserved : DWORD; + dwAlphaDestConstBitDepth : DWORD; // Bit depth used to specify alpha constant for destination + case integer of + 0: ( + dwAlphaDestConst : DWORD; // Constant to use as Alpha Channel + ); + 1: ( + lpDDSAlphaDest : ^PDirectDrawSurface; // Surface to use as Alpha Channel + dwAlphaSrcConstBitDepth : DWORD; // Bit depth used to specify alpha constant for source + case integer of + 0: ( + dwAlphaSrcConst : DWORD; // Constant to use as Alpha Channel + ); + 1: ( + lpDDSAlphaSrc : ^PDirectDrawSurface; // Surface to use as Alpha Channel + case integer of + 0: ( + dwFillColor : DWORD; // color in RGB or Palettized + ); + 1: ( + dwFillDepth : DWORD; // depth value for z-buffer + ); + 2: ( + dwFillPixel : DWORD; // pixel value + ); + 3: ( + lpDDSPattern : ^PDirectDrawSurface; // Surface to use as pattern + ddckDestColorkey : TDDColorKey; // DestColorkey override + ddckSrcColorkey : TDDColorKey; // SrcColorkey override + ) + ) + ) + ) + ) + end; + {$EXTERNALSYM _DDBLTFX} + DDBLTFX = _DDBLTFX; + {$EXTERNALSYM DDBLTFX} + TDDBltFX = _DDBLTFX; + +(* + * TDDSCaps + *) + PDDSCaps = ^TDDSCaps; + _DDSCAPS = packed record + dwCaps: DWORD; // capabilities of surface wanted + end; + {$EXTERNALSYM _DDSCAPS} + DDSCAPS = _DDSCAPS; + {$EXTERNALSYM DDSCAPS} + TDDSCaps = _DDSCAPS; + +(* + * TDDOSCaps + *) + PDDOSCaps = ^TDDOSCaps; + _DDOSCAPS = packed record + dwCaps: DWORD; // capabilities of surface wanted + end; + {$EXTERNALSYM _DDOSCAPS} + DDOSCAPS = _DDOSCAPS; + {$EXTERNALSYM DDOSCAPS} + TDDOSCaps = _DDOSCAPS; + +(* + * This structure is used internally by DirectDraw. + *) + PDDSCapsEx = ^TDDSCapsEx; + _DDSCAPSEX = packed record + dwCaps2 : DWORD; + dwCaps3 : DWORD; + dwCaps4 : DWORD; + end; + {$EXTERNALSYM _DDSCAPSEX} + DDSCAPSEX = _DDSCAPSEX; + {$EXTERNALSYM DDSCAPSEX} + TDDSCapsEx = _DDSCAPSEX; + +(* + * TDDSCaps2 + *) + PDDSCaps2 = ^TDDSCaps2; + _DDSCAPS2 = packed record + dwCaps: DWORD; // capabilities of surface wanted + dwCaps2 : DWORD; + dwCaps3 : DWORD; + dwCaps4 : DWORD; + end; + {$EXTERNALSYM _DDSCAPS2} + DDSCAPS2 = _DDSCAPS2; + {$EXTERNALSYM DDSCAPS2} + TDDSCaps2 = _DDSCAPS2; + +(* + * NOTE: Our choosen structure number scheme is to append a single digit to + * the end of the structure giving the version that structure is associated + * with. + *) + +(* + * This structure represents the DDCAPS structure released in DirectDraw 1.0. It is used internally + * by DirectDraw to interpret caps passed into ddraw by drivers written prior to the release of DirectDraw 2.0. + * New applications should use the DDCAPS structure defined below. + *) + PDDCaps_DX1 = ^TDDCaps_DX1; + _DDCAPS_DX1 = packed record + dwSize: DWORD; // size of the DDDRIVERCAPS structure + dwCaps: DWORD; // driver specific capabilities + dwCaps2: DWORD; // more driver specific capabilites + dwCKeyCaps: DWORD; // color key capabilities of the surface + dwFXCaps: DWORD; // driver specific stretching and effects capabilites + dwFXAlphaCaps: DWORD; // alpha driver specific capabilities + dwPalCaps: DWORD; // palette capabilities + dwSVCaps: DWORD; // stereo vision capabilities + dwAlphaBltConstBitDepths: DWORD; // DDBD_2,4,8 + dwAlphaBltPixelBitDepths: DWORD; // DDBD_1,2,4,8 + dwAlphaBltSurfaceBitDepths: DWORD; // DDBD_1,2,4,8 + dwAlphaOverlayConstBitDepths: DWORD; // DDBD_2,4,8 + dwAlphaOverlayPixelBitDepths: DWORD; // DDBD_1,2,4,8 + dwAlphaOverlaySurfaceBitDepths: DWORD; // DDBD_1,2,4,8 + dwZBufferBitDepths: DWORD; // DDBD_8,16,24,32 + dwVidMemTotal: DWORD; // total amount of video memory + dwVidMemFree: DWORD; // amount of free video memory + dwMaxVisibleOverlays: DWORD; // maximum number of visible overlays + dwCurrVisibleOverlays: DWORD; // current number of visible overlays + dwNumFourCCCodes: DWORD; // number of four cc codes + dwAlignBoundarySrc: DWORD; // source rectangle alignment + dwAlignSizeSrc: DWORD; // source rectangle byte size + dwAlignBoundaryDest: DWORD; // dest rectangle alignment + dwAlignSizeDest: DWORD; // dest rectangle byte size + dwAlignStrideAlign: DWORD; // stride alignment + dwRops: Array [0..DD_ROP_SPACE-1] of DWORD; // ROPS supported + ddsCaps: TDDSCaps; // TDDSCaps structure has all the general capabilities + dwMinOverlayStretch: DWORD; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMaxOverlayStretch: DWORD; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMinLiveVideoStretch: DWORD; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMaxLiveVideoStretch: DWORD; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMinHwCodecStretch: DWORD; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMaxHwCodecStretch: DWORD; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwReserved1: DWORD; // reserved + dwReserved2: DWORD; // reserved + dwReserved3: DWORD; // reserved + end; + {$EXTERNALSYM _DDCAPS_DX1} + DDCAPS_DX1 = _DDCAPS_DX1; + {$EXTERNALSYM DDCAPS_DX1} + TDDCaps_DX1 = _DDCAPS_DX1; + +(* + * This structure is the TDDCaps structure as it was in version 2 and 3 of Direct X. + * It is present for back compatability. + *) + PDDCaps_DX3 = ^TDDCaps_DX3; + _DDCAPS_DX3 = packed record + dwSize: DWORD; // size of the DDDRIVERCAPS structure + dwCaps: DWORD; // driver specific capabilities + dwCaps2: DWORD; // more driver specific capabilites + dwCKeyCaps: DWORD; // color key capabilities of the surface + dwFXCaps: DWORD; // driver specific stretching and effects capabilites + dwFXAlphaCaps: DWORD; // alpha driver specific capabilities + dwPalCaps: DWORD; // palette capabilities + dwSVCaps: DWORD; // stereo vision capabilities + dwAlphaBltConstBitDepths: DWORD; // DDBD_2,4,8 + dwAlphaBltPixelBitDepths: DWORD; // DDBD_1,2,4,8 + dwAlphaBltSurfaceBitDepths: DWORD; // DDBD_1,2,4,8 + dwAlphaOverlayConstBitDepths: DWORD; // DDBD_2,4,8 + dwAlphaOverlayPixelBitDepths: DWORD; // DDBD_1,2,4,8 + dwAlphaOverlaySurfaceBitDepths: DWORD; // DDBD_1,2,4,8 + dwZBufferBitDepths: DWORD; // DDBD_8,16,24,32 + dwVidMemTotal: DWORD; // total amount of video memory + dwVidMemFree: DWORD; // amount of free video memory + dwMaxVisibleOverlays: DWORD; // maximum number of visible overlays + dwCurrVisibleOverlays: DWORD; // current number of visible overlays + dwNumFourCCCodes: DWORD; // number of four cc codes + dwAlignBoundarySrc: DWORD; // source rectangle alignment + dwAlignSizeSrc: DWORD; // source rectangle byte size + dwAlignBoundaryDest: DWORD; // dest rectangle alignment + dwAlignSizeDest: DWORD; // dest rectangle byte size + dwAlignStrideAlign: DWORD; // stride alignment + dwRops: Array [0..DD_ROP_SPACE-1] of DWORD; // ROPS supported + ddsCaps: TDDSCaps; // TDDSCaps structure has all the general capabilities + dwMinOverlayStretch: DWORD; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMaxOverlayStretch: DWORD; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMinLiveVideoStretch: DWORD; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMaxLiveVideoStretch: DWORD; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMinHwCodecStretch: DWORD; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMaxHwCodecStretch: DWORD; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwReserved1: DWORD; // reserved + dwReserved2: DWORD; // reserved + dwReserved3: DWORD; // reserved + dwSVBCaps: DWORD; // driver specific capabilities for System->Vmem blts + dwSVBCKeyCaps: DWORD; // driver color key capabilities for System->Vmem blts + dwSVBFXCaps: DWORD; // driver FX capabilities for System->Vmem blts + dwSVBRops: array[0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->Vmem blts + dwVSBCaps: DWORD; // driver specific capabilities for Vmem->System blts + dwVSBCKeyCaps: DWORD; // driver color key capabilities for Vmem->System blts + dwVSBFXCaps: DWORD; // driver FX capabilities for Vmem->System blts + dwVSBRops: array[0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for Vmem->System blts + dwSSBCaps: DWORD; // driver specific capabilities for System->System blts + dwSSBCKeyCaps: DWORD; // driver color key capabilities for System->System blts + dwSSBFXCaps: DWORD; // driver FX capabilities for System->System blts + dwSSBRops: array[0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->System blts + dwReserved4 : DWORD; + dwReserved5 : DWORD; + dwReserved6 : DWORD; + end; + {$EXTERNALSYM _DDCAPS_DX3} + DDCAPS_DX3 = _DDCAPS_DX3; + {$EXTERNALSYM DDCAPS_DX3} + TDDCaps_DX3 = _DDCAPS_DX3; + +(* + * This structure is the TDDCaps structure as it was in version 5 of Direct X. + * It is present for back compatability. + *) + PDDCaps_DX5 = ^TDDCaps_DX5; + _DDCAPS_DX5 = packed record + dwSize: DWORD; // size of the DDDRIVERCAPS structure + dwCaps: DWORD; // driver specific capabilities + dwCaps2: DWORD; // more driver specific capabilites + dwCKeyCaps: DWORD; // color key capabilities of the surface + dwFXCaps: DWORD; // driver specific stretching and effects capabilites + dwFXAlphaCaps: DWORD; // alpha driver specific capabilities + dwPalCaps: DWORD; // palette capabilities + dwSVCaps: DWORD; // stereo vision capabilities + dwAlphaBltConstBitDepths: DWORD; // DDBD_2,4,8 + dwAlphaBltPixelBitDepths: DWORD; // DDBD_1,2,4,8 + dwAlphaBltSurfaceBitDepths: DWORD; // DDBD_1,2,4,8 + dwAlphaOverlayConstBitDepths: DWORD; // DDBD_2,4,8 + dwAlphaOverlayPixelBitDepths: DWORD; // DDBD_1,2,4,8 + dwAlphaOverlaySurfaceBitDepths: DWORD; // DDBD_1,2,4,8 + dwZBufferBitDepths: DWORD; // DDBD_8,16,24,32 + dwVidMemTotal: DWORD; // total amount of video memory + dwVidMemFree: DWORD; // amount of free video memory + dwMaxVisibleOverlays: DWORD; // maximum number of visible overlays + dwCurrVisibleOverlays: DWORD; // current number of visible overlays + dwNumFourCCCodes: DWORD; // number of four cc codes + dwAlignBoundarySrc: DWORD; // source rectangle alignment + dwAlignSizeSrc: DWORD; // source rectangle byte size + dwAlignBoundaryDest: DWORD; // dest rectangle alignment + dwAlignSizeDest: DWORD; // dest rectangle byte size + dwAlignStrideAlign: DWORD; // stride alignment + dwRops: Array [0..DD_ROP_SPACE-1] of DWORD; // ROPS supported + ddsCaps: TDDSCaps; // TDDSCaps structure has all the general capabilities + dwMinOverlayStretch: DWORD; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMaxOverlayStretch: DWORD; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMinLiveVideoStretch: DWORD; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMaxLiveVideoStretch: DWORD; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMinHwCodecStretch: DWORD; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMaxHwCodecStretch: DWORD; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwReserved1: DWORD; // reserved + dwReserved2: DWORD; // reserved + dwReserved3: DWORD; // reserved + dwSVBCaps: DWORD; // driver specific capabilities for System->Vmem blts + dwSVBCKeyCaps: DWORD; // driver color key capabilities for System->Vmem blts + dwSVBFXCaps: DWORD; // driver FX capabilities for System->Vmem blts + dwSVBRops: Array [0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->Vmem blts + dwVSBCaps: DWORD; // driver specific capabilities for Vmem->System blts + dwVSBCKeyCaps: DWORD; // driver color key capabilities for Vmem->System blts + dwVSBFXCaps: DWORD; // driver FX capabilities for Vmem->System blts + dwVSBRops: Array [0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for Vmem->System blts + dwSSBCaps: DWORD; // driver specific capabilities for System->System blts + dwSSBCKeyCaps: DWORD; // driver color key capabilities for System->System blts + dwSSBFXCaps: DWORD; // driver FX capabilities for System->System blts + dwSSBRops: Array [0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->System blts + // Members added for DX5: + dwMaxVideoPorts: DWORD; // maximum number of usable video ports + dwCurrVideoPorts: DWORD; // current number of video ports used + dwSVBCaps2: DWORD; // more driver specific capabilities for System->Vmem blts + dwNLVBCaps: DWORD; // driver specific capabilities for non-local->local vidmem blts + dwNLVBCaps2: DWORD; // more driver specific capabilities non-local->local vidmem blts + dwNLVBCKeyCaps: DWORD; // driver color key capabilities for non-local->local vidmem blts + dwNLVBFXCaps: DWORD; // driver FX capabilities for non-local->local blts + dwNLVBRops: Array [0..DD_ROP_SPACE-1] of DWORD; // ROPS supported for non-local->local blts + end; + {$EXTERNALSYM _DDCAPS_DX5} + DDCAPS_DX5 = _DDCAPS_DX5; + {$EXTERNALSYM DDCAPS_DX5} + TDDCaps_DX5 = _DDCAPS_DX5; + + PDDCaps_DX6 = ^TDDCaps_DX6; + _DDCAPS_DX6 = packed record + dwSize: DWORD; // size of the DDDRIVERCAPS structure + dwCaps: DWORD; // driver specific capabilities + dwCaps2: DWORD; // more driver specific capabilites + dwCKeyCaps: DWORD; // color key capabilities of the surface + dwFXCaps: DWORD; // driver specific stretching and effects capabilites + dwFXAlphaCaps: DWORD; // alpha driver specific capabilities + dwPalCaps: DWORD; // palette capabilities + dwSVCaps: DWORD; // stereo vision capabilities + dwAlphaBltConstBitDepths: DWORD; // DDBD_2,4,8 + dwAlphaBltPixelBitDepths: DWORD; // DDBD_1,2,4,8 + dwAlphaBltSurfaceBitDepths: DWORD; // DDBD_1,2,4,8 + dwAlphaOverlayConstBitDepths: DWORD; // DDBD_2,4,8 + dwAlphaOverlayPixelBitDepths: DWORD; // DDBD_1,2,4,8 + dwAlphaOverlaySurfaceBitDepths: DWORD; // DDBD_1,2,4,8 + dwZBufferBitDepths: DWORD; // DDBD_8,16,24,32 + dwVidMemTotal: DWORD; // total amount of video memory + dwVidMemFree: DWORD; // amount of free video memory + dwMaxVisibleOverlays: DWORD; // maximum number of visible overlays + dwCurrVisibleOverlays: DWORD; // current number of visible overlays + dwNumFourCCCodes: DWORD; // number of four cc codes + dwAlignBoundarySrc: DWORD; // source rectangle alignment + dwAlignSizeSrc: DWORD; // source rectangle byte size + dwAlignBoundaryDest: DWORD; // dest rectangle alignment + dwAlignSizeDest: DWORD; // dest rectangle byte size + dwAlignStrideAlign: DWORD; // stride alignment + dwRops: Array [0..DD_ROP_SPACE-1] of DWORD; // ROPS supported + ddsOldCaps: TDDSCaps; // Was dssCaps: TDDSCaps. ddsCaps is of type TDDScaps2 for DX6 + dwMinOverlayStretch: DWORD; // minimum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMaxOverlayStretch: DWORD; // maximum overlay stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMinLiveVideoStretch: DWORD; // minimum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMaxLiveVideoStretch: DWORD; // maximum live video stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMinHwCodecStretch: DWORD; // minimum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwMaxHwCodecStretch: DWORD; // maximum hardware codec stretch factor multiplied by 1000, eg 1000 == 1.0, 1300 == 1.3 + dwReserved1: DWORD; // reserved + dwReserved2: DWORD; // reserved + dwReserved3: DWORD; // reserved + dwSVBCaps: DWORD; // driver specific capabilities for System->Vmem blts + dwSVBCKeyCaps: DWORD; // driver color key capabilities for System->Vmem blts + dwSVBFXCaps: DWORD; // driver FX capabilities for System->Vmem blts + dwSVBRops: Array [0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->Vmem blts + dwVSBCaps: DWORD; // driver specific capabilities for Vmem->System blts + dwVSBCKeyCaps: DWORD; // driver color key capabilities for Vmem->System blts + dwVSBFXCaps: DWORD; // driver FX capabilities for Vmem->System blts + dwVSBRops: Array [0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for Vmem->System blts + dwSSBCaps: DWORD; // driver specific capabilities for System->System blts + dwSSBCKeyCaps: DWORD; // driver color key capabilities for System->System blts + dwSSBFXCaps: DWORD; // driver FX capabilities for System->System blts + dwSSBRops: Array [0..DD_ROP_SPACE-1] of DWORD;// ROPS supported for System->System blts + // Members added for DX5: + dwMaxVideoPorts: DWORD; // maximum number of usable video ports + dwCurrVideoPorts: DWORD; // current number of video ports used + dwSVBCaps2: DWORD; // more driver specific capabilities for System->Vmem blts + dwNLVBCaps: DWORD; // driver specific capabilities for non-local->local vidmem blts + dwNLVBCaps2: DWORD; // more driver specific capabilities non-local->local vidmem blts + dwNLVBCKeyCaps: DWORD; // driver color key capabilities for non-local->local vidmem blts + dwNLVBFXCaps: DWORD; // driver FX capabilities for non-local->local blts + dwNLVBRops: Array [0..DD_ROP_SPACE-1] of DWORD; // ROPS supported for non-local->local blts + // Members added for DX6 release + ddsCaps : TDDSCaps2 ; // Surface Caps + end; + {$EXTERNALSYM _DDCAPS_DX6} + DDCAPS_DX6 = _DDCAPS_DX6; + {$EXTERNALSYM DDCAPS_DX6} + TDDCaps_DX6 = _DDCAPS_DX6; + + _DDCAPS_DX7 = TDDCaps_DX6; + {$EXTERNALSYM _DDCAPS_DX7} + DDCAPS_DX7 = _DDCAPS_DX7; + {$EXTERNALSYM DDCAPS_DX7} + PDDCaps_DX7 = ^TDDCaps_DX7; + TDDCaps_DX7 = TDDCaps_DX6; + +{$IFDEF DIRECTDRAW_VERSION_7} + PDDCaps = PDDCaps_DX7; + TDDCaps = TDDCaps_DX7; +{$ELSE} +{$IFDEF DIRECTDRAW_VERSION_6} + PDDCaps = PDDCaps_DX6; + TDDCaps = TDDCaps_DX6; +{$ELSE} +{$IFDEF DIRECTDRAW_VERSION_5} + PDDCaps = PDDCaps_DX5; + TDDCaps = TDDCaps_DX5; +{$ELSE} +{$IFDEF DIRECTDRAW_VERSION_3} + PDDCaps = PDDCaps_DX3; + TDDCaps = TDDCaps_DX3; +{$ELSE} + PDDCaps = PDDCaps_DX1; + TDDCaps = TDDCaps_DX1; +{$ENDIF} +{$ENDIF} +{$ENDIF} +{$ENDIF} + + + +(* + * TDDPixelFormat + *) + PDDPixelFormat = ^TDDPixelFormat; + _DDPIXELFORMAT = packed record + dwSize: DWORD; // size of structure + dwFlags: DWORD; // pixel format flags + dwFourCC: DWORD; // (FOURCC code) + case Integer of + 1: ( + dwRGBBitCount : DWORD; // how many bits per pixel + dwRBitMask : DWORD; // mask for red bit + dwGBitMask : DWORD; // mask for green bits + dwBBitMask : DWORD; // mask for blue bits + dwRGBAlphaBitMask : DWORD; // mask for alpha channel + ); + 2: ( + dwYUVBitCount : DWORD; // how many bits per pixel + dwYBitMask : DWORD; // mask for Y bits + dwUBitMask : DWORD; // mask for U bits + dwVBitMask : DWORD; // mask for V bits + dwYUVAlphaBitMask : DWORD; // mask for alpha channel + ); + 3: ( + dwZBufferBitDepth : DWORD; // how many total bits/pixel in z buffer (including any stencil bits) + dwStencilBitDepth : DWORD; // how many stencil bits (note: dwZBufferBitDepth-dwStencilBitDepth is total Z-only bits) + dwZBitMask : DWORD; // mask for Z bits + dwStencilBitMask : DWORD; // mask for stencil bits + dwLuminanceAlphaBitMask : DWORD; // mask for alpha channel + ); + 4: ( + dwAlphaBitDepth : DWORD; // how many bits for alpha channels + dwLuminanceBitMask : DWORD; // mask for luminance bits + dwBumpDvBitMask : DWORD; // mask for bump map V delta bits + dwBumpLuminanceBitMask : DWORD; // mask for luminance in bump map + dwRGBZBitMask : DWORD; // mask for Z channel + ); + 5: ( + dwLuminanceBitCount : DWORD; // how many bits per pixel + dwBumpDuBitMask : DWORD; // mask for bump map U delta bits + Fill1, Fill2 : DWORD; + dwYUVZBitMask : DWORD; // mask for Z channel + ); + 6: ( dwBumpBitCount : DWORD; // how many bits per "buxel", total + ); + end; + {$EXTERNALSYM _DDPIXELFORMAT} + DDPIXELFORMAT = _DDPIXELFORMAT; + {$EXTERNALSYM DDPIXELFORMAT} + TDDPixelFormat = _DDPIXELFORMAT; + + // These definitions are for compatibility with Erik Unger original conversion + PDDPixelFormat_DX3 = PDDPixelFormat; + TDDPixelFormat_DX3 = TDDPixelFormat; + + PDDPixelFormat_DX5 = PDDPixelFormat; + TDDPixelFormat_DX5 = TDDPixelFormat; + + PDDPixelFormat_DX6 = PDDPixelFormat; + TDDPixelFormat_DX6 = TDDPixelFormat; + + PDDPixelFormat_DX7 = PDDPixelFormat; + TDDPixelFormat_DX7 = TDDPixelFormat; + + + +(* + * TDDOverlayFX + *) + PDDOverlayFX = ^TDDOverlayFX; + _DDOVERLAYFX = packed record + dwSize: DWORD; // size of structure + dwAlphaEdgeBlendBitDepth: DWORD; // Bit depth used to specify constant for alpha edge blend + dwAlphaEdgeBlend: DWORD; // Constant to use as alpha for edge blend + dwReserved: DWORD; + dwAlphaDestConstBitDepth: DWORD; // Bit depth used to specify alpha constant for destination + case Integer of + 0: ( + dwAlphaDestConst: DWORD; // Constant to use as alpha channel for dest + dwAlphaSrcConstBitDepth: DWORD; // Bit depth used to specify alpha constant for source + dwAlphaSrcConst: DWORD; // Constant to use as alpha channel for src + dckDestColorkey: TDDColorKey; // DestColorkey override + dckSrcColorkey: TDDColorKey; // DestColorkey override + dwDDFX: DWORD; // Overlay FX + dwFlags: DWORD; // flags + ); + 1: ( + lpDDSAlphaDest: ^PDirectDrawSurface; // Surface to use as alpha channel for dest + filler: DWORD; + lpDDSAlphaSrc: ^PDirectDrawSurface; // Surface to use as alpha channel for src + ); + end; + {$EXTERNALSYM _DDOVERLAYFX} + DDOVERLAYFX = _DDOVERLAYFX; + {$EXTERNALSYM DDOVERLAYFX} + TDDOverlayFX = _DDOVERLAYFX; + +(* + * TDDBltBatch: BltBatch entry structure + *) + PDDBltBatch = ^TDDBltBatch; + _DDBLTBATCH = packed record + lprDest: PRect; + lpDDSSrc: IDirectDrawSurface; + lprSrc: PRect; + dwFlags: DWORD; + lpDDBltFx: TDDBltFX; + end; + {$EXTERNALSYM _DDBLTBATCH} + DDBLTBATCH = _DDBLTBATCH; + {$EXTERNALSYM DDBLTBATCH} + TDDBltBatch = _DDBLTBATCH; + +(* + * TDDGammaRamp + *) + PDDGammaRamp = ^TDDGammaRamp; + _DDGAMMARAMP = packed record + red : array[0..255] of WORD; + green : array[0..255] of WORD; + blue : array[0..255] of WORD; + end; + {$EXTERNALSYM _DDGAMMARAMP} + DDGAMMARAMP = _DDGAMMARAMP; + {$EXTERNALSYM DDGAMMARAMP} + TDDGammaRamp = _DDGAMMARAMP; + +(* + * This is the structure within which DirectDraw returns data about the current graphics driver and chipset + *) + + PDDDeviceIdentifier = ^TDDDeviceIdentifier; + tagDDDEVICEIDENTIFIER = packed record + // + // These elements are for presentation to the user only. They should not be used to identify particular + // drivers, since this is unreliable and many different strings may be associated with the same + // device, and the same driver from different vendors. + // + szDriver: array[0..MAX_DDDEVICEID_STRING-1] of Char; + szDescription: array[0..MAX_DDDEVICEID_STRING-1] of Char; + + // + // This element is the version of the DirectDraw/3D driver. It is legal to do <, > comparisons + // on the whole 64 bits. Caution should be exercised if you use this element to identify problematic + // drivers. It is recommended that guidDeviceIdentifier is used for this purpose. + // + // This version has the form: + // wProduct = HIWORD(liDriverVersion.HighPart) + // wVersion = LOWORD(liDriverVersion.HighPart) + // wSubVersion = HIWORD(liDriverVersion.LowPart) + // wBuild = LOWORD(liDriverVersion.LowPart) + // + liDriverVersion: TLargeInteger; // Defined for applications and other 32 bit components + + // + // These elements can be used to identify particular chipsets. Use with extreme caution. + // dwVendorId Identifies the manufacturer. May be zero if unknown. + // dwDeviceId Identifies the type of chipset. May be zero if unknown. + // dwSubSysId Identifies the subsystem, typically this means the particular board. May be zero if unknown. + // dwRevision Identifies the revision level of the chipset. May be zero if unknown. + // + dwVendorId: DWORD; + dwDeviceId: DWORD; + dwSubSysId: DWORD; + dwRevision: DWORD; + + // + // This element can be used to check changes in driver/chipset. This GUID is a unique identifier for the + // driver/chipset pair. Use this element if you wish to track changes to the driver/chipset in order to + // reprofile the graphics subsystem. + // This element can also be used to identify particular problematic drivers. + // + guidDeviceIdentifier: TGUID; + end; + {$EXTERNALSYM tagDDDEVICEIDENTIFIER} + DDDEVICEIDENTIFIER = tagDDDEVICEIDENTIFIER; + {$EXTERNALSYM DDDEVICEIDENTIFIER} + TDDDeviceIdentifier = tagDDDEVICEIDENTIFIER; + + PDDDeviceIdentifier2 = ^TDDDeviceIdentifier2; + tagDDDEVICEIDENTIFIER2 = packed record + // + // These elements are for presentation to the user only. They should not be used to identify particular + // drivers, since this is unreliable and many different strings may be associated with the same + // device, and the same driver from different vendors. + // + szDriver: array[0..MAX_DDDEVICEID_STRING-1] of Char; + szDescription: array[0..MAX_DDDEVICEID_STRING-1] of Char; + + // + // This element is the version of the DirectDraw/3D driver. It is legal to do <, > comparisons + // on the whole 64 bits. Caution should be exercised if you use this element to identify problematic + // drivers. It is recommended that guidDeviceIdentifier is used for this purpose. + // + // This version has the form: + // wProduct = HIWORD(liDriverVersion.HighPart) + // wVersion = LOWORD(liDriverVersion.HighPart) + // wSubVersion = HIWORD(liDriverVersion.LowPart) + // wBuild = LOWORD(liDriverVersion.LowPart) + // + liDriverVersion: TLargeInteger; // Defined for applications and other 32 bit components + + // + // These elements can be used to identify particular chipsets. Use with extreme caution. + // dwVendorId Identifies the manufacturer. May be zero if unknown. + // dwDeviceId Identifies the type of chipset. May be zero if unknown. + // dwSubSysId Identifies the subsystem, typically this means the particular board. May be zero if unknown. + // dwRevision Identifies the revision level of the chipset. May be zero if unknown. + // + dwVendorId: DWORD; + dwDeviceId: DWORD; + dwSubSysId: DWORD; + dwRevision: DWORD; + + // + // This element can be used to check changes in driver/chipset. This GUID is a unique identifier for the + // driver/chipset pair. Use this element if you wish to track changes to the driver/chipset in order to + // reprofile the graphics subsystem. + // This element can also be used to identify particular problematic drivers. + // + guidDeviceIdentifier: TGUID; + + (* + * This element is used to determine the Windows Hardware Quality Lab (WHQL) + * certification level for this driver/device pair. + *) + dwWHQLLevel: DWORD; + end; + {$EXTERNALSYM tagDDDEVICEIDENTIFIER2} + DDDEVICEIDENTIFIER2 = tagDDDEVICEIDENTIFIER2; + {$EXTERNALSYM DDDEVICEIDENTIFIER2} + TDDDeviceIdentifier2 = tagDDDEVICEIDENTIFIER2; + +(* + * callbacks + *) + TClipperCallback = function(lpDDClipper: IDirectDrawClipper; hWnd: HWND; + Code: DWORD; lpContext: Pointer): HResult; stdcall; + {$NODEFINE TClipperCallback} + {$HPPEMIT 'typedef LPCLIPPERCALLBACK TClipperCallback;'} + TSurfacesStreamingCallback = function(arg: DWORD): HResult; stdcall; + {$NODEFINE TSurfacesStreamingCallback} + +(* + * TDDSurfaceDesc + *) + PDDSurfaceDesc = ^TDDSurfaceDesc; + _DDSURFACEDESC = packed record + dwSize: DWORD; // size of the TDDSurfaceDesc structure + dwFlags: DWORD; // determines what fields are valid + dwHeight: DWORD; // height of surface to be created + dwWidth: DWORD; // width of input surface + case Integer of + 0: ( + dwLinearSize: DWORD; // unused at the moment + ); + 1: ( + lPitch: Longint; // distance to start of next line (return value only) + dwBackBufferCount: DWORD; // number of back buffers requested + case Integer of + 0: ( + dwMipMapCount: DWORD; // number of mip-map levels requested + dwAlphaBitDepth: DWORD; // depth of alpha buffer requested + dwReserved: DWORD; // reserved + lpSurface: Pointer; // pointer to the associated surface memory + ddckCKDestOverlay: TDDColorKey; // color key for destination overlay use + ddckCKDestBlt: TDDColorKey; // color key for destination blt use + ddckCKSrcOverlay: TDDColorKey; // color key for source overlay use + ddckCKSrcBlt: TDDColorKey; // color key for source blt use + ddpfPixelFormat: TDDPixelFormat; // pixel format description of the surface + ddsCaps: TDDSCaps; // direct draw surface capabilities + ); + 1: ( + dwZBufferBitDepth: DWORD; // depth of Z buffer requested + ); + 2: ( + dwRefreshRate: DWORD; // refresh rate (used when display mode is described) + ); + ); + end; + {$EXTERNALSYM _DDSURFACEDESC} + DDSURFACEDESC = _DDSURFACEDESC; + {$EXTERNALSYM DDSURFACEDESC} + TDDSurfaceDesc = _DDSURFACEDESC; + + // These definitions are for compatibility with Erik Unger original conversion + PDDSurfaceDesc_DX5 = PDDSurfaceDesc; + TDDSurfaceDesc_DX5 = TDDSurfaceDesc; + + PDDSurfaceDesc_DX6 = PDDSurfaceDesc; + TDDSurfaceDesc_DX6 = TDDSurfaceDesc; + + +(* + * TDDSurfaceDesc2 + *) + PDDSurfaceDesc2 = ^TDDSurfaceDesc2; + _DDSURFACEDESC2 = packed record + dwSize: DWORD; // size of the TDDSurfaceDesc structure + dwFlags: DWORD; // determines what fields are valid + dwHeight: DWORD; // height of surface to be created + dwWidth: DWORD; // width of input surface + case Integer of + 0: ( + lPitch : Longint; // distance to start of next line (return value only) + ); + 1: ( + dwLinearSize : DWORD; // Formless late-allocated optimized surface size + dwBackBufferCount: DWORD; // number of back buffers requested + case Integer of + 0: ( + dwMipMapCount: DWORD; // number of mip-map levels requested + dwAlphaBitDepth: DWORD; // depth of alpha buffer requested + dwReserved: DWORD; // reserved + lpSurface: Pointer; // pointer to the associated surface memory + ddckCKDestOverlay: TDDColorKey; // color key for destination overlay use + ddckCKDestBlt: TDDColorKey; // color key for destination blt use + ddckCKSrcOverlay: TDDColorKey; // color key for source overlay use + ddckCKSrcBlt: TDDColorKey; // color key for source blt use + ddpfPixelFormat: TDDPixelFormat; // pixel format description of the surface + ddsCaps: TDDSCaps2; // direct draw surface capabilities + dwTextureStage: DWORD; // stage in multitexture cascade + ); + 1: ( + dwRefreshRate: DWORD; // refresh rate (used when display mode is described) + ); + ); + end; + {$EXTERNALSYM _DDSURFACEDESC2} + DDSURFACEDESC2 = _DDSURFACEDESC2; + {$EXTERNALSYM DDSURFACEDESC2} + TDDSurfaceDesc2 = _DDSURFACEDESC2; + +(* + * TDDOptSurfaceDesc + *) + + PDDOptSurfaceDesc = ^TDDOptSurfaceDesc; + _DDOPTSURFACEDESC = packed record + dwSize : DWORD; // size of the DDOPTSURFACEDESC structure + dwFlags : DWORD; // determines what fields are valid + ddSCaps : TDDSCaps2; // Common caps like: Memory type + ddOSCaps : TDDOSCaps; // Common caps like: Memory type + guid : TGUID; // Compression technique GUID + dwCompressionRatio : DWORD; // Compression ratio + end; + {$EXTERNALSYM _DDOPTSURFACEDESC} + DDOPTSURFACEDESC = _DDOPTSURFACEDESC; + {$EXTERNALSYM DDOPTSURFACEDESC} + TDDOptSurfaceDesc = _DDOPTSURFACEDESC; + +(* + * DDCOLORCONTROL + *) + PDDColorControl = ^TDDColorControl; + _DDCOLORCONTROL = packed record + dwSize: DWORD; + dwFlags: DWORD; + lBrightness: Longint; + lContrast: Longint; + lHue: Longint; + lSaturation: Longint; + lSharpness: Longint; + lGamma: Longint; + lColorEnable: Longint; + dwReserved1: DWORD; + end; + {$EXTERNALSYM _DDCOLORCONTROL} + DDCOLORCONTROL = _DDCOLORCONTROL; + {$EXTERNALSYM DDCOLORCONTROL} + TDDColorControl = _DDCOLORCONTROL; + +(* + * callbacks + *) + +//{$IFNDEF WINNT} + TDDEnumModesCallback = function (const lpDDSurfaceDesc: TDDSurfaceDesc; + lpContext: Pointer): HResult; stdcall; + {$NODEFINE TDDEnumModesCallback} + {$HPPEMIT 'typedef LPCLIPPERCALLBACK TDDEnumModesCallback;'} + TDDEnumModesCallback2 = function (const lpDDSurfaceDesc: TDDSurfaceDesc2; + lpContext: Pointer): HResult; stdcall; + {$NODEFINE TDDEnumModesCallback2} + {$HPPEMIT 'typedef LPDDENUMMODESCALLBACK2 TDDEnumModesCallback2;'} + TDDEnumSurfacesCallback = function (lpDDSurface: IDirectDrawSurface; + const lpDDSurfaceDesc: TDDSurfaceDesc; lpContext: Pointer): HResult; stdcall; + {$NODEFINE TDDEnumSurfacesCallback} + {$HPPEMIT 'typedef LPDDENUMSURFACESCALLBACK TDDEnumSurfacesCallback;'} + TDDEnumSurfacesCallback2 = function (lpDDSurface: IDirectDrawSurface4; + const lpDDSurfaceDesc: TDDSurfaceDesc2; lpContext: Pointer): HResult; stdcall; + {$NODEFINE TDDEnumSurfacesCallback2} + {$HPPEMIT 'typedef LPDDENUMSURFACESCALLBACK2 TDDEnumSurfacesCallback2;'} + TDDEnumSurfacesCallback7 = function (lpDDSurface: IDirectDrawSurface7; + const lpDDSurfaceDesc: TDDSurfaceDesc2; lpContext: Pointer): HResult; stdcall; + {$NODEFINE TDDEnumSurfacesCallback7} + {$HPPEMIT 'typedef LPDDENUMSURFACESCALLBACK7 TDDEnumSurfacesCallback7;'} +//{$ENDIF} + +(* + * INTERACES FOLLOW: + * IDirectDraw + * IDirectDrawClipper + * IDirectDrawPalette + * IDirectDrawSurface + *) + +(* + * IDirectDraw + *) + + IDirectDraw = interface(IUnknown) + ['{6C14DB80-A733-11CE-A521-0020AF0BE560}'] + (*** IDirectDraw methods ***) + function Compact: HResult; stdcall; + function CreateClipper(dwFlags: DWORD; + out lplpDDClipper: IDirectDrawClipper; + pUnkOuter: IUnknown): HResult; stdcall; + function CreatePalette(dwFlags: DWORD; lpColorTable: Pointer; + out lplpDDPalette: IDirectDrawPalette; + pUnkOuter: IUnknown): HResult; stdcall; + function CreateSurface(var lpDDSurfaceDesc: TDDSurfaceDesc; + out lplpDDSurface: IDirectDrawSurface; + pUnkOuter: IUnknown): HResult; stdcall; + function DuplicateSurface(lpDDSurface: IDirectDrawSurface; + out lplpDupDDSurface: IDirectDrawSurface): HResult; stdcall; + function EnumDisplayModes(dwFlags: DWORD; + lpDDSurfaceDesc: PDDSurfaceDesc; lpContext: Pointer; + lpEnumModesCallback: TDDEnumModesCallback): HResult; stdcall; + function EnumSurfaces(dwFlags: DWORD; const lpDDSD: TDDSurfaceDesc; + lpContext: Pointer; lpEnumCallback: TDDEnumSurfacesCallback) : + HResult; stdcall; + function FlipToGDISurface: HResult; stdcall; + function GetCaps(lpDDDriverCaps: PDDCaps; lpDDHELCaps: PDDCaps): HResult; stdcall; + function GetDisplayMode(out lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall; + function GetFourCCCodes(var lpNumCodes: DWORD; lpCodes: PDWORD): HResult; stdcall; + function GetGDISurface(out lplpGDIDDSSurface: IDirectDrawSurface): HResult; stdcall; + function GetMonitorFrequency(out lpdwFrequency: DWORD): HResult; stdcall; + function GetScanLine(out lpdwScanLine: DWORD): HResult; stdcall; + function GetVerticalBlankStatus(out lpbIsInVB: BOOL): HResult; stdcall; + function Initialize(lpGUID: PGUID): HResult; stdcall; + function RestoreDisplayMode: HResult; stdcall; + function SetCooperativeLevel(hWnd: HWND; dwFlags: DWORD): HResult; stdcall; + (*** Warning! SetDisplayMode differs between DirectDraw 1 and DirectDraw 2 ***) + function SetDisplayMode(dwWidth: DWORD; dwHeight: DWORD; + dwBpp: DWORD): HResult; stdcall; + function WaitForVerticalBlank(dwFlags: DWORD; hEvent: THandle): HResult; stdcall; + end; + + IDirectDraw2 = interface(IUnknown) + ['{B3A6F3E0-2B43-11CF-A2DE-00AA00B93356}'] + (*** IDirectDraw methods ***) + function Compact: HResult; stdcall; + function CreateClipper(dwFlags: DWORD; + out lplpDDClipper: IDirectDrawClipper; + pUnkOuter: IUnknown): HResult; stdcall; + function CreatePalette(dwFlags: DWORD; lpColorTable: Pointer; + out lplpDDPalette: IDirectDrawPalette; + pUnkOuter: IUnknown): HResult; stdcall; + function CreateSurface(var lpDDSurfaceDesc: TDDSurfaceDesc; + out lplpDDSurface: IDirectDrawSurface; + pUnkOuter: IUnknown): HResult; stdcall; + function DuplicateSurface(lpDDSurface: IDirectDrawSurface; + out lplpDupDDSurface: IDirectDrawSurface): HResult; stdcall; + function EnumDisplayModes(dwFlags: DWORD; + lpDDSurfaceDesc: PDDSurfaceDesc; lpContext: Pointer; + lpEnumModesCallback: TDDEnumModesCallback): HResult; stdcall; + function EnumSurfaces(dwFlags: DWORD; var lpDDSD: TDDSurfaceDesc; + lpContext: Pointer; lpEnumCallback: TDDEnumSurfacesCallback): HResult; stdcall; + function FlipToGDISurface: HResult; stdcall; + function GetCaps(lpDDDriverCaps: PDDCaps; lpDDHELCaps: PDDCaps): HResult; stdcall; + function GetDisplayMode(out lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall; + function GetFourCCCodes(var lpNumCodes: DWORD; lpCodes: PDWORD): HResult; stdcall; + function GetGDISurface(out lplpGDIDDSSurface: IDirectDrawSurface): HResult; stdcall; + function GetMonitorFrequency(out lpdwFrequency: DWORD): HResult; stdcall; + function GetScanLine(out lpdwScanLine: DWORD): HResult; stdcall; + function GetVerticalBlankStatus(out lpbIsInVB: BOOL): HResult; stdcall; + function Initialize(lpGUID: PGUID): HResult; stdcall; + function RestoreDisplayMode: HResult; stdcall; + function SetCooperativeLevel(hWnd: HWND; dwFlags: DWORD): HResult; stdcall; + function SetDisplayMode(dwWidth: DWORD; dwHeight: DWORD; dwBPP: DWORD; + dwRefreshRate: DWORD; dwFlags: DWORD): HResult; stdcall; + function WaitForVerticalBlank(dwFlags: DWORD; hEvent: THandle): HResult; stdcall; + (*** Added in the v2 interface ***) + function GetAvailableVidMem(var lpDDSCaps: TDDSCaps; + out lpdwTotal, lpdwFree: DWORD): HResult; stdcall; + end; + + IDirectDraw4 = interface(IUnknown) + ['{9c59509a-39bd-11d1-8c4a-00c04fd930c5}'] + (*** IDirectDraw methods ***) + function Compact: HResult; stdcall; + function CreateClipper(dwFlags: DWORD; + out lplpDDClipper: IDirectDrawClipper; + pUnkOuter: IUnknown): HResult; stdcall; + function CreatePalette(dwFlags: DWORD; lpColorTable: Pointer; + out lplpDDPalette: IDirectDrawPalette; + pUnkOuter: IUnknown): HResult; stdcall; + function CreateSurface(const lpDDSurfaceDesc: TDDSurfaceDesc2; + out lplpDDSurface: IDirectDrawSurface4; + pUnkOuter: IUnknown): HResult; stdcall; + function DuplicateSurface(lpDDSurface: IDirectDrawSurface4; + out lplpDupDDSurface: IDirectDrawSurface4): HResult; stdcall; + function EnumDisplayModes(dwFlags: DWORD; + lpDDSurfaceDesc: PDDSurfaceDesc2; lpContext: Pointer; + lpEnumModesCallback: TDDEnumModesCallback2): HResult; stdcall; + function EnumSurfaces(dwFlags: DWORD; const lpDDSD: TDDSurfaceDesc2; + lpContext: Pointer; lpEnumCallback: TDDEnumSurfacesCallback2): + HResult; stdcall; + function FlipToGDISurface: HResult; stdcall; + function GetCaps(lpDDDriverCaps: PDDCaps; lpDDHELCaps: PDDCaps): HResult; stdcall; + function GetDisplayMode(out lpDDSurfaceDesc: TDDSurfaceDesc2): HResult; stdcall; + function GetFourCCCodes(var lpNumCodes: DWORD; lpCodes: PDWORD): HResult; stdcall; + function GetGDISurface(out lplpGDIDDSSurface: IDirectDrawSurface4): HResult; stdcall; + function GetMonitorFrequency(out lpdwFrequency: DWORD): HResult; stdcall; + function GetScanLine(out lpdwScanLine: DWORD): HResult; stdcall; + function GetVerticalBlankStatus(out lpbIsInVB: BOOL): HResult; stdcall; + function Initialize(lpGUID: PGUID): HResult; stdcall; + function RestoreDisplayMode: HResult; stdcall; + function SetCooperativeLevel(hWnd: HWND; dwFlags: DWORD): HResult; stdcall; + function SetDisplayMode(dwWidth: DWORD; dwHeight: DWORD; dwBPP: DWORD; + dwRefreshRate: DWORD; dwFlags: DWORD): HResult; stdcall; + function WaitForVerticalBlank(dwFlags: DWORD; hEvent: THandle): HResult; stdcall; + (*** Added in the v2 interface ***) + function GetAvailableVidMem(const lpDDSCaps: TDDSCaps2; + out lpdwTotal, lpdwFree: DWORD): HResult; stdcall; + (*** Added in the V4 Interface ***) + function GetSurfaceFromDC(hdc: Windows.HDC; + out lpDDS4: IDirectDrawSurface4): HResult; stdcall; + function RestoreAllSurfaces: HResult; stdcall; + function TestCooperativeLevel: HResult; stdcall; + function GetDeviceIdentifier(out lpdddi: TDDDeviceIdentifier; + dwFlags: DWORD): HResult; stdcall; + end; + + IDirectDraw7 = interface(IUnknown) + ['{15e65ec0-3b9c-11d2-b92f-00609797ea5b}'] + (*** IDirectDraw methods ***) + function Compact: HResult; stdcall; + function CreateClipper(dwFlags: DWORD; + out lplpDDClipper: IDirectDrawClipper; + pUnkOuter: IUnknown): HResult; stdcall; + function CreatePalette(dwFlags: DWORD; lpColorTable: Pointer; + out lplpDDPalette: IDirectDrawPalette; + pUnkOuter: IUnknown): HResult; stdcall; + function CreateSurface(const lpDDSurfaceDesc: TDDSurfaceDesc2; + out lplpDDSurface: IDirectDrawSurface7; + pUnkOuter: IUnknown): HResult; stdcall; + function DuplicateSurface(lpDDSurface: IDirectDrawSurface7; + out lplpDupDDSurface: IDirectDrawSurface7): HResult; stdcall; + function EnumDisplayModes(dwFlags: DWORD; + lpDDSurfaceDesc: PDDSurfaceDesc2; lpContext: Pointer; + lpEnumModesCallback: TDDEnumModesCallback2): HResult; stdcall; + function EnumSurfaces(dwFlags: DWORD; const lpDDSD: TDDSurfaceDesc2; + lpContext: Pointer; lpEnumCallback: TDDEnumSurfacesCallback7) : + HResult; stdcall; + function FlipToGDISurface: HResult; stdcall; + function GetCaps(lpDDDriverCaps: PDDCaps; lpDDHELCaps: PDDCaps): HResult; stdcall; + function GetDisplayMode(out lpDDSurfaceDesc: TDDSurfaceDesc2): HResult; stdcall; + function GetFourCCCodes(var lpNumCodes: DWORD; lpCodes: PDWORD): HResult; stdcall; + function GetGDISurface(out lplpGDIDDSSurface: IDirectDrawSurface7) : + HResult; stdcall; + function GetMonitorFrequency(out lpdwFrequency: DWORD): HResult; stdcall; + function GetScanLine(out lpdwScanLine: DWORD): HResult; stdcall; + function GetVerticalBlankStatus(out lpbIsInVB: BOOL): HResult; stdcall; + function Initialize(lpGUID: PGUID): HResult; stdcall; + function RestoreDisplayMode: HResult; stdcall; + function SetCooperativeLevel(hWnd: HWND; dwFlags: DWORD): HResult; stdcall; + function SetDisplayMode(dwWidth: DWORD; dwHeight: DWORD; dwBPP: DWORD; + dwRefreshRate: DWORD; dwFlags: DWORD): HResult; stdcall; + function WaitForVerticalBlank(dwFlags: DWORD; hEvent: THandle) : + HResult; stdcall; + (*** Added in the v2 interface ***) + function GetAvailableVidMem(const lpDDSCaps: TDDSCaps2; + out lpdwTotal, lpdwFree: DWORD): HResult; stdcall; + (*** Added in the V4 Interface ***) + function GetSurfaceFromDC(hdc: Windows.HDC; + out lpDDS: IDirectDrawSurface7): HResult; stdcall; + function RestoreAllSurfaces: HResult; stdcall; + function TestCooperativeLevel: HResult; stdcall; + function GetDeviceIdentifier(out lpdddi: TDDDeviceIdentifier2; + dwFlags: DWORD): HResult; stdcall; + function StartModeTest(const lpModesToTest; dwNumEntries, dwFlags: DWORD): HResult; stdcall; + function EvaluateMode(dwFlags: DWORD; out pSecondsUntilTimeout: DWORD): HResult; stdcall; + end; + + + +(* + * IDirectDrawPalette + *) + + IDirectDrawPalette = interface(IUnknown) + ['{6C14DB84-A733-11CE-A521-0020AF0BE560}'] + (*** IDirectDrawPalette methods ***) + function GetCaps(out lpdwCaps: DWORD): HResult; stdcall; + function GetEntries(dwFlags: DWORD; dwBase: DWORD; dwNumEntries: DWORD; + lpEntries: Pointer): HResult; stdcall; + function Initialize(lpDD: IDirectDraw; dwFlags: DWORD; + lpDDColorTable: Pointer): HResult; stdcall; + function SetEntries(dwFlags: DWORD; dwStartingEntry: DWORD; + dwCount: DWORD; lpEntries: Pointer): HResult; stdcall; + end; + +(* + * IDirectDrawClipper + *) + + IDirectDrawClipper = interface(IUnknown) + ['{6C14DB85-A733-11CE-A521-0020AF0BE560}'] + (*** IDirectDrawClipper methods ***) + function GetClipList(lpRect: PRect; lpClipList: PRgnData; + var lpdwSize: DWORD): HResult; stdcall; + function GetHWnd(out lphWnd: HWND): HResult; stdcall; + function Initialize(lpDD: IDirectDraw; dwFlags: DWORD): HResult; stdcall; + function IsClipListChanged(out lpbChanged: BOOL): HResult; stdcall; + function SetClipList(lpClipList: PRgnData; dwFlags: DWORD): HResult; stdcall; + function SetHWnd(dwFlags: DWORD; hWnd: HWND): HResult; stdcall; + end; + +(* + * IDirectDrawSurface and related interfaces + *) + + IDirectDrawSurface = interface(IUnknown) + ['{6C14DB81-A733-11CE-A521-0020AF0BE560}'] + (*** IDirectDrawSurface methods ***) + function AddAttachedSurface(lpDDSAttachedSurface: IDirectDrawSurface) : + HResult; stdcall; + function AddOverlayDirtyRect(const lpRect: TRect): HResult; stdcall; + function Blt(lpDestRect: PRect; + lpDDSrcSurface: IDirectDrawSurface; lpSrcRect: PRect; + dwFlags: DWORD; lpDDBltFx: PDDBltFX): HResult; stdcall; + function BltBatch(const lpDDBltBatch: TDDBltBatch; dwCount: DWORD; + dwFlags: DWORD): HResult; stdcall; + function BltFast(dwX: DWORD; dwY: DWORD; + lpDDSrcSurface: IDirectDrawSurface; lpSrcRect: PRect; + dwTrans: DWORD): HResult; stdcall; + function DeleteAttachedSurface(dwFlags: DWORD; + lpDDSAttachedSurface: IDirectDrawSurface): HResult; stdcall; + function EnumAttachedSurfaces(lpContext: Pointer; + lpEnumSurfacesCallback: TDDEnumSurfacesCallback): HResult; stdcall; + function EnumOverlayZOrders(dwFlags: DWORD; lpContext: Pointer; + lpfnCallback: TDDEnumSurfacesCallback): HResult; stdcall; + function Flip(lpDDSurfaceTargetOverride: IDirectDrawSurface; + dwFlags: DWORD): HResult; stdcall; + function GetAttachedSurface(var lpDDSCaps: TDDSCaps; + (*out*)var lplpDDAttachedSurface: IDirectDrawSurface): HResult; stdcall; + function GetBltStatus(dwFlags: DWORD): HResult; stdcall; + function GetCaps(out lpDDSCaps: TDDSCaps): HResult; stdcall; + function GetClipper(out lplpDDClipper: IDirectDrawClipper): HResult; stdcall; + function GetColorKey(dwFlags: DWORD; out lpDDColorKey: TDDColorKey) : + HResult; stdcall; + function GetDC(out lphDC: HDC): HResult; stdcall; + function GetFlipStatus(dwFlags: DWORD): HResult; stdcall; + function GetOverlayPosition(out lplX, lplY: Longint): HResult; stdcall; + function GetPalette(out lplpDDPalette: IDirectDrawPalette): HResult; stdcall; + function GetPixelFormat(out lpDDPixelFormat: TDDPixelFormat): HResult; stdcall; + function GetSurfaceDesc(out lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall; + function Initialize(lpDD: IDirectDraw; + out lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall; + function IsLost: HResult; stdcall; + function Lock(lpDestRect: PRect; out lpDDSurfaceDesc: + TDDSurfaceDesc; dwFlags: DWORD; hEvent: THandle): HResult; stdcall; + function ReleaseDC(hDC: Windows.HDC): HResult; stdcall; + function _Restore: HResult; stdcall; + function SetClipper(lpDDClipper: IDirectDrawClipper): HResult; stdcall; + function SetColorKey(dwFlags: DWORD; lpDDColorKey: PDDColorKey) : + HResult; stdcall; + function SetOverlayPosition(lX, lY: Longint): HResult; stdcall; + function SetPalette(lpDDPalette: IDirectDrawPalette): HResult; stdcall; + function Unlock(lpSurfaceData: Pointer): HResult; stdcall; + function UpdateOverlay(lpSrcRect: PRect; + lpDDDestSurface: IDirectDrawSurface; lpDestRect: PRect; + dwFlags: DWORD; lpDDOverlayFx: PDDOverlayFX): HResult; stdcall; + function UpdateOverlayDisplay(dwFlags: DWORD): HResult; stdcall; + function UpdateOverlayZOrder(dwFlags: DWORD; + lpDDSReference: IDirectDrawSurface): HResult; stdcall; + end; + +(* + * IDirectDrawSurface2 and related interfaces + *) + + IDirectDrawSurface2 = interface(IUnknown) + ['{57805885-6eec-11cf-9441-a82303c10e27}'] + (*** IDirectDrawSurface methods ***) + function AddAttachedSurface(lpDDSAttachedSurface: IDirectDrawSurface2) : + HResult; stdcall; + function AddOverlayDirtyRect(const lpRect: TRect): HResult; stdcall; + function Blt(lpDestRect: PRect; + lpDDSrcSurface: IDirectDrawSurface2; lpSrcRect: PRect; + dwFlags: DWORD; lpDDBltFx: PDDBltFX): HResult; stdcall; + function BltBatch(const lpDDBltBatch: TDDBltBatch; dwCount: DWORD; + dwFlags: DWORD): HResult; stdcall; + function BltFast(dwX: DWORD; dwY: DWORD; + lpDDSrcSurface: IDirectDrawSurface2; lpSrcRect: PRect; + dwTrans: DWORD): HResult; stdcall; + function DeleteAttachedSurface(dwFlags: DWORD; + lpDDSAttachedSurface: IDirectDrawSurface2): HResult; stdcall; + function EnumAttachedSurfaces(lpContext: Pointer; + lpEnumSurfacesCallback: TDDEnumSurfacesCallback): HResult; stdcall; + function EnumOverlayZOrders(dwFlags: DWORD; lpContext: Pointer; + lpfnCallback: TDDEnumSurfacesCallback): HResult; stdcall; + function Flip(lpDDSurfaceTargetOverride: IDirectDrawSurface2; + dwFlags: DWORD): HResult; stdcall; + function GetAttachedSurface(var lpDDSCaps: TDDSCaps; + out lplpDDAttachedSurface: IDirectDrawSurface2): HResult; stdcall; + function GetBltStatus(dwFlags: DWORD): HResult; stdcall; + function GetCaps(out lpDDSCaps: TDDSCaps): HResult; stdcall; + function GetClipper(out lplpDDClipper: IDirectDrawClipper): HResult; stdcall; + function GetColorKey(dwFlags: DWORD; out lpDDColorKey: TDDColorKey) : + HResult; stdcall; + function GetDC(out lphDC: HDC): HResult; stdcall; + function GetFlipStatus(dwFlags: DWORD): HResult; stdcall; + function GetOverlayPosition(out lplX, lplY: Longint): HResult; stdcall; + function GetPalette(out lplpDDPalette: IDirectDrawPalette): HResult; stdcall; + function GetPixelFormat(out lpDDPixelFormat: TDDPixelFormat): HResult; stdcall; + function GetSurfaceDesc(out lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall; + function Initialize(lpDD: IDirectDraw; + out lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall; + function IsLost: HResult; stdcall; + function Lock(lpDestRect: PRect; + out lpDDSurfaceDesc: TDDSurfaceDesc; dwFlags: DWORD; + hEvent: THandle): HResult; stdcall; + function ReleaseDC(hDC: Windows.HDC): HResult; stdcall; + function _Restore: HResult; stdcall; + function SetClipper(lpDDClipper: IDirectDrawClipper): HResult; stdcall; + function SetColorKey(dwFlags: DWORD; lpDDColorKey: PDDColorKey) : + HResult; stdcall; + function SetOverlayPosition(lX, lY: Longint): HResult; stdcall; + function SetPalette(lpDDPalette: IDirectDrawPalette): HResult; stdcall; + function Unlock(lpSurfaceData: Pointer): HResult; stdcall; + function UpdateOverlay(lpSrcRect: PRect; + lpDDDestSurface: IDirectDrawSurface2; lpDestRect: PRect; + dwFlags: DWORD; lpDDOverlayFx: PDDOverlayFX): HResult; stdcall; + function UpdateOverlayDisplay(dwFlags: DWORD): HResult; stdcall; + function UpdateOverlayZOrder(dwFlags: DWORD; + lpDDSReference: IDirectDrawSurface2): HResult; stdcall; + (*** Added in the v2 interface ***) + function GetDDInterface(var lplpDD: IDirectDraw): HResult; stdcall; + function PageLock(dwFlags: DWORD): HResult; stdcall; + function PageUnlock(dwFlags: DWORD): HResult; stdcall; + end; + + IDirectDrawSurface3 = interface(IUnknown) + ['{DA044E00-69B2-11D0-A1D5-00AA00B8DFBB}'] + (*** IDirectDrawSurface methods ***) + function AddAttachedSurface(lpDDSAttachedSurface: IDirectDrawSurface3) : + HResult; stdcall; + function AddOverlayDirtyRect(const lpRect: TRect): HResult; stdcall; + function Blt(lpDestRect: PRect; + lpDDSrcSurface: IDirectDrawSurface3; lpSrcRect: PRect; + dwFlags: DWORD; lpDDBltFx: PDDBltFX): HResult; stdcall; + function BltBatch(const lpDDBltBatch: TDDBltBatch; dwCount: DWORD; + dwFlags: DWORD): HResult; stdcall; + function BltFast(dwX: DWORD; dwY: DWORD; + lpDDSrcSurface: IDirectDrawSurface3; lpSrcRect: PRect; + dwTrans: DWORD): HResult; stdcall; + function DeleteAttachedSurface(dwFlags: DWORD; + lpDDSAttachedSurface: IDirectDrawSurface3): HResult; stdcall; + function EnumAttachedSurfaces(lpContext: Pointer; + lpEnumSurfacesCallback: TDDEnumSurfacesCallback): HResult; stdcall; + function EnumOverlayZOrders(dwFlags: DWORD; lpContext: Pointer; + lpfnCallback: TDDEnumSurfacesCallback): HResult; stdcall; + function Flip(lpDDSurfaceTargetOverride: IDirectDrawSurface3; + dwFlags: DWORD): HResult; stdcall; + function GetAttachedSurface(var lpDDSCaps: TDDSCaps; + out lplpDDAttachedSurface: IDirectDrawSurface3): HResult; stdcall; + function GetBltStatus(dwFlags: DWORD): HResult; stdcall; + function GetCaps(out lpDDSCaps: TDDSCaps): HResult; stdcall; + function GetClipper(out lplpDDClipper: IDirectDrawClipper): HResult; stdcall; + function GetColorKey(dwFlags: DWORD; out lpDDColorKey: TDDColorKey) : + HResult; stdcall; + function GetDC(out lphDC: HDC): HResult; stdcall; + function GetFlipStatus(dwFlags: DWORD): HResult; stdcall; + function GetOverlayPosition(out lplX, lplY: Longint): HResult; stdcall; + function GetPalette(out lplpDDPalette: IDirectDrawPalette): HResult; stdcall; + function GetPixelFormat(out lpDDPixelFormat: TDDPixelFormat): HResult; stdcall; + function GetSurfaceDesc(out lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall; + function Initialize(lpDD: IDirectDraw; + out lpDDSurfaceDesc: TDDSurfaceDesc): HResult; stdcall; + function IsLost: HResult; stdcall; + function Lock(lpDestRect: PRect; + out lpDDSurfaceDesc: TDDSurfaceDesc; dwFlags: DWORD; + hEvent: THandle): HResult; stdcall; + function ReleaseDC(hDC: Windows.HDC): HResult; stdcall; + function _Restore: HResult; stdcall; + function SetClipper(lpDDClipper: IDirectDrawClipper): HResult; stdcall; + function SetColorKey(dwFlags: DWORD; lpDDColorKey: PDDColorKey) : + HResult; stdcall; + function SetOverlayPosition(lX, lY: Longint): HResult; stdcall; + function SetPalette(lpDDPalette: IDirectDrawPalette): HResult; stdcall; + function Unlock(lpSurfaceData: Pointer): HResult; stdcall; + function UpdateOverlay(lpSrcRect: PRect; + lpDDDestSurface: IDirectDrawSurface3; lpDestRect: PRect; + dwFlags: DWORD; lpDDOverlayFx: PDDOverlayFX): HResult; stdcall; + function UpdateOverlayDisplay(dwFlags: DWORD): HResult; stdcall; + function UpdateOverlayZOrder(dwFlags: DWORD; + lpDDSReference: IDirectDrawSurface3): HResult; stdcall; + (*** Added in the v2 interface ***) + function GetDDInterface(out lplpDD: IDirectDraw): HResult; stdcall; + function PageLock(dwFlags: DWORD): HResult; stdcall; + function PageUnlock(dwFlags: DWORD): HResult; stdcall; + (*** Added in the V3 interface ***) + function SetSurfaceDesc(const lpddsd: TDDSurfaceDesc; dwFlags: DWORD): HResult; stdcall; + end; + +(* + * IDirectDrawSurface4 and related interfaces + *) + IDirectDrawSurface4 = interface(IUnknown) + ['{0B2B8630-AD35-11D0-8EA6-00609797EA5B}'] + (*** IDirectDrawSurface methods ***) + function AddAttachedSurface(lpDDSAttachedSurface: IDirectDrawSurface4) : + HResult; stdcall; + function AddOverlayDirtyRect(const lpRect: TRect): HResult; stdcall; + function Blt(lpDestRect: PRect; + lpDDSrcSurface: IDirectDrawSurface4; lpSrcRect: PRect; + dwFlags: DWORD; lpDDBltFx: PDDBltFX): HResult; stdcall; + function BltBatch(const lpDDBltBatch: TDDBltBatch; dwCount: DWORD; + dwFlags: DWORD): HResult; stdcall; + function BltFast(dwX: DWORD; dwY: DWORD; + lpDDSrcSurface: IDirectDrawSurface4; lpSrcRect: PRect; + dwTrans: DWORD): HResult; stdcall; + function DeleteAttachedSurface(dwFlags: DWORD; + lpDDSAttachedSurface: IDirectDrawSurface4): HResult; stdcall; + function EnumAttachedSurfaces(lpContext: Pointer; + lpEnumSurfacesCallback: TDDEnumSurfacesCallback2): HResult; stdcall; + function EnumOverlayZOrders(dwFlags: DWORD; lpContext: Pointer; + lpfnCallback: TDDEnumSurfacesCallback2): HResult; stdcall; + function Flip(lpDDSurfaceTargetOverride: IDirectDrawSurface4; + dwFlags: DWORD): HResult; stdcall; + function GetAttachedSurface(const lpDDSCaps: TDDSCaps2; + out lplpDDAttachedSurface: IDirectDrawSurface4): HResult; stdcall; + function GetBltStatus(dwFlags: DWORD): HResult; stdcall; + function GetCaps(out lpDDSCaps: TDDSCaps2): HResult; stdcall; + function GetClipper(out lplpDDClipper: IDirectDrawClipper): HResult; stdcall; + function GetColorKey(dwFlags: DWORD; out lpDDColorKey: TDDColorKey) : + HResult; stdcall; + function GetDC(out lphDC: HDC): HResult; stdcall; + function GetFlipStatus(dwFlags: DWORD): HResult; stdcall; + function GetOverlayPosition(out lplX, lplY: Longint): HResult; stdcall; + function GetPalette(out lplpDDPalette: IDirectDrawPalette): HResult; stdcall; + function GetPixelFormat(out lpDDPixelFormat: TDDPixelFormat): HResult; stdcall; + function GetSurfaceDesc(out lpDDSurfaceDesc: TDDSurfaceDesc2): HResult; stdcall; + function Initialize(lpDD: IDirectDraw; + out lpDDSurfaceDesc: TDDSurfaceDesc2): HResult; stdcall; + function IsLost: HResult; stdcall; + function Lock(lpDestRect: PRect; + out lpDDSurfaceDesc: TDDSurfaceDesc2; dwFlags: DWORD; + hEvent: THandle): HResult; stdcall; + function ReleaseDC(hDC: Windows.HDC): HResult; stdcall; + function _Restore: HResult; stdcall; + function SetClipper(lpDDClipper: IDirectDrawClipper): HResult; stdcall; + function SetColorKey(dwFlags: DWORD; lpDDColorKey: PDDColorKey) : + HResult; stdcall; + function SetOverlayPosition(lX, lY: Longint): HResult; stdcall; + function SetPalette(lpDDPalette: IDirectDrawPalette): HResult; stdcall; + function Unlock(lpRect: PRect): HResult; stdcall; + function UpdateOverlay(lpSrcRect: PRect; + lpDDDestSurface: IDirectDrawSurface4; lpDestRect: PRect; + dwFlags: DWORD; lpDDOverlayFx: PDDOverlayFX): HResult; stdcall; + function UpdateOverlayDisplay(dwFlags: DWORD): HResult; stdcall; + function UpdateOverlayZOrder(dwFlags: DWORD; + lpDDSReference: IDirectDrawSurface4): HResult; stdcall; + (*** Added in the v2 interface ***) + function GetDDInterface(out lplpDD: IUnknown): HResult; stdcall; + function PageLock(dwFlags: DWORD): HResult; stdcall; + function PageUnlock(dwFlags: DWORD): HResult; stdcall; + (*** Added in the V3 interface ***) + function SetSurfaceDesc(const lpddsd2: TDDSurfaceDesc2; dwFlags: DWORD): HResult; stdcall; + (*** Added in the v4 interface ***) + function SetPrivateData(const guidTag: TGUID; lpData: Pointer; + cbSize: DWORD; dwFlags: DWORD): HResult; stdcall; + function GetPrivateData(const guidTag: TGUID; lpBuffer: Pointer; + var lpcbBufferSize: DWORD): HResult; stdcall; + function FreePrivateData(const guidTag: TGUID): HResult; stdcall; + function GetUniquenessValue(out lpValue: DWORD): HResult; stdcall; + function ChangeUniquenessValue: HResult; stdcall; + end; + + IDirectDrawSurface7 = interface(IUnknown) + ['{06675a80-3b9b-11d2-b92f-00609797ea5b}'] + (*** IDirectDrawSurface methods ***) + function AddAttachedSurface(lpDDSAttachedSurface: IDirectDrawSurface7) : + HResult; stdcall; + function AddOverlayDirtyRect(const lpRect: TRect): HResult; stdcall; + function Blt(lpDestRect: PRect; + lpDDSrcSurface: IDirectDrawSurface7; lpSrcRect: PRect; + dwFlags: DWORD; lpDDBltFx: PDDBltFX): HResult; stdcall; + function BltBatch(const lpDDBltBatch: TDDBltBatch; dwCount: DWORD; + dwFlags: DWORD): HResult; stdcall; + function BltFast(dwX: DWORD; dwY: DWORD; + lpDDSrcSurface: IDirectDrawSurface7; lpSrcRect: PRect; + dwTrans: DWORD): HResult; stdcall; + function DeleteAttachedSurface(dwFlags: DWORD; + lpDDSAttachedSurface: IDirectDrawSurface7): HResult; stdcall; + function EnumAttachedSurfaces(lpContext: Pointer; + lpEnumSurfacesCallback: TDDEnumSurfacesCallback7): HResult; stdcall; + function EnumOverlayZOrders(dwFlags: DWORD; lpContext: Pointer; + lpfnCallback: TDDEnumSurfacesCallback7): HResult; stdcall; + function Flip(lpDDSurfaceTargetOverride: IDirectDrawSurface7; + dwFlags: DWORD): HResult; stdcall; + function GetAttachedSurface(const lpDDSCaps: TDDSCaps2; + out lplpDDAttachedSurface: IDirectDrawSurface7): HResult; stdcall; + function GetBltStatus(dwFlags: DWORD): HResult; stdcall; + function GetCaps(out lpDDSCaps: TDDSCaps2): HResult; stdcall; + function GetClipper(out lplpDDClipper: IDirectDrawClipper): HResult; stdcall; + function GetColorKey(dwFlags: DWORD; out lpDDColorKey: TDDColorKey) : + HResult; stdcall; + function GetDC(out lphDC: HDC): HResult; stdcall; + function GetFlipStatus(dwFlags: DWORD): HResult; stdcall; + function GetOverlayPosition(out lplX, lplY: Longint): HResult; stdcall; + function GetPalette(out lplpDDPalette: IDirectDrawPalette): HResult; stdcall; + function GetPixelFormat(out lpDDPixelFormat: TDDPixelFormat): HResult; stdcall; + function GetSurfaceDesc(out lpDDSurfaceDesc: TDDSurfaceDesc2): HResult; stdcall; + function Initialize(lpDD: IDirectDraw; + out lpDDSurfaceDesc: TDDSurfaceDesc2): HResult; stdcall; + function IsLost: HResult; stdcall; + function Lock(lpDestRect: PRect; + out lpDDSurfaceDesc: TDDSurfaceDesc2; dwFlags: DWORD; + hEvent: THandle): HResult; stdcall; + function ReleaseDC(hDC: Windows.HDC): HResult; stdcall; + function _Restore: HResult; stdcall; + function SetClipper(lpDDClipper: IDirectDrawClipper): HResult; stdcall; + function SetColorKey(dwFlags: DWORD; lpDDColorKey: PDDColorKey) : + HResult; stdcall; + function SetOverlayPosition(lX, lY: Longint): HResult; stdcall; + function SetPalette(lpDDPalette: IDirectDrawPalette): HResult; stdcall; + function Unlock(lpRect: PRect): HResult; stdcall; + function UpdateOverlay(lpSrcRect: PRect; + lpDDDestSurface: IDirectDrawSurface7; lpDestRect: PRect; + dwFlags: DWORD; lpDDOverlayFx: PDDOverlayFX): HResult; stdcall; + function UpdateOverlayDisplay(dwFlags: DWORD): HResult; stdcall; + function UpdateOverlayZOrder(dwFlags: DWORD; + lpDDSReference: IDirectDrawSurface7): HResult; stdcall; + (*** Added in the v2 interface ***) + function GetDDInterface(out lplpDD: IUnknown): HResult; stdcall; + function PageLock(dwFlags: DWORD): HResult; stdcall; + function PageUnlock(dwFlags: DWORD): HResult; stdcall; + (*** Added in the V3 interface ***) + function SetSurfaceDesc(const lpddsd2: TDDSurfaceDesc2; dwFlags: DWORD): HResult; stdcall; + (*** Added in the v4 interface ***) + function SetPrivateData(const guidTag: TGUID; lpData: Pointer; + cbSize: DWORD; dwFlags: DWORD): HResult; stdcall; + function GetPrivateData(const guidTag: TGUID; lpBuffer: Pointer; + var lpcbBufferSize: DWORD): HResult; stdcall; + function FreePrivateData(const guidTag: TGUID): HResult; stdcall; + function GetUniquenessValue(out lpValue: DWORD): HResult; stdcall; + function ChangeUniquenessValue: HResult; stdcall; + (*** Moved Texture7 methods here ***) + function SetPriority(dwPriority: DWORD): HResult; stdcall; + function GetPriority(out lpdwPriority: DWORD): HResult; stdcall; + function SetLOD(dwMaxLOD: DWORD): HResult; stdcall; + function GetLOD(out lpdwMaxLOD: DWORD): HResult; stdcall; + end; + + IDirectDrawColorControl = interface(IUnknown) + ['{4B9F0EE0-0D7E-11D0-9B06-00A0C903A3B8}'] + function GetColorControls(out lpColorControl: TDDColorControl): HResult; stdcall; + function SetColorControls(const lpColorControl: TDDColorControl): HResult; stdcall; + end; + +(* + * IDirectDrawGammaControl + *) + IDirectDrawGammaControl = interface(IUnknown) + ['{69C11C3E-B46B-11D1-AD7A-00C04FC29B4E}'] + function GetGammaRamp(dwFlags: DWORD; out lpRampData: TDDGammaRamp): HResult; stdcall; + function SetGammaRamp(dwFlags: DWORD; const lpRampData: TDDGammaRamp): HResult; stdcall; + end; + +type + IID_IDirectDraw = IDirectDraw; + {$EXTERNALSYM IID_IDirectDraw} + IID_IDirectDraw2 = IDirectDraw2; + {$EXTERNALSYM IID_IDirectDraw2} + IID_IDirectDraw4 = IDirectDraw4; + {$EXTERNALSYM IID_IDirectDraw4} + IID_IDirectDraw7 = IDirectDraw7; + {$EXTERNALSYM IID_IDirectDraw7} + IID_IDirectDrawSurface = IDirectDrawSurface; + {$EXTERNALSYM IID_IDirectDrawSurface} + IID_IDirectDrawSurface2 = IDirectDrawSurface2; + {$EXTERNALSYM IID_IDirectDrawSurface2} + IID_IDirectDrawSurface3 = IDirectDrawSurface3; + {$EXTERNALSYM IID_IDirectDrawSurface3} + IID_IDirectDrawSurface4 = IDirectDrawSurface4; + {$EXTERNALSYM IID_IDirectDrawSurface4} + IID_IDirectDrawSurface7 = IDirectDrawSurface7; + {$EXTERNALSYM IID_IDirectDrawSurface7} + + IID_IDirectDrawPalette = IDirectDrawPalette; + {$EXTERNALSYM IID_IDirectDrawPalette} + IID_IDirectDrawClipper = IDirectDrawClipper; + {$EXTERNALSYM IID_IDirectDrawClipper} + IID_IDirectDrawColorControl = IDirectDrawColorControl; + {$EXTERNALSYM IID_IDirectDrawColorControl} + IID_IDirectDrawGammaControl = IDirectDrawGammaControl; + {$EXTERNALSYM IID_IDirectDrawGammaControl} + +const +(* + * ddsCaps field is valid. + *) + DDSD_CAPS = $00000001; // default + {$EXTERNALSYM DDSD_CAPS} + +(* + * dwHeight field is valid. + *) + DDSD_HEIGHT = $00000002; + {$EXTERNALSYM DDSD_HEIGHT} + +(* + * dwWidth field is valid. + *) + DDSD_WIDTH = $00000004; + {$EXTERNALSYM DDSD_WIDTH} + +(* + * lPitch is valid. + *) + DDSD_PITCH = $00000008; + {$EXTERNALSYM DDSD_PITCH} + +(* + * dwBackBufferCount is valid. + *) + DDSD_BACKBUFFERCOUNT = $00000020; + {$EXTERNALSYM DDSD_BACKBUFFERCOUNT} + +(* + * dwZBufferBitDepth is valid. (shouldnt be used in DDSURFACEDESC2) + *) + DDSD_ZBUFFERBITDEPTH = $00000040; + {$EXTERNALSYM DDSD_ZBUFFERBITDEPTH} + +(* + * dwAlphaBitDepth is valid. + *) + DDSD_ALPHABITDEPTH = $00000080; + {$EXTERNALSYM DDSD_ALPHABITDEPTH} + +(* + * lpSurface is valid. + *) + DDSD_LPSURFACE = $00000800; + {$EXTERNALSYM DDSD_LPSURFACE} + +(* + * ddpfPixelFormat is valid. + *) + DDSD_PIXELFORMAT = $00001000; + {$EXTERNALSYM DDSD_PIXELFORMAT} + +(* + * ddckCKDestOverlay is valid. + *) + DDSD_CKDESTOVERLAY = $00002000; + {$EXTERNALSYM DDSD_CKDESTOVERLAY} + +(* + * ddckCKDestBlt is valid. + *) + DDSD_CKDESTBLT = $00004000; + {$EXTERNALSYM DDSD_CKDESTBLT} + +(* + * ddckCKSrcOverlay is valid. + *) + DDSD_CKSRCOVERLAY = $00008000; + {$EXTERNALSYM DDSD_CKSRCOVERLAY} + +(* + * ddckCKSrcBlt is valid. + *) + DDSD_CKSRCBLT = $00010000; + {$EXTERNALSYM DDSD_CKSRCBLT} + +(* + * dwMipMapCount is valid. + *) + DDSD_MIPMAPCOUNT = $00020000; + {$EXTERNALSYM DDSD_MIPMAPCOUNT} + + (* + * dwRefreshRate is valid + *) + DDSD_REFRESHRATE = $00040000; + {$EXTERNALSYM DDSD_REFRESHRATE} + +(* + * dwLinearSize is valid + *) + DDSD_LINEARSIZE = $00080000; + {$EXTERNALSYM DDSD_LINEARSIZE} + +(* + * dwTextureStage is valid + *) + DDSD_TEXTURESTAGE = $00100000; + {$EXTERNALSYM DDSD_TEXTURESTAGE} + +(* + * dwFVF is valid + *) + DDSD_FVF = $00200000; + {$EXTERNALSYM DDSD_FVF} + +(* + * dwSrcVBHandle is valid + *) + DDSD_SRCVBHANDLE = $00400000; + {$EXTERNALSYM DDSD_SRCVBHANDLE} + +(* + * dwDepth is valid + *) + DDSD_DEPTH = $00800000; + {$EXTERNALSYM DDSD_DEPTH} + +(* + * All input fields are valid. + *) + DDSD_ALL = $00fff9ee; + {$EXTERNALSYM DDSD_ALL} + + +(* + * guid field is valid. + *) + DDOSD_GUID = $00000001; + {$EXTERNALSYM DDOSD_GUID} + +(* + * dwCompressionRatio field is valid. + *) + DDOSD_COMPRESSION_RATIO = $00000002; + {$EXTERNALSYM DDOSD_COMPRESSION_RATIO} + +(* + * ddSCaps field is valid. + *) + DDOSD_SCAPS = $00000004; + {$EXTERNALSYM DDOSD_SCAPS} + +(* + * ddOSCaps field is valid. + *) + DDOSD_OSCAPS = $00000008; + {$EXTERNALSYM DDOSD_OSCAPS} + +(* + * All input fields are valid. + *) + DDOSD_ALL = $0000000f; + {$EXTERNALSYM DDOSD_ALL} + +(* + * The surface's optimized pixelformat is compressed + *) + DDOSDCAPS_OPTCOMPRESSED = $00000001; + {$EXTERNALSYM DDOSDCAPS_OPTCOMPRESSED} + +(* + * The surface's optimized pixelformat is reordered + *) + DDOSDCAPS_OPTREORDERED = $00000002; + {$EXTERNALSYM DDOSDCAPS_OPTREORDERED} + +(* + * The opt surface is a monolithic mipmap + *) + DDOSDCAPS_MONOLITHICMIPMAP = $00000004; + {$EXTERNALSYM DDOSDCAPS_MONOLITHICMIPMAP} + +(* + * The valid Surf caps: + * DDSCAPS_SYSTEMMEMORY = $00000800; + * DDSCAPS_VIDEOMEMORY = $00004000; + * DDSCAPS_LOCALVIDMEM = $10000000; + * DDSCAPS_NONLOCALVIDMEM = $20000000; + *) + DDOSDCAPS_VALIDSCAPS = $30004800; + {$EXTERNALSYM DDOSDCAPS_VALIDSCAPS} + +(* + * The valid OptSurf caps + *) + DDOSDCAPS_VALIDOSCAPS = $00000007; + {$EXTERNALSYM DDOSDCAPS_VALIDOSCAPS} + + +(* + * DDCOLORCONTROL + *) + +(* + * lBrightness field is valid. + *) + DDCOLOR_BRIGHTNESS = $00000001; + {$EXTERNALSYM DDCOLOR_BRIGHTNESS} + +(* + * lContrast field is valid. + *) + DDCOLOR_CONTRAST = $00000002; + {$EXTERNALSYM DDCOLOR_CONTRAST} + +(* + * lHue field is valid. + *) + DDCOLOR_HUE = $00000004; + {$EXTERNALSYM DDCOLOR_HUE} + +(* + * lSaturation field is valid. + *) + DDCOLOR_SATURATION = $00000008; + {$EXTERNALSYM DDCOLOR_SATURATION} + +(* + * lSharpness field is valid. + *) + DDCOLOR_SHARPNESS = $00000010; + {$EXTERNALSYM DDCOLOR_SHARPNESS} + +(* + * lGamma field is valid. + *) + DDCOLOR_GAMMA = $00000020; + {$EXTERNALSYM DDCOLOR_GAMMA} + +(* + * lColorEnable field is valid. + *) + DDCOLOR_COLORENABLE = $00000040; + {$EXTERNALSYM DDCOLOR_COLORENABLE} + + + +(*============================================================================ + * + * Direct Draw Capability Flags + * + * These flags are used to describe the capabilities of a given Surface. + * All flags are bit flags. + * + *==========================================================================*) + +(**************************************************************************** + * + * DIRECTDRAWSURFACE CAPABILITY FLAGS + * + ****************************************************************************) +(* + * This bit currently has no meaning. + *) + DDSCAPS_RESERVED1 = $00000001; + {$EXTERNALSYM DDSCAPS_RESERVED1} + +(* + * Indicates that this surface contains alpha-only information. + * (To determine if a surface is RGBA/YUVA, the pixel format must be + * interrogated.) + *) + DDSCAPS_ALPHA = $00000002; + {$EXTERNALSYM DDSCAPS_ALPHA} + +(* + * Indicates that this surface is a backbuffer. It is generally + * set by CreateSurface when the DDSCAPS_FLIP capability bit is set. + * It indicates that this surface is THE back buffer of a surface + * flipping structure. DirectDraw supports N surfaces in a + * surface flipping structure. Only the surface that immediately + * precedeces the DDSCAPS_FRONTBUFFER has this capability bit set. + * The other surfaces are identified as back buffers by the presence + * of the DDSCAPS_FLIP capability, their attachment order, and the + * absence of the DDSCAPS_FRONTBUFFER and DDSCAPS_BACKBUFFER + * capabilities. The bit is sent to CreateSurface when a standalone + * back buffer is being created. This surface could be attached to + * a front buffer and/or back buffers to form a flipping surface + * structure after the CreateSurface call. See AddAttachments for + * a detailed description of the behaviors in this case. + *) + DDSCAPS_BACKBUFFER = $00000004; + {$EXTERNALSYM DDSCAPS_BACKBUFFER} + +(* + * Indicates a complex surface structure is being described. A + * complex surface structure results in the creation of more than + * one surface. The additional surfaces are attached to the root + * surface. The complex structure can only be destroyed by + * destroying the root. + *) + DDSCAPS_COMPLEX = $00000008; + {$EXTERNALSYM DDSCAPS_COMPLEX} + +(* + * Indicates that this surface is a part of a surface flipping structure. + * When it is passed to CreateSurface the DDSCAPS_FRONTBUFFER and + * DDSCAP_BACKBUFFER bits are not set. They are set by CreateSurface + * on the resulting creations. The dwBackBufferCount field in the + * TDDSurfaceDesc structure must be set to at least 1 in order for + * the CreateSurface call to succeed. The DDSCAPS_COMPLEX capability + * must always be set with creating multiple surfaces through CreateSurface. + *) + DDSCAPS_FLIP = $00000010; + {$EXTERNALSYM DDSCAPS_FLIP} + +(* + * Indicates that this surface is THE front buffer of a surface flipping + * structure. It is generally set by CreateSurface when the DDSCAPS_FLIP + * capability bit is set. + * If this capability is sent to CreateSurface then a standalonw front buffer + * is created. This surface will not have the DDSCAPS_FLIP capability. + * It can be attached to other back buffers to form a flipping structure. + * See AddAttachments for a detailed description of the behaviors in this + * case. + *) + DDSCAPS_FRONTBUFFER = $00000020; + {$EXTERNALSYM DDSCAPS_FRONTBUFFER} + +(* + * Indicates that this surface is any offscreen surface that is not an overlay, + * texture, zbuffer, front buffer, back buffer, or alpha surface. It is used + * to identify plain vanilla surfaces. + *) + DDSCAPS_OFFSCREENPLAIN = $00000040; + {$EXTERNALSYM DDSCAPS_OFFSCREENPLAIN} + +(* + * Indicates that this surface is an overlay. It may or may not be directly visible + * depending on whether or not it is currently being overlayed onto the primary + * surface. DDSCAPS_VISIBLE can be used to determine whether or not it is being + * overlayed at the moment. + *) + DDSCAPS_OVERLAY = $00000080; + {$EXTERNALSYM DDSCAPS_OVERLAY} + +(* + * Indicates that unique DirectDrawPalette objects can be created and + * attached to this surface. + *) + DDSCAPS_PALETTE = $00000100; + {$EXTERNALSYM DDSCAPS_PALETTE} + +(* + * Indicates that this surface is the primary surface. The primary + * surface represents what the user is seeing at the moment. + *) + DDSCAPS_PRIMARYSURFACE = $00000200; + {$EXTERNALSYM DDSCAPS_PRIMARYSURFACE} + +(* + * This flag used to be DDSCAPS_PRIMARYSURFACELEFT, which is now + * obsolete. + *) + DDSCAPS_RESERVED3 = $00000400; + {$EXTERNALSYM DDSCAPS_RESERVED3} + DDSCAPS_PRIMARYSURFACELEFT = DDSCAPS_RESERVED3; + {$EXTERNALSYM DDSCAPS_PRIMARYSURFACELEFT} + +(* + * Indicates that this surface memory was allocated in system memory + *) + DDSCAPS_SYSTEMMEMORY = $00000800; + {$EXTERNALSYM DDSCAPS_SYSTEMMEMORY} + +(* + * Indicates that this surface can be used as a 3D texture. It does not + * indicate whether or not the surface is being used for that purpose. + *) + DDSCAPS_TEXTURE = $00001000; + {$EXTERNALSYM DDSCAPS_TEXTURE} + +(* + * Indicates that a surface may be a destination for 3D rendering. This + * bit must be set in order to query for a Direct3D Device Interface + * from this surface. + *) + DDSCAPS_3DDEVICE = $00002000; + {$EXTERNALSYM DDSCAPS_3DDEVICE} + +(* + * Indicates that this surface exists in video memory. + *) + DDSCAPS_VIDEOMEMORY = $00004000; + {$EXTERNALSYM DDSCAPS_VIDEOMEMORY} + +(* + * Indicates that changes made to this surface are immediately visible. + * It is always set for the primary surface and is set for overlays while + * they are being overlayed and texture maps while they are being textured. + *) + DDSCAPS_VISIBLE = $00008000; + {$EXTERNALSYM DDSCAPS_VISIBLE} + +(* + * Indicates that only writes are permitted to the surface. Read accesses + * from the surface may or may not generate a protection fault, but the + * results of a read from this surface will not be meaningful. READ ONLY. + *) + DDSCAPS_WRITEONLY = $00010000; + {$EXTERNALSYM DDSCAPS_WRITEONLY} + +(* + * Indicates that this surface is a z buffer. A z buffer does not contain + * displayable information. Instead it contains bit depth information that is + * used to determine which pixels are visible and which are obscured. + *) + DDSCAPS_ZBUFFER = $00020000; + {$EXTERNALSYM DDSCAPS_ZBUFFER} + +(* + * Indicates surface will have a DC associated long term + *) + DDSCAPS_OWNDC = $00040000; + {$EXTERNALSYM DDSCAPS_OWNDC} + +(* + * Indicates surface should be able to receive live video + *) + DDSCAPS_LIVEVIDEO = $00080000; + {$EXTERNALSYM DDSCAPS_LIVEVIDEO} + +(* + * Indicates surface should be able to have a stream decompressed + * to it by the hardware. + *) + DDSCAPS_HWCODEC = $00100000; + {$EXTERNALSYM DDSCAPS_HWCODEC} + +(* + * Surface is a ModeX surface. + * + *) + DDSCAPS_MODEX = $00200000; + {$EXTERNALSYM DDSCAPS_MODEX} + +(* + * Indicates surface is one level of a mip-map. This surface will + * be attached to other DDSCAPS_MIPMAP surfaces to form the mip-map. + * This can be done explicitly, by creating a number of surfaces and + * attaching them with AddAttachedSurface or by implicitly by CreateSurface. + * If this bit is set then DDSCAPS_TEXTURE must also be set. + *) + DDSCAPS_MIPMAP = $00400000; + {$EXTERNALSYM DDSCAPS_MIPMAP} + +(* + * This bit is reserved. It should not be specified. + *) + DDSCAPS_RESERVED2 = $00800000; + {$EXTERNALSYM DDSCAPS_RESERVED2} + +(* + * Indicates that memory for the surface is not allocated until the surface + * is loaded (via the Direct3D texture Load() function). + *) + DDSCAPS_ALLOCONLOAD = $04000000; + {$EXTERNALSYM DDSCAPS_ALLOCONLOAD} + +(* + * Indicates that the surface will recieve data from a video port. + *) + DDSCAPS_VIDEOPORT = $08000000; + {$EXTERNALSYM DDSCAPS_VIDEOPORT} + +(* + * Indicates that a video memory surface is resident in true, local video + * memory rather than non-local video memory. If this flag is specified then + * so must DDSCAPS_VIDEOMEMORY. This flag is mutually exclusive with + * DDSCAPS_NONLOCALVIDMEM. + *) + DDSCAPS_LOCALVIDMEM = $10000000; + {$EXTERNALSYM DDSCAPS_LOCALVIDMEM} + +(* + * Indicates that a video memory surface is resident in non-local video + * memory rather than true, local video memory. If this flag is specified + * then so must DDSCAPS_VIDEOMEMORY. This flag is mutually exclusive with + * DDSCAPS_LOCALVIDMEM. + *) + DDSCAPS_NONLOCALVIDMEM = $20000000; + {$EXTERNALSYM DDSCAPS_NONLOCALVIDMEM} + +(* + * Indicates that this surface is a standard VGA mode surface, and not a + * ModeX surface. (This flag will never be set in combination with the + * DDSCAPS_MODEX flag). + *) + DDSCAPS_STANDARDVGAMODE = $40000000; + {$EXTERNALSYM DDSCAPS_STANDARDVGAMODE} + +(* + * Indicates that this surface will be an optimized surface. This flag is + * currently only valid in conjunction with the DDSCAPS_TEXTURE flag. The surface + * will be created without any underlying video memory until loaded. + *) + DDSCAPS_OPTIMIZED = $80000000; + {$EXTERNALSYM DDSCAPS_OPTIMIZED} + + + +(* + * This bit is reserved + *) + DDSCAPS2_RESERVED4 = $00000002; + {$EXTERNALSYM DDSCAPS2_RESERVED4} + DDSCAPS2_HARDWAREDEINTERLACE = $00000000; + {$EXTERNALSYM DDSCAPS2_HARDWAREDEINTERLACE} + +(* + * Indicates to the driver that this surface will be locked very frequently + * (for procedural textures, dynamic lightmaps, etc). Surfaces with this cap + * set must also have DDSCAPS_TEXTURE. This cap cannot be used with + * DDSCAPS2_HINTSTATIC and DDSCAPS2_OPAQUE. + *) + DDSCAPS2_HINTDYNAMIC = $00000004; + {$EXTERNALSYM DDSCAPS2_HINTDYNAMIC} + +(* + * Indicates to the driver that this surface can be re-ordered/retiled on + * load. This operation will not change the size of the texture. It is + * relatively fast and symmetrical, since the application may lock these + * bits (although it will take a performance hit when doing so). Surfaces + * with this cap set must also have DDSCAPS_TEXTURE. This cap cannot be + * used with DDSCAPS2_HINTDYNAMIC and DDSCAPS2_OPAQUE. + *) + DDSCAPS2_HINTSTATIC = $00000008; + {$EXTERNALSYM DDSCAPS2_HINTSTATIC} + +(* + * Indicates that the client would like this texture surface to be managed by the + * DirectDraw/Direct3D runtime. Surfaces with this cap set must also have + * DDSCAPS_TEXTURE and DDSCAPS_SYSTEMMEMORY. + *) + DDSCAPS2_TEXTUREMANAGE = $00000010; + {$EXTERNALSYM DDSCAPS2_TEXTUREMANAGE} + +(* + * These bits are reserved for internal use *) + DDSCAPS2_RESERVED1 = $00000020; + {$EXTERNALSYM DDSCAPS2_RESERVED1} + DDSCAPS2_RESERVED2 = $00000040; + {$EXTERNALSYM DDSCAPS2_RESERVED2} + +(* + * Indicates to the driver that this surface will never be locked again. + * The driver is free to optimize this surface via retiling and actual compression. + * All calls to Lock() or Blts from this surface will fail. Surfaces with this + * cap set must also have DDSCAPS_TEXTURE. This cap cannot be used with + * DDSCAPS2_HINTDYNAMIC and DDSCAPS2_HINTSTATIC. + *) + DDSCAPS2_OPAQUE = $00000080; + {$EXTERNALSYM DDSCAPS2_OPAQUE} + +(* + * Applications should set this bit at CreateSurface time to indicate that they + * intend to use antialiasing. Only valid if DDSCAPS_3DDEVICE is also set. + *) + DDSCAPS2_HINTANTIALIASING = $00000100; + {$EXTERNALSYM DDSCAPS2_HINTANTIALIASING} + +(* + * This flag is used at CreateSurface time to indicate that this set of + * surfaces is a cubic environment map + *) + DDSCAPS2_CUBEMAP = $00000200; + {$EXTERNALSYM DDSCAPS2_CUBEMAP} + +(* + * These flags preform two functions: + * - At CreateSurface time, they define which of the six cube faces are + * required by the application. + * - After creation, each face in the cubemap will have exactly one of these + * bits set. + *) + DDSCAPS2_CUBEMAP_POSITIVEX = $00000400; + {$EXTERNALSYM DDSCAPS2_CUBEMAP_POSITIVEX} + DDSCAPS2_CUBEMAP_NEGATIVEX = $00000800; + {$EXTERNALSYM DDSCAPS2_CUBEMAP_NEGATIVEX} + DDSCAPS2_CUBEMAP_POSITIVEY = $00001000; + {$EXTERNALSYM DDSCAPS2_CUBEMAP_POSITIVEY} + DDSCAPS2_CUBEMAP_NEGATIVEY = $00002000; + {$EXTERNALSYM DDSCAPS2_CUBEMAP_NEGATIVEY} + DDSCAPS2_CUBEMAP_POSITIVEZ = $00004000; + {$EXTERNALSYM DDSCAPS2_CUBEMAP_POSITIVEZ} + DDSCAPS2_CUBEMAP_NEGATIVEZ = $00008000; + {$EXTERNALSYM DDSCAPS2_CUBEMAP_NEGATIVEZ} + +(* + * This macro may be used to specify all faces of a cube map at CreateSurface time + *) + DDSCAPS2_CUBEMAP_ALLFACES = ( DDSCAPS2_CUBEMAP_POSITIVEX or + DDSCAPS2_CUBEMAP_NEGATIVEX or + DDSCAPS2_CUBEMAP_POSITIVEY or + DDSCAPS2_CUBEMAP_NEGATIVEY or + DDSCAPS2_CUBEMAP_POSITIVEZ or + DDSCAPS2_CUBEMAP_NEGATIVEZ ); + {$EXTERNALSYM DDSCAPS2_CUBEMAP_ALLFACES} + + +(* + * This flag is an additional flag which is present on mipmap sublevels from DX7 onwards + * It enables easier use of GetAttachedSurface rather than EnumAttachedSurfaces for surface + * constructs such as Cube Maps, wherein there are more than one mipmap surface attached + * to the root surface. + * This caps bit is ignored by CreateSurface + *) + DDSCAPS2_MIPMAPSUBLEVEL = $00010000; + {$EXTERNALSYM DDSCAPS2_MIPMAPSUBLEVEL} + +(* This flag indicates that the texture should be managed by D3D only *) + DDSCAPS2_D3DTEXTUREMANAGE = $00020000; + {$EXTERNALSYM DDSCAPS2_D3DTEXTUREMANAGE} + +(* This flag indicates that the managed surface can be safely lost *) + DDSCAPS2_DONOTPERSIST = $00040000; + {$EXTERNALSYM DDSCAPS2_DONOTPERSIST} + +(* indicates that this surface is part of a stereo flipping chain *) + DDSCAPS2_STEREOSURFACELEFT = $00080000; + {$EXTERNALSYM DDSCAPS2_STEREOSURFACELEFT} + + +(* + * Indicates that the surface is a volume. + * Can be combined with DDSCAPS_MIPMAP to indicate a multi-level volume + *) + DDSCAPS2_VOLUME = $00200000; + {$EXTERNALSYM DDSCAPS2_VOLUME} + +(* + * Indicates that the surface may be locked multiple times by the application. + * This cap cannot be used with DDSCAPS2_OPAQUE. + *) + DDSCAPS2_NOTUSERLOCKABLE = $00400000; + {$EXTERNALSYM DDSCAPS2_NOTUSERLOCKABLE} + +(* + * Indicates that the vertex buffer data can be used to render points and + * point sprites. + *) + DDSCAPS2_POINTS = $00800000; + {$EXTERNALSYM DDSCAPS2_POINTS} + +(* + * Indicates that the vertex buffer data can be used to render rt pactches. + *) + DDSCAPS2_RTPATCHES = $01000000; + {$EXTERNALSYM DDSCAPS2_RTPATCHES} + +(* + * Indicates that the vertex buffer data can be used to render n patches. + *) + DDSCAPS2_NPATCHES = $02000000; + {$EXTERNALSYM DDSCAPS2_NPATCHES} + +(* + * This bit is reserved for internal use + *) + DDSCAPS2_RESERVED3 = $04000000; + {$EXTERNALSYM DDSCAPS2_RESERVED3} + + +(* + * Indicates that the contents of the backbuffer do not have to be preserved + * the contents of the backbuffer after they are presented. + *) + DDSCAPS2_DISCARDBACKBUFFER = $10000000; + {$EXTERNALSYM DDSCAPS2_DISCARDBACKBUFFER} + +(* + * Indicates that all surfaces in this creation chain should be given an alpha channel. + * This flag will be set on primary surface chains that may have no explicit pixel format + * (and thus take on the format of the current display mode). + * The driver should infer that all these surfaces have a format having an alpha channel. + * (e.g. assume D3DFMT_A8R8G8B8 if the display mode is x888.) + *) + DDSCAPS2_ENABLEALPHACHANNEL = $20000000; + {$EXTERNALSYM DDSCAPS2_ENABLEALPHACHANNEL} + +(* + * Indicates that all surfaces in this creation chain is extended primary surface format. + * This flag will be set on extended primary surface chains that always have explicit pixel + * format and the pixel format is typically GDI (Graphics Device Interface) couldn't handle, + * thus only used with fullscreen application. (e.g. D3DFMT_A2R10G10B10 format) + *) + DDSCAPS2_EXTENDEDFORMATPRIMARY = $40000000; + {$EXTERNALSYM DDSCAPS2_EXTENDEDFORMATPRIMARY} + +(* + * Indicates that all surfaces in this creation chain is additional primary surface. + * This flag will be set on primary surface chains which must present on the adapter + * id provided on dwCaps4. Typically this will be used to create secondary primary surface + * on DualView display adapter. + *) + DDSCAPS2_ADDITIONALPRIMARY = $80000000; + {$EXTERNALSYM DDSCAPS2_ADDITIONALPRIMARY} + +(* + * This is a mask that indicates the set of bits that may be set + * at createsurface time to indicate number of samples per pixel + * when multisampling + *) + DDSCAPS3_MULTISAMPLE_MASK = $0000001F; + {$EXTERNALSYM DDSCAPS3_MULTISAMPLE_MASK} + +(* + * This is a mask that indicates the set of bits that may be set + * at createsurface time to indicate the quality level of rendering + * for the current number of samples per pixel + *) + DDSCAPS3_MULTISAMPLE_QUALITY_MASK = $000000E0; + {$EXTERNALSYM DDSCAPS3_MULTISAMPLE_QUALITY_MASK} + DDSCAPS3_MULTISAMPLE_QUALITY_SHIFT = 5; + {$EXTERNALSYM DDSCAPS3_MULTISAMPLE_QUALITY_SHIFT} + +(* + * This bit is reserved for internal use + *) + DDSCAPS3_RESERVED1 = $00000100; + {$EXTERNALSYM DDSCAPS3_RESERVED1} + +(* + * This bit is reserved for internal use + *) + DDSCAPS3_RESERVED2 = $00000200; + {$EXTERNALSYM DDSCAPS3_RESERVED2} + +(* + * This indicates whether this surface has light-weight miplevels + *) + DDSCAPS3_LIGHTWEIGHTMIPMAP = $00000400; + {$EXTERNALSYM DDSCAPS3_LIGHTWEIGHTMIPMAP} + +(* + * This indicates that the mipsublevels for this surface are auto-generated + *) + DDSCAPS3_AUTOGENMIPMAP = $00000800; + {$EXTERNALSYM DDSCAPS3_AUTOGENMIPMAP} + +(* + * This indicates that the mipsublevels for this surface are auto-generated + *) + DDSCAPS3_DMAP = $00001000; + {$EXTERNALSYM DDSCAPS3_DMAP} + + + (**************************************************************************** + * + * DIRECTDRAW DRIVER CAPABILITY FLAGS + * + ****************************************************************************) + +(* + * Display hardware has 3D acceleration. + *) + DDCAPS_3D = $00000001; + {$EXTERNALSYM DDCAPS_3D} + +(* + * Indicates that DirectDraw will support only dest rectangles that are aligned + * on DIRECTDRAWCAPS.dwAlignBoundaryDest boundaries of the surface, respectively. + * READ ONLY. + *) + DDCAPS_ALIGNBOUNDARYDEST = $00000002; + {$EXTERNALSYM DDCAPS_ALIGNBOUNDARYDEST} + +(* + * Indicates that DirectDraw will support only source rectangles whose sizes in + * BYTEs are DIRECTDRAWCAPS.dwAlignSizeDest multiples, respectively. READ ONLY. + *) + DDCAPS_ALIGNSIZEDEST = $00000004; + {$EXTERNALSYM DDCAPS_ALIGNSIZEDEST} +(* + * Indicates that DirectDraw will support only source rectangles that are aligned + * on DIRECTDRAWCAPS.dwAlignBoundarySrc boundaries of the surface, respectively. + * READ ONLY. + *) + DDCAPS_ALIGNBOUNDARYSRC = $00000008; + {$EXTERNALSYM DDCAPS_ALIGNBOUNDARYSRC} + +(* + * Indicates that DirectDraw will support only source rectangles whose sizes in + * BYTEs are DIRECTDRAWCAPS.dwAlignSizeSrc multiples, respectively. READ ONLY. + *) + DDCAPS_ALIGNSIZESRC = $00000010; + {$EXTERNALSYM DDCAPS_ALIGNSIZESRC} + +(* + * Indicates that DirectDraw will create video memory surfaces that have a stride + * alignment equal to DIRECTDRAWCAPS.dwAlignStride. READ ONLY. + *) + DDCAPS_ALIGNSTRIDE = $00000020; + {$EXTERNALSYM DDCAPS_ALIGNSTRIDE} + +(* + * Display hardware is capable of blt operations. + *) + DDCAPS_BLT = $00000040; + {$EXTERNALSYM DDCAPS_BLT} + +(* + * Display hardware is capable of asynchronous blt operations. + *) + DDCAPS_BLTQUEUE = $00000080; + {$EXTERNALSYM DDCAPS_BLTQUEUE} + +(* + * Display hardware is capable of color space conversions during the blt operation. + *) + DDCAPS_BLTFOURCC = $00000100; + {$EXTERNALSYM DDCAPS_BLTFOURCC} + +(* + * Display hardware is capable of stretching during blt operations. + *) + DDCAPS_BLTSTRETCH = $00000200; + {$EXTERNALSYM DDCAPS_BLTSTRETCH} + +(* + * Display hardware is shared with GDI. + *) + DDCAPS_GDI = $00000400; + {$EXTERNALSYM DDCAPS_GDI} + +(* + * Display hardware can overlay. + *) + DDCAPS_OVERLAY = $00000800; + {$EXTERNALSYM DDCAPS_OVERLAY} + +(* + * Set if display hardware supports overlays but can not clip them. + *) + DDCAPS_OVERLAYCANTCLIP = $00001000; + {$EXTERNALSYM DDCAPS_OVERLAYCANTCLIP} + +(* + * Indicates that overlay hardware is capable of color space conversions during + * the overlay operation. + *) + DDCAPS_OVERLAYFOURCC = $00002000; + {$EXTERNALSYM DDCAPS_OVERLAYFOURCC} + +(* + * Indicates that stretching can be done by the overlay hardware. + *) + DDCAPS_OVERLAYSTRETCH = $00004000; + {$EXTERNALSYM DDCAPS_OVERLAYSTRETCH} + +(* + * Indicates that unique DirectDrawPalettes can be created for DirectDrawSurfaces + * other than the primary surface. + *) + DDCAPS_PALETTE = $00008000; + {$EXTERNALSYM DDCAPS_PALETTE} + +(* + * Indicates that palette changes can be syncd with the veritcal refresh. + *) + DDCAPS_PALETTEVSYNC = $00010000; + {$EXTERNALSYM DDCAPS_PALETTEVSYNC} + +(* + * Display hardware can return the current scan line. + *) + DDCAPS_READSCANLINE = $00020000; + {$EXTERNALSYM DDCAPS_READSCANLINE} + +(* + * This flag used to bo DDCAPS_STEREOVIEW, which is now obsolete + *) + DDCAPS_RESERVED1 = $00040000; + {$EXTERNALSYM DDCAPS_RESERVED1} + +(* + * Display hardware is capable of generating a vertical blank interrupt. + *) + DDCAPS_VBI = $00080000; + {$EXTERNALSYM DDCAPS_VBI} + +(* + * Supports the use of z buffers with blt operations. + *) + DDCAPS_ZBLTS = $00100000; + {$EXTERNALSYM DDCAPS_ZBLTS} + +(* + * Supports Z Ordering of overlays. + *) + DDCAPS_ZOVERLAYS = $00200000; + {$EXTERNALSYM DDCAPS_ZOVERLAYS} + +(* + * Supports color key + *) + DDCAPS_COLORKEY = $00400000; + {$EXTERNALSYM DDCAPS_COLORKEY} + +(* + * Supports alpha surfaces + *) + DDCAPS_ALPHA = $00800000; + {$EXTERNALSYM DDCAPS_ALPHA} + +(* + * colorkey is hardware assisted(DDCAPS_COLORKEY will also be set) + *) + DDCAPS_COLORKEYHWASSIST = $01000000; + {$EXTERNALSYM DDCAPS_COLORKEYHWASSIST} + +(* + * no hardware support at all + *) + DDCAPS_NOHARDWARE = $02000000; + {$EXTERNALSYM DDCAPS_NOHARDWARE} + +(* + * Display hardware is capable of color fill with bltter + *) + DDCAPS_BLTCOLORFILL = $04000000; + {$EXTERNALSYM DDCAPS_BLTCOLORFILL} + +(* + * Display hardware is bank switched, and potentially very slow at + * random access to VRAM. + *) + DDCAPS_BANKSWITCHED = $08000000; + {$EXTERNALSYM DDCAPS_BANKSWITCHED} + +(* + * Display hardware is capable of depth filling Z-buffers with bltter + *) + DDCAPS_BLTDEPTHFILL = $10000000; + {$EXTERNALSYM DDCAPS_BLTDEPTHFILL} + +(* + * Display hardware is capable of clipping while bltting. + *) + DDCAPS_CANCLIP = $20000000; + {$EXTERNALSYM DDCAPS_CANCLIP} + +(* + * Display hardware is capable of clipping while stretch bltting. + *) + DDCAPS_CANCLIPSTRETCHED = $40000000; + {$EXTERNALSYM DDCAPS_CANCLIPSTRETCHED} + +(* + * Display hardware is capable of bltting to or from system memory + *) + DDCAPS_CANBLTSYSMEM = $80000000; + {$EXTERNALSYM DDCAPS_CANBLTSYSMEM} + + + (**************************************************************************** + * + * MORE DIRECTDRAW DRIVER CAPABILITY FLAGS (dwCaps2) + * + ****************************************************************************) + +(* + * Display hardware is certified + *) + DDCAPS2_CERTIFIED = $00000001; + {$EXTERNALSYM DDCAPS2_CERTIFIED} + +(* + * Driver cannot interleave 2D operations (lock and blt) to surfaces with + * Direct3D rendering operations between calls to BeginScene() and EndScene() + *) + DDCAPS2_NO2DDURING3DSCENE = $00000002; + {$EXTERNALSYM DDCAPS2_NO2DDURING3DSCENE} + +(* + * Display hardware contains a video port + *) + DDCAPS2_VIDEOPORT = $00000004; + {$EXTERNALSYM DDCAPS2_VIDEOPORT} + +(* + * The overlay can be automatically flipped according to the video port + * VSYNCs, providing automatic doubled buffered display of video port + * data using an overlay + *) + DDCAPS2_AUTOFLIPOVERLAY = $00000008; + {$EXTERNALSYM DDCAPS2_AUTOFLIPOVERLAY} + +(* + * Overlay can display each field of interlaced data individually while + * it is interleaved in memory without causing jittery artifacts. + *) + DDCAPS2_CANBOBINTERLEAVED = $00000010; + {$EXTERNALSYM DDCAPS2_CANBOBINTERLEAVED} + +(* + * Overlay can display each field of interlaced data individually while + * it is not interleaved in memory without causing jittery artifacts. + *) + DDCAPS2_CANBOBNONINTERLEAVED = $00000020; + {$EXTERNALSYM DDCAPS2_CANBOBNONINTERLEAVED} + +(* + * The overlay surface contains color controls (brightness, sharpness, etc.) + *) + DDCAPS2_COLORCONTROLOVERLAY = $00000040; + {$EXTERNALSYM DDCAPS2_COLORCONTROLOVERLAY} + +(* + * The primary surface contains color controls (gamma, etc.) + *) + DDCAPS2_COLORCONTROLPRIMARY = $00000080; + {$EXTERNALSYM DDCAPS2_COLORCONTROLPRIMARY} + +(* + * RGBZ -> RGB supported for 16:16 RGB:Z + *) + DDCAPS2_CANDROPZ16BIT = $00000100; + {$EXTERNALSYM DDCAPS2_CANDROPZ16BIT} + +(* + * Driver supports non-local video memory. + *) + DDCAPS2_NONLOCALVIDMEM = $00000200; + {$EXTERNALSYM DDCAPS2_NONLOCALVIDMEM} + +(* + * Dirver supports non-local video memory but has different capabilities for + * non-local video memory surfaces. If this bit is set then so must + * DDCAPS2_NONLOCALVIDMEM. + *) + DDCAPS2_NONLOCALVIDMEMCAPS = $00000400; + {$EXTERNALSYM DDCAPS2_NONLOCALVIDMEMCAPS} + +(* + * Driver neither requires nor prefers surfaces to be pagelocked when performing + * blts involving system memory surfaces + *) + DDCAPS2_NOPAGELOCKREQUIRED = $00000800; + {$EXTERNALSYM DDCAPS2_NOPAGELOCKREQUIRED} + +(* + * Driver can create surfaces which are wider than the primary surface + *) + DDCAPS2_WIDESURFACES = $00001000; + {$EXTERNALSYM DDCAPS2_WIDESURFACES} + +(* + * Driver supports bob without using a video port by handling the + * DDFLIP_ODD and DDFLIP_EVEN flags specified in Flip. + *) + DDCAPS2_CANFLIPODDEVEN = $00002000; + {$EXTERNALSYM DDCAPS2_CANFLIPODDEVEN} + +(* + * Driver supports bob using hardware + *) + DDCAPS2_CANBOBHARDWARE = $00004000; + {$EXTERNALSYM DDCAPS2_CANBOBHARDWARE} + +(* + * Driver supports bltting any FOURCC surface to another surface of the same FOURCC + *) + DDCAPS2_COPYFOURCC = $00008000; + {$EXTERNALSYM DDCAPS2_COPYFOURCC} + + +(* + * Driver supports loadable gamma ramps for the primary surface + *) + DDCAPS2_PRIMARYGAMMA = $00020000; + {$EXTERNALSYM DDCAPS2_PRIMARYGAMMA} + +(* + * Driver can render in windowed mode. + *) + DDCAPS2_CANRENDERWINDOWED = $00080000; + {$EXTERNALSYM DDCAPS2_CANRENDERWINDOWED} + +(* + * A calibrator is available to adjust the gamma ramp according to the + * physical display properties so that the result will be identical on + * all calibrated systems. + *) + DDCAPS2_CANCALIBRATEGAMMA = $00100000; + {$EXTERNALSYM DDCAPS2_CANCALIBRATEGAMMA} + +(* + * Indicates that the driver will respond to DDFLIP_INTERVALn flags + *) + DDCAPS2_FLIPINTERVAL = $00200000; + {$EXTERNALSYM DDCAPS2_FLIPINTERVAL} + +(* + * Indicates that the driver will respond to DDFLIP_NOVSYNC + *) + DDCAPS2_FLIPNOVSYNC = $00400000; + {$EXTERNALSYM DDCAPS2_FLIPNOVSYNC} + +(* + * Driver supports management of video memory, if this flag is ON, + * driver manages the texture if requested with DDSCAPS2_TEXTUREMANAGE on + * DirectX manages the texture if this flag is OFF and surface has DDSCAPS2_TEXTUREMANAGE on + *) + DDCAPS2_CANMANAGETEXTURE = $00800000; + {$EXTERNALSYM DDCAPS2_CANMANAGETEXTURE} + +(* + * The Direct3D texture manager uses this cap to decide whether to put managed + * surfaces in non-local video memory. If the cap is set, the texture manager will + * put managed surfaces in non-local vidmem. Drivers that cannot texture from + * local vidmem SHOULD NOT set this cap. + *) + DDCAPS2_TEXMANINNONLOCALVIDMEM = $01000000; + {$EXTERNALSYM DDCAPS2_TEXMANINNONLOCALVIDMEM} + +(* + * Indicates that the driver supports DX7 type of stereo in at least one mode (which may + * not necessarily be the current mode). Applications should use IDirectDraw7 (or higher) + * ::EnumDisplayModes and check the DDSURFACEDESC.ddsCaps.dwCaps2 field for the presence of + * DDSCAPS2_STEREOSURFACELEFT to check if a particular mode supports stereo. The application + * can also use IDirectDraw7(or higher)::GetDisplayMode to check the current mode. + *) + DDCAPS2_STEREO = $02000000; + {$EXTERNALSYM DDCAPS2_STEREO} + +(* + * This caps bit is intended for internal DirectDraw use. + * -It is only valid if DDCAPS2_NONLOCALVIDMEMCAPS is set. + * -If this bit is set, then DDCAPS_CANBLTSYSMEM MUST be set by the driver (and + * all the assoicated system memory blt caps must be correct). + * -It implies that the system->video blt caps in DDCAPS also apply to system to + * nonlocal blts. I.e. the dwSVBCaps, dwSVBCKeyCaps, dwSVBFXCaps and dwSVBRops + * members of DDCAPS (DDCORECAPS) are filled in correctly. + * -Any blt from system to nonlocal memory that matches these caps bits will + * be passed to the driver. + * + * NOTE: This is intended to enable the driver itself to do efficient reordering + * of textures. This is NOT meant to imply that hardware can write into AGP memory. + * This operation is not currently supported. + *) + DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL = $04000000; + {$EXTERNALSYM DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL} + +(* + * was DDCAPS2_PUREHAL + *) + DDCAPS2_RESERVED1 = $08000000; + {$EXTERNALSYM DDCAPS2_RESERVED1} + +(* + * Driver supports management of video memory, if this flag is ON, + * driver manages the resource if requested with DDSCAPS2_TEXTUREMANAGE on + * DirectX manages the resource if this flag is OFF and surface has DDSCAPS2_TEXTUREMANAGE on + *) + DDCAPS2_CANMANAGERESOURCE = $10000000; + {$EXTERNALSYM DDCAPS2_CANMANAGERESOURCE} + +(* + * Driver supports dynamic textures. This will allow the application to set + * D3DUSAGE_DYNAMIC (DDSCAPS2_HINTDYNAMIC for drivers) at texture create time. + * Video memory dynamic textures WILL be lockable by applications. It is + * expected that these locks will be very efficient (which implies that the + * driver should always maintain a linear copy, a pointer to which can be + * quickly handed out to the application). + *) + DDCAPS2_DYNAMICTEXTURES = $20000000; + {$EXTERNALSYM DDCAPS2_DYNAMICTEXTURES} + +(* + * Driver supports auto-generation of mipmaps. + *) + DDCAPS2_CANAUTOGENMIPMAP = $40000000; + {$EXTERNALSYM DDCAPS2_CANAUTOGENMIPMAP} + + +(**************************************************************************** + * + * DIRECTDRAW FX ALPHA CAPABILITY FLAGS + * + ****************************************************************************) + +(* + * Supports alpha blending around the edge of a source color keyed surface. + * For Blt. + *) + DDFXALPHACAPS_BLTALPHAEDGEBLEND = $00000001; + {$EXTERNALSYM DDFXALPHACAPS_BLTALPHAEDGEBLEND} + +(* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value becomes + * more opaque as the alpha value increases. (0 is transparent.) + * For Blt. + *) + DDFXALPHACAPS_BLTALPHAPIXELS = $00000002; + {$EXTERNALSYM DDFXALPHACAPS_BLTALPHAPIXELS} + +(* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value + * becomes more transparent as the alpha value increases. (0 is opaque.) + * This flag can only be set if DDCAPS_ALPHA is set. + * For Blt. + *) + DDFXALPHACAPS_BLTALPHAPIXELSNEG = $00000004; + {$EXTERNALSYM DDFXALPHACAPS_BLTALPHAPIXELSNEG} + +(* + * Supports alpha only surfaces. The bit depth of an alpha only surface can be + * 1,2,4, or 8. The alpha value becomes more opaque as the alpha value increases. + * (0 is transparent.) + * For Blt. + *) + DDFXALPHACAPS_BLTALPHASURFACES = $00000008; + {$EXTERNALSYM DDFXALPHACAPS_BLTALPHASURFACES} + +(* + * The depth of the alpha channel data can range can be 1,2,4, or 8. + * The NEG suffix indicates that this alpha channel becomes more transparent + * as the alpha value increases. (0 is opaque.) This flag can only be set if + * DDCAPS_ALPHA is set. + * For Blt. + *) + DDFXALPHACAPS_BLTALPHASURFACESNEG = $00000010; + {$EXTERNALSYM DDFXALPHACAPS_BLTALPHASURFACESNEG} + +(* + * Supports alpha blending around the edge of a source color keyed surface. + * For Overlays. + *) + DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND = $00000020; + {$EXTERNALSYM DDFXALPHACAPS_OVERLAYALPHAEDGEBLEND} + +(* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value becomes + * more opaque as the alpha value increases. (0 is transparent.) + * For Overlays. + *) + DDFXALPHACAPS_OVERLAYALPHAPIXELS = $00000040; + {$EXTERNALSYM DDFXALPHACAPS_OVERLAYALPHAPIXELS} + +(* + * Supports alpha information in the pixel format. The bit depth of alpha + * information in the pixel format can be 1,2,4, or 8. The alpha value + * becomes more transparent as the alpha value increases. (0 is opaque.) + * This flag can only be set if DDCAPS_ALPHA is set. + * For Overlays. + *) + DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG = $00000080; + {$EXTERNALSYM DDFXALPHACAPS_OVERLAYALPHAPIXELSNEG} + +(* + * Supports alpha only surfaces. The bit depth of an alpha only surface can be + * 1,2,4, or 8. The alpha value becomes more opaque as the alpha value increases. + * (0 is transparent.) + * For Overlays. + *) + DDFXALPHACAPS_OVERLAYALPHASURFACES = $00000100; + {$EXTERNALSYM DDFXALPHACAPS_OVERLAYALPHASURFACES} + +(* + * The depth of the alpha channel data can range can be 1,2,4, or 8. + * The NEG suffix indicates that this alpha channel becomes more transparent + * as the alpha value increases. (0 is opaque.) This flag can only be set if + * DDCAPS_ALPHA is set. + * For Overlays. + *) + DDFXALPHACAPS_OVERLAYALPHASURFACESNEG = $00000200; + {$EXTERNALSYM DDFXALPHACAPS_OVERLAYALPHASURFACESNEG} + +(**************************************************************************** + * + * DIRECTDRAW FX CAPABILITY FLAGS + * + ****************************************************************************) + +(* + * Uses arithmetic operations to stretch and shrink surfaces during blt + * rather than pixel doubling techniques. Along the Y axis. + *) + DDFXCAPS_BLTARITHSTRETCHY = $00000020; + {$EXTERNALSYM DDFXCAPS_BLTARITHSTRETCHY} + +(* + * Uses arithmetic operations to stretch during blt + * rather than pixel doubling techniques. Along the Y axis. Only + * works for x1, x2, etc. + *) + DDFXCAPS_BLTARITHSTRETCHYN = $00000010; + {$EXTERNALSYM DDFXCAPS_BLTARITHSTRETCHYN} + +(* + * Supports mirroring left to right in blt. + *) + DDFXCAPS_BLTMIRRORLEFTRIGHT = $00000040; + {$EXTERNALSYM DDFXCAPS_BLTMIRRORLEFTRIGHT} + +(* + * Supports mirroring top to bottom in blt. + *) + DDFXCAPS_BLTMIRRORUPDOWN = $00000080; + {$EXTERNALSYM DDFXCAPS_BLTMIRRORUPDOWN} + +(* + * Supports arbitrary rotation for blts. + *) + DDFXCAPS_BLTROTATION = $00000100; + {$EXTERNALSYM DDFXCAPS_BLTROTATION} + +(* + * Supports 90 degree rotations for blts. + *) + DDFXCAPS_BLTROTATION90 = $00000200; + {$EXTERNALSYM DDFXCAPS_BLTROTATION90} + +(* + * DirectDraw supports arbitrary shrinking of a surface along the + * x axis (horizontal direction) for blts. + *) + DDFXCAPS_BLTSHRINKX = $00000400; + {$EXTERNALSYM DDFXCAPS_BLTSHRINKX} + +(* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the x axis (horizontal direction) for blts. + *) + DDFXCAPS_BLTSHRINKXN = $00000800; + {$EXTERNALSYM DDFXCAPS_BLTSHRINKXN} + +(* + * DirectDraw supports arbitrary shrinking of a surface along the + * y axis (horizontal direction) for blts. + *) + DDFXCAPS_BLTSHRINKY = $00001000; + {$EXTERNALSYM DDFXCAPS_BLTSHRINKY} + +(* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the y axis (vertical direction) for blts. + *) + DDFXCAPS_BLTSHRINKYN = $00002000; + {$EXTERNALSYM DDFXCAPS_BLTSHRINKYN} + +(* + * DirectDraw supports arbitrary stretching of a surface along the + * x axis (horizontal direction) for blts. + *) + DDFXCAPS_BLTSTRETCHX = $00004000; + {$EXTERNALSYM DDFXCAPS_BLTSTRETCHX} + +(* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the x axis (horizontal direction) for blts. + *) + DDFXCAPS_BLTSTRETCHXN = $00008000; + {$EXTERNALSYM DDFXCAPS_BLTSTRETCHXN} + +(* + * DirectDraw supports arbitrary stretching of a surface along the + * y axis (horizontal direction) for blts. + *) + DDFXCAPS_BLTSTRETCHY = $00010000; + {$EXTERNALSYM DDFXCAPS_BLTSTRETCHY} + +(* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the y axis (vertical direction) for blts. + *) + DDFXCAPS_BLTSTRETCHYN = $00020000; + {$EXTERNALSYM DDFXCAPS_BLTSTRETCHYN} + +(* + * Uses arithmetic operations to stretch and shrink surfaces during + * overlay rather than pixel doubling techniques. Along the Y axis + * for overlays. + *) + DDFXCAPS_OVERLAYARITHSTRETCHY = $00040000; + {$EXTERNALSYM DDFXCAPS_OVERLAYARITHSTRETCHY} + +(* + * Uses arithmetic operations to stretch surfaces during + * overlay rather than pixel doubling techniques. Along the Y axis + * for overlays. Only works for x1, x2, etc. + *) + DDFXCAPS_OVERLAYARITHSTRETCHYN = $00000008; + {$EXTERNALSYM DDFXCAPS_OVERLAYARITHSTRETCHYN} + +(* + * DirectDraw supports arbitrary shrinking of a surface along the + * x axis (horizontal direction) for overlays. + *) + DDFXCAPS_OVERLAYSHRINKX = $00080000; + {$EXTERNALSYM DDFXCAPS_OVERLAYSHRINKX} + +(* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the x axis (horizontal direction) for overlays. + *) + DDFXCAPS_OVERLAYSHRINKXN = $00100000; + {$EXTERNALSYM DDFXCAPS_OVERLAYSHRINKXN} + +(* + * DirectDraw supports arbitrary shrinking of a surface along the + * y axis (horizontal direction) for overlays. + *) + DDFXCAPS_OVERLAYSHRINKY = $00200000; + {$EXTERNALSYM DDFXCAPS_OVERLAYSHRINKY} + +(* + * DirectDraw supports integer shrinking (1x,2x,) of a surface + * along the y axis (vertical direction) for overlays. + *) + DDFXCAPS_OVERLAYSHRINKYN = $00400000; + {$EXTERNALSYM DDFXCAPS_OVERLAYSHRINKYN} + +(* + * DirectDraw supports arbitrary stretching of a surface along the + * x axis (horizontal direction) for overlays. + *) + DDFXCAPS_OVERLAYSTRETCHX = $00800000; + {$EXTERNALSYM DDFXCAPS_OVERLAYSTRETCHX} + +(* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the x axis (horizontal direction) for overlays. + *) + DDFXCAPS_OVERLAYSTRETCHXN = $01000000; + {$EXTERNALSYM DDFXCAPS_OVERLAYSTRETCHXN} + +(* + * DirectDraw supports arbitrary stretching of a surface along the + * y axis (horizontal direction) for overlays. + *) + DDFXCAPS_OVERLAYSTRETCHY = $02000000; + {$EXTERNALSYM DDFXCAPS_OVERLAYSTRETCHY} + +(* + * DirectDraw supports integer stretching (1x,2x,) of a surface + * along the y axis (vertical direction) for overlays. + *) + DDFXCAPS_OVERLAYSTRETCHYN = $04000000; + {$EXTERNALSYM DDFXCAPS_OVERLAYSTRETCHYN} + +(* + * DirectDraw supports mirroring of overlays across the vertical axis + *) + DDFXCAPS_OVERLAYMIRRORLEFTRIGHT = $08000000; + {$EXTERNALSYM DDFXCAPS_OVERLAYMIRRORLEFTRIGHT} + +(* + * DirectDraw supports mirroring of overlays across the horizontal axis + *) + DDFXCAPS_OVERLAYMIRRORUPDOWN = $10000000; + {$EXTERNALSYM DDFXCAPS_OVERLAYMIRRORUPDOWN} + +(* + * DirectDraw supports deinterlacing of overlay surfaces + *) + DDFXCAPS_OVERLAYDEINTERLACE = $20000000; + {$EXTERNALSYM DDFXCAPS_OVERLAYDEINTERLACE} + + +(* + * Driver can do alpha blending for blits. + *) + DDFXCAPS_BLTALPHA = $00000001; + {$EXTERNALSYM DDFXCAPS_BLTALPHA} + +(* + * Driver can do geometric transformations (or warps) for blits. + *) + DDFXCAPS_BLTTRANSFORM = $00000002; + {$EXTERNALSYM DDFXCAPS_BLTTRANSFORM} + +(* + * Driver can do surface-reconstruction filtering for warped blits. + *) + DDFXCAPS_BLTFILTER = DDFXCAPS_BLTARITHSTRETCHY; + {$EXTERNALSYM DDFXCAPS_BLTFILTER} + +(* + * Driver can do alpha blending for overlays. + *) + DDFXCAPS_OVERLAYALPHA = $00000004; + {$EXTERNALSYM DDFXCAPS_OVERLAYALPHA} + +(* + * Driver can do geometric transformations (or warps) for overlays. + *) + DDFXCAPS_OVERLAYTRANSFORM = $20000000; + {$EXTERNALSYM DDFXCAPS_OVERLAYTRANSFORM} + +(* + * Driver can do surface-reconstruction filtering for warped overlays. + *) + DDFXCAPS_OVERLAYFILTER = DDFXCAPS_OVERLAYARITHSTRETCHY; + {$EXTERNALSYM DDFXCAPS_OVERLAYFILTER} + +(**************************************************************************** + * + * DIRECTDRAW STEREO VIEW CAPABILITIES + * + ****************************************************************************) + +(* + * This flag used to be DDSVCAPS_ENIGMA, which is now obsolete + *) + DDSVCAPS_RESERVED1 = $00000001; + {$EXTERNALSYM DDSVCAPS_RESERVED1} + +(* + * This flag used to be DDSVCAPS_FLICKER, which is now obsolete + *) + DDSVCAPS_RESERVED2 = $00000002; + {$EXTERNALSYM DDSVCAPS_RESERVED2} + +(* + * This flag used to be DDSVCAPS_REDBLUE, which is now obsolete + *) + DDSVCAPS_RESERVED3 = $00000004; + {$EXTERNALSYM DDSVCAPS_RESERVED3} + +(* + * This flag used to be DDSVCAPS_SPLIT, which is now obsolete + *) + DDSVCAPS_RESERVED4 = $00000008; + {$EXTERNALSYM DDSVCAPS_RESERVED4} + +(* + * The stereo view is accomplished with switching technology + *) + DDSVCAPS_STEREOSEQUENTIAL = $00000010; + {$EXTERNALSYM DDSVCAPS_STEREOSEQUENTIAL} + +(**************************************************************************** + * + * DIRECTDRAWPALETTE CAPABILITIES + * + ****************************************************************************) + +(* + * Index is 4 bits. There are sixteen color entries in the palette table. + *) + DDPCAPS_4BIT = $00000001; + {$EXTERNALSYM DDPCAPS_4BIT} + +(* + * Index is onto a 8 bit color index. This field is only valid with the + * DDPCAPS_1BIT, DDPCAPS_2BIT or DDPCAPS_4BIT capability and the target + * surface is in 8bpp. Each color entry is one byte long and is an index + * into destination surface's 8bpp palette. + *) + DDPCAPS_8BITENTRIES = $00000002; + {$EXTERNALSYM DDPCAPS_8BITENTRIES} + +(* + * Index is 8 bits. There are 256 color entries in the palette table. + *) + DDPCAPS_8BIT = $00000004; + {$EXTERNALSYM DDPCAPS_8BIT} + +(* + * Indicates that this DIRECTDRAWPALETTE should use the palette color array + * passed into the lpDDColorArray parameter to initialize the DIRECTDRAWPALETTE + * object. + * This flag is obsolete. DirectDraw always initializes the color array from + * the lpDDColorArray parameter. The definition remains for source-level + * compatibility. + *) + DDPCAPS_INITIALIZE = $00000008; + {$EXTERNALSYM DDPCAPS_INITIALIZE} + +(* + * This palette is the one attached to the primary surface. Changing this + * table has immediate effect on the display unless DDPSETPAL_VSYNC is specified + * and supported. + *) + DDPCAPS_PRIMARYSURFACE = $00000010; + {$EXTERNALSYM DDPCAPS_PRIMARYSURFACE} + +(* + * This palette is the one attached to the primary surface left. Changing + * this table has immediate effect on the display for the left eye unless + * DDPSETPAL_VSYNC is specified and supported. + *) + DDPCAPS_PRIMARYSURFACELEFT = $00000020; + {$EXTERNALSYM DDPCAPS_PRIMARYSURFACELEFT} + +(* + * This palette can have all 256 entries defined + *) + DDPCAPS_ALLOW256 = $00000040; + {$EXTERNALSYM DDPCAPS_ALLOW256} + +(* + * This palette can have modifications to it synced with the monitors + * refresh rate. + *) + DDPCAPS_VSYNC = $00000080; + {$EXTERNALSYM DDPCAPS_VSYNC} + +(* + * Index is 1 bit. There are two color entries in the palette table. + *) + DDPCAPS_1BIT = $00000100; + {$EXTERNALSYM DDPCAPS_1BIT} + +(* + * Index is 2 bit. There are four color entries in the palette table. + *) + DDPCAPS_2BIT = $00000200; + {$EXTERNALSYM DDPCAPS_2BIT} + +(* + * The peFlags member of PALETTEENTRY denotes an 8 bit alpha value + *) + DDPCAPS_ALPHA = $00000400; + {$EXTERNALSYM DDPCAPS_ALPHA} + + +(**************************************************************************** + * + * DIRECTDRAWPALETTE SETENTRY CONSTANTS + * + ****************************************************************************) + + +(**************************************************************************** + * + * DIRECTDRAWPALETTE GETENTRY CONSTANTS + * + ****************************************************************************) + +(* 0 is the only legal value *) + +(**************************************************************************** + * + * DIRECTDRAWSURFACE SETPRIVATEDATA CONSTANTS + * + ****************************************************************************) + +(* + * The passed pointer is an IUnknown ptr. The cbData argument to SetPrivateData + * must be set to SizeOf(IUnknown^). DirectDraw will call AddRef through this + * pointer and Release when the private data is destroyed. This includes when + * the surface or palette is destroyed before such priovate data is destroyed. + *) + DDSPD_IUNKNOWNPOINTER = $00000001; + {$EXTERNALSYM DDSPD_IUNKNOWNPOINTER} + +(* + * Private data is only valid for the current state of the object, + * as determined by the uniqueness value. + *) + DDSPD_VOLATILE = $00000002; + {$EXTERNALSYM DDSPD_VOLATILE} + + +(**************************************************************************** + * + * DIRECTDRAWSURFACE SETPALETTE CONSTANTS + * + ****************************************************************************) + + +(**************************************************************************** + * + * DIRECTDRAW BITDEPTH CONSTANTS + * + * NOTE: These are only used to indicate supported bit depths. These + * are flags only, they are not to be used as an actual bit depth. The + * absolute numbers 1, 2, 4, 8, 16, 24 and 32 are used to indicate actual + * bit depths in a surface or for changing the display mode. + * + ****************************************************************************) + +(* + * 1 bit per pixel. + *) + DDBD_1 = $00004000; + {$EXTERNALSYM DDBD_1} + +(* + * 2 bits per pixel. + *) + DDBD_2 = $00002000; + {$EXTERNALSYM DDBD_2} + +(* + * 4 bits per pixel. + *) + DDBD_4 = $00001000; + {$EXTERNALSYM DDBD_4} + +(* + * 8 bits per pixel. + *) + DDBD_8 = $00000800; + {$EXTERNALSYM DDBD_8} + +(* + * 16 bits per pixel. + *) + DDBD_16 = $00000400; + {$EXTERNALSYM DDBD_16} + +(* + * 24 bits per pixel. + *) + DDBD_24 = $00000200; + {$EXTERNALSYM DDBD_24} + +(* + * 32 bits per pixel. + *) + DDBD_32 = $00000100; + {$EXTERNALSYM DDBD_32} + +(**************************************************************************** + * + * DIRECTDRAWSURFACE SET/GET COLOR KEY FLAGS + * + ****************************************************************************) + +(* + * Set if the structure contains a color space. Not set if the structure + * contains a single color key. + *) + DDCKEY_COLORSPACE = $00000001; + {$EXTERNALSYM DDCKEY_COLORSPACE} + +(* + * Set if the structure specifies a color key or color space which is to be + * used as a destination color key for blt operations. + *) + DDCKEY_DESTBLT = $00000002; + {$EXTERNALSYM DDCKEY_DESTBLT} + +(* + * Set if the structure specifies a color key or color space which is to be + * used as a destination color key for overlay operations. + *) + DDCKEY_DESTOVERLAY = $00000004; + {$EXTERNALSYM DDCKEY_DESTOVERLAY} + +(* + * Set if the structure specifies a color key or color space which is to be + * used as a source color key for blt operations. + *) + DDCKEY_SRCBLT = $00000008; + {$EXTERNALSYM DDCKEY_SRCBLT} + +(* + * Set if the structure specifies a color key or color space which is to be + * used as a source color key for overlay operations. + *) + DDCKEY_SRCOVERLAY = $00000010; + {$EXTERNALSYM DDCKEY_SRCOVERLAY} + + +(**************************************************************************** + * + * DIRECTDRAW COLOR KEY CAPABILITY FLAGS + * + ****************************************************************************) + +(* + * Supports transparent blting using a color key to identify the replaceable + * bits of the destination surface for RGB colors. + *) + DDCKEYCAPS_DESTBLT = $00000001; + {$EXTERNALSYM DDCKEYCAPS_DESTBLT} + +(* + * Supports transparent blting using a color space to identify the replaceable + * bits of the destination surface for RGB colors. + *) + DDCKEYCAPS_DESTBLTCLRSPACE = $00000002; + {$EXTERNALSYM DDCKEYCAPS_DESTBLTCLRSPACE} + +(* + * Supports transparent blting using a color space to identify the replaceable + * bits of the destination surface for YUV colors. + *) + DDCKEYCAPS_DESTBLTCLRSPACEYUV = $00000004; + {$EXTERNALSYM DDCKEYCAPS_DESTBLTCLRSPACEYUV} + +(* + * Supports transparent blting using a color key to identify the replaceable + * bits of the destination surface for YUV colors. + *) + DDCKEYCAPS_DESTBLTYUV = $00000008; + {$EXTERNALSYM DDCKEYCAPS_DESTBLTYUV} + +(* + * Supports overlaying using colorkeying of the replaceable bits of the surface + * being overlayed for RGB colors. + *) + DDCKEYCAPS_DESTOVERLAY = $00000010; + {$EXTERNALSYM DDCKEYCAPS_DESTOVERLAY} + +(* + * Supports a color space as the color key for the destination for RGB colors. + *) + DDCKEYCAPS_DESTOVERLAYCLRSPACE = $00000020; + {$EXTERNALSYM DDCKEYCAPS_DESTOVERLAYCLRSPACE} + +(* + * Supports a color space as the color key for the destination for YUV colors. + *) + DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV = $00000040; + {$EXTERNALSYM DDCKEYCAPS_DESTOVERLAYCLRSPACEYUV} + +(* + * Supports only one active destination color key value for visible overlay + * surfaces. + *) + DDCKEYCAPS_DESTOVERLAYONEACTIVE = $00000080; + {$EXTERNALSYM DDCKEYCAPS_DESTOVERLAYONEACTIVE} + +(* + * Supports overlaying using colorkeying of the replaceable bits of the + * surface being overlayed for YUV colors. + *) + DDCKEYCAPS_DESTOVERLAYYUV = $00000100; + {$EXTERNALSYM DDCKEYCAPS_DESTOVERLAYYUV} + +(* + * Supports transparent blting using the color key for the source with + * this surface for RGB colors. + *) + DDCKEYCAPS_SRCBLT = $00000200; + {$EXTERNALSYM DDCKEYCAPS_SRCBLT} + +(* + * Supports transparent blting using a color space for the source with + * this surface for RGB colors. + *) + DDCKEYCAPS_SRCBLTCLRSPACE = $00000400; + {$EXTERNALSYM DDCKEYCAPS_SRCBLTCLRSPACE} + +(* + * Supports transparent blting using a color space for the source with + * this surface for YUV colors. + *) + DDCKEYCAPS_SRCBLTCLRSPACEYUV = $00000800; + {$EXTERNALSYM DDCKEYCAPS_SRCBLTCLRSPACEYUV} + +(* + * Supports transparent blting using the color key for the source with + * this surface for YUV colors. + *) + DDCKEYCAPS_SRCBLTYUV = $00001000; + {$EXTERNALSYM DDCKEYCAPS_SRCBLTYUV} + +(* + * Supports overlays using the color key for the source with this + * overlay surface for RGB colors. + *) + DDCKEYCAPS_SRCOVERLAY = $00002000; + {$EXTERNALSYM DDCKEYCAPS_SRCOVERLAY} + +(* + * Supports overlays using a color space as the source color key for + * the overlay surface for RGB colors. + *) + DDCKEYCAPS_SRCOVERLAYCLRSPACE = $00004000; + {$EXTERNALSYM DDCKEYCAPS_SRCOVERLAYCLRSPACE} + +(* + * Supports overlays using a color space as the source color key for + * the overlay surface for YUV colors. + *) + DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV = $00008000; + {$EXTERNALSYM DDCKEYCAPS_SRCOVERLAYCLRSPACEYUV} + +(* + * Supports only one active source color key value for visible + * overlay surfaces. + *) + DDCKEYCAPS_SRCOVERLAYONEACTIVE = $00010000; + {$EXTERNALSYM DDCKEYCAPS_SRCOVERLAYONEACTIVE} + +(* + * Supports overlays using the color key for the source with this + * overlay surface for YUV colors. + *) + DDCKEYCAPS_SRCOVERLAYYUV = $00020000; + {$EXTERNALSYM DDCKEYCAPS_SRCOVERLAYYUV} + +(* + * there are no bandwidth trade-offs for using colorkey with an overlay + *) + DDCKEYCAPS_NOCOSTOVERLAY = $00040000; + {$EXTERNALSYM DDCKEYCAPS_NOCOSTOVERLAY} + + +(**************************************************************************** + * + * DIRECTDRAW PIXELFORMAT FLAGS + * + ****************************************************************************) + +(* + * The surface has alpha channel information in the pixel format. + *) + DDPF_ALPHAPIXELS = $00000001; + {$EXTERNALSYM DDPF_ALPHAPIXELS} + +(* + * The pixel format contains alpha only information + *) + DDPF_ALPHA = $00000002; + {$EXTERNALSYM DDPF_ALPHA} + +(* + * The FourCC code is valid. + *) + DDPF_FOURCC = $00000004; + {$EXTERNALSYM DDPF_FOURCC} + +(* + * The surface is 4-bit color indexed. + *) + DDPF_PALETTEINDEXED4 = $00000008; + {$EXTERNALSYM DDPF_PALETTEINDEXED4} + +(* + * The surface is indexed into a palette which stores indices + * into the destination surface's 8-bit palette. + *) + DDPF_PALETTEINDEXEDTO8 = $00000010; + {$EXTERNALSYM DDPF_PALETTEINDEXEDTO8} + +(* + * The surface is 8-bit color indexed. + *) + DDPF_PALETTEINDEXED8 = $00000020; + {$EXTERNALSYM DDPF_PALETTEINDEXED8} + +(* + * The RGB data in the pixel format structure is valid. + *) + DDPF_RGB = $00000040; + {$EXTERNALSYM DDPF_RGB} + +(* + * The surface will accept pixel data in the format specified + * and compress it during the write. + *) + DDPF_COMPRESSED = $00000080; + {$EXTERNALSYM DDPF_COMPRESSED} + +(* + * The surface will accept RGB data and translate it during + * the write to YUV data. The format of the data to be written + * will be contained in the pixel format structure. The DDPF_RGB + * flag will be set. + *) + DDPF_RGBTOYUV = $00000100; + {$EXTERNALSYM DDPF_RGBTOYUV} + +(* + * pixel format is YUV - YUV data in pixel format struct is valid + *) + DDPF_YUV = $00000200; + {$EXTERNALSYM DDPF_YUV} + +(* + * pixel format is a z buffer only surface + *) + DDPF_ZBUFFER = $00000400; + {$EXTERNALSYM DDPF_ZBUFFER} + +(* + * The surface is 1-bit color indexed. + *) + DDPF_PALETTEINDEXED1 = $00000800; + {$EXTERNALSYM DDPF_PALETTEINDEXED1} + +(* + * The surface is 2-bit color indexed. + *) + DDPF_PALETTEINDEXED2 = $00001000; + {$EXTERNALSYM DDPF_PALETTEINDEXED2} + +(* + * The surface contains Z information in the pixels + *) + DDPF_ZPIXELS = $00002000; + {$EXTERNALSYM DDPF_ZPIXELS} + +(* + * The surface contains stencil information along with Z + *) + DDPF_STENCILBUFFER = $00004000; + {$EXTERNALSYM DDPF_STENCILBUFFER} + +(* + * Premultiplied alpha format -- the color components have been + * premultiplied by the alpha component. + *) + DDPF_ALPHAPREMULT = $00008000; + {$EXTERNALSYM DDPF_ALPHAPREMULT} + + +(* + * Luminance data in the pixel format is valid. + * Use this flag for luminance-only or luminance+alpha surfaces, + * the bit depth is then ddpf.dwLuminanceBitCount. + *) + DDPF_LUMINANCE = $00020000; + {$EXTERNALSYM DDPF_LUMINANCE} + +(* + * Luminance data in the pixel format is valid. + * Use this flag when hanging luminance off bumpmap surfaces, + * the bit mask for the luminance portion of the pixel is then + * ddpf.dwBumpLuminanceBitMask + *) + DDPF_BUMPLUMINANCE = $00040000; + {$EXTERNALSYM DDPF_BUMPLUMINANCE} + +(* + * Bump map dUdV data in the pixel format is valid. + *) + DDPF_BUMPDUDV = $00080000; + {$EXTERNALSYM DDPF_BUMPDUDV} + + +(*=========================================================================== + * + * + * DIRECTDRAW CALLBACK FLAGS + * + * + *==========================================================================*) + +(**************************************************************************** + * + * DIRECTDRAW ENUMSURFACES FLAGS + * + ****************************************************************************) + +(* + * Enumerate all of the surfaces that meet the search criterion. + *) + DDENUMSURFACES_ALL = $00000001; + {$EXTERNALSYM DDENUMSURFACES_ALL} + {$EXTERNALSYM DDENUMSURFACES_ALL} + +(* + * A search hit is a surface that matches the surface description. + *) + DDENUMSURFACES_MATCH = $00000002; + {$EXTERNALSYM DDENUMSURFACES_MATCH} + +(* + * A search hit is a surface that does not match the surface description. + *) + DDENUMSURFACES_NOMATCH = $00000004; + {$EXTERNALSYM DDENUMSURFACES_NOMATCH} + +(* + * Enumerate the first surface that can be created which meets the search criterion. + *) + DDENUMSURFACES_CANBECREATED = $00000008; + {$EXTERNALSYM DDENUMSURFACES_CANBECREATED} + +(* + * Enumerate the surfaces that already exist that meet the search criterion. + *) + DDENUMSURFACES_DOESEXIST = $00000010; + {$EXTERNALSYM DDENUMSURFACES_DOESEXIST} + + +(**************************************************************************** + * + * DIRECTDRAW SETDISPLAYMODE FLAGS + * + ****************************************************************************) + +(* + * The desired mode is a standard VGA mode + *) + DDSDM_STANDARDVGAMODE = $00000001; + {$EXTERNALSYM DDSDM_STANDARDVGAMODE} + + +(**************************************************************************** + * + * DIRECTDRAW ENUMDISPLAYMODES FLAGS + * + ****************************************************************************) + +(* + * Enumerate Modes with different refresh rates. EnumDisplayModes guarantees + * that a particular mode will be enumerated only once. This flag specifies whether + * the refresh rate is taken into account when determining if a mode is unique. + *) + DDEDM_REFRESHRATES = $00000001; + {$EXTERNALSYM DDEDM_REFRESHRATES} + +(* + * Enumerate VGA modes. Specify this flag if you wish to enumerate supported VGA + * modes such as mode 0x13 in addition to the usual ModeX modes (which are always + * enumerated if the application has previously called SetCooperativeLevel with the + * DDSCL_ALLOWMODEX flag set). + *) + DDEDM_STANDARDVGAMODES = $00000002; + {$EXTERNALSYM DDEDM_STANDARDVGAMODES} + + +(**************************************************************************** + * + * DIRECTDRAW SETCOOPERATIVELEVEL FLAGS + * + ****************************************************************************) + +(* + * Exclusive mode owner will be responsible for the entire primary surface. + * GDI can be ignored. used with DD + *) + DDSCL_FULLSCREEN = $00000001; + {$EXTERNALSYM DDSCL_FULLSCREEN} + +(* + * allow CTRL_ALT_DEL to work while in fullscreen exclusive mode + *) + DDSCL_ALLOWREBOOT = $00000002; + {$EXTERNALSYM DDSCL_ALLOWREBOOT} + +(* + * prevents DDRAW from modifying the application window. + * prevents DDRAW from minimize/restore the application window on activation. + *) + DDSCL_NOWINDOWCHANGES = $00000004; + {$EXTERNALSYM DDSCL_NOWINDOWCHANGES} + +(* + * app wants to work as a regular Windows application + *) + DDSCL_NORMAL = $00000008; + {$EXTERNALSYM DDSCL_NORMAL} + +(* + * app wants exclusive access + *) + DDSCL_EXCLUSIVE = $00000010; + {$EXTERNALSYM DDSCL_EXCLUSIVE} + + +(* + * app can deal with non-windows display modes + *) + DDSCL_ALLOWMODEX = $00000040; + {$EXTERNALSYM DDSCL_ALLOWMODEX} + +(* + * this window will receive the focus messages + *) + DDSCL_SETFOCUSWINDOW = $00000080; + {$EXTERNALSYM DDSCL_SETFOCUSWINDOW} + +(* + * this window is associated with the DDRAW object and will + * cover the screen in fullscreen mode + *) + DDSCL_SETDEVICEWINDOW = $00000100; + {$EXTERNALSYM DDSCL_SETDEVICEWINDOW} + +(* + * app wants DDRAW to create a window to be associated with the + * DDRAW object + *) + DDSCL_CREATEDEVICEWINDOW = $00000200; + {$EXTERNALSYM DDSCL_CREATEDEVICEWINDOW} + +(* + * App explicitly asks DDRAW/D3D to be multithread safe. This makes D3D + * take the global crtisec more frequently. + *) + DDSCL_MULTITHREADED = $00000400; + {$EXTERNALSYM DDSCL_MULTITHREADED} + +(* + * App specifies that it would like to keep the FPU set up for optimal Direct3D + * performance (single precision and exceptions disabled) so Direct3D + * does not need to explicitly set the FPU each time. This is assumed by + * default in DirectX 7. See also DDSCL_FPUPRESERVE + *) + DDSCL_FPUSETUP = $00000800; + {$EXTERNALSYM DDSCL_FPUSETUP} + +(* + * App specifies that it needs either double precision FPU or FPU exceptions + * enabled. This makes Direct3D explicitly set the FPU state eah time it is + * called. Setting the flag will reduce Direct3D performance. The flag is + * assumed by default in DirectX 6 and earlier. See also DDSCL_FPUSETUP + *) + DDSCL_FPUPRESERVE = $00001000; + {$EXTERNALSYM DDSCL_FPUPRESERVE} + + +(**************************************************************************** + * + * DIRECTDRAW BLT FLAGS + * + ****************************************************************************) + +(* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the destination surface as the alpha channel for this blt. + *) + DDBLT_ALPHADEST = $00000001; + {$EXTERNALSYM DDBLT_ALPHADEST} + +(* + * Use the dwConstAlphaDest field in the DDBLTFX structure as the alpha channel + * for the destination surface for this blt. + *) + DDBLT_ALPHADESTCONSTOVERRIDE = $00000002; + {$EXTERNALSYM DDBLT_ALPHADESTCONSTOVERRIDE} + +(* + * The NEG suffix indicates that the destination surface becomes more + * transparent as the alpha value increases. (0 is opaque) + *) + DDBLT_ALPHADESTNEG = $00000004; + {$EXTERNALSYM DDBLT_ALPHADESTNEG} + +(* + * Use the lpDDSAlphaDest field in the DDBLTFX structure as the alpha + * channel for the destination for this blt. + *) + DDBLT_ALPHADESTSURFACEOVERRIDE = $00000008; + {$EXTERNALSYM DDBLT_ALPHADESTSURFACEOVERRIDE} + +(* + * Use the dwAlphaEdgeBlend field in the DDBLTFX structure as the alpha channel + * for the edges of the image that border the color key colors. + *) + DDBLT_ALPHAEDGEBLEND = $00000010; + {$EXTERNALSYM DDBLT_ALPHAEDGEBLEND} + +(* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the source surface as the alpha channel for this blt. + *) + DDBLT_ALPHASRC = $00000020; + {$EXTERNALSYM DDBLT_ALPHASRC} + +(* + * Use the dwConstAlphaSrc field in the DDBLTFX structure as the alpha channel + * for the source for this blt. + *) + DDBLT_ALPHASRCCONSTOVERRIDE = $00000040; + {$EXTERNALSYM DDBLT_ALPHASRCCONSTOVERRIDE} + +(* + * The NEG suffix indicates that the source surface becomes more transparent + * as the alpha value increases. (0 is opaque) + *) + DDBLT_ALPHASRCNEG = $00000080; + {$EXTERNALSYM DDBLT_ALPHASRCNEG} + +(* + * Use the lpDDSAlphaSrc field in the DDBLTFX structure as the alpha channel + * for the source for this blt. + *) + DDBLT_ALPHASRCSURFACEOVERRIDE = $00000100; + {$EXTERNALSYM DDBLT_ALPHASRCSURFACEOVERRIDE} + +(* + * Do this blt asynchronously through the FIFO in the order received. If + * there is no room in the hardware FIFO fail the call. + *) + DDBLT_ASYNC = $00000200; + {$EXTERNALSYM DDBLT_ASYNC} + +(* + * Uses the dwFillColor field in the DDBLTFX structure as the RGB color + * to fill the destination rectangle on the destination surface with. + *) + DDBLT_COLORFILL = $00000400; + {$EXTERNALSYM DDBLT_COLORFILL} + +(* + * Uses the dwDDFX field in the DDBLTFX structure to specify the effects + * to use for the blt. + *) + DDBLT_DDFX = $00000800; + {$EXTERNALSYM DDBLT_DDFX} + +(* + * Uses the dwDDROPS field in the DDBLTFX structure to specify the ROPS + * that are not part of the Win32 API. + *) + DDBLT_DDROPS = $00001000; + {$EXTERNALSYM DDBLT_DDROPS} + +(* + * Use the color key associated with the destination surface. + *) + DDBLT_KEYDEST = $00002000; + {$EXTERNALSYM DDBLT_KEYDEST} + +(* + * Use the dckDestColorkey field in the DDBLTFX structure as the color key + * for the destination surface. + *) + DDBLT_KEYDESTOVERRIDE = $00004000; + {$EXTERNALSYM DDBLT_KEYDESTOVERRIDE} + +(* + * Use the color key associated with the source surface. + *) + DDBLT_KEYSRC = $00008000; + {$EXTERNALSYM DDBLT_KEYSRC} + +(* + * Use the dckSrcColorkey field in the DDBLTFX structure as the color key + * for the source surface. + *) + DDBLT_KEYSRCOVERRIDE = $00010000; + {$EXTERNALSYM DDBLT_KEYSRCOVERRIDE} + +(* + * Use the dwROP field in the DDBLTFX structure for the raster operation + * for this blt. These ROPs are the same as the ones defined in the Win32 API. + *) + DDBLT_ROP = $00020000; + {$EXTERNALSYM DDBLT_ROP} + +(* + * Use the dwRotationAngle field in the DDBLTFX structure as the angle + * (specified in 1/100th of a degree) to rotate the surface. + *) + DDBLT_ROTATIONANGLE = $00040000; + {$EXTERNALSYM DDBLT_ROTATIONANGLE} + +(* + * Z-buffered blt using the z-buffers attached to the source and destination + * surfaces and the dwZBufferOpCode field in the DDBLTFX structure as the + * z-buffer opcode. + *) + DDBLT_ZBUFFER = $00080000; + {$EXTERNALSYM DDBLT_ZBUFFER} + +(* + * Z-buffered blt using the dwConstDest Zfield and the dwZBufferOpCode field + * in the DDBLTFX structure as the z-buffer and z-buffer opcode respectively + * for the destination. + *) + DDBLT_ZBUFFERDESTCONSTOVERRIDE = $00100000; + {$EXTERNALSYM DDBLT_ZBUFFERDESTCONSTOVERRIDE} + +(* + * Z-buffered blt using the lpDDSDestZBuffer field and the dwZBufferOpCode + * field in the DDBLTFX structure as the z-buffer and z-buffer opcode + * respectively for the destination. + *) + DDBLT_ZBUFFERDESTOVERRIDE = $00200000; + {$EXTERNALSYM DDBLT_ZBUFFERDESTOVERRIDE} + +(* + * Z-buffered blt using the dwConstSrcZ field and the dwZBufferOpCode field + * in the DDBLTFX structure as the z-buffer and z-buffer opcode respectively + * for the source. + *) + DDBLT_ZBUFFERSRCCONSTOVERRIDE = $00400000; + {$EXTERNALSYM DDBLT_ZBUFFERSRCCONSTOVERRIDE} + +(* + * Z-buffered blt using the lpDDSSrcZBuffer field and the dwZBufferOpCode + * field in the DDBLTFX structure as the z-buffer and z-buffer opcode + * respectively for the source. + *) + DDBLT_ZBUFFERSRCOVERRIDE = $00800000; + {$EXTERNALSYM DDBLT_ZBUFFERSRCOVERRIDE} + +(* + * wait until the device is ready to handle the blt + * this will cause blt to not return DDERR_WASSTILLDRAWING + *) + DDBLT_WAIT = $01000000; + {$EXTERNALSYM DDBLT_WAIT} + +(* + * Uses the dwFillDepth field in the DDBLTFX structure as the depth value + * to fill the destination rectangle on the destination Z-buffer surface + * with. + *) + DDBLT_DEPTHFILL = $02000000; + {$EXTERNALSYM DDBLT_DEPTHFILL} + + +(* + * Return immediately (with DDERR_WASSTILLDRAWING) if the device is not + * ready to schedule the blt at the time Blt() is called. + *) + DDBLT_DONOTWAIT = $08000000; + {$EXTERNALSYM DDBLT_DONOTWAIT} + +(* + * These flags indicate a presentation blt (i.e. a blt + * that moves surface contents from an offscreen back buffer to the primary + * surface). The driver is not allowed to "queue" more than three such blts. + * The "end" of the presentation blt is indicated, since the + * blt may be clipped, in which case the runtime will call the driver with + * several blts. All blts (even if not clipped) are tagged with DDBLT_PRESENTATION + * and the last (even if not clipped) additionally with DDBLT_LAST_PRESENTATION. + * Thus the true rule is that the driver must not schedule a DDBLT_PRESENTATION + * blt if there are 3 or more DDBLT_PRESENTLAST blts in the hardware pipe. + * If there are such blts in the pipe, the driver should return DDERR_WASSTILLDRAWING + * until the oldest queued DDBLT_LAST_PRESENTATION blts has been retired (i.e. the + * pixels have been actually written to the primary surface). Once the oldest blt + * has been retired, the driver is free to schedule the current blt. + * The goal is to provide a mechanism whereby the device's hardware queue never + * gets more than 3 frames ahead of the frames being generated by the application. + * When excessive queueing occurs, applications become unusable because the application + * visibly lags user input, and such problems make windowed interactive applications impossible. + * Some drivers may not have sufficient knowledge of their hardware's FIFO to know + * when a certain blt has been retired. Such drivers should code cautiously, and + * simply not allow any frames to be queued at all. DDBLT_LAST_PRESENTATION should cause + * such drivers to return DDERR_WASSTILLDRAWING until the accelerator is completely + * finished- exactly as if the application had called Lock on the source surface + * before calling Blt. + * In other words, the driver is allowed and encouraged to + * generate as much latency as it can, but never more than 3 frames worth. + * Implementation detail: Drivers should count blts against the SOURCE surface, not + * against the primary surface. This enables multiple parallel windowed application + * to function more optimally. + * This flag is passed only to DX8 or higher drivers. + * + * APPLICATIONS DO NOT SET THESE FLAGS. THEY ARE SET BY THE DIRECTDRAW RUNTIME. + * + *) + DDBLT_PRESENTATION = $10000000; + {$EXTERNALSYM DDBLT_PRESENTATION} + DDBLT_LAST_PRESENTATION = $20000000; + {$EXTERNALSYM DDBLT_LAST_PRESENTATION} + +(* + * If DDBLT_EXTENDED_FLAGS is set, then the driver should re-interpret + * other flags according to the definitions that follow. + * For example, bit 0 (0x00000001L) means DDBLT_ALPHADEST, unless + * DDBLT_EXTENDED_FLAGS is also set, in which case bit 0 means + * DDBLT_EXTENDED_LINEAR_CONTENT. + * Only DirectX9 and higher drivers will be given extended blt flags. + * Only flags explicitly mentioned here should be re-interpreted. + * All other flags retain their original meanings. + * + * List of re-interpreted flags: + * + * Bit Hex value New meaning old meaning + * --------------------------------------------------------------- + * 2 0x00000004 DDBLT_EXTENDED_LINEAR_CONTENT DDBLT_ALPHADESTNEG + * 4 0x00000010 DDBLT_EXTENDED_PRESENTATION_STRETCHFACTOR DDBLT_ALPHAEDGEBLEND + * + * + * NOTE: APPLICATIONS SHOULD NOT SET THIS FLAG. THIS FLAG IS INTENDED + * FOR USE BY THE DIRECT3D RUNTIME. + *) + DDBLT_EXTENDED_FLAGS = $40000000; + {$EXTERNALSYM DDBLT_EXTENDED_FLAGS} + +(* + * EXTENDED FLAG. SEE DEFINITION OF DDBLT_EXTENDED_FLAGS. + * This flag indidcates that the source surface contains content in a + * linear color space. The driver may perform gamma correction to the + * desktop color space (i.e. sRGB, gamma 2.2) as part of this blt. + * If the device can perform such a conversion as part of the copy, + * the driver should also set D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION + * + * NOTE: APPLICATIONS SHOULD NOT SET THIS FLAG. THIS FLAG IS INTENDED + * FOR USE BY THE DIRECT3D RUNTIME. Use IDirect3DSwapChain9::Present + * and specify D3DPRESENT_LINEAR_CONTENT in order to use this functionality. + *) + DDBLT_EXTENDED_LINEAR_CONTENT = $00000004; + {$EXTERNALSYM DDBLT_EXTENDED_LINEAR_CONTENT} + + +(**************************************************************************** + * + * BLTFAST FLAGS + * + ****************************************************************************) + + DDBLTFAST_NOCOLORKEY = $00000000; + {$EXTERNALSYM DDBLTFAST_NOCOLORKEY} + DDBLTFAST_SRCCOLORKEY = $00000001; + {$EXTERNALSYM DDBLTFAST_SRCCOLORKEY} + DDBLTFAST_DESTCOLORKEY = $00000002; + {$EXTERNALSYM DDBLTFAST_DESTCOLORKEY} + DDBLTFAST_WAIT = $00000010; + {$EXTERNALSYM DDBLTFAST_WAIT} + DDBLTFAST_DONOTWAIT = $00000020; + {$EXTERNALSYM DDBLTFAST_DONOTWAIT} + +(**************************************************************************** + * + * FLIP FLAGS + * + ****************************************************************************) + + DDFLIP_WAIT = $00000001; + {$EXTERNALSYM DDFLIP_WAIT} + +(* + * Indicates that the target surface contains the even field of video data. + * This flag is only valid with an overlay surface. + *) + DDFLIP_EVEN = $00000002; + {$EXTERNALSYM DDFLIP_EVEN} + +(* + * Indicates that the target surface contains the odd field of video data. + * This flag is only valid with an overlay surface. + *) + DDFLIP_ODD = $00000004; + {$EXTERNALSYM DDFLIP_ODD} + +(* + * Causes DirectDraw to perform the physical flip immediately and return + * to the application. Typically, what was the front buffer but is now the back + * buffer will still be visible (depending on timing) until the next vertical + * retrace. Subsequent operations involving the two flipped surfaces will + * not check to see if the physical flip has finished (i.e. will not return + * DDERR_WASSTILLDRAWING for that reason (but may for other reasons)). + * This allows an application to perform Flips at a higher frequency than the + * monitor refresh rate, but may introduce visible artifacts. + * Only effective if DDCAPS2_FLIPNOVSYNC is set. If that bit is not set, + * DDFLIP_NOVSYNC has no effect. + *) + DDFLIP_NOVSYNC = $00000008; + {$EXTERNALSYM DDFLIP_NOVSYNC} + + +(* + * Flip Interval Flags. These flags indicate how many vertical retraces to wait between + * each flip. The default is one. DirectDraw will return DDERR_WASSTILLDRAWING for each + * surface involved in the flip until the specified number of vertical retraces has + * ocurred. Only effective if DDCAPS2_FLIPINTERVAL is set. If that bit is not set, + * DDFLIP_INTERVALn has no effect. + *) + +(* + * DirectDraw will flip on every other vertical sync + *) + DDFLIP_INTERVAL2 = $02000000; + {$EXTERNALSYM DDFLIP_INTERVAL2} + + +(* + * DirectDraw will flip on every third vertical sync + *) + DDFLIP_INTERVAL3 = $03000000; + {$EXTERNALSYM DDFLIP_INTERVAL3} + + +(* + * DirectDraw will flip on every fourth vertical sync + *) + DDFLIP_INTERVAL4 = $04000000; + {$EXTERNALSYM DDFLIP_INTERVAL4} + +(* + * DirectDraw will flip and display a main stereo surface + *) + DDFLIP_STEREO = $00000010; + {$EXTERNALSYM DDFLIP_STEREO} + +(* + * On IDirectDrawSurface7 and higher interfaces, the default is DDFLIP_WAIT. If you wish + * to override the default and use time when the accelerator is busy (as denoted by + * the DDERR_WASSTILLDRAWING return code) then use DDFLIP_DONOTWAIT. + *) + DDFLIP_DONOTWAIT = $00000020; + {$EXTERNALSYM DDFLIP_DONOTWAIT} + + +(**************************************************************************** + * + * DIRECTDRAW SURFACE OVERLAY FLAGS + * + ****************************************************************************) + +(* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the destination surface as the alpha channel for the + * destination overlay. + *) + DDOVER_ALPHADEST = $00000001; + {$EXTERNALSYM DDOVER_ALPHADEST} + +(* + * Use the dwConstAlphaDest field in the DDOVERLAYFX structure as the + * destination alpha channel for this overlay. + *) + DDOVER_ALPHADESTCONSTOVERRIDE = $00000002; + {$EXTERNALSYM DDOVER_ALPHADESTCONSTOVERRIDE} + +(* + * The NEG suffix indicates that the destination surface becomes more + * transparent as the alpha value increases. + *) + DDOVER_ALPHADESTNEG = $00000004; + {$EXTERNALSYM DDOVER_ALPHADESTNEG} + +(* + * Use the lpDDSAlphaDest field in the DDOVERLAYFX structure as the alpha + * channel destination for this overlay. + *) + DDOVER_ALPHADESTSURFACEOVERRIDE = $00000008; + {$EXTERNALSYM DDOVER_ALPHADESTSURFACEOVERRIDE} + +(* + * Use the dwAlphaEdgeBlend field in the DDOVERLAYFX structure as the alpha + * channel for the edges of the image that border the color key colors. + *) + DDOVER_ALPHAEDGEBLEND = $00000010; + {$EXTERNALSYM DDOVER_ALPHAEDGEBLEND} + +(* + * Use the alpha information in the pixel format or the alpha channel surface + * attached to the source surface as the source alpha channel for this overlay. + *) + DDOVER_ALPHASRC = $00000020; + {$EXTERNALSYM DDOVER_ALPHASRC} + +(* + * Use the dwConstAlphaSrc field in the DDOVERLAYFX structure as the source + * alpha channel for this overlay. + *) + DDOVER_ALPHASRCCONSTOVERRIDE = $00000040; + {$EXTERNALSYM DDOVER_ALPHASRCCONSTOVERRIDE} + +(* + * The NEG suffix indicates that the source surface becomes more transparent + * as the alpha value increases. + *) + DDOVER_ALPHASRCNEG = $00000080; + {$EXTERNALSYM DDOVER_ALPHASRCNEG} + +(* + * Use the lpDDSAlphaSrc field in the DDOVERLAYFX structure as the alpha channel + * source for this overlay. + *) + DDOVER_ALPHASRCSURFACEOVERRIDE = $00000100; + {$EXTERNALSYM DDOVER_ALPHASRCSURFACEOVERRIDE} + +(* + * Turn this overlay off. + *) + DDOVER_HIDE = $00000200; + {$EXTERNALSYM DDOVER_HIDE} + +(* + * Use the color key associated with the destination surface. + *) + DDOVER_KEYDEST = $00000400; + {$EXTERNALSYM DDOVER_KEYDEST} + +(* + * Use the dckDestColorkey field in the DDOVERLAYFX structure as the color key + * for the destination surface + *) + DDOVER_KEYDESTOVERRIDE = $00000800; + {$EXTERNALSYM DDOVER_KEYDESTOVERRIDE} + +(* + * Use the color key associated with the source surface. + *) + DDOVER_KEYSRC = $00001000; + {$EXTERNALSYM DDOVER_KEYSRC} + +(* + * Use the dckSrcColorkey field in the DDOVERLAYFX structure as the color key + * for the source surface. + *) + DDOVER_KEYSRCOVERRIDE = $00002000; + {$EXTERNALSYM DDOVER_KEYSRCOVERRIDE} + +(* + * Turn this overlay on. + *) + DDOVER_SHOW = $00004000; + {$EXTERNALSYM DDOVER_SHOW} + +(* + * Add a dirty rect to an emulated overlayed surface. + *) + DDOVER_ADDDIRTYRECT = $00008000; + {$EXTERNALSYM DDOVER_ADDDIRTYRECT} + +(* + * Redraw all dirty rects on an emulated overlayed surface. + *) + DDOVER_REFRESHDIRTYRECTS = $00010000; + {$EXTERNALSYM DDOVER_REFRESHDIRTYRECTS} + +(* + * Redraw the entire surface on an emulated overlayed surface. + *) + DDOVER_REFRESHALL = $00020000; + {$EXTERNALSYM DDOVER_REFRESHALL} + + +(* + * Use the overlay FX flags to define special overlay FX + *) + DDOVER_DDFX = $00080000; + {$EXTERNALSYM DDOVER_DDFX} + +(* + * Autoflip the overlay when ever the video port autoflips + *) + DDOVER_AUTOFLIP = $00100000; + {$EXTERNALSYM DDOVER_AUTOFLIP} + +(* + * Display each field of video port data individually without + * causing any jittery artifacts + *) + DDOVER_BOB = $00200000; + {$EXTERNALSYM DDOVER_BOB} + +(* + * Indicates that bob/weave decisions should not be overridden by other + * interfaces. + *) + DDOVER_OVERRIDEBOBWEAVE = $00400000; + {$EXTERNALSYM DDOVER_OVERRIDEBOBWEAVE} + +(* + * Indicates that the surface memory is composed of interleaved fields. + *) + DDOVER_INTERLEAVED = $00800000; + {$EXTERNALSYM DDOVER_INTERLEAVED} + +(* + * Indicates that bob will be performed using hardware rather than + * software or emulated. + *) + DDOVER_BOBHARDWARE = $01000000; + {$EXTERNALSYM DDOVER_BOBHARDWARE} + +(* + * Indicates that overlay FX structure contains valid ARGB scaling factors. + *) + DDOVER_ARGBSCALEFACTORS = $02000000; + {$EXTERNALSYM DDOVER_ARGBSCALEFACTORS} + +(* + * Indicates that ARGB scaling factors can be degraded to fit driver capabilities. + *) + DDOVER_DEGRADEARGBSCALING = $04000000; + {$EXTERNALSYM DDOVER_DEGRADEARGBSCALING} + + +(**************************************************************************** + * + * DIRECTDRAWSURFACE LOCK FLAGS + * + ****************************************************************************) + +(* + * The default. Set to indicate that Lock should return a valid memory pointer + * to the top of the specified rectangle. If no rectangle is specified then a + * pointer to the top of the surface is returned. + *) + DDLOCK_SURFACEMEMORYPTR = $00000000; // = default + {$EXTERNALSYM DDLOCK_SURFACEMEMORYPTR} + +(* + * Set to indicate that Lock should wait until it can obtain a valid memory + * pointer before returning. If this bit is set, Lock will never return + * DDERR_WASSTILLDRAWING. + *) + DDLOCK_WAIT = $00000001; + {$EXTERNALSYM DDLOCK_WAIT} + +(* + * Set if an event handle is being passed to Lock. Lock will trigger the event + * when it can return the surface memory pointer requested. + *) + DDLOCK_EVENT = $00000002; + {$EXTERNALSYM DDLOCK_EVENT} + +(* + * Indicates that the surface being locked will only be read from. + *) + DDLOCK_READONLY = $00000010; + {$EXTERNALSYM DDLOCK_READONLY} + +(* + * Indicates that the surface being locked will only be written to + *) + DDLOCK_WRITEONLY = $00000020; + {$EXTERNALSYM DDLOCK_WRITEONLY} + + +(* + * Indicates that a system wide lock should not be taken when this surface + * is locked. This has several advantages (cursor responsiveness, ability + * to call more Windows functions, easier debugging) when locking video + * memory surfaces. However, an application specifying this flag must + * comply with a number of conditions documented in the help file. + * Furthermore, this flag cannot be specified when locking the primary. + *) + DDLOCK_NOSYSLOCK = $00000800; + {$EXTERNALSYM DDLOCK_NOSYSLOCK} + +(* + * Used only with Direct3D Vertex Buffer Locks. Indicates that no vertices + * that were referred to in Draw*PrimtiveVB calls since the start of the + * frame (or the last lock without this flag) will be modified during the + * lock. This can be useful when one is only appending data to the vertex + * buffer + *) + DDLOCK_NOOVERWRITE = $00001000; + {$EXTERNALSYM DDLOCK_NOOVERWRITE} + +(* + * Indicates that no assumptions will be made about the contents of the + * surface or vertex buffer during this lock. + * This enables two things: + * - Direct3D or the driver may provide an alternative memory + * area as the vertex buffer. This is useful when one plans to clear the + * contents of the vertex buffer and fill in new data. + * - Drivers sometimes store surface data in a re-ordered format. + * When the application locks the surface, the driver is forced to un-re-order + * the surface data before allowing the application to see the surface contents. + * This flag is a hint to the driver that it can skip the un-re-ordering process + * since the application plans to overwrite every single pixel in the surface + * or locked rectangle (and so erase any un-re-ordered pixels anyway). + * Applications should always set this flag when they intend to overwrite the entire + * surface or locked rectangle. + *) + DDLOCK_DISCARDCONTENTS = $00002000; + {$EXTERNALSYM DDLOCK_DISCARDCONTENTS} + (* + * DDLOCK_OKTOSWAP is an older, less informative name for DDLOCK_DISCARDCONTENTS + *) + DDLOCK_OKTOSWAP = $00002000; + {$EXTERNALSYM DDLOCK_OKTOSWAP} + +(* + * On IDirectDrawSurface7 and higher interfaces, the default is DDLOCK_WAIT. If you wish + * to override the default and use time when the accelerator is busy (as denoted by + * the DDERR_WASSTILLDRAWING return code) then use DDLOCK_DONOTWAIT. + *) + DDLOCK_DONOTWAIT = $00004000; + {$EXTERNALSYM DDLOCK_DONOTWAIT} + +(* + * This indicates volume texture lock with front and back specified. + *) + DDLOCK_HASVOLUMETEXTUREBOXRECT = $00008000; + {$EXTERNALSYM DDLOCK_HASVOLUMETEXTUREBOXRECT} + +(* + * This indicates that the driver should not update dirty rect information for this lock. + *) + DDLOCK_NODIRTYUPDATE = $00010000; + {$EXTERNALSYM DDLOCK_NODIRTYUPDATE} + + +(**************************************************************************** + * + * DIRECTDRAWSURFACE PAGELOCK FLAGS + * + ****************************************************************************) + +(* + * No flags defined at present + *) + + +(**************************************************************************** + * + * DIRECTDRAWSURFACE PAGEUNLOCK FLAGS + * + ****************************************************************************) + +(* + * No flags defined at present + *) + + +(**************************************************************************** + * + * DIRECTDRAWSURFACE BLT FX FLAGS + * + ****************************************************************************) + +(* + * If stretching, use arithmetic stretching along the Y axis for this blt. + *) + DDBLTFX_ARITHSTRETCHY = $00000001; + {$EXTERNALSYM DDBLTFX_ARITHSTRETCHY} + +(* + * Do this blt mirroring the surface left to right. Spin the + * surface around its y-axis. + *) + DDBLTFX_MIRRORLEFTRIGHT = $00000002; + {$EXTERNALSYM DDBLTFX_MIRRORLEFTRIGHT} + +(* + * Do this blt mirroring the surface up and down. Spin the surface + * around its x-axis. + *) + DDBLTFX_MIRRORUPDOWN = $00000004; + {$EXTERNALSYM DDBLTFX_MIRRORUPDOWN} + +(* + * Schedule this blt to avoid tearing. + *) + DDBLTFX_NOTEARING = $00000008; + {$EXTERNALSYM DDBLTFX_NOTEARING} + +(* + * Do this blt rotating the surface one hundred and eighty degrees. + *) + DDBLTFX_ROTATE180 = $00000010; + {$EXTERNALSYM DDBLTFX_ROTATE180} + +(* + * Do this blt rotating the surface two hundred and seventy degrees. + *) + DDBLTFX_ROTATE270 = $00000020; + {$EXTERNALSYM DDBLTFX_ROTATE270} + +(* + * Do this blt rotating the surface ninety degrees. + *) + DDBLTFX_ROTATE90 = $00000040; + {$EXTERNALSYM DDBLTFX_ROTATE90} + +(* + * Do this z blt using dwZBufferLow and dwZBufferHigh as range values + * specified to limit the bits copied from the source surface. + *) + DDBLTFX_ZBUFFERRANGE = $00000080; + {$EXTERNALSYM DDBLTFX_ZBUFFERRANGE} + +(* + * Do this z blt adding the dwZBufferBaseDest to each of the sources z values + * before comparing it with the desting z values. + *) + DDBLTFX_ZBUFFERBASEDEST = $00000100; + {$EXTERNALSYM DDBLTFX_ZBUFFERBASEDEST} + +(**************************************************************************** + * + * DIRECTDRAWSURFACE OVERLAY FX FLAGS + * + ****************************************************************************) + +(* + * If stretching, use arithmetic stretching along the Y axis for this overlay. + *) + DDOVERFX_ARITHSTRETCHY = $00000001; + {$EXTERNALSYM DDOVERFX_ARITHSTRETCHY} + +(* + * Mirror the overlay across the vertical axis + *) + DDOVERFX_MIRRORLEFTRIGHT = $00000002; + {$EXTERNALSYM DDOVERFX_MIRRORLEFTRIGHT} + +(* + * Mirror the overlay across the horizontal axis + *) + DDOVERFX_MIRRORUPDOWN = $00000004; + {$EXTERNALSYM DDOVERFX_MIRRORUPDOWN} + +(* + * Deinterlace the overlay, if possible + *) + DDOVERFX_DEINTERLACE = $00000008; + {$EXTERNALSYM DDOVERFX_DEINTERLACE} + + +(**************************************************************************** + * + * DIRECTDRAW WAITFORVERTICALBLANK FLAGS + * + ****************************************************************************) + +(* + * return when the vertical blank interval begins + *) + DDWAITVB_BLOCKBEGIN = $00000001; + {$EXTERNALSYM DDWAITVB_BLOCKBEGIN} + +(* + * set up an event to trigger when the vertical blank begins + *) + DDWAITVB_BLOCKBEGINEVENT = $00000002; + {$EXTERNALSYM DDWAITVB_BLOCKBEGINEVENT} + +(* + * return when the vertical blank interval ends and display begins + *) + DDWAITVB_BLOCKEND = $00000004; + {$EXTERNALSYM DDWAITVB_BLOCKEND} + +(**************************************************************************** + * + * DIRECTDRAW GETFLIPSTATUS FLAGS + * + ****************************************************************************) + +(* + * is it OK to flip now? + *) + DDGFS_CANFLIP = $00000001; + {$EXTERNALSYM DDGFS_CANFLIP} + +(* + * is the last flip finished? + *) + DDGFS_ISFLIPDONE = $00000002; + {$EXTERNALSYM DDGFS_ISFLIPDONE} + +(**************************************************************************** + * + * DIRECTDRAW GETBLTSTATUS FLAGS + * + ****************************************************************************) + +(* + * is it OK to blt now? + *) + DDGBS_CANBLT = $00000001; + {$EXTERNALSYM DDGBS_CANBLT} + +(* + * is the blt to the surface finished? + *) + DDGBS_ISBLTDONE = $00000002; + {$EXTERNALSYM DDGBS_ISBLTDONE} + + +(**************************************************************************** + * + * DIRECTDRAW ENUMOVERLAYZORDER FLAGS + * + ****************************************************************************) + +(* + * Enumerate overlays back to front. + *) + DDENUMOVERLAYZ_BACKTOFRONT = $00000000; + {$EXTERNALSYM DDENUMOVERLAYZ_BACKTOFRONT} + +(* + * Enumerate overlays front to back + *) + DDENUMOVERLAYZ_FRONTTOBACK = $00000001; + {$EXTERNALSYM DDENUMOVERLAYZ_FRONTTOBACK} + +(**************************************************************************** + * + * DIRECTDRAW UPDATEOVERLAYZORDER FLAGS + * + ****************************************************************************) + +(* + * Send overlay to front + *) + DDOVERZ_SENDTOFRONT = $00000000; + {$EXTERNALSYM DDOVERZ_SENDTOFRONT} + +(* + * Send overlay to back + *) + DDOVERZ_SENDTOBACK = $00000001; + {$EXTERNALSYM DDOVERZ_SENDTOBACK} + +(* + * Move Overlay forward + *) + DDOVERZ_MOVEFORWARD = $00000002; + {$EXTERNALSYM DDOVERZ_MOVEFORWARD} + +(* + * Move Overlay backward + *) + DDOVERZ_MOVEBACKWARD = $00000003; + {$EXTERNALSYM DDOVERZ_MOVEBACKWARD} + +(* + * Move Overlay in front of relative surface + *) + DDOVERZ_INSERTINFRONTOF = $00000004; + {$EXTERNALSYM DDOVERZ_INSERTINFRONTOF} + +(* + * Move Overlay in back of relative surface + *) + DDOVERZ_INSERTINBACKOF = $00000005; + {$EXTERNALSYM DDOVERZ_INSERTINBACKOF} + + +(**************************************************************************** + * + * DIRECTDRAW SETGAMMARAMP FLAGS + * + ****************************************************************************) + +(* + * Request calibrator to adjust the gamma ramp according to the physical + * properties of the display so that the result should appear identical + * on all systems. + *) + DDSGR_CALIBRATE = $00000001; + {$EXTERNALSYM DDSGR_CALIBRATE} + + +(**************************************************************************** + * + * DIRECTDRAW STARTMODETEST FLAGS + * + ****************************************************************************) + +(* + * Indicates that the mode being tested has passed + *) + DDSMT_ISTESTREQUIRED = $00000001; + {$EXTERNALSYM DDSMT_ISTESTREQUIRED} + + +(**************************************************************************** + * + * DIRECTDRAW EVALUATEMODE FLAGS + * + ****************************************************************************) + +(* + * Indicates that the mode being tested has passed + *) + DDEM_MODEPASSED = $00000001; + {$EXTERNALSYM DDEM_MODEPASSED} + +(* + * Indicates that the mode being tested has failed + *) + DDEM_MODEFAILED = $00000002; + {$EXTERNALSYM DDEM_MODEFAILED} + + +(*=========================================================================== + * + * + * DIRECTDRAW RETURN CODES + * + * The return values from DirectDraw Commands and Surface that return an HRESULT + * are codes from DirectDraw concerning the results of the action + * requested by DirectDraw. + * + *==========================================================================*) + +(* + * Status is OK + * + * Issued by: DirectDraw Commands and all callbacks + *) + DD_OK = 0; + {$EXTERNALSYM DD_OK} + DD_FALSE = S_FALSE; + {$EXTERNALSYM DD_FALSE} + +(**************************************************************************** + * + * DIRECTDRAW ENUMCALLBACK RETURN VALUES + * + * EnumCallback returns are used to control the flow of the DIRECTDRAW and + * DIRECTDRAWSURFACE object enumerations. They can only be returned by + * enumeration callback routines. + * + ****************************************************************************) + +(* + * stop the enumeration + *) + DDENUMRET_CANCEL = 0; + {$EXTERNALSYM DDENUMRET_CANCEL} + +(* + * continue the enumeration + *) + DDENUMRET_OK = 1; + {$EXTERNALSYM DDENUMRET_OK} + +(**************************************************************************** + * + * DIRECTDRAW ERRORS + * + * Errors are represented by negative values and cannot be combined. + * + ****************************************************************************) + +const + _FACDD = $876; + {$EXTERNALSYM _FACDD} + _MAKE_DDHRESULT = HResult(1 shl 31) or HResult(_FACDD shl 16); + +//#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) +function MAKE_DDHRESULT(Code: DWORD): HResult; +{$EXTERNALSYM MAKE_DDHRESULT} + +const +(* + * This object is already initialized + *) + DDERR_ALREADYINITIALIZED = HResult(_MAKE_DDHRESULT + 5); + {$EXTERNALSYM DDERR_ALREADYINITIALIZED} + +(* + * This surface can not be attached to the requested surface. + *) + DDERR_CANNOTATTACHSURFACE = HResult(_MAKE_DDHRESULT + 10); + {$EXTERNALSYM DDERR_CANNOTATTACHSURFACE} + +(* + * This surface can not be detached from the requested surface. + *) + DDERR_CANNOTDETACHSURFACE = HResult(_MAKE_DDHRESULT + 20); + {$EXTERNALSYM DDERR_CANNOTDETACHSURFACE} + +(* + * Support is currently not available. + *) + DDERR_CURRENTLYNOTAVAIL = HResult(_MAKE_DDHRESULT + 40); + {$EXTERNALSYM DDERR_CURRENTLYNOTAVAIL} + +(* + * An exception was encountered while performing the requested operation + *) + DDERR_EXCEPTION = HResult(_MAKE_DDHRESULT + 55); + {$EXTERNALSYM DDERR_EXCEPTION} + +(* + * Generic failure. + *) + DDERR_GENERIC = E_FAIL; + {$EXTERNALSYM DDERR_GENERIC} + +(* + * Height of rectangle provided is not a multiple of reqd alignment + *) + DDERR_HEIGHTALIGN = HResult(_MAKE_DDHRESULT + 90); + {$EXTERNALSYM DDERR_HEIGHTALIGN} + +(* + * Unable to match primary surface creation request with existing + * primary surface. + *) + DDERR_INCOMPATIBLEPRIMARY = HResult(_MAKE_DDHRESULT + 95); + {$EXTERNALSYM DDERR_INCOMPATIBLEPRIMARY} + +(* + * One or more of the caps bits passed to the callback are incorrect. + *) + DDERR_INVALIDCAPS = HResult(_MAKE_DDHRESULT + 100); + {$EXTERNALSYM DDERR_INVALIDCAPS} + +(* + * DirectDraw does not support provided Cliplist. + *) + DDERR_INVALIDCLIPLIST = HResult(_MAKE_DDHRESULT + 110); + {$EXTERNALSYM DDERR_INVALIDCLIPLIST} + +(* + * DirectDraw does not support the requested mode + *) + DDERR_INVALIDMODE = HResult(_MAKE_DDHRESULT + 120); + {$EXTERNALSYM DDERR_INVALIDMODE} + +(* + * DirectDraw received a pointer that was an invalid DIRECTDRAW object. + *) + DDERR_INVALIDOBJECT = HResult(_MAKE_DDHRESULT + 130); + {$EXTERNALSYM DDERR_INVALIDOBJECT} + +(* + * One or more of the parameters passed to the callback function are + * incorrect. + *) + DDERR_INVALIDPARAMS = E_INVALIDARG; + {$EXTERNALSYM DDERR_INVALIDPARAMS} + +(* + * pixel format was invalid as specified + *) + DDERR_INVALIDPIXELFORMAT = HResult(_MAKE_DDHRESULT + 145); + {$EXTERNALSYM DDERR_INVALIDPIXELFORMAT} + +(* + * Rectangle provided was invalid. + *) + DDERR_INVALIDRECT = HResult(_MAKE_DDHRESULT + 150); + {$EXTERNALSYM DDERR_INVALIDRECT} + +(* + * Operation could not be carried out because one or more surfaces are locked + *) + DDERR_LOCKEDSURFACES = HResult(_MAKE_DDHRESULT + 160); + {$EXTERNALSYM DDERR_LOCKEDSURFACES} + +(* + * There is no 3D present. + *) + DDERR_NO3D = HResult(_MAKE_DDHRESULT + 170); + {$EXTERNALSYM DDERR_NO3D} + +(* + * Operation could not be carried out because there is no alpha accleration + * hardware present or available. + *) + DDERR_NOALPHAHW = HResult(_MAKE_DDHRESULT + 180); + {$EXTERNALSYM DDERR_NOALPHAHW} + +(* + * Operation could not be carried out because there is no stereo + * hardware present or available. + *) + DDERR_NOSTEREOHARDWARE = HResult(_MAKE_DDHRESULT + 181); + {$EXTERNALSYM DDERR_NOSTEREOHARDWARE} + +(* + * Operation could not be carried out because there is no hardware + * present which supports stereo surfaces + *) + DDERR_NOSURFACELEFT = HResult(_MAKE_DDHRESULT + 182); + {$EXTERNALSYM DDERR_NOSURFACELEFT} + + + +(* + * no clip list available + *) + DDERR_NOCLIPLIST = HResult(_MAKE_DDHRESULT + 205); + {$EXTERNALSYM DDERR_NOCLIPLIST} + +(* + * Operation could not be carried out because there is no color conversion + * hardware present or available. + *) + DDERR_NOCOLORCONVHW = HResult(_MAKE_DDHRESULT + 210); + {$EXTERNALSYM DDERR_NOCOLORCONVHW} + +(* + * Create function called without DirectDraw object method SetCooperativeLevel + * being called. + *) + DDERR_NOCOOPERATIVELEVELSET = HResult(_MAKE_DDHRESULT + 212); + {$EXTERNALSYM DDERR_NOCOOPERATIVELEVELSET} + +(* + * Surface doesn't currently have a color key + *) + DDERR_NOCOLORKEY = HResult(_MAKE_DDHRESULT + 215); + {$EXTERNALSYM DDERR_NOCOLORKEY} + +(* + * Operation could not be carried out because there is no hardware support + * of the dest color key. + *) + DDERR_NOCOLORKEYHW = HResult(_MAKE_DDHRESULT + 220); + {$EXTERNALSYM DDERR_NOCOLORKEYHW} + +(* + * No DirectDraw support possible with current display driver + *) + DDERR_NODIRECTDRAWSUPPORT = HResult(_MAKE_DDHRESULT + 222); + {$EXTERNALSYM DDERR_NODIRECTDRAWSUPPORT} + +(* + * Operation requires the application to have exclusive mode but the + * application does not have exclusive mode. + *) + DDERR_NOEXCLUSIVEMODE = HResult(_MAKE_DDHRESULT + 225); + {$EXTERNALSYM DDERR_NOEXCLUSIVEMODE} + +(* + * Flipping visible surfaces is not supported. + *) + DDERR_NOFLIPHW = HResult(_MAKE_DDHRESULT + 230); + {$EXTERNALSYM DDERR_NOFLIPHW} + +(* + * There is no GDI present. + *) + DDERR_NOGDI = HResult(_MAKE_DDHRESULT + 240); + {$EXTERNALSYM DDERR_NOGDI} + +(* + * Operation could not be carried out because there is no hardware present + * or available. + *) + DDERR_NOMIRRORHW = HResult(_MAKE_DDHRESULT + 250); + {$EXTERNALSYM DDERR_NOMIRRORHW} + +(* + * Requested item was not found + *) + DDERR_NOTFOUND = HResult(_MAKE_DDHRESULT + 255); + {$EXTERNALSYM DDERR_NOTFOUND} + +(* + * Operation could not be carried out because there is no overlay hardware + * present or available. + *) + DDERR_NOOVERLAYHW = HResult(_MAKE_DDHRESULT + 260); + {$EXTERNALSYM DDERR_NOOVERLAYHW} + +(* + * Operation could not be carried out because the source and destination + * rectangles are on the same surface and overlap each other. + *) + DDERR_OVERLAPPINGRECTS = HResult(_MAKE_DDHRESULT + 270); + {$EXTERNALSYM DDERR_OVERLAPPINGRECTS} + +(* + * Operation could not be carried out because there is no appropriate raster + * op hardware present or available. + *) + DDERR_NORASTEROPHW = HResult(_MAKE_DDHRESULT + 280); + {$EXTERNALSYM DDERR_NORASTEROPHW} + +(* + * Operation could not be carried out because there is no rotation hardware + * present or available. + *) + DDERR_NOROTATIONHW = HResult(_MAKE_DDHRESULT + 290); + {$EXTERNALSYM DDERR_NOROTATIONHW} + +(* + * Operation could not be carried out because there is no hardware support + * for stretching + *) + DDERR_NOSTRETCHHW = HResult(_MAKE_DDHRESULT + 310); + {$EXTERNALSYM DDERR_NOSTRETCHHW} + +(* + * DirectDrawSurface is not in 4 bit color palette and the requested operation + * requires 4 bit color palette. + *) + DDERR_NOT4BITCOLOR = HResult(_MAKE_DDHRESULT + 316); + {$EXTERNALSYM DDERR_NOT4BITCOLOR} + +(* + * DirectDrawSurface is not in 4 bit color index palette and the requested + * operation requires 4 bit color index palette. + *) + DDERR_NOT4BITCOLORINDEX = HResult(_MAKE_DDHRESULT + 317); + {$EXTERNALSYM DDERR_NOT4BITCOLORINDEX} + +(* + * DirectDraw Surface is not in 8 bit color mode and the requested operation + * requires 8 bit color. + *) + DDERR_NOT8BITCOLOR = HResult(_MAKE_DDHRESULT + 320); + {$EXTERNALSYM DDERR_NOT8BITCOLOR} + +(* + * Operation could not be carried out because there is no texture mapping + * hardware present or available. + *) + DDERR_NOTEXTUREHW = HResult(_MAKE_DDHRESULT + 330); + {$EXTERNALSYM DDERR_NOTEXTUREHW} + +(* + * Operation could not be carried out because there is no hardware support + * for vertical blank synchronized operations. + *) + DDERR_NOVSYNCHW = HResult(_MAKE_DDHRESULT + 335); + {$EXTERNALSYM DDERR_NOVSYNCHW} + +(* + * Operation could not be carried out because there is no hardware support + * for zbuffer blting. + *) + DDERR_NOZBUFFERHW = HResult(_MAKE_DDHRESULT + 340); + {$EXTERNALSYM DDERR_NOZBUFFERHW} + +(* + * Overlay surfaces could not be z layered based on their BltOrder because + * the hardware does not support z layering of overlays. + *) + DDERR_NOZOVERLAYHW = HResult(_MAKE_DDHRESULT + 350); + {$EXTERNALSYM DDERR_NOZOVERLAYHW} + +(* + * The hardware needed for the requested operation has already been + * allocated. + *) + DDERR_OUTOFCAPS = HResult(_MAKE_DDHRESULT + 360); + {$EXTERNALSYM DDERR_OUTOFCAPS} + +(* + * DirectDraw does not have enough memory to perform the operation. + *) + DDERR_OUTOFMEMORY = E_OUTOFMEMORY; + {$EXTERNALSYM DDERR_OUTOFMEMORY} + +(* + * DirectDraw does not have enough memory to perform the operation. + *) + DDERR_OUTOFVIDEOMEMORY = HResult(_MAKE_DDHRESULT + 380); + {$EXTERNALSYM DDERR_OUTOFVIDEOMEMORY} + +(* + * hardware does not support clipped overlays + *) + DDERR_OVERLAYCANTCLIP = HResult(_MAKE_DDHRESULT + 382); + {$EXTERNALSYM DDERR_OVERLAYCANTCLIP} + +(* + * Can only have ony color key active at one time for overlays + *) + DDERR_OVERLAYCOLORKEYONLYONEACTIVE = HResult(_MAKE_DDHRESULT + 384); + {$EXTERNALSYM DDERR_OVERLAYCOLORKEYONLYONEACTIVE} + +(* + * Access to this palette is being refused because the palette is already + * locked by another thread. + *) + DDERR_PALETTEBUSY = HResult(_MAKE_DDHRESULT + 387); + {$EXTERNALSYM DDERR_PALETTEBUSY} + +(* + * No src color key specified for this operation. + *) + DDERR_COLORKEYNOTSET = HResult(_MAKE_DDHRESULT + 400); + {$EXTERNALSYM DDERR_COLORKEYNOTSET} + +(* + * This surface is already attached to the surface it is being attached to. + *) + DDERR_SURFACEALREADYATTACHED = HResult(_MAKE_DDHRESULT + 410); + {$EXTERNALSYM DDERR_SURFACEALREADYATTACHED} + +(* + * This surface is already a dependency of the surface it is being made a + * dependency of. + *) + DDERR_SURFACEALREADYDEPENDENT = HResult(_MAKE_DDHRESULT + 420); + {$EXTERNALSYM DDERR_SURFACEALREADYDEPENDENT} + +(* + * Access to this surface is being refused because the surface is already + * locked by another thread. + *) + DDERR_SURFACEBUSY = HResult(_MAKE_DDHRESULT + 430); + {$EXTERNALSYM DDERR_SURFACEBUSY} + +(* + * Access to this surface is being refused because no driver exists + * which can supply a pointer to the surface. + * This is most likely to happen when attempting to lock the primary + * surface when no DCI provider is present. + * Will also happen on attempts to lock an optimized surface. + *) + DDERR_CANTLOCKSURFACE = HResult(_MAKE_DDHRESULT + 435); + {$EXTERNALSYM DDERR_CANTLOCKSURFACE} + +(* + * Access to Surface refused because Surface is obscured. + *) + DDERR_SURFACEISOBSCURED = HResult(_MAKE_DDHRESULT + 440); + {$EXTERNALSYM DDERR_SURFACEISOBSCURED} + +(* + * Access to this surface is being refused because the surface is gone. + * The DIRECTDRAWSURFACE object representing this surface should + * have Restore called on it. + *) + DDERR_SURFACELOST = HResult(_MAKE_DDHRESULT + 450); + {$EXTERNALSYM DDERR_SURFACELOST} + +(* + * The requested surface is not attached. + *) + DDERR_SURFACENOTATTACHED = HResult(_MAKE_DDHRESULT + 460); + {$EXTERNALSYM DDERR_SURFACENOTATTACHED} + +(* + * Height requested by DirectDraw is too large. + *) + DDERR_TOOBIGHEIGHT = HResult(_MAKE_DDHRESULT + 470); + {$EXTERNALSYM DDERR_TOOBIGHEIGHT} + +(* + * Size requested by DirectDraw is too large -- The individual height and + * width are OK. + *) + DDERR_TOOBIGSIZE = HResult(_MAKE_DDHRESULT + 480); + {$EXTERNALSYM DDERR_TOOBIGSIZE} + +(* + * Width requested by DirectDraw is too large. + *) + DDERR_TOOBIGWIDTH = HResult(_MAKE_DDHRESULT + 490); + {$EXTERNALSYM DDERR_TOOBIGWIDTH} + +(* + * Action not supported. + *) + DDERR_UNSUPPORTED = E_NOTIMPL; + {$EXTERNALSYM DDERR_UNSUPPORTED} + +(* + * FOURCC format requested is unsupported by DirectDraw + *) + DDERR_UNSUPPORTEDFORMAT = HResult(_MAKE_DDHRESULT + 510); + {$EXTERNALSYM DDERR_UNSUPPORTEDFORMAT} + +(* + * Bitmask in the pixel format requested is unsupported by DirectDraw + *) + DDERR_UNSUPPORTEDMASK = HResult(_MAKE_DDHRESULT + 520); + {$EXTERNALSYM DDERR_UNSUPPORTEDMASK} + +(* + * The specified stream contains invalid data + *) + DDERR_INVALIDSTREAM = HResult(_MAKE_DDHRESULT + 521); + {$EXTERNALSYM DDERR_INVALIDSTREAM} + +(* + * vertical blank is in progress + *) + DDERR_VERTICALBLANKINPROGRESS = HResult(_MAKE_DDHRESULT + 537); + {$EXTERNALSYM DDERR_VERTICALBLANKINPROGRESS} + +(* + * Informs DirectDraw that the previous Blt which is transfering information + * to or from this Surface is incomplete. + *) + DDERR_WASSTILLDRAWING = HResult(_MAKE_DDHRESULT + 540); + {$EXTERNALSYM DDERR_WASSTILLDRAWING} + + +(* + * The specified surface type requires specification of the COMPLEX flag + *) + DDERR_DDSCAPSCOMPLEXREQUIRED = HResult(_MAKE_DDHRESULT + 542); + {$EXTERNALSYM DDERR_DDSCAPSCOMPLEXREQUIRED} + + +(* + * Rectangle provided was not horizontally aligned on reqd. boundary + *) + DDERR_XALIGN = HResult(_MAKE_DDHRESULT + 560); + {$EXTERNALSYM DDERR_XALIGN} + +(* + * The GUID passed to DirectDrawCreate is not a valid DirectDraw driver + * identifier. + *) + DDERR_INVALIDDIRECTDRAWGUID = HResult(_MAKE_DDHRESULT + 561); + {$EXTERNALSYM DDERR_INVALIDDIRECTDRAWGUID} + +(* + * A DirectDraw object representing this driver has already been created + * for this process. + *) + DDERR_DIRECTDRAWALREADYCREATED = HResult(_MAKE_DDHRESULT + 562); + {$EXTERNALSYM DDERR_DIRECTDRAWALREADYCREATED} + +(* + * A hardware only DirectDraw object creation was attempted but the driver + * did not support any hardware. + *) + DDERR_NODIRECTDRAWHW = HResult(_MAKE_DDHRESULT + 563); + {$EXTERNALSYM DDERR_NODIRECTDRAWHW} + +(* + * this process already has created a primary surface + *) + DDERR_PRIMARYSURFACEALREADYEXISTS = HResult(_MAKE_DDHRESULT + 564); + {$EXTERNALSYM DDERR_PRIMARYSURFACEALREADYEXISTS} + +(* + * software emulation not available. + *) + DDERR_NOEMULATION = HResult(_MAKE_DDHRESULT + 565); + {$EXTERNALSYM DDERR_NOEMULATION} + +(* + * region passed to Clipper::GetClipList is too small. + *) + DDERR_REGIONTOOSMALL = HResult(_MAKE_DDHRESULT + 566); + {$EXTERNALSYM DDERR_REGIONTOOSMALL} + +(* + * an attempt was made to set a clip list for a clipper objec that + * is already monitoring an hwnd. + *) + DDERR_CLIPPERISUSINGHWND = HResult(_MAKE_DDHRESULT + 567); + {$EXTERNALSYM DDERR_CLIPPERISUSINGHWND} + +(* + * No clipper object attached to surface object + *) + DDERR_NOCLIPPERATTACHED = HResult(_MAKE_DDHRESULT + 568); + {$EXTERNALSYM DDERR_NOCLIPPERATTACHED} + +(* + * Clipper notification requires an HWND or + * no HWND has previously been set as the CooperativeLevel HWND. + *) + DDERR_NOHWND = HResult(_MAKE_DDHRESULT + 569); + {$EXTERNALSYM DDERR_NOHWND} + +(* + * HWND used by DirectDraw CooperativeLevel has been subclassed, + * this prevents DirectDraw from restoring state. + *) + DDERR_HWNDSUBCLASSED = HResult(_MAKE_DDHRESULT + 570); + {$EXTERNALSYM DDERR_HWNDSUBCLASSED} + +(* + * The CooperativeLevel HWND has already been set. + * It can not be reset while the process has surfaces or palettes created. + *) + DDERR_HWNDALREADYSET = HResult(_MAKE_DDHRESULT + 571); + {$EXTERNALSYM DDERR_HWNDALREADYSET} + +(* + * No palette object attached to this surface. + *) + DDERR_NOPALETTEATTACHED = HResult(_MAKE_DDHRESULT + 572); + {$EXTERNALSYM DDERR_NOPALETTEATTACHED} + +(* + * No hardware support for 16 or 256 color palettes. + *) + DDERR_NOPALETTEHW = HResult(_MAKE_DDHRESULT + 573); + {$EXTERNALSYM DDERR_NOPALETTEHW} + +(* + * If a clipper object is attached to the source surface passed into a + * BltFast call. + *) + DDERR_BLTFASTCANTCLIP = HResult(_MAKE_DDHRESULT + 574); + {$EXTERNALSYM DDERR_BLTFASTCANTCLIP} + +(* + * No blter. + *) + DDERR_NOBLTHW = HResult(_MAKE_DDHRESULT + 575); + {$EXTERNALSYM DDERR_NOBLTHW} + +(* + * No DirectDraw ROP hardware. + *) + DDERR_NODDROPSHW = HResult(_MAKE_DDHRESULT + 576); + {$EXTERNALSYM DDERR_NODDROPSHW} + +(* + * returned when GetOverlayPosition is called on a hidden overlay + *) + DDERR_OVERLAYNOTVISIBLE = HResult(_MAKE_DDHRESULT + 577); + {$EXTERNALSYM DDERR_OVERLAYNOTVISIBLE} + +(* + * returned when GetOverlayPosition is called on a overlay that UpdateOverlay + * has never been called on to establish a destionation. + *) + DDERR_NOOVERLAYDEST = HResult(_MAKE_DDHRESULT + 578); + {$EXTERNALSYM DDERR_NOOVERLAYDEST} + +(* + * returned when the position of the overlay on the destionation is no longer + * legal for that destionation. + *) + DDERR_INVALIDPOSITION = HResult(_MAKE_DDHRESULT + 579); + {$EXTERNALSYM DDERR_INVALIDPOSITION} + +(* + * returned when an overlay member is called for a non-overlay surface + *) + DDERR_NOTAOVERLAYSURFACE = HResult(_MAKE_DDHRESULT + 580); + {$EXTERNALSYM DDERR_NOTAOVERLAYSURFACE} + +(* + * An attempt was made to set the cooperative level when it was already + * set to exclusive. + *) + DDERR_EXCLUSIVEMODEALREADYSET = HResult(_MAKE_DDHRESULT + 581); + {$EXTERNALSYM DDERR_EXCLUSIVEMODEALREADYSET} + +(* + * An attempt has been made to flip a surface that is not flippable. + *) + DDERR_NOTFLIPPABLE = HResult(_MAKE_DDHRESULT + 582); + {$EXTERNALSYM DDERR_NOTFLIPPABLE} + +(* + * Can't duplicate primary & 3D surfaces, or surfaces that are implicitly + * created. + *) + DDERR_CANTDUPLICATE = HResult(_MAKE_DDHRESULT + 583); + {$EXTERNALSYM DDERR_CANTDUPLICATE} + +(* + * Surface was not locked. An attempt to unlock a surface that was not + * locked at all, or by this process, has been attempted. + *) + DDERR_NOTLOCKED = HResult(_MAKE_DDHRESULT + 584); + {$EXTERNALSYM DDERR_NOTLOCKED} + +(* + * Windows can not create any more DCs, or a DC was requested for a paltte-indexed + * surface when the surface had no palette AND the display mode was not palette-indexed + * (in this case DirectDraw cannot select a proper palette into the DC) + *) + DDERR_CANTCREATEDC = HResult(_MAKE_DDHRESULT + 585); + {$EXTERNALSYM DDERR_CANTCREATEDC} + +(* + * No DC was ever created for this surface. + *) + DDERR_NODC = HResult(_MAKE_DDHRESULT + 586); + {$EXTERNALSYM DDERR_NODC} + +(* + * This surface can not be restored because it was created in a different + * mode. + *) + DDERR_WRONGMODE = HResult(_MAKE_DDHRESULT + 587); + {$EXTERNALSYM DDERR_WRONGMODE} + +(* + * This surface can not be restored because it is an implicitly created + * surface. + *) + DDERR_IMPLICITLYCREATED = HResult(_MAKE_DDHRESULT + 588); + {$EXTERNALSYM DDERR_IMPLICITLYCREATED} + +(* + * The surface being used is not a palette-based surface + *) + DDERR_NOTPALETTIZED = HResult(_MAKE_DDHRESULT + 589); + {$EXTERNALSYM DDERR_NOTPALETTIZED} + + +(* + * The display is currently in an unsupported mode + *) + DDERR_UNSUPPORTEDMODE = HResult(_MAKE_DDHRESULT + 590); + {$EXTERNALSYM DDERR_UNSUPPORTEDMODE} + +(* + * Operation could not be carried out because there is no mip-map + * texture mapping hardware present or available. + *) + DDERR_NOMIPMAPHW = HResult(_MAKE_DDHRESULT + 591); + {$EXTERNALSYM DDERR_NOMIPMAPHW} + +(* + * The requested action could not be performed because the surface was of + * the wrong type. + *) + DDERR_INVALIDSURFACETYPE = HResult(_MAKE_DDHRESULT + 592); + {$EXTERNALSYM DDERR_INVALIDSURFACETYPE} + + +(* + * Device does not support optimized surfaces, therefore no video memory optimized surfaces + *) + DDERR_NOOPTIMIZEHW = HResult(_MAKE_DDHRESULT + 600); + {$EXTERNALSYM DDERR_NOOPTIMIZEHW} + +(* + * Surface is an optimized surface, but has not yet been allocated any memory + *) + DDERR_NOTLOADED = HResult(_MAKE_DDHRESULT + 601); + {$EXTERNALSYM DDERR_NOTLOADED} + +(* + * Attempt was made to create or set a device window without first setting + * the focus window + *) + DDERR_NOFOCUSWINDOW = HResult(_MAKE_DDHRESULT + 602); + {$EXTERNALSYM DDERR_NOFOCUSWINDOW} + +(* + * Attempt was made to set a palette on a mipmap sublevel + *) + DDERR_NOTONMIPMAPSUBLEVEL = HResult(_MAKE_DDHRESULT + 603); + {$EXTERNALSYM DDERR_NOTONMIPMAPSUBLEVEL} + +(* + * A DC has already been returned for this surface. Only one DC can be + * retrieved per surface. + *) + DDERR_DCALREADYCREATED = HResult(_MAKE_DDHRESULT + 620); + {$EXTERNALSYM DDERR_DCALREADYCREATED} + +(* + * An attempt was made to allocate non-local video memory from a device + * that does not support non-local video memory. + *) + DDERR_NONONLOCALVIDMEM = HResult(_MAKE_DDHRESULT + 630); + {$EXTERNALSYM DDERR_NONONLOCALVIDMEM} + +(* + * The attempt to page lock a surface failed. + *) + DDERR_CANTPAGELOCK = HResult(_MAKE_DDHRESULT + 640); + {$EXTERNALSYM DDERR_CANTPAGELOCK} + + +(* + * The attempt to page unlock a surface failed. + *) + DDERR_CANTPAGEUNLOCK = HResult(_MAKE_DDHRESULT + 660); + {$EXTERNALSYM DDERR_CANTPAGEUNLOCK} + +(* + * An attempt was made to page unlock a surface with no outstanding page locks. + *) + DDERR_NOTPAGELOCKED = HResult(_MAKE_DDHRESULT + 680); + {$EXTERNALSYM DDERR_NOTPAGELOCKED} + +(* + * There is more data available than the specified buffer size could hold + *) + DDERR_MOREDATA = HResult(_MAKE_DDHRESULT + 690); + {$EXTERNALSYM DDERR_MOREDATA} + +(* + * The data has expired and is therefore no longer valid. + *) + DDERR_EXPIRED = HResult(_MAKE_DDHRESULT + 691); + {$EXTERNALSYM DDERR_EXPIRED} + +(* + * The mode test has finished executing. + *) + DDERR_TESTFINISHED = HResult(_MAKE_DDHRESULT + 692); + {$EXTERNALSYM DDERR_TESTFINISHED} + +(* + * The mode test has switched to a new mode. + *) + DDERR_NEWMODE = HResult(_MAKE_DDHRESULT + 693); + {$EXTERNALSYM DDERR_NEWMODE} + +(* + * D3D has not yet been initialized. + *) + DDERR_D3DNOTINITIALIZED = HResult(_MAKE_DDHRESULT + 694); + {$EXTERNALSYM DDERR_D3DNOTINITIALIZED} + +(* + * The video port is not active + *) + DDERR_VIDEONOTACTIVE = HResult(_MAKE_DDHRESULT + 695); + {$EXTERNALSYM DDERR_VIDEONOTACTIVE} + +(* + * The monitor does not have EDID data. + *) + DDERR_NOMONITORINFORMATION = HResult(_MAKE_DDHRESULT + 696); + {$EXTERNALSYM DDERR_NOMONITORINFORMATION} + +(* + * The driver does not enumerate display mode refresh rates. + *) + DDERR_NODRIVERSUPPORT = HResult(_MAKE_DDHRESULT + 697); + {$EXTERNALSYM DDERR_NODRIVERSUPPORT} + +(* + * Surfaces created by one direct draw device cannot be used directly by + * another direct draw device. + *) + DDERR_DEVICEDOESNTOWNSURFACE = HResult(_MAKE_DDHRESULT + 699); + {$EXTERNALSYM DDERR_DEVICEDOESNTOWNSURFACE} + + + +(* + * An attempt was made to invoke an interface member of a DirectDraw object + * created by CoCreateInstance() before it was initialized. + *) + DDERR_NOTINITIALIZED = CO_E_NOTINITIALIZED; + {$EXTERNALSYM DDERR_NOTINITIALIZED} + +(* Alpha bit depth constants *) + + + +(* + * API's + *) + +const + DirectDrawDll = 'ddraw.dll'; + +type + HMonitor = THandle; + {$EXTERNALSYM HMonitor} + + TDDEnumCallbackA = function (lpGUID: PGUID; lpDriverDescription: PAnsiChar; + lpDriverName: PAnsiChar; lpContext: Pointer): BOOL; stdcall; + {$EXTERNALSYM TDDEnumCallbackA} + TDDEnumCallbackW = function (lpGUID: PGUID; lpDriverDescription: PWideChar; + lpDriverName: PWideChar; lpContext: Pointer): BOOL; stdcall; + {$EXTERNALSYM TDDEnumCallbackW} + TDDEnumCallback = function (lpGUID: PGUID; lpDriverDescription: PChar; + lpDriverName: PChar; lpContext: Pointer): BOOL; stdcall; + {$EXTERNALSYM TDDEnumCallback} + + TDDEnumCallbackExA = function (lpGUID: PGUID; lpDriverDescription: PAnsiChar; + lpDriverName: PAnsiChar; lpContext: Pointer; Monitor: HMonitor): BOOL; + stdcall; + {$EXTERNALSYM TDDEnumCallbackExA} + TDDEnumCallbackExW = function (lpGUID: PGUID; lpDriverDescription: PWideChar; + lpDriverName: PWideChar; lpContext: Pointer; Monitor: HMonitor): BOOL; + stdcall; + {$EXTERNALSYM TDDEnumCallbackExW} + TDDEnumCallbackEx = function (lpGUID: PGUID; lpDriverDescription: PChar; + lpDriverName: PChar; lpContext: Pointer; Monitor: HMonitor): BOOL; + stdcall; + {$EXTERNALSYM TDDEnumCallbackEx} + +function DirectDrawLoaded: Boolean; +function UnLoadDirectDraw: Boolean; +function LoadDirectDraw: Boolean; + +{$IFDEF DIRECTDRAW_DYNAMIC_LINK} +var + DirectDrawEnumerateA : function (lpCallback: TDDEnumCallbackA; + lpContext: Pointer): HResult; stdcall; + {$EXTERNALSYM DirectDrawEnumerateA} + DirectDrawEnumerateW : function (lpCallback: TDDEnumCallbackW; + lpContext: Pointer): HResult; stdcall; + {$EXTERNALSYM DirectDrawEnumerateW} + DirectDrawEnumerate : function (lpCallback: TDDEnumCallback; + lpContext: Pointer): HResult; stdcall; + {$EXTERNALSYM DirectDrawEnumerate} + + DirectDrawEnumerateExA : function (lpCallback: TDDEnumCallbackExA; + lpContext: Pointer; dwFlags: DWORD): HResult; stdcall; + {$EXTERNALSYM DirectDrawEnumerateExA} + DirectDrawEnumerateExW : function (lpCallback: TDDEnumCallbackExW; + lpContext: Pointer; dwFlags: DWORD): HResult; stdcall; + {$EXTERNALSYM DirectDrawEnumerateExW} + DirectDrawEnumerateEx : function (lpCallback: TDDEnumCallbackEx; + lpContext: Pointer; dwFlags: DWORD): HResult; stdcall; + {$EXTERNALSYM DirectDrawEnumerateEx} + + DirectDrawCreate : function (lpGUID: PGUID; + out lplpDD: IDirectDraw; + pUnkOuter: IUnknown): HResult; stdcall; + {$EXTERNALSYM DirectDrawCreate} + DirectDrawCreateEx : function (lpGUID: PGUID; + out lplpDD: IDirectDraw7; const iid: TGUID; + pUnkOuter: IUnknown): HResult; stdcall; + {$EXTERNALSYM DirectDrawCreateEx} + DirectDrawCreateClipper : function (dwFlags: DWORD; + out lplpDDClipper: IDirectDrawClipper; + pUnkOuter: IUnknown): HResult; stdcall; + {$EXTERNALSYM DirectDrawCreateClipper} +{$ELSE} + +function DirectDrawEnumerateA(lpCallback: TDDEnumCallbackA; lpContext: Pointer): HResult; stdcall; external DirectDrawDll; +{$EXTERNALSYM DirectDrawEnumerateA} +function DirectDrawEnumerateW(lpCallback: TDDEnumCallbackW; lpContext: Pointer): HResult; stdcall; external DirectDrawDll; +{$EXTERNALSYM DirectDrawEnumerateW} +function DirectDrawEnumerate(lpCallback: TDDEnumCallback; lpContext: Pointer): HResult; stdcall; + external DirectDrawDll name {$IFDEF UNICODE}'DirectDrawEnumerateW'{$ELSE}'DirectDrawEnumerateA'{$ENDIF}; +{$EXTERNALSYM DirectDrawEnumerate} + +function DirectDrawEnumerateExA(lpCallback: TDDEnumCallbackExA; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall; external DirectDrawDll; +{$EXTERNALSYM DirectDrawEnumerateExA} +function DirectDrawEnumerateExW(lpCallback: TDDEnumCallbackExW; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall; external DirectDrawDll; +{$EXTERNALSYM DirectDrawEnumerateExW} +function DirectDrawEnumerateEx(lpCallback: TDDEnumCallbackEx; lpContext: Pointer; dwFlags: DWORD): HResult; stdcall; + external DirectDrawDll name {$IFDEF UNICODE}'DirectDrawEnumerateExW'{$ELSE}'DirectDrawEnumerateExA'{$ENDIF}; +{$EXTERNALSYM DirectDrawEnumerateEx} + +function DirectDrawCreate(lpGUID: PGUID; out lplpDD: IDirectDraw; + pUnkOuter: IUnknown): HResult; stdcall; external DirectDrawDll; +{$EXTERNALSYM DirectDrawCreate} + +function DirectDrawCreateEx(lpGUID: PGUID; out lplpDD: IDirectDraw7; + const iid: TGUID; pUnkOuter: IUnknown): HResult; stdcall; external DirectDrawDll; +{$EXTERNALSYM DirectDrawCreateEx} + +function DirectDrawCreateClipper(dwFlags: DWORD; out lplpDDClipper: IDirectDrawClipper; + pUnkOuter: IUnknown): HResult; stdcall; external DirectDrawDll; +{$EXTERNALSYM DirectDrawCreateClipper} + +{$ENDIF} + +const +(* + * Flags for DirectDrawEnumerateEx + * DirectDrawEnumerateEx supercedes DirectDrawEnumerate. You must use GetProcAddress to + * obtain a function pointer (of type LPDIRECTDRAWENUMERATEEX) to DirectDrawEnumerateEx. + * By default, only the primary display device is enumerated. + * DirectDrawEnumerate is equivalent to DirectDrawEnumerate(,,DDENUM_NONDISPLAYDEVICES) + *) + +(* + * This flag causes enumeration of any GDI display devices which are part of + * the Windows Desktop + *) + DDENUM_ATTACHEDSECONDARYDEVICES = $00000001; + {$EXTERNALSYM DDENUM_ATTACHEDSECONDARYDEVICES} + +(* + * This flag causes enumeration of any GDI display devices which are not + * part of the Windows Desktop + *) + DDENUM_DETACHEDSECONDARYDEVICES = $00000002; + {$EXTERNALSYM DDENUM_DETACHEDSECONDARYDEVICES} + +(* + * This flag causes enumeration of non-display devices + *) + DDENUM_NONDISPLAYDEVICES = $00000004; + {$EXTERNALSYM DDENUM_NONDISPLAYDEVICES} + + + REGSTR_KEY_DDHW_DESCRIPTION = 'Description'; + {$EXTERNALSYM REGSTR_KEY_DDHW_DESCRIPTION} + REGSTR_KEY_DDHW_DRIVERNAME = 'DriverName'; + {$EXTERNALSYM REGSTR_KEY_DDHW_DRIVERNAME} + REGSTR_PATH_DDHW = 'Hardware\DirectDrawDrivers'; + {$EXTERNALSYM REGSTR_PATH_DDHW} + + DDCREATE_HARDWAREONLY = $00000001; + {$EXTERNALSYM DDCREATE_HARDWAREONLY} + DDCREATE_EMULATIONONLY = $00000002; + {$EXTERNALSYM DDCREATE_EMULATIONONLY} + +(* + * Flags for the IDirectDraw4::GetDeviceIdentifier method + *) + +(* + * This flag causes GetDeviceIdentifier to return information about the host (typically 2D) adapter in a system equipped + * with a stacked secondary 3D adapter. Such an adapter appears to the application as if it were part of the + * host adapter, but is typically physcially located on a separate card. The stacked secondary's information is + * returned when GetDeviceIdentifier's dwFlags field is zero, since this most accurately reflects the qualities + * of the DirectDraw object involved. + *) + DDGDI_GETHOSTIDENTIFIER = $00000001; + {$EXTERNALSYM DDGDI_GETHOSTIDENTIFIER} + +(* + * Macros for interpretting DDEVICEIDENTIFIER2.dwWHQLLevel + *) +function GET_WHQL_YEAR(dwWHQLLevel: DWORD): DWORD; +{$EXTERNALSYM GET_WHQL_YEAR} +function GET_WHQL_MONTH(dwWHQLLevel: DWORD): DWORD; +{$EXTERNALSYM GET_WHQL_MONTH} +function GET_WHQL_DAY(dwWHQLLevel: DWORD): DWORD; +{$EXTERNALSYM GET_WHQL_DAY} + + +(*==========================================================================; + * + * Copyright (C) 1996-1997 Microsoft Corporation. All Rights Reserved. + * + * File: dvp.h + * Content: DirectDrawVideoPort include file + * + ***************************************************************************) + +const +(* + * GUIDS used by DirectDrawVideoPort objects + *) + +(* + IID_IDDVideoPortContainer, + IID_IDirectDrawVideoPort, + IID_IDirectDrawVideoPortNotify + - are defined later in Delphi header +*) + + DDVPTYPE_E_HREFH_VREFH: TGUID = (D1:$54F39980;D2:$DA60;D3:$11CF;D4:($9B,$06,$00,$A0,$C9,$03,$A3,$B8)); + {$EXTERNALSYM DDVPTYPE_E_HREFH_VREFH} + DDVPTYPE_E_HREFH_VREFL: TGUID = (D1:$92783220;D2:$DA60;D3:$11CF;D4:($9B,$06,$00,$A0,$C9,$03,$A3,$B8)); + {$EXTERNALSYM DDVPTYPE_E_HREFH_VREFL} + DDVPTYPE_E_HREFL_VREFH: TGUID = (D1:$A07A02E0;D2:$DA60;D3:$11CF;D4:($9B,$06,$00,$A0,$C9,$03,$A3,$B8)); + {$EXTERNALSYM DDVPTYPE_E_HREFL_VREFH} + DDVPTYPE_E_HREFL_VREFL: TGUID = (D1:$E09C77E0;D2:$DA60;D3:$11CF;D4:($9B,$06,$00,$A0,$C9,$03,$A3,$B8)); + {$EXTERNALSYM DDVPTYPE_E_HREFL_VREFL} + DDVPTYPE_CCIR656: TGUID = (D1:$FCA326A0;D2:$DA60;D3:$11CF;D4:($9B,$06,$00,$A0,$C9,$03,$A3,$B8)); + {$EXTERNALSYM DDVPTYPE_CCIR656} + DDVPTYPE_BROOKTREE: TGUID = (D1:$1352A560;D2:$DA61;D3:$11CF;D4:($9B,$06,$00,$A0,$C9,$03,$A3,$B8)); + {$EXTERNALSYM DDVPTYPE_BROOKTREE} + DDVPTYPE_PHILIPS: TGUID = (D1:$332CF160;D2:$DA61;D3:$11CF;D4:($9B,$06,$00,$A0,$C9,$03,$A3,$B8)); + {$EXTERNALSYM DDVPTYPE_PHILIPS} + + +(* + * These definitions are required to allow polymorphic structure members (i.e. those + * that are referred to both as DWORDs and as pointers) to resolve into a type + * of correct size to hold the largest of those two types (i.e. pointer) on 64 bit + * systems. For 32 bit environments, ULONG_PTR resolves to a DWORD. + *) +type + ULONG_PTR = DWORD; + {$EXTERNALSYM ULONG_PTR} + +(*============================================================================ + * + * DirectDraw Structures + * + * Various structures used to invoke DirectDraw. + * + *==========================================================================*) + +type + +(* + * DDVIDEOPORTCONNECT + *) + PDDVideoPortConnect = ^TDDVideoPortConnect; + _DDVIDEOPORTCONNECT = packed record + dwSize: DWORD; // size of the TDDVideoPortConnect structure + dwPortWidth: DWORD; // Width of the video port + guidTypeID: TGUID; // Description of video port connection + dwFlags: DWORD; // Connection flags + dwReserved1: ULONG_PTR; // Reserved, set to zero. + end; + {$EXTERNALSYM _DDVIDEOPORTCONNECT} + DDVIDEOPORTCONNECT = _DDVIDEOPORTCONNECT; + {$EXTERNALSYM DDVIDEOPORTCONNECT} + TDDVideoPortConnect = _DDVIDEOPORTCONNECT; + +(* + * DDVIDEOPORTCAPS + *) + PDDVideoPortCaps = ^TDDVideoPortCaps; + _DDVIDEOPORTCAPS = packed record + dwSize: DWORD; // size of the TDDVideoPortCaps structure + dwFlags: DWORD; // indicates which fields contain data + dwMaxWidth: DWORD; // max width of the video port field + dwMaxVBIWidth: DWORD; // max width of the VBI data + dwMaxHeight: DWORD; // max height of the video port field + dwVideoPortID: DWORD; // Video port ID (0 - (dwMaxVideoPorts -1)) + dwCaps: DWORD; // Video port capabilities + dwFX: DWORD; // More video port capabilities + dwNumAutoFlipSurfaces: DWORD; // Number of autoflippable surfaces + dwAlignVideoPortBoundary: DWORD; // Byte restriction of placement within the surface + dwAlignVideoPortPrescaleWidth: DWORD; // Byte restriction of width after prescaling + dwAlignVideoPortCropBoundary: DWORD; // Byte restriction of left cropping + dwAlignVideoPortCropWidth: DWORD; // Byte restriction of cropping width + dwPreshrinkXStep: DWORD; // Width can be shrunk in steps of 1/x + dwPreshrinkYStep: DWORD; // Height can be shrunk in steps of 1/x + dwNumVBIAutoFlipSurfaces: DWORD; // Number of VBI autoflippable surfaces allowed + dwNumPreferredAutoflip: DWORD; // Optimal number of autoflippable surfaces for hardware + wNumFilterTapsX: Word; // Number of taps the prescaler uses in the X direction (0 - no prescale, 1 - replication, etc.) + wNumFilterTapsY: Word; // Number of taps the prescaler uses in the Y direction (0 - no prescale, 1 - replication, etc.) + end; + {$EXTERNALSYM _DDVIDEOPORTCAPS} + DDVIDEOPORTCAPS = _DDVIDEOPORTCAPS; + {$EXTERNALSYM DDVIDEOPORTCAPS} + TDDVideoPortCaps = _DDVIDEOPORTCAPS; + +const +(* + * The dwMaxWidth and dwMaxVBIWidth members are valid + *) + DDVPD_WIDTH = $00000001; + {$EXTERNALSYM DDVPD_WIDTH} + +(* + * The dwMaxHeight member is valid + *) + DDVPD_HEIGHT = $00000002; + {$EXTERNALSYM DDVPD_HEIGHT} + +(* + * The dwVideoPortID member is valid + *) + DDVPD_ID = $00000004; + {$EXTERNALSYM DDVPD_ID} + +(* + * The dwCaps member is valid + *) + DDVPD_CAPS = $00000008; + {$EXTERNALSYM DDVPD_CAPS} + +(* + * The dwFX member is valid + *) + DDVPD_FX = $00000010; + {$EXTERNALSYM DDVPD_FX} + +(* + * The dwNumAutoFlipSurfaces member is valid + *) + DDVPD_AUTOFLIP = $00000020; + {$EXTERNALSYM DDVPD_AUTOFLIP} + +(* + * All of the alignment members are valid + *) + DDVPD_ALIGN = $00000040; + {$EXTERNALSYM DDVPD_ALIGN} + +(* + * The dwNumPreferredAutoflip member is valid + *) + DDVPD_PREFERREDAUTOFLIP = $00000080; + {$EXTERNALSYM DDVPD_PREFERREDAUTOFLIP} + +(* + * The wNumFilterTapsX and wNumFilterTapsY fields are valid + *) + DDVPD_FILTERQUALITY = $00000100; + {$EXTERNALSYM DDVPD_FILTERQUALITY} + +type +(* + * DDVIDEOPORTDESC + *) + PDDVideoPortDesc = ^TDDVideoPortDesc; + _DDVIDEOPORTDESC = packed record + dwSize: DWORD; // size of the TDDVideoPortDesc structure + dwFieldWidth: DWORD; // width of the video port field + dwVBIWidth: DWORD; // width of the VBI data + dwFieldHeight: DWORD; // height of the video port field + dwMicrosecondsPerField: DWORD; // Microseconds per video field + dwMaxPixelsPerSecond: DWORD; // Maximum pixel rate per second + dwVideoPortID: DWORD; // Video port ID (0 - (dwMaxVideoPorts -1)) + dwReserved1: DWORD; // Reserved for future use - set to zero (struct padding) + VideoPortType: TDDVideoPortConnect; // Description of video port connection + dwReserved2: DWORD; // Reserved for future use - set to zero + dwReserved3: DWORD; // Reserved for future use - set to zero + end; + {$EXTERNALSYM _DDVIDEOPORTDESC} + DDVIDEOPORTDESC = _DDVIDEOPORTDESC; + {$EXTERNALSYM DDVIDEOPORTDESC} + TDDVideoPortDesc = _DDVIDEOPORTDESC; + +(* + * DDVIDEOPORTINFO + *) + PDDVideoPortInfo = ^TDDVideoPortInfo; + _DDVIDEOPORTINFO = packed record + dwSize: DWORD; // Size of the structure + dwOriginX: DWORD; // Placement of the video data within the surface. + dwOriginY: DWORD; // Placement of the video data within the surface. + dwVPFlags: DWORD; // Video port options + rCrop: TRect; // Cropping rectangle (optional). + dwPrescaleWidth: DWORD; // Determines pre-scaling/zooming in the X direction (optional). + dwPrescaleHeight: DWORD; // Determines pre-scaling/zooming in the Y direction (optional). + lpddpfInputFormat: PDDPixelFormat; // Video format written to the video port + lpddpfVBIInputFormat: PDDPixelFormat; // Input format of the VBI data + lpddpfVBIOutputFormat: PDDPixelFormat; // Output format of the data + dwVBIHeight: DWORD; // Specifies the number of lines of data within the vertical blanking interval. + dwReserved1: DWORD; // Reserved for future use - set to zero + dwReserved2: DWORD; // Reserved for future use - set to zero + end; + {$EXTERNALSYM _DDVIDEOPORTINFO} + DDVIDEOPORTINFO = _DDVIDEOPORTINFO; + {$EXTERNALSYM DDVIDEOPORTINFO} + TDDVideoPortInfo = _DDVIDEOPORTINFO; + +(* + * DDVIDEOPORTBANDWIDTH + *) + PDDVideoPortBandWidth = ^TDDVideoPortBandWidth; + _DDVIDEOPORTBANDWIDTH = packed record + dwSize: DWORD; // Size of the structure + dwCaps: DWORD; + dwOverlay: DWORD; // Zoom factor at which overlay is supported + dwColorkey: DWORD; // Zoom factor at which overlay w/ colorkey is supported + dwYInterpolate: DWORD; // Zoom factor at which overlay w/ Y interpolation is supported + dwYInterpAndColorkey: DWORD; // Zoom factor at which ovelray w/ Y interpolation and colorkeying is supported + dwReserved1: DWORD; // Reserved for future use - set to zero + dwReserved2: DWORD; // Reserved for future use - set to zero + end; + {$EXTERNALSYM _DDVIDEOPORTBANDWIDTH} + DDVIDEOPORTBANDWIDTH = _DDVIDEOPORTBANDWIDTH; + {$EXTERNALSYM DDVIDEOPORTBANDWIDTH} + TDDVideoPortBandWidth = _DDVIDEOPORTBANDWIDTH; + +(* + * DDVIDEOPORTSTATUS + *) + PDDVideoPortStatus = ^TDDVideoPortStatus; + _DDVIDEOPORTSTATUS = record + dwSize: DWORD; // Size of the structure + bInUse: BOOL; // TRUE if video port is currently being used + dwFlags: DWORD; // Currently not used + dwReserved1: DWORD; // Reserved for future use + VideoPortType: TDDVideoPortConnect; // Information about the connection + dwReserved2: DWORD; // Reserved for future use + dwReserved3: DWORD; // Reserved for future use + end; + {$EXTERNALSYM _DDVIDEOPORTSTATUS} + DDVIDEOPORTSTATUS = _DDVIDEOPORTSTATUS; + {$EXTERNALSYM DDVIDEOPORTSTATUS} + TDDVideoPortStatus = _DDVIDEOPORTSTATUS; + +(* + * DDVIDEOPORTNOTIFY + *) + PDDVideoPortNotify = ^TDDVideoPortNotify; + _DDVIDEOPORTNOTIFY = packed record + ApproximateTimeStamp: Int64; // Timestamp in the event notification + lField: Longint; // 0 if even, 1 if odd, -1 if unknown + dwSurfaceIndex: Longword; // Index in the surface chain of the surface that received the sample + lDone: Longint; // Call InterlockedIncrement on this when done with sample + end; + {$EXTERNALSYM _DDVIDEOPORTNOTIFY} + DDVIDEOPORTNOTIFY = _DDVIDEOPORTNOTIFY; + {$EXTERNALSYM DDVIDEOPORTNOTIFY} + TDDVideoPortNotify = _DDVIDEOPORTNOTIFY; + + +(*============================================================================ + * + * Video Port Flags + * + * All flags are bit flags. + * + *==========================================================================*) +const +(**************************************************************************** + * + * VIDEOPORT DDVIDEOPORTCONNECT / TDDVideoPortConnect FLAGS + * + ****************************************************************************) + +(* + * When this is set by the driver and passed to the client, this + * indicates that the video port is capable of double clocking the data. + * When this is set by the client, this indicates that the video port + * should enable double clocking. This flag is only valid with external + * syncs. + *) + DDVPCONNECT_DOUBLECLOCK = $00000001; + {$EXTERNALSYM DDVPCONNECT_DOUBLECLOCK} + +(* + * When this is set by the driver and passed to the client, this + * indicates that the video port is capable of using an external VACT + * signal. When this is set by the client, this indicates that the + * video port should use the external VACT signal. + *) + DDVPCONNECT_VACT = $00000002; + {$EXTERNALSYM DDVPCONNECT_VACT} + +(* + * When this is set by the driver and passed to the client, this + * indicates that the video port is capable of treating even fields + * like odd fields and visa versa. When this is set by the client, + * this indicates that the video port should treat even fields like odd + * fields. + *) + DDVPCONNECT_INVERTPOLARITY = $00000004; + {$EXTERNALSYM DDVPCONNECT_INVERTPOLARITY} + +(* + * Indicates that any data written to the video port during the VREF + * period will not be written into the frame buffer. This flag is read only. + *) + DDVPCONNECT_DISCARDSVREFDATA = $00000008; + {$EXTERNALSYM DDVPCONNECT_DISCARDSVREFDATA} + +(* + * When this is set be the driver and passed to the client, this + * indicates that the device will write half lines into the frame buffer + * if half lines are provided by the decoder. If this is set by the client, + * this indicates that the decoder will be supplying half lines. + *) + DDVPCONNECT_HALFLINE = $00000010; + {$EXTERNALSYM DDVPCONNECT_HALFLINE} + +(* + * Indicates that the signal is interlaced. This flag is only + * set by the client. + *) + DDVPCONNECT_INTERLACED = $00000020; + {$EXTERNALSYM DDVPCONNECT_INTERLACED} + +(* + * Indicates that video port is shareable and that this video port + * will use the even fields. This flag is only set by the client. + *) + DDVPCONNECT_SHAREEVEN = $00000040; + {$EXTERNALSYM DDVPCONNECT_SHAREEVEN} + +(* + * Indicates that video port is shareable and that this video port + * will use the odd fields. This flag is only set by the client. + *) + DDVPCONNECT_SHAREODD = $00000080; + {$EXTERNALSYM DDVPCONNECT_SHAREODD} + +(**************************************************************************** + * + * VIDEOPORT DDVIDEOPORTDESC / TDDVideoPortDesc CAPS + * + ****************************************************************************) + +(* + * Flip can be performed automatically to avoid tearing. + *) + DDVPCAPS_AUTOFLIP = $00000001; + {$EXTERNALSYM DDVPCAPS_AUTOFLIP} + +(* + * Supports interlaced video + *) + DDVPCAPS_INTERLACED = $00000002; + {$EXTERNALSYM DDVPCAPS_INTERLACED} + +(* + * Supports non-interlaced video + *) + DDVPCAPS_NONINTERLACED = $00000004; + {$EXTERNALSYM DDVPCAPS_NONINTERLACED} + +(* + * Indicates that the device can return whether the current field + * of an interlaced signal is even or odd. + *) + DDVPCAPS_READBACKFIELD = $00000008; + {$EXTERNALSYM DDVPCAPS_READBACKFIELD} + +(* + * Indicates that the device can return the current line of video + * being written into the frame buffer. + *) + DDVPCAPS_READBACKLINE = $00000010; + {$EXTERNALSYM DDVPCAPS_READBACKLINE} + +(* + * Allows two gen-locked video streams to share a single video port, + * where one stream uses the even fields and the other uses the odd + * fields. Separate parameters (including address, scaling, + * cropping, etc.) are maintained for both fields.) + *) + DDVPCAPS_SHAREABLE = $00000020; + {$EXTERNALSYM DDVPCAPS_SHAREABLE} + +(* + * Even fields of video can be automatically discarded. + *) + DDVPCAPS_SKIPEVENFIELDS = $00000040; + {$EXTERNALSYM DDVPCAPS_SKIPEVENFIELDS} + +(* + * Odd fields of video can be automatically discarded. + *) + DDVPCAPS_SKIPODDFIELDS = $00000080; + {$EXTERNALSYM DDVPCAPS_SKIPODDFIELDS} + +(* + * Indicates that the device is capable of driving the graphics + * VSYNC with the video port VSYNC. + *) + DDVPCAPS_SYNCMASTER = $00000100; + {$EXTERNALSYM DDVPCAPS_SYNCMASTER} + +(* + * Indicates that data within the vertical blanking interval can + * be written to a different surface. + *) + DDVPCAPS_VBISURFACE = $00000200; + {$EXTERNALSYM DDVPCAPS_VBISURFACE} + +(* + * Indicates that the video port can perform color operations + * on the incoming data before it is written to the frame buffer. + *) + DDVPCAPS_COLORCONTROL = $00000400; + {$EXTERNALSYM DDVPCAPS_COLORCONTROL} + +(* + * Indicates that the video port can accept VBI data in a different + * width or format than the regular video data. + *) + DDVPCAPS_OVERSAMPLEDVBI = $00000800; + {$EXTERNALSYM DDVPCAPS_OVERSAMPLEDVBI} + +(* + * Indicates that the video port can write data directly to system memory + *) + DDVPCAPS_SYSTEMMEMORY = $00001000; + {$EXTERNALSYM DDVPCAPS_SYSTEMMEMORY} + +(* + * Indicates that the VBI and video portions of the video stream can + * be controlled by an independent processes. + *) + DDVPCAPS_VBIANDVIDEOINDEPENDENT = $00002000; + {$EXTERNALSYM DDVPCAPS_VBIANDVIDEOINDEPENDENT} + +(* + * Indicates that the video port contains high quality hardware + * de-interlacing hardware that should be used instead of the + * bob/weave algorithms. + *) + DDVPCAPS_HARDWAREDEINTERLACE = $00004000; + {$EXTERNALSYM DDVPCAPS_HARDWAREDEINTERLACE} + + +(**************************************************************************** + * + * VIDEOPORT DDVIDEOPORTDESC / TDDVideoPortDesc FX + * + ****************************************************************************) + +(* + * Limited cropping is available to crop out the vertical interval data. + *) + DDVPFX_CROPTOPDATA = $00000001; + {$EXTERNALSYM DDVPFX_CROPTOPDATA} + +(* + * Incoming data can be cropped in the X direction before it is written + * to the surface. + *) + DDVPFX_CROPX = $00000002; + {$EXTERNALSYM DDVPFX_CROPX} + +(* + * Incoming data can be cropped in the Y direction before it is written + * to the surface. + *) + DDVPFX_CROPY = $00000004; + {$EXTERNALSYM DDVPFX_CROPY} + +(* + * Supports interleaving interlaced fields in memory. + *) + DDVPFX_INTERLEAVE = $00000008; + {$EXTERNALSYM DDVPFX_INTERLEAVE} + +(* + * Supports mirroring left to right as the video data is written + * into the frame buffer. + *) + DDVPFX_MIRRORLEFTRIGHT = $00000010; + {$EXTERNALSYM DDVPFX_MIRRORLEFTRIGHT} + +(* + * Supports mirroring top to bottom as the video data is written + * into the frame buffer. + *) + DDVPFX_MIRRORUPDOWN = $00000020; + {$EXTERNALSYM DDVPFX_MIRRORUPDOWN} + +(* + * Data can be arbitrarily shrunk in the X direction before it + * is written to the surface. + *) + DDVPFX_PRESHRINKX = $00000040; + {$EXTERNALSYM DDVPFX_PRESHRINKX} + +(* + * Data can be arbitrarily shrunk in the Y direction before it + * is written to the surface. + *) + DDVPFX_PRESHRINKY = $00000080; + {$EXTERNALSYM DDVPFX_PRESHRINKY} + +(* + * Data can be binary shrunk (1/2, 1/4, 1/8, etc.) in the X + * direction before it is written to the surface. + *) + DDVPFX_PRESHRINKXB = $00000100; + {$EXTERNALSYM DDVPFX_PRESHRINKXB} + +(* + * Data can be binary shrunk (1/2, 1/4, 1/8, etc.) in the Y + * direction before it is written to the surface. + *) + DDVPFX_PRESHRINKYB = $00000200; + {$EXTERNALSYM DDVPFX_PRESHRINKYB} + +(* + * Data can be shrunk in increments of 1/x in the X direction + * (where X is specified in the TDDVideoPortCaps.dwPreshrinkXStep) + * before it is written to the surface. + *) + DDVPFX_PRESHRINKXS = $00000400; + {$EXTERNALSYM DDVPFX_PRESHRINKXS} + +(* + * Data can be shrunk in increments of 1/x in the Y direction + * (where X is specified in the TDDVideoPortCaps.dwPreshrinkYStep) + * before it is written to the surface. + *) + DDVPFX_PRESHRINKYS = $00000800; + {$EXTERNALSYM DDVPFX_PRESHRINKYS} + +(* + * Data can be arbitrarily stretched in the X direction before + * it is written to the surface. + *) + DDVPFX_PRESTRETCHX = $00001000; + {$EXTERNALSYM DDVPFX_PRESTRETCHX} + +(* + * Data can be arbitrarily stretched in the Y direction before + * it is written to the surface. + *) + DDVPFX_PRESTRETCHY = $00002000; + {$EXTERNALSYM DDVPFX_PRESTRETCHY} + +(* + * Data can be integer stretched in the X direction before it is + * written to the surface. + *) + DDVPFX_PRESTRETCHXN = $00004000; + {$EXTERNALSYM DDVPFX_PRESTRETCHXN} + +(* + * Data can be integer stretched in the Y direction before it is + * written to the surface. + *) + DDVPFX_PRESTRETCHYN = $00008000; + {$EXTERNALSYM DDVPFX_PRESTRETCHYN} + +(* + * Indicates that data within the vertical blanking interval can + * be converted independently of the remaining video data. + *) + DDVPFX_VBICONVERT = $00010000; + {$EXTERNALSYM DDVPFX_VBICONVERT} + +(* + * Indicates that scaling can be disabled for data within the + * vertical blanking interval. + *) + DDVPFX_VBINOSCALE = $00020000; + {$EXTERNALSYM DDVPFX_VBINOSCALE} + +(* + * Indicates that the video data can ignore the left and right + * cropping coordinates when cropping oversampled VBI data. + *) + DDVPFX_IGNOREVBIXCROP = $00040000; + {$EXTERNALSYM DDVPFX_IGNOREVBIXCROP} + +(* + * Indicates that interleaving can be disabled for data within the + * vertical blanking interval. + *) + DDVPFX_VBINOINTERLEAVE = $00080000; + {$EXTERNALSYM DDVPFX_VBINOINTERLEAVE} + + +(**************************************************************************** + * + * VIDEOPORT DDVIDEOPORTINFO / TDDVideoPortInfo FLAGS + * + ****************************************************************************) + +(* + * Perform automatic flipping. Auto-flipping is performed between + * the overlay surface that was attached to the video port using + * IDirectDrawVideoPort::AttachSurface and the overlay surfaces that + * are attached to the surface via the IDirectDrawSurface::AttachSurface + * method. The flip order is the order in which the overlay surfaces + * were. attached. + *) + DDVP_AUTOFLIP = $00000001; + {$EXTERNALSYM DDVP_AUTOFLIP} + +(* + * Perform conversion using the ddpfOutputFormat information. + *) + DDVP_CONVERT = $00000002; + {$EXTERNALSYM DDVP_CONVERT} + +(* + * Perform cropping using the specified rectangle. + *) + DDVP_CROP = $00000004; + {$EXTERNALSYM DDVP_CROP} + +(* + * Indicates that interlaced fields should be interleaved in memory. + *) + DDVP_INTERLEAVE = $00000008; + {$EXTERNALSYM DDVP_INTERLEAVE} + +(* + * Indicates that the data should be mirrored left to right as it's + * written into the frame buffer. + *) + DDVP_MIRRORLEFTRIGHT = $00000010; + {$EXTERNALSYM DDVP_MIRRORLEFTRIGHT} + +(* + * Indicates that the data should be mirrored top to bottom as it's + * written into the frame buffer. + *) + DDVP_MIRRORUPDOWN = $00000020; + {$EXTERNALSYM DDVP_MIRRORUPDOWN} + +(* + * Perform pre-scaling/zooming based on the pre-scale parameters. + *) + DDVP_PRESCALE = $00000040; + {$EXTERNALSYM DDVP_PRESCALE} + +(* + * Ignore input of even fields. + *) + DDVP_SKIPEVENFIELDS = $00000080; + {$EXTERNALSYM DDVP_SKIPEVENFIELDS} + +(* + * Ignore input of odd fields. + *) + DDVP_SKIPODDFIELDS = $00000100; + {$EXTERNALSYM DDVP_SKIPODDFIELDS} + +(* + * Drive the graphics VSYNCs using the video port VYSNCs. + *) + DDVP_SYNCMASTER = $00000200; + {$EXTERNALSYM DDVP_SYNCMASTER} + +(* + * The ddpfVBIOutputFormatFormat member contains data that should be used + * to convert the data within the vertical blanking interval. + *) + DDVP_VBICONVERT = $00000400; + {$EXTERNALSYM DDVP_VBICONVERT} + +(* + * Indicates that data within the vertical blanking interval + * should not be scaled. + *) + DDVP_VBINOSCALE = $00000800; + {$EXTERNALSYM DDVP_VBINOSCALE} + +(* + * Indicates that these bob/weave decisions should not be + * overriden by other interfaces. + *) + DDVP_OVERRIDEBOBWEAVE = $00001000; + {$EXTERNALSYM DDVP_OVERRIDEBOBWEAVE} + +(* + * Indicates that the video data should ignore the left and right + * cropping coordinates when cropping the VBI data. + *) + DDVP_IGNOREVBIXCROP = $00002000; + {$EXTERNALSYM DDVP_IGNOREVBIXCROP} + +(* + * Indicates that interleaving can be disabled for data within the + * vertical blanking interval. + *) + DDVP_VBINOINTERLEAVE = $00004000; + {$EXTERNALSYM DDVP_VBINOINTERLEAVE} + +(* + * Indicates that the video port should use the hardware + * de-interlacing hardware. + *) + DDVP_HARDWAREDEINTERLACE = $00008000; + {$EXTERNALSYM DDVP_HARDWAREDEINTERLACE} + +(**************************************************************************** + * + * DIRIRECTDRAWVIDEOPORT GETINPUTFORMAT/GETOUTPUTFORMAT FLAGS + * + ****************************************************************************) + +(* + * Return formats for the video data + *) + DDVPFORMAT_VIDEO = $00000001; + {$EXTERNALSYM DDVPFORMAT_VIDEO} + +(* + * Return formats for the VBI data + *) + DDVPFORMAT_VBI = $00000002; + {$EXTERNALSYM DDVPFORMAT_VBI} + +(**************************************************************************** + * + * DIRIRECTDRAWVIDEOPORT SETTARGETSURFACE FLAGS + * + ****************************************************************************) + +(* + * Surface should receive video data (and VBI data if a surface + * is not explicitly attached for that purpose) + *) + DDVPTARGET_VIDEO = $00000001; + {$EXTERNALSYM DDVPTARGET_VIDEO} + +(* + * Surface should receive VBI data + *) + DDVPTARGET_VBI = $00000002; + {$EXTERNALSYM DDVPTARGET_VBI} + + +(**************************************************************************** + * + * DIRIRECTDRAWVIDEOPORT WAITFORSYNC FLAGS + * + ****************************************************************************) + +(* + * Waits until the beginning of the next VSYNC + *) + DDVPWAIT_BEGIN = $00000001; + {$EXTERNALSYM DDVPWAIT_BEGIN} + +(* + * Waits until the end of the next/current VSYNC + *) + DDVPWAIT_END = $00000002; + {$EXTERNALSYM DDVPWAIT_END} + +(* + * Waits until the beginning of the specified line + *) + DDVPWAIT_LINE = $00000003; + {$EXTERNALSYM DDVPWAIT_LINE} + +(**************************************************************************** + * + * DIRECTDRAWVIDEOPORT FLIP FLAGS + * + ****************************************************************************) + +(* + * Flips the normal video surface + *) + DDVPFLIP_VIDEO = $00000001; + {$EXTERNALSYM DDVPFLIP_VIDEO} + +(* + * Flips the VBI surface + *) + DDVPFLIP_VBI = $00000002; + {$EXTERNALSYM DDVPFLIP_VBI} + +(**************************************************************************** + * + * DIRIRECTDRAWVIDEOPORT GETVIDEOSIGNALSTATUS VALUES + * + ****************************************************************************) + +(* + * No video signal is present at the video port + *) + DDVPSQ_NOSIGNAL = $00000001; + {$EXTERNALSYM DDVPSQ_NOSIGNAL} + +(* + * A valid video signal is present at the video port + *) + DDVPSQ_SIGNALOK = $00000002; + {$EXTERNALSYM DDVPSQ_SIGNALOK} + +(**************************************************************************** + * + * VIDEOPORTBANDWIDTH Flags + * + ****************************************************************************) + +(* + * The specified height/width refer to the size of the video port data + * written into memory, after prescaling has occured. + *) + DDVPB_VIDEOPORT = $00000001; + {$EXTERNALSYM DDVPB_VIDEOPORT} + +(* + * The specified height/width refer to the source size of the overlay. + *) + DDVPB_OVERLAY = $00000002; + {$EXTERNALSYM DDVPB_OVERLAY} + +(* + * This is a query for the device to return which caps this device requires. + *) + DDVPB_TYPE = $00000004; + {$EXTERNALSYM DDVPB_TYPE} + +(**************************************************************************** + * + * VIDEOPORTBANDWIDTH Caps + * + ****************************************************************************) + +(* + * The bandwidth for this device is dependant on the overlay source size. + *) + DDVPBCAPS_SOURCE = $00000001; + {$EXTERNALSYM DDVPBCAPS_SOURCE} + +(* + * The bandwidth for this device is dependant on the overlay destination + * size. + *) + DDVPBCAPS_DESTINATION = $00000002; + {$EXTERNALSYM DDVPBCAPS_DESTINATION} + +(**************************************************************************** + * + * DDVIDEOPORTCONTAINER CreateVideoPort flags + * + ****************************************************************************) + +(* + * The process only wants to control the VBI portion of the video stream. + *) + DDVPCREATE_VBIONLY = $00000001; + {$EXTERNALSYM DDVPCREATE_VBIONLY} + +(* + * The process only wants to control the non-VBI (video) portion of + * the video stream. + *) + DDVPCREATE_VIDEOONLY = $00000002; + {$EXTERNALSYM DDVPCREATE_VIDEOONLY} + +(**************************************************************************** + * + * DDVIDEOPORTSTATUS flags + * + ****************************************************************************) + +(* + * The video port interface is only controlling the VBI portion of the + * video stream + *) + DDVPSTATUS_VBIONLY = $00000001; + {$EXTERNALSYM DDVPSTATUS_VBIONLY} + +(* + * The video port interface is only controlling the video portion of the + * video stream + *) + DDVPSTATUS_VIDEOONLY = $00000002; + {$EXTERNALSYM DDVPSTATUS_VIDEOONLY} + + +type +(* + * API's + *) + + TDDEnumVideoCallback = function (lpTDDVideoPortCaps: PDDVideoPortCaps; + lpContext: Pointer): HResult; stdcall; + {$EXTERNALSYM TDDEnumVideoCallback} + +(* + * INTERACES FOLLOW: + * IDirectDrawVideoPort + * IVideoPort + *) + IDirectDrawVideoPort = interface; + {$HPPEMIT 'typedef System::DelphiInterface _di_IDirectDrawVideoPort;'} + {$EXTERNALSYM IDirectDrawVideoPort} + +(* + * IDirectDrawVideoPortContainer + *) + {$HPPEMIT 'typedef System::DelphiInterface _di_IDDVideoPortContainer;'} + {$EXTERNALSYM IDDVideoPortContainer} + IDDVideoPortContainer = interface(IUnknown) + ['{6C142760-A733-11CE-A521-0020AF0BE560}'] + (*** IDDVideoPortContainer methods ***) + function CreateVideoPort(dwFlags: DWORD; var lpTDDVideoPortDesc: + TDDVideoPortDesc; var lplpDDVideoPort: IDirectDrawVideoPort; + pUnkOuter: IUnknown): HResult; stdcall; + function EnumVideoPorts(dwFlags: DWORD; + lpTDDVideoPortCaps: PDDVideoPortCaps; lpContext: Pointer; + lpEnumVideoCallback: TDDEnumVideoCallback): HResult; stdcall; + function GetVideoPortConnectInfo(dwPortId: DWORD; var lpNumEntries: DWORD; + lpConnectInfo: PDDVideoPortConnect): HResult; stdcall; + function QueryVideoPortStatus(dwPortId: DWORD; + var lpVPStatus: TDDVideoPortStatus): HResult; stdcall; + end; + +(* + * IDirectDrawVideoPort + *) + IDirectDrawVideoPort = interface(IUnknown) + ['{B36D93E0-2B43-11CF-A2DE-00AA00B93356}'] + (*** IDirectDrawVideoPort methods ***) + function Flip(lpDDSurface: IDirectDrawSurface; dwFlags: DWORD): HResult; stdcall; + function GetBandwidthInfo(var lpddpfFormat: TDDPixelFormat; + dwWidth: DWORD; dwHeight: DWORD; dwFlags: DWORD; + var lpBandwidth: TDDVideoPortBandWidth): HResult; stdcall; + function GetColorControls(var lpColorControl: TDDColorControl): HResult; stdcall; + function GetInputFormats(var lpNumFormats: DWORD; var lpFormats: + TDDPixelFormat; dwFlags: DWORD): HResult; stdcall; + function GetOutputFormats(var lpInputFormat: TDDPixelFormat; + var lpNumFormats: DWORD; lpFormats: PDDPixelFormat; dwFlags: DWORD): + HResult; stdcall; + function GetFieldPolarity(var lpbVideoField: BOOL): HResult; stdcall; + function GetVideoLine(var lpdwLine: DWORD): HResult; stdcall; + function GetVideoSignalStatus(varlpdwStatus: DWORD): HResult; stdcall; + function SetColorControls(var lpColorControl: TDDColorControl): HResult; stdcall; + function SetTargetSurface(lpDDSurface: IDirectDrawSurface; dwFlags: DWORD): + HResult; stdcall; + function StartVideo(var lpVideoInfo: TDDVideoPortInfo): HResult; stdcall; + function StopVideo: HResult; stdcall; + function UpdateVideo(var lpVideoInfo: TDDVideoPortInfo): HResult; stdcall; + function WaitForSync(dwFlags: DWORD; dwLine: DWORD; dwTimeout: DWORD): + HResult; stdcall; + end; + + IID_IDDVideoPortContainer = IDDVideoPortContainer; + {$EXTERNALSYM IID_IDDVideoPortContainer} + IID_IDirectDrawVideoPort = IDirectDrawVideoPort; + {$EXTERNALSYM IID_IDirectDrawVideoPort} + +(* + * IDirectDrawVideoPort + *) + {$HPPEMIT 'typedef System::DelphiInterface _di_IDirectDrawVideoPortNotify;'} + {$EXTERNALSYM IDirectDrawVideoPortNotify} + IDirectDrawVideoPortNotify = interface(IUnknown) + ['{6C142760-A733-11CE-A521-0020AF0BE560}'] + (*** IVideoPort methods ***) + function AcquireNotification(hEvent: THandle; const params: TDDVideoPortNotify): HResult; stdcall; + function ReleaseNotification(hEvent: THandle): HResult; stdcall; + end; + + +var + DDrawDLL : HMODULE = 0; + +function DDErrorString(Value: HResult): String; + +implementation + +//#define MAKE_DDHRESULT( code ) MAKE_HRESULT( 1, _FACDD, code ) +function MAKE_DDHRESULT(Code: DWORD): HResult; +begin + Result:= MakeResult(1, _FACDD, code); +end; + +//#define GET_WHQL_YEAR( dwWHQLLevel ) \ +// ( (dwWHQLLevel) / 0x10000 ) +function GET_WHQL_YEAR(dwWHQLLevel: DWORD): DWORD; +begin + Result := (dwWHQLLevel) div $10000; +end; + +//#define GET_WHQL_MONTH( dwWHQLLevel ) \ +// ( ( (dwWHQLLevel) / 0x100 ) & 0x00ff ) +function GET_WHQL_MONTH(dwWHQLLevel: DWORD): DWORD; +begin + Result := ((dwWHQLLevel) div $100) and $00ff; +end; + +//#define GET_WHQL_DAY( dwWHQLLevel ) \ +// ( (dwWHQLLevel) & 0xff ) +function GET_WHQL_DAY(dwWHQLLevel: DWORD): DWORD; +begin + Result := (dwWHQLLevel) and $ff; +end; + + +function MAKEFOURCC(ch0, ch1, ch2, ch3: Char): DWORD; +begin + Result := DWORD(Byte(ch0) shl 0) or + DWORD(Byte(ch1) shl 8) or + DWORD(Byte(ch2) shl 16) or + DWORD(Byte(ch3) shl 24); +end; + +function DDErrorString(Value: HResult): String; +begin + case Value of + DD_OK: Result := 'The request completed successfully.'; + DDERR_ALREADYINITIALIZED: Result := 'This object is already initialized.'; + DDERR_BLTFASTCANTCLIP: Result := ' if a clipper object is attached to the source surface passed into a BltFast call.'; + DDERR_CANNOTATTACHSURFACE: Result := 'This surface can not be attached to the requested surface.'; + DDERR_CANNOTDETACHSURFACE: Result := 'This surface can not be detached from the requested surface.'; + DDERR_CANTCREATEDC: Result := 'Windows can not create any more DCs.'; + DDERR_CANTDUPLICATE: Result := 'Cannot duplicate primary & 3D surfaces, or surfaces that are implicitly created.'; + DDERR_CLIPPERISUSINGHWND: Result := 'An attempt was made to set a cliplist for a clipper object that is already monitoring an hwnd.'; + DDERR_COLORKEYNOTSET: Result := 'No src color key specified for this operation.'; + DDERR_CURRENTLYNOTAVAIL: Result := 'Support is currently not available.'; + DDERR_DIRECTDRAWALREADYCREATED: Result := 'A DirectDraw object representing this driver has already been created for this process.'; + DDERR_EXCEPTION: Result := 'An exception was encountered while performing the requested operation.'; + DDERR_EXCLUSIVEMODEALREADYSET: Result := 'An attempt was made to set the cooperative level when it was already set to exclusive.'; + DDERR_GENERIC: Result := 'Generic failure.'; + DDERR_HEIGHTALIGN: Result := 'Height of rectangle provided is not a multiple of reqd alignment.'; + DDERR_HWNDALREADYSET: Result := 'The CooperativeLevel HWND has already been set. It can not be reset while the process has surfaces or palettes created.'; + DDERR_HWNDSUBCLASSED: Result := 'HWND used by DirectDraw CooperativeLevel has been subclassed, this prevents DirectDraw from restoring state.'; + DDERR_IMPLICITLYCREATED: Result := 'This surface can not be restored because it is an implicitly created surface.'; + DDERR_INCOMPATIBLEPRIMARY: Result := 'Unable to match primary surface creation request with existing primary surface.'; + DDERR_INVALIDCAPS: Result := 'One or more of the caps bits passed to the callback are incorrect.'; + DDERR_INVALIDCLIPLIST: Result := 'DirectDraw does not support the provided cliplist.'; + DDERR_INVALIDDIRECTDRAWGUID: Result := 'The GUID passed to DirectDrawCreate is not a valid DirectDraw driver identifier.'; + DDERR_INVALIDMODE: Result := 'DirectDraw does not support the requested mode.'; + DDERR_INVALIDOBJECT: Result := 'DirectDraw received a pointer that was an invalid DIRECTDRAW object.'; + DDERR_INVALIDPARAMS: Result := 'One or more of the parameters passed to the function are incorrect.'; + DDERR_INVALIDPIXELFORMAT: Result := 'The pixel format was invalid as specified.'; + DDERR_INVALIDPOSITION: Result := 'Returned when the position of the overlay on the destination is no longer legal for that destination.'; + DDERR_INVALIDRECT: Result := 'Rectangle provided was invalid.'; + DDERR_LOCKEDSURFACES: Result := 'Operation could not be carried out because one or more surfaces are locked.'; + DDERR_NO3D: Result := 'There is no 3D present.'; + DDERR_NOALPHAHW: Result := 'Operation could not be carried out because there is no alpha accleration hardware present or available.'; + DDERR_NOBLTHW: Result := 'No blitter hardware present.'; + DDERR_NOCLIPLIST: Result := 'No cliplist available.'; + DDERR_NOCLIPPERATTACHED: Result := 'No clipper object attached to surface object.'; + DDERR_NOCOLORCONVHW: Result := 'Operation could not be carried out because there is no color conversion hardware present or available.'; + DDERR_NOCOLORKEY: Result := 'Surface does not currently have a color key'; + DDERR_NOCOLORKEYHW: Result := 'Operation could not be carried out because there is no hardware support of the destination color key.'; + DDERR_NOCOOPERATIVELEVELSET: Result := 'Create function called without DirectDraw object method SetCooperativeLevel being called.'; + DDERR_NODC: Result := 'No DC was ever created for this surface.'; + DDERR_NODDROPSHW: Result := 'No DirectDraw ROP hardware.'; + DDERR_NODIRECTDRAWHW: Result := 'A hardware-only DirectDraw object creation was attempted but the driver did not support any hardware.'; + DDERR_NOEMULATION: Result := 'Software emulation not available.'; + DDERR_NOEXCLUSIVEMODE: Result := 'Operation requires the application to have exclusive mode but the application does not have exclusive mode.'; + DDERR_NOFLIPHW: Result := 'Flipping visible surfaces is not supported.'; + DDERR_NOGDI: Result := 'There is no GDI present.'; + DDERR_NOHWND: Result := 'Clipper notification requires an HWND or no HWND has previously been set as the CooperativeLevel HWND.'; + DDERR_NOMIRRORHW: Result := 'Operation could not be carried out because there is no hardware present or available.'; + DDERR_NOOVERLAYDEST: Result := 'Returned when GetOverlayPosition is called on an overlay that UpdateOverlay has never been called on to establish a destination.'; + DDERR_NOOVERLAYHW: Result := 'Operation could not be carried out because there is no overlay hardware present or available.'; + DDERR_NOPALETTEATTACHED: Result := 'No palette object attached to this surface.'; + DDERR_NOPALETTEHW: Result := 'No hardware support for 16 or 256 color palettes.'; + DDERR_NORASTEROPHW: Result := 'Operation could not be carried out because there is no appropriate raster op hardware present or available.'; + DDERR_NOROTATIONHW: Result := 'Operation could not be carried out because there is no rotation hardware present or available.'; + DDERR_NOSTRETCHHW: Result := 'Operation could not be carried out because there is no hardware support for stretching.'; + DDERR_NOT4BITCOLOR: Result := 'DirectDrawSurface is not in 4 bit color palette and the requested operation requires 4 bit color palette.'; + DDERR_NOT4BITCOLORINDEX: Result := 'DirectDrawSurface is not in 4 bit color index palette and the requested operation requires 4 bit color index palette.'; + DDERR_NOT8BITCOLOR: Result := 'DirectDrawSurface is not in 8 bit color mode and the requested operation requires 8 bit color.'; + DDERR_NOTAOVERLAYSURFACE: Result := 'Returned when an overlay member is called for a non-overlay surface.'; + DDERR_NOTEXTUREHW: Result := 'Operation could not be carried out because there is no texture mapping hardware present or available.'; + DDERR_NOTFLIPPABLE: Result := 'An attempt has been made to flip a surface that is not flippable.'; + DDERR_NOTFOUND: Result := 'Requested item was not found.'; + DDERR_NOTLOCKED: Result := 'Surface was not locked. An attempt to unlock a surface that was not locked at all, or by this process, has been attempted.'; + DDERR_NOTPALETTIZED: Result := 'The surface being used is not a palette-based surface.'; + DDERR_NOVSYNCHW: Result := 'Operation could not be carried out because there is no hardware support for vertical blank synchronized operations.'; + DDERR_NOZBUFFERHW: Result := 'Operation could not be carried out because there is no hardware support for zbuffer blitting.'; + DDERR_NOZOVERLAYHW: Result := 'Overlay surfaces could not be z layered based on their BltOrder because the hardware does not support z layering of overlays.'; + DDERR_OUTOFCAPS: Result := 'The hardware needed for the requested operation has already been allocated.'; + DDERR_OUTOFMEMORY: Result := 'DirectDraw does not have enough memory to perform the operation.'; + DDERR_OUTOFVIDEOMEMORY: Result := 'DirectDraw does not have enough memory to perform the operation.'; + DDERR_OVERLAYCANTCLIP: Result := 'The hardware does not support clipped overlays.'; + DDERR_OVERLAYCOLORKEYONLYONEACTIVE: Result := 'Can only have ony color key active at one time for overlays.'; + DDERR_OVERLAYNOTVISIBLE: Result := 'Returned when GetOverlayPosition is called on a hidden overlay.'; + DDERR_PALETTEBUSY: Result := 'Access to this palette is being refused because the palette is already locked by another thread.'; + DDERR_PRIMARYSURFACEALREADYEXISTS: Result := 'This process already has created a primary surface.'; + DDERR_REGIONTOOSMALL: Result := 'Region passed to Clipper::GetClipList is too small.'; + DDERR_SURFACEALREADYATTACHED: Result := 'This surface is already attached to the surface it is being attached to.'; + DDERR_SURFACEALREADYDEPENDENT: Result := 'This surface is already a dependency of the surface it is being made a dependency of.'; + DDERR_SURFACEBUSY: Result := 'Access to this surface is being refused because the surface is already locked by another thread.'; + DDERR_SURFACEISOBSCURED: Result := 'Access to surface refused because the surface is obscured.'; + DDERR_SURFACELOST: Result := 'Access to this surface is being refused because the surface memory is gone. The DirectDrawSurface object representing this surface should have Restore called on it.'; + DDERR_SURFACENOTATTACHED: Result := 'The requested surface is not attached.'; + DDERR_TOOBIGHEIGHT: Result := 'Height requested by DirectDraw is too large.'; + DDERR_TOOBIGSIZE: Result := 'Size requested by DirectDraw is too large, but the individual height and width are OK.'; + DDERR_TOOBIGWIDTH: Result := 'Width requested by DirectDraw is too large.'; + DDERR_UNSUPPORTED: Result := 'Action not supported.'; + DDERR_UNSUPPORTEDFORMAT: Result := 'FOURCC format requested is unsupported by DirectDraw.'; + DDERR_UNSUPPORTEDMASK: Result := 'Bitmask in the pixel format requested is unsupported by DirectDraw.'; + DDERR_VERTICALBLANKINPROGRESS: Result := 'Vertical blank is in progress.'; + DDERR_WASSTILLDRAWING: Result := 'Informs DirectDraw that the previous Blt which is transfering information to or from this Surface is incomplete.'; + DDERR_WRONGMODE: Result := 'This surface can not be restored because it was created in a different mode.'; + DDERR_XALIGN: Result := 'Rectangle provided was not horizontally aligned on required boundary.'; + // new: + DDERR_OVERLAPPINGRECTS: Result := 'Operation could not be carried out because the source and destination rectangles are on the same surface and overlap each other.'; + DDERR_INVALIDSTREAM: Result := 'The specified stream contains invalid data'; + DDERR_UNSUPPORTEDMODE: Result := 'The display is currently in an unsupported mode'; + DDERR_NOMIPMAPHW: Result := 'Operation could not be carried out because there is no mip-map texture mapping hardware present or available.'; + DDERR_INVALIDSURFACETYPE: Result := 'The requested action could not be performed because the surface was of the wrong type.'; + DDERR_NOOPTIMIZEHW: Result := 'Device does not support optimized surfaces, therefore no video memory optimized surfaces'; + DDERR_NOTLOADED: Result := 'Surface is an optimized surface, but has not yet been allocated any memory'; + DDERR_NOFOCUSWINDOW: Result := 'Attempt was made to create or set a device window without first setting the focus window'; + DDERR_DCALREADYCREATED: Result := 'A DC has already been returned for this surface. Only one DC can be retrieved per surface.'; + DDERR_NONONLOCALVIDMEM: Result := 'An attempt was made to allocate non-local video memory from a device that does not support non-local video memory.'; + DDERR_CANTPAGELOCK: Result := 'The attempt to page lock a surface failed.'; + DDERR_CANTPAGEUNLOCK: Result := 'The attempt to page unlock a surface failed.'; + DDERR_NOTPAGELOCKED: Result := 'An attempt was made to page unlock a surface with no outstanding page locks.'; + DDERR_MOREDATA: Result := 'There is more data available than the specified buffer size could hold'; + DDERR_EXPIRED: Result := 'The data has expired and is therefore no longer valid.'; + DDERR_VIDEONOTACTIVE: Result := 'The video port is not active'; + DDERR_DEVICEDOESNTOWNSURFACE: Result := 'Surfaces created by one direct draw device cannot be used directly by another direct draw device.'; + DDERR_NOTINITIALIZED: Result := 'An attempt was made to invoke an interface member of a DirectDraw object created by CoCreateInstance() before it was initialized.'; + else Result := 'Unrecognized Error'; + end; +end; + +{$IFDEF DIRECTDRAW_DYNAMIC_LINK} +var + DirectDrawLib: THandle = 0; + +function DirectDrawLoaded: Boolean; +begin + Result:= DirectDrawLib <> 0; +end; + +function UnLoadDirectDraw: Boolean; +begin + Result:= True; + if DirectDrawLoaded then + begin + Result:= FreeLibrary(DirectDrawLib); + + DirectDrawEnumerateA := nil; + DirectDrawEnumerateW := nil; + DirectDrawEnumerate := nil; + + DirectDrawEnumerateExA := nil; + DirectDrawEnumerateExW := nil; + DirectDrawEnumerateEx := nil; + + DirectDrawCreate := nil; + DirectDrawCreateEx := nil; + DirectDrawCreateClipper := nil; + {$IFDEF WINNT} + NtDirectDrawCreate := nil; + {$ENDIF} + + DirectDrawLib:= 0; + end; +end; + +function LoadDirectDraw: Boolean; +begin + Result:= DirectDrawLoaded; + if (not Result) then + begin + DirectDrawLib:= LoadLibrary(DirectDrawDll); + if DirectDrawLoaded then + begin + DirectDrawEnumerateA := GetProcAddress(DirectDrawLib, 'DirectDrawEnumerateA'); + DirectDrawEnumerateW := GetProcAddress(DirectDrawLib, 'DirectDrawEnumerateW'); + {$IFDEF UNICODE} + DirectDrawEnumerate := GetProcAddress(DirectDrawLib, 'DirectDrawEnumerateW'); + {$ELSE} + DirectDrawEnumerate := GetProcAddress(DirectDrawLib, 'DirectDrawEnumerateA'); + {$ENDIF} + + DirectDrawEnumerateExA := GetProcAddress(DirectDrawLib, 'DirectDrawEnumerateExA'); + DirectDrawEnumerateExW := GetProcAddress(DirectDrawLib, 'DirectDrawEnumerateExW'); + {$IFDEF UNICODE} + DirectDrawEnumerateEx := GetProcAddress(DirectDrawLib, 'DirectDrawEnumerateExW'); + {$ELSE} + DirectDrawEnumerateEx := GetProcAddress(DirectDrawLib, 'DirectDrawEnumerateExA'); + {$ENDIF} + + DirectDrawCreate := GetProcAddress(DDrawDLL,'DirectDrawCreate'); + DirectDrawCreateEx := GetProcAddress(DDrawDLL,'DirectDrawCreateEx'); + DirectDrawCreateClipper := GetProcAddress(DDrawDLL,'DirectDrawCreateClipper'); + {$IFDEF WINNT} + NtDirectDrawCreate := GetProcAddress(DDrawDLL,'NtDirectDrawCreate'); + {$ENDIF} + + Result:= Assigned(DirectDrawCreate); // At least basic procedure is found! + if not Result then UnLoadDirectDraw; + end; + end; +end; +{$ELSE} +function DirectDrawLoaded: Boolean; +begin // Stub function for static linking + Result:= True; +end; + +function UnLoadDirectDraw: Boolean; +begin // Stub function for static linking + Result:= True; // should emulate "normal" behaviour +end; + +function LoadDirectDraw: Boolean; +begin // Stub function for static linking + Result:= True; +end; + +{$ENDIF} + +{$IFDEF DIRECTDRAW_DYNAMIC_LINK} +initialization +{$IFNDEF DIRECTDRAW_DYNAMIC_LINK_EXPLICIT} + LoadDirectDraw; +{$ENDIF} +finalization + UnLoadDirectDraw; +{$ENDIF} +end. + diff --git a/thirparty/DirectX.inc b/thirparty/DirectX.inc new file mode 100644 index 0000000..3a5da80 --- /dev/null +++ b/thirparty/DirectX.inc @@ -0,0 +1,29 @@ +{******************************************************************************} +{ } +{ The contents of this file are 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/ } +{ } +{ 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. } +{ } +{ The Original Code is DirectX.inc. } +{ } +{******************************************************************************} + +// Borland compilers support +{$INCLUDE versions.inc} + +{$DEFINE TYPE_IDENTITY} +{$DEFINE SUPPORTS_EXCEPTIONS} + +// Additional settings +{$MINENUMSIZE 4} +{$ALIGN ON} + +{$IFDEF COMPILER7_UP} + {$WARN UNSAFE_CODE OFF} + {$WARN UNSAFE_TYPE OFF} + {$WARN UNSAFE_CAST OFF} +{$ENDIF} diff --git a/thirparty/DwmApi.pas b/thirparty/DwmApi.pas new file mode 100644 index 0000000..c2478f5 --- /dev/null +++ b/thirparty/DwmApi.pas @@ -0,0 +1,548 @@ +{*******************************************************} +{ } +{ Delphi Runtime Library } +{ } +{ File: dwmapi.h } +{ Copyright (c) Microsoft Corporation } +{ All Rights Reserved. } +{ } +{ Translator: Embarcadero Technologies, Inc. } +{ Copyright(c) 1995-2010 Embarcadero Technologies, Inc. } +{ } +{*******************************************************} + + +{*******************************************************} +{ Win32 API Desktop Window Manager Interface Unit } +{*******************************************************} + +unit Dwmapi; + +{$WEAKPACKAGEUNIT} + +{$HPPEMIT ''} +{$HPPEMIT '#include "dwmapi.h"'} +{$HPPEMIT '#pragma link "dwmapi.lib"'} +{$HPPEMIT ''} + +interface + +uses Windows, Uxtheme; + +const + // Blur behind data structures + DWM_BB_ENABLE = $00000001; // fEnable has been specified + {$EXTERNALSYM DWM_BB_ENABLE} + DWM_BB_BLURREGION = $00000002; // hRgnBlur has been specified + {$EXTERNALSYM DWM_BB_BLURREGION} + DWM_BB_TRANSITIONONMAXIMIZED = $00000004; // fTransitionOnMaximized has been specified + {$EXTERNALSYM DWM_BB_TRANSITIONONMAXIMIZED} + +type + PDWM_BLURBEHIND = ^DWM_BLURBEHIND; + DWM_BLURBEHIND = record + dwFlags: DWORD; + fEnable: BOOL; + hRgnBlur: HRGN; + fTransitionOnMaximized: BOOL; + end; + _DWM_BLURBEHIND = DWM_BLURBEHIND; + TDwmBlurBehind = DWM_BLURBEHIND; + PDwmBlurBehind = ^TDwmBlurbehind; + {$EXTERNALSYM DWM_BLURBEHIND} + {$EXTERNALSYM PDWM_BLURBEHIND} + +// Window attributes + DWMWINDOWATTRIBUTE = type Integer; + {$EXTERNALSYM DWMWINDOWATTRIBUTE} +const + DWMWA_NCRENDERING_ENABLED = 1; // [get] Is non-client rendering enabled/disabled + {$EXTERNALSYM DWMWA_NCRENDERING_ENABLED} + DWMWA_NCRENDERING_POLICY = 2; // [set] Non-client rendering policy + {$EXTERNALSYM DWMWA_NCRENDERING_POLICY} + DWMWA_TRANSITIONS_FORCEDISABLED = 3; // [set] Potentially enable/forcibly disable transitions + {$EXTERNALSYM DWMWA_TRANSITIONS_FORCEDISABLED} + DWMWA_ALLOW_NCPAINT = 4; // [set] Allow contents rendered in the non-client area to be visible on the DWM-drawn frame. + {$EXTERNALSYM DWMWA_ALLOW_NCPAINT} + DWMWA_CAPTION_BUTTON_BOUNDS = 5; // [get] Bounds of the caption button area in window-relative space. + {$EXTERNALSYM DWMWA_CAPTION_BUTTON_BOUNDS} + DWMWA_NONCLIENT_RTL_LAYOUT = 6; // [set] Is non-client content RTL mirrored + {$EXTERNALSYM DWMWA_NONCLIENT_RTL_LAYOUT} + DWMWA_FORCE_ICONIC_REPRESENTATION = 7; // [set] Force this window to display iconic thumbnails. + {$EXTERNALSYM DWMWA_FORCE_ICONIC_REPRESENTATION} + DWMWA_FLIP3D_POLICY = 8; // [set] Designates how Flip3D will treat the window. + {$EXTERNALSYM DWMWA_FLIP3D_POLICY} + DWMWA_EXTENDED_FRAME_BOUNDS = 9; // [get] Gets the extended frame bounds rectangle in screen space + {$EXTERNALSYM DWMWA_EXTENDED_FRAME_BOUNDS} + DWMWA_HAS_ICONIC_BITMAP = 10; // [set] Indicates an available bitmap when there is no better thumbnail representation. + {$EXTERNALSYM DWMWA_HAS_ICONIC_BITMAP} + DWMWA_DISALLOW_PEEK = 11; // [set] Don't invoke Peek on the window. + {$EXTERNALSYM DWMWA_DISALLOW_PEEK} + DWMWA_EXCLUDED_FROM_PEEK = 12; // [set] LivePreview exclusion information + {$EXTERNALSYM DWMWA_EXCLUDED_FROM_PEEK} + DWMWA_LAST = 13; + {$EXTERNALSYM DWMWA_LAST} + + // Non-client rendering policy attribute values + {$EXTERNALSYM DWMNCRP_USEWINDOWSTYLE} + DWMNCRP_USEWINDOWSTYLE = 0; // Enable/disable non-client rendering based on window style + {$EXTERNALSYM DWMNCRP_DISABLED} + DWMNCRP_DISABLED = 1; // Disabled non-client rendering; window style is ignored + {$EXTERNALSYM DWMNCRP_ENABLED} + DWMNCRP_ENABLED = 2; // Enabled non-client rendering; window style is ignored + {$EXTERNALSYM DWMNCRP_LAST} + DWMNCRP_LAST = 3; + + // Values designating how Flip3D treats a given window. + + {$EXTERNALSYM DWMFLIP3D_DEFAULT} + DWMFLIP3D_DEFAULT = 0; // Hide or include the window in Flip3D based on window style and visibility. + {$EXTERNALSYM DWMFLIP3D_EXCLUDEBELOW} + DWMFLIP3D_EXCLUDEBELOW = 1; // Display the window under Flip3D and disabled. + {$EXTERNALSYM DWMFLIP3D_EXCLUDEABOVE} + DWMFLIP3D_EXCLUDEABOVE = 2; // Display the window above Flip3D and enabled. + {$EXTERNALSYM DWMFLIP3D_LAST} + DWMFLIP3D_LAST = 3; + + +// Thumbnails +type + HTHUMBNAIL = THandle; + {$EXTERNALSYM HTHUMBNAIL} + PHTHUMBNAIL = ^HTHUMBNAIL; + {$EXTERNALSYM PHTHUMBNAIL} + +const + DWM_TNP_RECTDESTINATION = $00000001; + {$EXTERNALSYM DWM_TNP_RECTDESTINATION} + DWM_TNP_RECTSOURCE = $00000002; + {$EXTERNALSYM DWM_TNP_RECTSOURCE} + DWM_TNP_OPACITY = $00000004; + {$EXTERNALSYM DWM_TNP_OPACITY} + DWM_TNP_VISIBLE = $00000008; + {$EXTERNALSYM DWM_TNP_VISIBLE} + DWM_TNP_SOURCECLIENTAREAONLY = $00000010; + {$EXTERNALSYM DWM_TNP_SOURCECLIENTAREAONLY} + +type + PDWM_THUMBNAIL_PROPERTIES = ^DWM_THUMBNAIL_PROPERTIES; + DWM_THUMBNAIL_PROPERTIES = record + dwFlags: DWORD; + rcDestination: TRect; + rcSource: TRect; + opacity: Byte; + fVisible: BOOL; + fSourceClientAreaOnly: BOOL; + end; + _DWM_THUMBNAIL_PROPERTIES = DWM_THUMBNAIL_PROPERTIES; + TDwmThumbnailProperties = DWM_THUMBNAIL_PROPERTIES; + PDwmThumbnailProperties = ^TDwmThumbnailProperties; + {$EXTERNALSYM DWM_THUMBNAIL_PROPERTIES} + {$EXTERNALSYM PDWM_THUMBNAIL_PROPERTIES} + +// Video enabling apis + +// DWM_FRAME_COUNT = ULONGLONG; +// {$EXTERNALSYM DWM_FRAME_COUNT} +// QPC_TIME = ULONGLONG; +// {$EXTERNALSYM QPC_TIME} + + UNSIGNED_RATIO = record + uiNumerator: Cardinal; + uiDenominator: Cardinal; + end; + _UNSIGNED_RATIO = UNSIGNED_RATIO; + TUnsignedRatio = UNSIGNED_RATIO; + PUnsignedRatio = ^TUnsignedRatio; + {$EXTERNALSYM UNSIGNED_RATIO} + + DWM_TIMING_INFO = record + cbSize: Cardinal; + + // Data on DWM composition overall + + // Monitor refresh rate + rateRefresh: TUnsignedRatio; + + // Actual period +// qpcRefreshPeriod: QPC_TIME; + + // composition rate + rateCompose: TUnsignedRatio; + + // QPC time at a VSync interupt +// qpcVBlank: QPC_TIME; + + // DWM refresh count of the last vsync + // DWM refresh count is a 64bit number where zero is + // the first refresh the DWM woke up to process +// cRefresh: DWM_FRAME_COUNT; + + // DX refresh count at the last Vsync Interupt + // DX refresh count is a 32bit number with zero + // being the first refresh after the card was initialized + // DX increments a counter when ever a VSync ISR is processed + // It is possible for DX to miss VSyncs + // + // There is not a fixed mapping between DX and DWM refresh counts + // because the DX will rollover and may miss VSync interupts + cDXRefresh: UINT; + + // QPC time at a compose time. +// qpcCompose: QPC_TIME; + + // Frame number that was composed at qpcCompose +// cFrame: DWM_FRAME_COUNT; + + // The present number DX uses to identify renderer frames + cDXPresent: UINT; + + // Refresh count of the frame that was composed at qpcCompose +// cRefreshFrame: DWM_FRAME_COUNT; + + + // DWM frame number that was last submitted +// cFrameSubmitted: DWM_FRAME_COUNT; + + // DX Present number that was last submitted + cDXPresentSubmitted: UINT; + + // DWM frame number that was last confirmed presented +// cFrameConfirmed: DWM_FRAME_COUNT; + + // DX Present number that was last confirmed presented + cDXPresentConfirmed: UINT; + + // The target refresh count of the last + // frame confirmed completed by the GPU +// cRefreshConfirmed: DWM_FRAME_COUNT; + + // DX refresh count when the frame was confirmed presented + cDXRefreshConfirmed: UINT; + + // Number of frames the DWM presented late + // AKA Glitches +// cFramesLate: DWM_FRAME_COUNT; + + // the number of composition frames that + // have been issued but not confirmed completed + cFramesOutstanding: UINT; + + + // Following fields are only relavent when an HWND is specified + // Display frame + + + // Last frame displayed +// cFrameDisplayed: DWM_FRAME_COUNT; + + // QPC time of the composition pass when the frame was displayed +// qpcFrameDisplayed: QPC_TIME; + + // Count of the VSync when the frame should have become visible +// cRefreshFrameDisplayed: DWM_FRAME_COUNT; + + // Complete frames: DX has notified the DWM that the frame is done rendering + + // ID of the the last frame marked complete (starts at 0) +// cFrameComplete: DWM_FRAME_COUNT; + + // QPC time when the last frame was marked complete +// qpcFrameComplete: QPC_TIME; + + // Pending frames: + // The application has been submitted to DX but not completed by the GPU + + // ID of the the last frame marked pending (starts at 0) +// cFramePending: DWM_FRAME_COUNT; + + // QPC time when the last frame was marked pending +// qpcFramePending: QPC_TIME; + + // number of unique frames displayed +// cFramesDisplayed: DWM_FRAME_COUNT; + + // number of new completed frames that have been received +// cFramesComplete: DWM_FRAME_COUNT; + + // number of new frames submitted to DX but not yet complete +// cFramesPending: DWM_FRAME_COUNT; + + // number of frames available but not displayed, used or dropped +// cFramesAvailable: DWM_FRAME_COUNT; + + // number of rendered frames that were never + // displayed because composition occured too late +// cFramesDropped: DWM_FRAME_COUNT; + + // number of times an old frame was composed + // when a new frame should have been used + // but was not available +// cFramesMissed: DWM_FRAME_COUNT; + + // the refresh at which the next frame is + // scheduled to be displayed +// cRefreshNextDisplayed: DWM_FRAME_COUNT; + + // the refresh at which the next DX present is + // scheduled to be displayed +// cRefreshNextPresented: DWM_FRAME_COUNT; + + // The total number of refreshes worth of content + // for this HWND that have been displayed by the DWM + // since DwmSetPresentParameters was called +// cRefreshesDisplayed: DWM_FRAME_COUNT; + + // The total number of refreshes worth of content + // that have been presented by the application + // since DwmSetPresentParameters was called +// cRefreshesPresented: DWM_FRAME_COUNT; + + + // The actual refresh # when content for this + // window started to be displayed + // it may be different than that requested + // DwmSetPresentParameters +// cRefreshStarted: DWM_FRAME_COUNT; + + // Total number of pixels DX redirected + // to the DWM. + // If Queueing is used the full buffer + // is transfered on each present. + // If not queuing it is possible only + // a dirty region is updated +// cPixelsReceived: ULONGLONG; + + // Total number of pixels drawn. + // Does not take into account if + // if the window is only partial drawn + // do to clipping or dirty rect management +// cPixelsDrawn: ULONGLONG; + + // The number of buffers in the flipchain + // that are empty. An application can + // present that number of times and guarantee + // it won't be blocked waiting for a buffer to + // become empty to present to +// cBuffersEmpty: DWM_FRAME_COUNT; + + end; + _DWM_TIMING_INFO = DWM_TIMING_INFO; + TDwmTimingInfo = DWM_TIMING_INFO; + PDwmTimingInfo = ^TDwmTimingInfo; + {$EXTERNALSYM DWM_TIMING_INFO} + + DWM_SOURCE_FRAME_SAMPLING = type Integer; + {$EXTERNALSYM DWM_SOURCE_FRAME_SAMPLING} +const + // includes the first refresh of the output frame + DWM_SOURCE_FRAME_SAMPLING_POINT = 0; + {$EXTERNALSYM DWM_SOURCE_FRAME_SAMPLING_POINT} + + // use the source frame that includes the most + // refreshes of out the output frame + // in case of multiple source frames with the + // same coverage the last will be used + DWM_SOURCE_FRAME_SAMPLING_COVERAGE = 1; + {$EXTERNALSYM DWM_SOURCE_FRAME_SAMPLING_COVERAGE} + + // Sentinel value + DWM_SOURCE_FRAME_SAMPLING_LAST = 2; + {$EXTERNALSYM DWM_SOURCE_FRAME_SAMPLING_LAST} + +const + c_DwmMaxQueuedBuffers = 8; + c_DwmMaxMonitors = 16; + c_DwmMaxAdapters = 16; + +type + DWM_PRESENT_PARAMETERS = record + cbSize: Cardinal; + fQueue: BOOL; +// cRefreshStart: DWM_FRAME_COUNT; + cBuffer: UINT; + fUseSourceRate: BOOL; + rateSource: TUnsignedRatio; + cRefreshesPerFrame: UINT; + eSampling: DWM_SOURCE_FRAME_SAMPLING; + end; + _DWM_PRESENT_PARAMETERS = DWM_PRESENT_PARAMETERS; + TDwmPresentParameters = DWM_PRESENT_PARAMETERS; + PDwmPresentParameters = ^TDwmPresentParameters; + {$EXTERNALSYM DWM_PRESENT_PARAMETERS} + + + +const + DWM_FRAME_DURATION_DEFAULT = -1; + {$EXTERNALSYM DWM_FRAME_DURATION_DEFAULT} + +function DwmDefWindowProc(hWnd: HWND; msg: UINT; wParam: WPARAM; lParam: LPARAM; + var plResult: LRESULT): BOOL; stdcall; +{$EXTERNALSYM DwmDefWindowProc} + +function DwmEnableBlurBehindWindow(hWnd: HWND; + var pBlurBehind: TDwmBlurbehind): HResult; stdcall; +{$EXTERNALSYM DwmEnableBlurBehindWindow} + +const + DWM_EC_DISABLECOMPOSITION = 0; + {$EXTERNALSYM DWM_EC_DISABLECOMPOSITION} + DWM_EC_ENABLECOMPOSITION = 1; + {$EXTERNALSYM DWM_EC_ENABLECOMPOSITION} + + +function DwmEnableComposition(uCompositionAction: UINT): HResult; stdcall; +{$EXTERNALSYM DwmEnableComposition} + +function DwmEnableMMCSS(fEnableMMCSS: BOOL): HResult; stdcall; +{$EXTERNALSYM DwmEnableMMCSS} + +function DwmExtendFrameIntoClientArea(hWnd: HWND; const pMarInset: TMargins): HResult; stdcall; +{$EXTERNALSYM DwmExtendFrameIntoClientArea} + +function DwmGetColorizationColor(var pcrColorization: DWORD; + var pfOpaqueBlend: BOOL): HResult; stdcall; +{$EXTERNALSYM DwmGetColorizationColor} + +function DwmGetCompositionTimingInfo(hwnd: HWND; + var pTimingInfo: TDwmTimingInfo): HResult; stdcall; +{$EXTERNALSYM DwmGetCompositionTimingInfo} + + +function DwmGetWindowAttribute(hwnd: HWND; dwAttribute: DWORD; + pvAttribute: Pointer; cbAttribute: DWORD): HResult; stdcall; +{$EXTERNALSYM DwmGetWindowAttribute} + +{$EXTERNALSYM DwmIsCompositionEnabled} +function DwmIsCompositionEnabled(var pfEnabled: BOOL): HResult; stdcall; + +function DwmModifyPreviousDxFrameDuration(hwnd: HWND; cRefreshes: Integer; + fRelative: BOOL): HResult; stdcall; +{$EXTERNALSYM DwmModifyPreviousDxFrameDuration} + +function DwmQueryThumbnailSourceSize(hThumbnail: HTHUMBNAIL; + pSize: PSIZE): HResult; stdcall; +{$EXTERNALSYM DwmQueryThumbnailSourceSize} + +function DwmRegisterThumbnail(hwndDestination: HWND; hwndSource: HWND; + phThumbnailId: PHTHUMBNAIL): HResult; stdcall; +{$EXTERNALSYM DwmRegisterThumbnail} + +function DwmSetDxFrameDuration(hwnd: HWND; cRefreshes: Integer): HResult; stdcall; +{$EXTERNALSYM DwmSetDxFrameDuration} + +function DwmSetPresentParameters(hwnd: HWND; + var pPresentParams: TDwmPresentParameters): HResult; stdcall; +{$EXTERNALSYM DwmSetPresentParameters} + +function DwmSetWindowAttribute(hwnd: HWND; dwAttribute: DWORD; + pvAttribute: Pointer; cbAttribute: DWORD): HResult; stdcall; +{$EXTERNALSYM DwmSetWindowAttribute} + +function DwmUnregisterThumbnail(hThumbnailId: HTHUMBNAIL): HResult; stdcall; +{$EXTERNALSYM DwmUnregisterThumbnail} + +function DwmUpdateThumbnailProperties(hThumbnailId: HTHUMBNAIL; + var ptnProperties: TDwmThumbnailProperties): HResult; stdcall; +{$EXTERNALSYM DwmUpdateThumbnailProperties} + +const + DWM_SIT_DISPLAYFRAME = $00000001; // Display a window frame around the provided bitmap + {$EXTERNALSYM DWM_SIT_DISPLAYFRAME} + +function DwmSetIconicThumbnail(hwnd: HWND; hbmp: HBITMAP; + dwSITFlags: DWORD): HResult; stdcall; +{$EXTERNALSYM DwmSetIconicThumbnail} + +function DwmSetIconicLivePreviewBitmap(hwnd: HWND; hbmp: HBITMAP; + var pptClient: TPoint; dwSITFlags: DWORD): HResult; stdcall; +{$EXTERNALSYM DwmSetIconicLivePreviewBitmap} + +function DwmInvalidateIconicBitmaps(hwnd: HWND): HResult; stdcall; +{$EXTERNALSYM DwmInvalidateIconicBitmaps} + +function DwmAttachMilContent(hwnd: HWND): HResult; stdcall; +{$EXTERNALSYM DwmAttachMilContent} + +function DwmDetachMilContent(hwnd: HWND): HResult; stdcall; +{$EXTERNALSYM DwmDetachMilContent} + +function DwmFlush: HResult; stdcall; +{$EXTERNALSYM DwmFlush} + +type + MilMatrix3x2D = record + S_11: Double; + S_12: Double; + S_21: Double; + S_22: Double; + DX: Double; + DY: Double; + end; + _MilMatrix3x2D = MilMatrix3x2D; + TMilMatrix3x2D = MilMatrix3x2D; + PMilMatrix3x2D = ^TMilMatrix3x2D; + {$EXTERNALSYM MilMatrix3x2D} + +// Compatibility for Vista dwm api. + MIL_MATRIX3X2D = MilMatrix3x2D; + {$EXTERNALSYM MIL_MATRIX3X2D} + +function DwmGetGraphicsStreamTransformHint(uIndex: UINT; + var pTransform: TMilMatrix3x2D): HResult; +{$EXTERNALSYM DwmGetGraphicsStreamTransformHint} + +function DwmGetGraphicsStreamClient(uIndex: UINT; + var pClientUuid: TGUID): HResult; +{$EXTERNALSYM DwmGetGraphicsStreamClient} + +function DwmGetTransportAttributes(var pfIsRemoting: BOOL; + var pfIsConnected: BOOL; var pDwGeneration: DWORD): HResult; +{$EXTERNALSYM DwmGetTransportAttributes} + +function DwmCompositionEnabled: Boolean; + +implementation + +uses + SysUtils; + +const + ModName = 'DWMAPI.DLL'; + +function DwmDefWindowProc; external ModName name 'DwmDefWindowProc'; +function DwmEnableBlurBehindWindow; external ModName name 'DwmEnableBlurBehindWindow'; +function DwmEnableComposition; external ModName name 'DwmEnableComposition'; +function DwmEnableMMCSS; external ModName name 'DwmEnableMMCSS'; +function DwmExtendFrameIntoClientArea; external ModName name 'DwmExtendFrameIntoClientArea'; +function DwmGetColorizationColor; external ModName name 'DwmGetColorizationColor'; +function DwmGetCompositionTimingInfo; external ModName name 'DwmGetCompositionTimingInfo'; +function DwmGetWindowAttribute; external ModName name 'DwmGetWindowAttribute'; +function DwmIsCompositionEnabled; external ModName name 'DwmIsCompositionEnabled'; +function DwmModifyPreviousDxFrameDuration; external ModName name 'DwmModifyPreviousDxFrameDuration'; +function DwmQueryThumbnailSourceSize; external ModName name 'DwmQueryThumbnailSourceSize'; +function DwmRegisterThumbnail; external ModName name 'DwmRegisterThumbnail'; +function DwmSetDxFrameDuration; external ModName name 'DwmSetDxFrameDuration'; +function DwmSetPresentParameters; external ModName name 'DwmSetPresentParameters'; +function DwmSetWindowAttribute; external ModName name 'DwmSetWindowAttribute'; +function DwmUnregisterThumbnail; external ModName name 'DwmUnregisterThumbnail'; +function DwmUpdateThumbnailProperties; external ModName name 'DwmUpdateThumbnailProperties'; +function DwmSetIconicThumbnail; external ModName name 'DwmSetIconicThumbnail'; +function DwmSetIconicLivePreviewBitmap; external ModName name 'DwmSetIconicLivePreviewBitmap'; +function DwmInvalidateIconicBitmaps; external ModName name 'DwmInvalidateIconicBitmaps'; +function DwmAttachMilContent; external ModName name 'DwmAttachMilContent'; +function DwmDetachMilContent; external ModName name 'DwmDetachMilContent'; +function DwmFlush; external ModName name 'DwmFlush'; +function DwmGetGraphicsStreamTransformHint; external ModName name 'DwmGetGraphicsStreamTransformHint'; +function DwmGetGraphicsStreamClient; external ModName name 'DwmGetGraphicsStreamClient'; +function DwmGetTransportAttributes; external ModName name 'DwmGetTransportAttributes'; + +function DwmCompositionEnabled: Boolean; +var + LEnabled: BOOL; +begin + Result := (Win32MajorVersion >= 6) and (DwmIsCompositionEnabled(LEnabled) = S_OK) and LEnabled; +end; + +end. diff --git a/thirparty/GDIPAPI.pas b/thirparty/GDIPAPI.pas new file mode 100644 index 0000000..7b64672 --- /dev/null +++ b/thirparty/GDIPAPI.pas @@ -0,0 +1,7015 @@ + {******************************************************************} + { GDI+ API } + { } + { 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 GDIPAPI; + +{$ALIGN ON} +{$MINENUMSIZE 4} + +interface + +(**************************************************************************\ +* +* GDI+ public header file +* +\**************************************************************************) + +uses + Windows, + ActiveX, + DirectDraw, + Math; + +type + INT16 = type Smallint; + UINT16 = type Word; + PUINT16 = ^UINT16; + UINT32 = type Cardinal; + TSingleDynArray = array of Single; + +(**************************************************************************\ +* +* GDI+ Private Memory Management APIs +* +\**************************************************************************) + +const WINGDIPDLL = 'gdiplus.dll'; + +//---------------------------------------------------------------------------- +// Memory Allocation APIs +//---------------------------------------------------------------------------- + +{$EXTERNALSYM GdipAlloc} +function GdipAlloc(size: ULONG): pointer; stdcall; +{$EXTERNALSYM GdipFree} +procedure GdipFree(ptr: pointer); stdcall; + +(**************************************************************************\ +* +* GDI+ base memory allocation class +* +\**************************************************************************) + +type + TGdiplusBase = class + public + class function NewInstance: TObject; override; + procedure FreeInstance; override; + end; + +(**************************************************************************\ +* +* GDI+ Enumeration Types +* +\**************************************************************************) + +//-------------------------------------------------------------------------- +// Default bezier flattening tolerance in device pixels. +//-------------------------------------------------------------------------- + +const + {$EXTERNALSYM FlatnessDefault} + FlatnessDefault = 0.25; + +//-------------------------------------------------------------------------- +// Graphics and Container State cookies +//-------------------------------------------------------------------------- +type + {$EXTERNALSYM GraphicsState} + GraphicsState = UINT; + {$EXTERNALSYM GraphicsContainer} + GraphicsContainer = UINT; + +//-------------------------------------------------------------------------- +// Fill mode constants +//-------------------------------------------------------------------------- + + {$EXTERNALSYM FillMode} + FillMode = ( + FillModeAlternate, // 0 + FillModeWinding // 1 + ); + TFillMode = FillMode; + +//-------------------------------------------------------------------------- +// Quality mode constants +//-------------------------------------------------------------------------- + +{$IFDEF DELPHI6_UP} + {$EXTERNALSYM QualityMode} + QualityMode = ( + QualityModeInvalid = -1, + QualityModeDefault = 0, + QualityModeLow = 1, // Best performance + QualityModeHigh = 2 // Best rendering quality + ); + TQualityMode = QualityMode; +{$ELSE} + {$EXTERNALSYM QualityMode} + QualityMode = Integer; + const + QualityModeInvalid = -1; + QualityModeDefault = 0; + QualityModeLow = 1; // Best performance + QualityModeHigh = 2; // Best rendering quality +{$ENDIF} + +//-------------------------------------------------------------------------- +// Alpha Compositing mode constants +//-------------------------------------------------------------------------- +type + {$EXTERNALSYM CompositingMode} + CompositingMode = ( + CompositingModeSourceOver, // 0 + CompositingModeSourceCopy // 1 + ); + TCompositingMode = CompositingMode; + +//-------------------------------------------------------------------------- +// Alpha Compositing quality constants +//-------------------------------------------------------------------------- +{$IFDEF DELPHI6_UP} + {$EXTERNALSYM CompositingQuality} + CompositingQuality = ( + CompositingQualityInvalid = ord(QualityModeInvalid), + CompositingQualityDefault = ord(QualityModeDefault), + CompositingQualityHighSpeed = ord(QualityModeLow), + CompositingQualityHighQuality = ord(QualityModeHigh), + CompositingQualityGammaCorrected, + CompositingQualityAssumeLinear + ); + TCompositingQuality = CompositingQuality; +{$ELSE} + {$EXTERNALSYM CompositingQuality} + CompositingQuality = Integer; + const + CompositingQualityInvalid = QualityModeInvalid; + CompositingQualityDefault = QualityModeDefault; + CompositingQualityHighSpeed = QualityModeLow; + CompositingQualityHighQuality = QualityModeHigh; + CompositingQualityGammaCorrected = 3; + CompositingQualityAssumeLinear = 4; + +type + TCompositingQuality = CompositingQuality; +{$ENDIF} + +//-------------------------------------------------------------------------- +// Unit constants +//-------------------------------------------------------------------------- + + // {$EXTERNALSYM Unit} + Unit_ = ( + UnitWorld, // 0 -- World coordinate (non-physical unit) + UnitDisplay, // 1 -- Variable -- for PageTransform only + UnitPixel, // 2 -- Each unit is one device pixel. + UnitPoint, // 3 -- Each unit is a printer's point, or 1/72 inch. + UnitInch, // 4 -- Each unit is 1 inch. + UnitDocument, // 5 -- Each unit is 1/300 inch. + UnitMillimeter // 6 -- Each unit is 1 millimeter. + ); + TUnit = Unit_; + +//-------------------------------------------------------------------------- +// MetafileFrameUnit +// +// The frameRect for creating a metafile can be specified in any of these +// units. There is an extra frame unit value (MetafileFrameUnitGdi) so +// that units can be supplied in the same units that GDI expects for +// frame rects -- these units are in .01 (1/100ths) millimeter units +// as defined by GDI. +//-------------------------------------------------------------------------- +{$IFDEF DELPHI6_UP} + {$EXTERNALSYM MetafileFrameUnit} + MetafileFrameUnit = ( + MetafileFrameUnitPixel = ord(UnitPixel), + MetafileFrameUnitPoint = ord(UnitPoint), + MetafileFrameUnitInch = ord(UnitInch), + MetafileFrameUnitDocument = ord(UnitDocument), + MetafileFrameUnitMillimeter = ord(UnitMillimeter), + MetafileFrameUnitGdi // GDI compatible .01 MM units + ); + TMetafileFrameUnit = MetafileFrameUnit; +{$ELSE} + {$EXTERNALSYM MetafileFrameUnit} + MetafileFrameUnit = Integer; + const + MetafileFrameUnitPixel = 2; + MetafileFrameUnitPoint = 3; + MetafileFrameUnitInch = 4; + MetafileFrameUnitDocument = 5; + MetafileFrameUnitMillimeter = 6; + MetafileFrameUnitGdi = 7; // GDI compatible .01 MM units + +type + TMetafileFrameUnit = MetafileFrameUnit; +{$ENDIF} +//-------------------------------------------------------------------------- +// Coordinate space identifiers +//-------------------------------------------------------------------------- + + {$EXTERNALSYM CoordinateSpace} + CoordinateSpace = ( + CoordinateSpaceWorld, // 0 + CoordinateSpacePage, // 1 + CoordinateSpaceDevice // 2 + ); + TCoordinateSpace = CoordinateSpace; + +//-------------------------------------------------------------------------- +// Various wrap modes for brushes +//-------------------------------------------------------------------------- + + {$EXTERNALSYM WrapMode} + WrapMode = ( + WrapModeTile, // 0 + WrapModeTileFlipX, // 1 + WrapModeTileFlipY, // 2 + WrapModeTileFlipXY, // 3 + WrapModeClamp // 4 + ); + TWrapMode = WrapMode; + +//-------------------------------------------------------------------------- +// Various hatch styles +//-------------------------------------------------------------------------- + + {$EXTERNALSYM HatchStyle} + HatchStyle = ( + HatchStyleHorizontal, // = 0, + HatchStyleVertical, // = 1, + HatchStyleForwardDiagonal, // = 2, + HatchStyleBackwardDiagonal, // = 3, + HatchStyleCross, // = 4, + HatchStyleDiagonalCross, // = 5, + HatchStyle05Percent, // = 6, + HatchStyle10Percent, // = 7, + HatchStyle20Percent, // = 8, + HatchStyle25Percent, // = 9, + HatchStyle30Percent, // = 10, + HatchStyle40Percent, // = 11, + HatchStyle50Percent, // = 12, + HatchStyle60Percent, // = 13, + HatchStyle70Percent, // = 14, + HatchStyle75Percent, // = 15, + HatchStyle80Percent, // = 16, + HatchStyle90Percent, // = 17, + HatchStyleLightDownwardDiagonal, // = 18, + HatchStyleLightUpwardDiagonal, // = 19, + HatchStyleDarkDownwardDiagonal, // = 20, + HatchStyleDarkUpwardDiagonal, // = 21, + HatchStyleWideDownwardDiagonal, // = 22, + HatchStyleWideUpwardDiagonal, // = 23, + HatchStyleLightVertical, // = 24, + HatchStyleLightHorizontal, // = 25, + HatchStyleNarrowVertical, // = 26, + HatchStyleNarrowHorizontal, // = 27, + HatchStyleDarkVertical, // = 28, + HatchStyleDarkHorizontal, // = 29, + HatchStyleDashedDownwardDiagonal, // = 30, + HatchStyleDashedUpwardDiagonal, // = 31, + HatchStyleDashedHorizontal, // = 32, + HatchStyleDashedVertical, // = 33, + HatchStyleSmallConfetti, // = 34, + HatchStyleLargeConfetti, // = 35, + HatchStyleZigZag, // = 36, + HatchStyleWave, // = 37, + HatchStyleDiagonalBrick, // = 38, + HatchStyleHorizontalBrick, // = 39, + HatchStyleWeave, // = 40, + HatchStylePlaid, // = 41, + HatchStyleDivot, // = 42, + HatchStyleDottedGrid, // = 43, + HatchStyleDottedDiamond, // = 44, + HatchStyleShingle, // = 45, + HatchStyleTrellis, // = 46, + HatchStyleSphere, // = 47, + HatchStyleSmallGrid, // = 48, + HatchStyleSmallCheckerBoard, // = 49, + HatchStyleLargeCheckerBoard, // = 50, + HatchStyleOutlinedDiamond, // = 51, + HatchStyleSolidDiamond, // = 52, + + HatchStyleTotal // = 53, + ); + + const + HatchStyleLargeGrid = HatchStyleCross; // 4 + HatchStyleMin = HatchStyleHorizontal; + HatchStyleMax = HatchStyleSolidDiamond; + +type + THatchStyle = HatchStyle; + +//-------------------------------------------------------------------------- +// Dash style constants +//-------------------------------------------------------------------------- + + {$EXTERNALSYM DashStyle} + DashStyle = ( + DashStyleSolid, // 0 + DashStyleDash, // 1 + DashStyleDot, // 2 + DashStyleDashDot, // 3 + DashStyleDashDotDot, // 4 + DashStyleCustom // 5 + ); + TDashStyle = DashStyle; + +//-------------------------------------------------------------------------- +// Dash cap constants +//-------------------------------------------------------------------------- +{$IFDEF DELPHI6_UP} + {$EXTERNALSYM DashCap} + DashCap = ( + DashCapFlat = 0, + DashCapRound = 2, + DashCapTriangle = 3 + ); + TDashCap = DashCap; +{$ELSE} + {$EXTERNALSYM DashCap} + DashCap = Integer; + const + DashCapFlat = 0; + DashCapRound = 2; + DashCapTriangle = 3; + +type + TDashCap = DashCap; +{$ENDIF} + +//-------------------------------------------------------------------------- +// Line cap constants (only the lowest 8 bits are used). +//-------------------------------------------------------------------------- +{$IFDEF DELPHI6_UP} + {$EXTERNALSYM LineCap} + LineCap = ( + LineCapFlat = 0, + LineCapSquare = 1, + LineCapRound = 2, + LineCapTriangle = 3, + + LineCapNoAnchor = $10, // corresponds to flat cap + LineCapSquareAnchor = $11, // corresponds to square cap + LineCapRoundAnchor = $12, // corresponds to round cap + LineCapDiamondAnchor = $13, // corresponds to triangle cap + LineCapArrowAnchor = $14, // no correspondence + + LineCapCustom = $ff, // custom cap + + LineCapAnchorMask = $f0 // mask to check for anchor or not. + ); + TLineCap = LineCap; +{$ELSE} + {$EXTERNALSYM LineCap} + LineCap = Integer; + const + LineCapFlat = 0; + LineCapSquare = 1; + LineCapRound = 2; + LineCapTriangle = 3; + + LineCapNoAnchor = $10; // corresponds to flat cap + LineCapSquareAnchor = $11; // corresponds to square cap + LineCapRoundAnchor = $12; // corresponds to round cap + LineCapDiamondAnchor = $13; // corresponds to triangle cap + LineCapArrowAnchor = $14; // no correspondence + + LineCapCustom = $ff; // custom cap + + LineCapAnchorMask = $f0; // mask to check for anchor or not. + +type + TLineCap = LineCap; +{$ENDIF} + +//-------------------------------------------------------------------------- +// Custom Line cap type constants +//-------------------------------------------------------------------------- + + {$EXTERNALSYM CustomLineCapType} + CustomLineCapType = ( + CustomLineCapTypeDefault, + CustomLineCapTypeAdjustableArrow + ); + TCustomLineCapType = CustomLineCapType; + +//-------------------------------------------------------------------------- +// Line join constants +//-------------------------------------------------------------------------- + + {$EXTERNALSYM LineJoin} + LineJoin = ( + LineJoinMiter, + LineJoinBevel, + LineJoinRound, + LineJoinMiterClipped + ); + TLineJoin = LineJoin; + +//-------------------------------------------------------------------------- +// Path point types (only the lowest 8 bits are used.) +// The lowest 3 bits are interpreted as point type +// The higher 5 bits are reserved for flags. +//-------------------------------------------------------------------------- + +{$IFDEF DELPHI6_UP} + {$Z1} + {$EXTERNALSYM PathPointType} + PathPointType = ( + PathPointTypeStart = $00, // move + PathPointTypeLine = $01, // line + PathPointTypeBezier = $03, // default Bezier (= cubic Bezier) + PathPointTypePathTypeMask = $07, // type mask (lowest 3 bits). + PathPointTypeDashMode = $10, // currently in dash mode. + PathPointTypePathMarker = $20, // a marker for the path. + PathPointTypeCloseSubpath = $80, // closed flag + + // Path types used for advanced path. + PathPointTypeBezier3 = $03 // cubic Bezier + ); + TPathPointType = PathPointType; + {$Z4} +{$ELSE} + {$EXTERNALSYM PathPointType} + PathPointType = Byte; + const + PathPointTypeStart : Byte = $00; // move + PathPointTypeLine : Byte = $01; // line + PathPointTypeBezier : Byte = $03; // default Bezier (= cubic Bezier) + PathPointTypePathTypeMask : Byte = $07; // type mask (lowest 3 bits). + PathPointTypeDashMode : Byte = $10; // currently in dash mode. + PathPointTypePathMarker : Byte = $20; // a marker for the path. + PathPointTypeCloseSubpath : Byte = $80; // closed flag + + // Path types used for advanced path. + PathPointTypeBezier3 : Byte = $03; // cubic Bezier + +type + TPathPointType = PathPointType; +{$ENDIF} + +//-------------------------------------------------------------------------- +// WarpMode constants +//-------------------------------------------------------------------------- + + {$EXTERNALSYM WarpMode} + WarpMode = ( + WarpModePerspective, // 0 + WarpModeBilinear // 1 + ); + TWarpMode = WarpMode; + +//-------------------------------------------------------------------------- +// LineGradient Mode +//-------------------------------------------------------------------------- + + {$EXTERNALSYM LinearGradientMode} + LinearGradientMode = ( + LinearGradientModeHorizontal, // 0 + LinearGradientModeVertical, // 1 + LinearGradientModeForwardDiagonal, // 2 + LinearGradientModeBackwardDiagonal // 3 + ); + TLinearGradientMode = LinearGradientMode; + +//-------------------------------------------------------------------------- +// Region Comine Modes +//-------------------------------------------------------------------------- + + {$EXTERNALSYM CombineMode} + CombineMode = ( + CombineModeReplace, // 0 + CombineModeIntersect, // 1 + CombineModeUnion, // 2 + CombineModeXor, // 3 + CombineModeExclude, // 4 + CombineModeComplement // 5 (Exclude From) + ); + TCombineMode = CombineMode; + +//-------------------------------------------------------------------------- + // Image types +//-------------------------------------------------------------------------- + + {$EXTERNALSYM ImageType} + ImageType = ( + ImageTypeUnknown, // 0 + ImageTypeBitmap, // 1 + ImageTypeMetafile // 2 + ); + TImageType = ImageType; + +//-------------------------------------------------------------------------- +// Interpolation modes +//-------------------------------------------------------------------------- +{$IFDEF DELPHI6_UP} + {$EXTERNALSYM InterpolationMode} + InterpolationMode = ( + InterpolationModeInvalid = ord(QualityModeInvalid), + InterpolationModeDefault = ord(QualityModeDefault), + InterpolationModeLowQuality = ord(QualityModeLow), + InterpolationModeHighQuality = ord(QualityModeHigh), + InterpolationModeBilinear, + InterpolationModeBicubic, + InterpolationModeNearestNeighbor, + InterpolationModeHighQualityBilinear, + InterpolationModeHighQualityBicubic + ); + TInterpolationMode = InterpolationMode; +{$ELSE} + {$EXTERNALSYM InterpolationMode} + InterpolationMode = Integer; + const + InterpolationModeInvalid = QualityModeInvalid; + InterpolationModeDefault = QualityModeDefault; + InterpolationModeLowQuality = QualityModeLow; + InterpolationModeHighQuality = QualityModeHigh; + InterpolationModeBilinear = 3; + InterpolationModeBicubic = 4; + InterpolationModeNearestNeighbor = 5; + InterpolationModeHighQualityBilinear = 6; + InterpolationModeHighQualityBicubic = 7; + +type + TInterpolationMode = InterpolationMode; +{$ENDIF} + +//-------------------------------------------------------------------------- +// Pen types +//-------------------------------------------------------------------------- + + {$EXTERNALSYM PenAlignment} + PenAlignment = ( + PenAlignmentCenter, + PenAlignmentInset + ); + TPenAlignment = PenAlignment; + +//-------------------------------------------------------------------------- +// Brush types +//-------------------------------------------------------------------------- + + {$EXTERNALSYM BrushType} + BrushType = ( + BrushTypeSolidColor, + BrushTypeHatchFill, + BrushTypeTextureFill, + BrushTypePathGradient, + BrushTypeLinearGradient + ); + TBrushType = BrushType; + +//-------------------------------------------------------------------------- +// Pen's Fill types +//-------------------------------------------------------------------------- +{$IFDEF DELPHI6_UP} + {$EXTERNALSYM PenType} + PenType = ( + PenTypeSolidColor = ord(BrushTypeSolidColor), + PenTypeHatchFill = ord(BrushTypeHatchFill), + PenTypeTextureFill = ord(BrushTypeTextureFill), + PenTypePathGradient = ord(BrushTypePathGradient), + PenTypeLinearGradient = ord(BrushTypeLinearGradient), + PenTypeUnknown = -1 + ); + TPenType = PenType; +{$ELSE} + {$EXTERNALSYM PenType} + PenType = Integer; + const + PenTypeSolidColor = 0; + PenTypeHatchFill = 1; + PenTypeTextureFill = 2; + PenTypePathGradient = 3; + PenTypeLinearGradient = 4; + PenTypeUnknown = -1; + +type + TPenType = PenType; +{$ENDIF} + +//-------------------------------------------------------------------------- +// Matrix Order +//-------------------------------------------------------------------------- + + {$EXTERNALSYM MatrixOrder} + MatrixOrder = ( + MatrixOrderPrepend, + MatrixOrderAppend + ); + TMatrixOrder = MatrixOrder; + +//-------------------------------------------------------------------------- +// Generic font families +//-------------------------------------------------------------------------- + + {$EXTERNALSYM GenericFontFamily} + GenericFontFamily = ( + GenericFontFamilySerif, + GenericFontFamilySansSerif, + GenericFontFamilyMonospace + ); + TGenericFontFamily = GenericFontFamily; + +//-------------------------------------------------------------------------- +// FontStyle: face types and common styles +//-------------------------------------------------------------------------- +type + {$EXTERNALSYM FontStyle} + FontStyle = Integer; + const + FontStyleRegular = Integer(0); + FontStyleBold = Integer(1); + FontStyleItalic = Integer(2); + FontStyleBoldItalic = Integer(3); + FontStyleUnderline = Integer(4); + FontStyleStrikeout = Integer(8); + Type + TFontStyle = FontStyle; + +//--------------------------------------------------------------------------- +// Smoothing Mode +//--------------------------------------------------------------------------- +{$IFDEF DELPHI6_UP} + {$EXTERNALSYM SmoothingMode} + SmoothingMode = ( + SmoothingModeInvalid = ord(QualityModeInvalid), + SmoothingModeDefault = ord(QualityModeDefault), + SmoothingModeHighSpeed = ord(QualityModeLow), + SmoothingModeHighQuality = ord(QualityModeHigh), + SmoothingModeNone, + SmoothingModeAntiAlias + ); + TSmoothingMode = SmoothingMode; +{$ELSE} + {$EXTERNALSYM SmoothingMode} + SmoothingMode = Integer; + const + SmoothingModeInvalid = QualityModeInvalid; + SmoothingModeDefault = QualityModeDefault; + SmoothingModeHighSpeed = QualityModeLow; + SmoothingModeHighQuality = QualityModeHigh; + SmoothingModeNone = 3; + SmoothingModeAntiAlias = 4; + +type + TSmoothingMode = SmoothingMode; +{$ENDIF} + +//--------------------------------------------------------------------------- +// Pixel Format Mode +//--------------------------------------------------------------------------- +{$IFDEF DELPHI6_UP} + {$EXTERNALSYM PixelOffsetMode} + PixelOffsetMode = ( + PixelOffsetModeInvalid = Ord(QualityModeInvalid), + PixelOffsetModeDefault = Ord(QualityModeDefault), + PixelOffsetModeHighSpeed = Ord(QualityModeLow), + PixelOffsetModeHighQuality = Ord(QualityModeHigh), + PixelOffsetModeNone, // No pixel offset + PixelOffsetModeHalf // Offset by -0.5, -0.5 for fast anti-alias perf + ); + TPixelOffsetMode = PixelOffsetMode; +{$ELSE} + {$EXTERNALSYM PixelOffsetMode} + PixelOffsetMode = Integer; + const + PixelOffsetModeInvalid = QualityModeInvalid; + PixelOffsetModeDefault = QualityModeDefault; + PixelOffsetModeHighSpeed = QualityModeLow; + PixelOffsetModeHighQuality = QualityModeHigh; + PixelOffsetModeNone = 3; // No pixel offset + PixelOffsetModeHalf = 4; // Offset by -0.5, -0.5 for fast anti-alias perf + +type + TPixelOffsetMode = PixelOffsetMode; +{$ENDIF} + +//--------------------------------------------------------------------------- +// Text Rendering Hint +//--------------------------------------------------------------------------- + + {$EXTERNALSYM TextRenderingHint} + TextRenderingHint = ( + TextRenderingHintSystemDefault, // Glyph with system default rendering hint + TextRenderingHintSingleBitPerPixelGridFit, // Glyph bitmap with hinting + TextRenderingHintSingleBitPerPixel, // Glyph bitmap without hinting + TextRenderingHintAntiAliasGridFit, // Glyph anti-alias bitmap with hinting + TextRenderingHintAntiAlias, // Glyph anti-alias bitmap without hinting + TextRenderingHintClearTypeGridFit // Glyph CT bitmap with hinting + ); + TTextRenderingHint = TextRenderingHint; + +//--------------------------------------------------------------------------- +// Metafile Types +//--------------------------------------------------------------------------- + + {$EXTERNALSYM MetafileType} + MetafileType = ( + MetafileTypeInvalid, // Invalid metafile + MetafileTypeWmf, // Standard WMF + MetafileTypeWmfPlaceable, // Placeable WMF + MetafileTypeEmf, // EMF (not EMF+) + MetafileTypeEmfPlusOnly, // EMF+ without dual, down-level records + MetafileTypeEmfPlusDual // EMF+ with dual, down-level records + ); + TMetafileType = MetafileType; + +//--------------------------------------------------------------------------- +// Specifies the type of EMF to record +//--------------------------------------------------------------------------- +{$IFDEF DELPHI6_UP} + {$EXTERNALSYM EmfType} + EmfType = ( + EmfTypeEmfOnly = Ord(MetafileTypeEmf), // no EMF+, only EMF + EmfTypeEmfPlusOnly = Ord(MetafileTypeEmfPlusOnly), // no EMF, only EMF+ + EmfTypeEmfPlusDual = Ord(MetafileTypeEmfPlusDual) // both EMF+ and EMF + ); + TEmfType = EmfType; +{$ELSE} + {$EXTERNALSYM EmfType} + EmfType = Integer; + const + EmfTypeEmfOnly = Ord(MetafileTypeEmf); // no EMF+, only EMF + EmfTypeEmfPlusOnly = Ord(MetafileTypeEmfPlusOnly); // no EMF, only EMF+ + EmfTypeEmfPlusDual = Ord(MetafileTypeEmfPlusDual); // both EMF+ and EMF + +type + TEmfType = EmfType; +{$ENDIF} + +//--------------------------------------------------------------------------- +// EMF+ Persistent object types +//--------------------------------------------------------------------------- + + {$EXTERNALSYM ObjectType} + ObjectType = ( + ObjectTypeInvalid, + ObjectTypeBrush, + ObjectTypePen, + ObjectTypePath, + ObjectTypeRegion, + ObjectTypeImage, + ObjectTypeFont, + ObjectTypeStringFormat, + ObjectTypeImageAttributes, + ObjectTypeCustomLineCap + ); + TObjectType = ObjectType; + +const + ObjectTypeMax = ObjectTypeCustomLineCap; + ObjectTypeMin = ObjectTypeBrush; + +function ObjectTypeIsValid(type_: ObjectType): BOOL; + +//--------------------------------------------------------------------------- +// EMF+ Records +//--------------------------------------------------------------------------- + + // We have to change the WMF record numbers so that they don't conflict with + // the EMF and EMF+ record numbers. + +const + GDIP_EMFPLUS_RECORD_BASE = $00004000; + {$EXTERNALSYM GDIP_EMFPLUS_RECORD_BASE} + GDIP_WMF_RECORD_BASE = $00010000; + {$EXTERNALSYM GDIP_WMF_RECORD_BASE} + +// macros +function GDIP_WMF_RECORD_TO_EMFPLUS(n: integer): Integer; +function GDIP_EMFPLUS_RECORD_TO_WMF(n: integer): Integer; +function GDIP_IS_WMF_RECORDTYPE(n: integer): BOOL; + + +{$IFDEF DELPHI6_UP} +type + {$EXTERNALSYM EmfPlusRecordType} + EmfPlusRecordType = ( + // Since we have to enumerate GDI records right along with GDI+ records, + // We list all the GDI records here so that they can be part of the + // same enumeration type which is used in the enumeration callback. + + WmfRecordTypeSetBkColor = (META_SETBKCOLOR or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetBkMode = (META_SETBKMODE or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetMapMode = (META_SETMAPMODE or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetROP2 = (META_SETROP2 or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetRelAbs = (META_SETRELABS or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetPolyFillMode = (META_SETPOLYFILLMODE or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetStretchBltMode = (META_SETSTRETCHBLTMODE or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetTextCharExtra = (META_SETTEXTCHAREXTRA or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetTextColor = (META_SETTEXTCOLOR or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetTextJustification = (META_SETTEXTJUSTIFICATION or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetWindowOrg = (META_SETWINDOWORG or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetWindowExt = (META_SETWINDOWEXT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetViewportOrg = (META_SETVIEWPORTORG or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetViewportExt = (META_SETVIEWPORTEXT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeOffsetWindowOrg = (META_OFFSETWINDOWORG or GDIP_WMF_RECORD_BASE), + WmfRecordTypeScaleWindowExt = (META_SCALEWINDOWEXT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeOffsetViewportOrg = (META_OFFSETVIEWPORTORG or GDIP_WMF_RECORD_BASE), + WmfRecordTypeScaleViewportExt = (META_SCALEVIEWPORTEXT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeLineTo = (META_LINETO or GDIP_WMF_RECORD_BASE), + WmfRecordTypeMoveTo = (META_MOVETO or GDIP_WMF_RECORD_BASE), + WmfRecordTypeExcludeClipRect = (META_EXCLUDECLIPRECT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeIntersectClipRect = (META_INTERSECTCLIPRECT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeArc = (META_ARC or GDIP_WMF_RECORD_BASE), + WmfRecordTypeEllipse = (META_ELLIPSE or GDIP_WMF_RECORD_BASE), + WmfRecordTypeFloodFill = (META_FLOODFILL or GDIP_WMF_RECORD_BASE), + WmfRecordTypePie = (META_PIE or GDIP_WMF_RECORD_BASE), + WmfRecordTypeRectangle = (META_RECTANGLE or GDIP_WMF_RECORD_BASE), + WmfRecordTypeRoundRect = (META_ROUNDRECT or GDIP_WMF_RECORD_BASE), + WmfRecordTypePatBlt = (META_PATBLT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSaveDC = (META_SAVEDC or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetPixel = (META_SETPIXEL or GDIP_WMF_RECORD_BASE), + WmfRecordTypeOffsetClipRgn = (META_OFFSETCLIPRGN or GDIP_WMF_RECORD_BASE), + WmfRecordTypeTextOut = (META_TEXTOUT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeBitBlt = (META_BITBLT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeStretchBlt = (META_STRETCHBLT or GDIP_WMF_RECORD_BASE), + WmfRecordTypePolygon = (META_POLYGON or GDIP_WMF_RECORD_BASE), + WmfRecordTypePolyline = (META_POLYLINE or GDIP_WMF_RECORD_BASE), + WmfRecordTypeEscape = (META_ESCAPE or GDIP_WMF_RECORD_BASE), + WmfRecordTypeRestoreDC = (META_RESTOREDC or GDIP_WMF_RECORD_BASE), + WmfRecordTypeFillRegion = (META_FILLREGION or GDIP_WMF_RECORD_BASE), + WmfRecordTypeFrameRegion = (META_FRAMEREGION or GDIP_WMF_RECORD_BASE), + WmfRecordTypeInvertRegion = (META_INVERTREGION or GDIP_WMF_RECORD_BASE), + WmfRecordTypePaintRegion = (META_PAINTREGION or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSelectClipRegion = (META_SELECTCLIPREGION or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSelectObject = (META_SELECTOBJECT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetTextAlign = (META_SETTEXTALIGN or GDIP_WMF_RECORD_BASE), + WmfRecordTypeDrawText = ($062F or GDIP_WMF_RECORD_BASE), // META_DRAWTEXT + WmfRecordTypeChord = (META_CHORD or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetMapperFlags = (META_SETMAPPERFLAGS or GDIP_WMF_RECORD_BASE), + WmfRecordTypeExtTextOut = (META_EXTTEXTOUT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetDIBToDev = (META_SETDIBTODEV or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSelectPalette = (META_SELECTPALETTE or GDIP_WMF_RECORD_BASE), + WmfRecordTypeRealizePalette = (META_REALIZEPALETTE or GDIP_WMF_RECORD_BASE), + WmfRecordTypeAnimatePalette = (META_ANIMATEPALETTE or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetPalEntries = (META_SETPALENTRIES or GDIP_WMF_RECORD_BASE), + WmfRecordTypePolyPolygon = (META_POLYPOLYGON or GDIP_WMF_RECORD_BASE), + WmfRecordTypeResizePalette = (META_RESIZEPALETTE or GDIP_WMF_RECORD_BASE), + WmfRecordTypeDIBBitBlt = (META_DIBBITBLT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeDIBStretchBlt = (META_DIBSTRETCHBLT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeDIBCreatePatternBrush = (META_DIBCREATEPATTERNBRUSH or GDIP_WMF_RECORD_BASE), + WmfRecordTypeStretchDIB = (META_STRETCHDIB or GDIP_WMF_RECORD_BASE), + WmfRecordTypeExtFloodFill = (META_EXTFLOODFILL or GDIP_WMF_RECORD_BASE), + WmfRecordTypeSetLayout = ($0149 or GDIP_WMF_RECORD_BASE), // META_SETLAYOUT + WmfRecordTypeResetDC = ($014C or GDIP_WMF_RECORD_BASE), // META_RESETDC + WmfRecordTypeStartDoc = ($014D or GDIP_WMF_RECORD_BASE), // META_STARTDOC + WmfRecordTypeStartPage = ($004F or GDIP_WMF_RECORD_BASE), // META_STARTPAGE + WmfRecordTypeEndPage = ($0050 or GDIP_WMF_RECORD_BASE), // META_ENDPAGE + WmfRecordTypeAbortDoc = ($0052 or GDIP_WMF_RECORD_BASE), // META_ABORTDOC + WmfRecordTypeEndDoc = ($005E or GDIP_WMF_RECORD_BASE), // META_ENDDOC + WmfRecordTypeDeleteObject = (META_DELETEOBJECT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeCreatePalette = (META_CREATEPALETTE or GDIP_WMF_RECORD_BASE), + WmfRecordTypeCreateBrush = ($00F8 or GDIP_WMF_RECORD_BASE), // META_CREATEBRUSH + WmfRecordTypeCreatePatternBrush = (META_CREATEPATTERNBRUSH or GDIP_WMF_RECORD_BASE), + WmfRecordTypeCreatePenIndirect = (META_CREATEPENINDIRECT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeCreateFontIndirect = (META_CREATEFONTINDIRECT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeCreateBrushIndirect = (META_CREATEBRUSHINDIRECT or GDIP_WMF_RECORD_BASE), + WmfRecordTypeCreateBitmapIndirect = ($02FD or GDIP_WMF_RECORD_BASE), // META_CREATEBITMAPINDIRECT + WmfRecordTypeCreateBitmap = ($06FE or GDIP_WMF_RECORD_BASE), // META_CREATEBITMAP + WmfRecordTypeCreateRegion = (META_CREATEREGION or GDIP_WMF_RECORD_BASE), + + EmfRecordTypeHeader = EMR_HEADER, + EmfRecordTypePolyBezier = EMR_POLYBEZIER, + EmfRecordTypePolygon = EMR_POLYGON, + EmfRecordTypePolyline = EMR_POLYLINE, + EmfRecordTypePolyBezierTo = EMR_POLYBEZIERTO, + EmfRecordTypePolyLineTo = EMR_POLYLINETO, + EmfRecordTypePolyPolyline = EMR_POLYPOLYLINE, + EmfRecordTypePolyPolygon = EMR_POLYPOLYGON, + EmfRecordTypeSetWindowExtEx = EMR_SETWINDOWEXTEX, + EmfRecordTypeSetWindowOrgEx = EMR_SETWINDOWORGEX, + EmfRecordTypeSetViewportExtEx = EMR_SETVIEWPORTEXTEX, + EmfRecordTypeSetViewportOrgEx = EMR_SETVIEWPORTORGEX, + EmfRecordTypeSetBrushOrgEx = EMR_SETBRUSHORGEX, + EmfRecordTypeEOF = EMR_EOF, + EmfRecordTypeSetPixelV = EMR_SETPIXELV, + EmfRecordTypeSetMapperFlags = EMR_SETMAPPERFLAGS, + EmfRecordTypeSetMapMode = EMR_SETMAPMODE, + EmfRecordTypeSetBkMode = EMR_SETBKMODE, + EmfRecordTypeSetPolyFillMode = EMR_SETPOLYFILLMODE, + EmfRecordTypeSetROP2 = EMR_SETROP2, + EmfRecordTypeSetStretchBltMode = EMR_SETSTRETCHBLTMODE, + EmfRecordTypeSetTextAlign = EMR_SETTEXTALIGN, + EmfRecordTypeSetColorAdjustment = EMR_SETCOLORADJUSTMENT, + EmfRecordTypeSetTextColor = EMR_SETTEXTCOLOR, + EmfRecordTypeSetBkColor = EMR_SETBKCOLOR, + EmfRecordTypeOffsetClipRgn = EMR_OFFSETCLIPRGN, + EmfRecordTypeMoveToEx = EMR_MOVETOEX, + EmfRecordTypeSetMetaRgn = EMR_SETMETARGN, + EmfRecordTypeExcludeClipRect = EMR_EXCLUDECLIPRECT, + EmfRecordTypeIntersectClipRect = EMR_INTERSECTCLIPRECT, + EmfRecordTypeScaleViewportExtEx = EMR_SCALEVIEWPORTEXTEX, + EmfRecordTypeScaleWindowExtEx = EMR_SCALEWINDOWEXTEX, + EmfRecordTypeSaveDC = EMR_SAVEDC, + EmfRecordTypeRestoreDC = EMR_RESTOREDC, + EmfRecordTypeSetWorldTransform = EMR_SETWORLDTRANSFORM, + EmfRecordTypeModifyWorldTransform = EMR_MODIFYWORLDTRANSFORM, + EmfRecordTypeSelectObject = EMR_SELECTOBJECT, + EmfRecordTypeCreatePen = EMR_CREATEPEN, + EmfRecordTypeCreateBrushIndirect = EMR_CREATEBRUSHINDIRECT, + EmfRecordTypeDeleteObject = EMR_DELETEOBJECT, + EmfRecordTypeAngleArc = EMR_ANGLEARC, + EmfRecordTypeEllipse = EMR_ELLIPSE, + EmfRecordTypeRectangle = EMR_RECTANGLE, + EmfRecordTypeRoundRect = EMR_ROUNDRECT, + EmfRecordTypeArc = EMR_ARC, + EmfRecordTypeChord = EMR_CHORD, + EmfRecordTypePie = EMR_PIE, + EmfRecordTypeSelectPalette = EMR_SELECTPALETTE, + EmfRecordTypeCreatePalette = EMR_CREATEPALETTE, + EmfRecordTypeSetPaletteEntries = EMR_SETPALETTEENTRIES, + EmfRecordTypeResizePalette = EMR_RESIZEPALETTE, + EmfRecordTypeRealizePalette = EMR_REALIZEPALETTE, + EmfRecordTypeExtFloodFill = EMR_EXTFLOODFILL, + EmfRecordTypeLineTo = EMR_LINETO, + EmfRecordTypeArcTo = EMR_ARCTO, + EmfRecordTypePolyDraw = EMR_POLYDRAW, + EmfRecordTypeSetArcDirection = EMR_SETARCDIRECTION, + EmfRecordTypeSetMiterLimit = EMR_SETMITERLIMIT, + EmfRecordTypeBeginPath = EMR_BEGINPATH, + EmfRecordTypeEndPath = EMR_ENDPATH, + EmfRecordTypeCloseFigure = EMR_CLOSEFIGURE, + EmfRecordTypeFillPath = EMR_FILLPATH, + EmfRecordTypeStrokeAndFillPath = EMR_STROKEANDFILLPATH, + EmfRecordTypeStrokePath = EMR_STROKEPATH, + EmfRecordTypeFlattenPath = EMR_FLATTENPATH, + EmfRecordTypeWidenPath = EMR_WIDENPATH, + EmfRecordTypeSelectClipPath = EMR_SELECTCLIPPATH, + EmfRecordTypeAbortPath = EMR_ABORTPATH, + EmfRecordTypeReserved_069 = 69, // Not Used + EmfRecordTypeGdiComment = EMR_GDICOMMENT, + EmfRecordTypeFillRgn = EMR_FILLRGN, + EmfRecordTypeFrameRgn = EMR_FRAMERGN, + EmfRecordTypeInvertRgn = EMR_INVERTRGN, + EmfRecordTypePaintRgn = EMR_PAINTRGN, + EmfRecordTypeExtSelectClipRgn = EMR_EXTSELECTCLIPRGN, + EmfRecordTypeBitBlt = EMR_BITBLT, + EmfRecordTypeStretchBlt = EMR_STRETCHBLT, + EmfRecordTypeMaskBlt = EMR_MASKBLT, + EmfRecordTypePlgBlt = EMR_PLGBLT, + EmfRecordTypeSetDIBitsToDevice = EMR_SETDIBITSTODEVICE, + EmfRecordTypeStretchDIBits = EMR_STRETCHDIBITS, + EmfRecordTypeExtCreateFontIndirect = EMR_EXTCREATEFONTINDIRECTW, + EmfRecordTypeExtTextOutA = EMR_EXTTEXTOUTA, + EmfRecordTypeExtTextOutW = EMR_EXTTEXTOUTW, + EmfRecordTypePolyBezier16 = EMR_POLYBEZIER16, + EmfRecordTypePolygon16 = EMR_POLYGON16, + EmfRecordTypePolyline16 = EMR_POLYLINE16, + EmfRecordTypePolyBezierTo16 = EMR_POLYBEZIERTO16, + EmfRecordTypePolylineTo16 = EMR_POLYLINETO16, + EmfRecordTypePolyPolyline16 = EMR_POLYPOLYLINE16, + EmfRecordTypePolyPolygon16 = EMR_POLYPOLYGON16, + EmfRecordTypePolyDraw16 = EMR_POLYDRAW16, + EmfRecordTypeCreateMonoBrush = EMR_CREATEMONOBRUSH, + EmfRecordTypeCreateDIBPatternBrushPt = EMR_CREATEDIBPATTERNBRUSHPT, + EmfRecordTypeExtCreatePen = EMR_EXTCREATEPEN, + EmfRecordTypePolyTextOutA = EMR_POLYTEXTOUTA, + EmfRecordTypePolyTextOutW = EMR_POLYTEXTOUTW, + EmfRecordTypeSetICMMode = 98, // EMR_SETICMMODE, + EmfRecordTypeCreateColorSpace = 99, // EMR_CREATECOLORSPACE, + EmfRecordTypeSetColorSpace = 100, // EMR_SETCOLORSPACE, + EmfRecordTypeDeleteColorSpace = 101, // EMR_DELETECOLORSPACE, + EmfRecordTypeGLSRecord = 102, // EMR_GLSRECORD, + EmfRecordTypeGLSBoundedRecord = 103, // EMR_GLSBOUNDEDRECORD, + EmfRecordTypePixelFormat = 104, // EMR_PIXELFORMAT, + EmfRecordTypeDrawEscape = 105, // EMR_RESERVED_105, + EmfRecordTypeExtEscape = 106, // EMR_RESERVED_106, + EmfRecordTypeStartDoc = 107, // EMR_RESERVED_107, + EmfRecordTypeSmallTextOut = 108, // EMR_RESERVED_108, + EmfRecordTypeForceUFIMapping = 109, // EMR_RESERVED_109, + EmfRecordTypeNamedEscape = 110, // EMR_RESERVED_110, + EmfRecordTypeColorCorrectPalette = 111, // EMR_COLORCORRECTPALETTE, + EmfRecordTypeSetICMProfileA = 112, // EMR_SETICMPROFILEA, + EmfRecordTypeSetICMProfileW = 113, // EMR_SETICMPROFILEW, + EmfRecordTypeAlphaBlend = 114, // EMR_ALPHABLEND, + EmfRecordTypeSetLayout = 115, // EMR_SETLAYOUT, + EmfRecordTypeTransparentBlt = 116, // EMR_TRANSPARENTBLT, + EmfRecordTypeReserved_117 = 117, // Not Used + EmfRecordTypeGradientFill = 118, // EMR_GRADIENTFILL, + EmfRecordTypeSetLinkedUFIs = 119, // EMR_RESERVED_119, + EmfRecordTypeSetTextJustification = 120, // EMR_RESERVED_120, + EmfRecordTypeColorMatchToTargetW = 121, // EMR_COLORMATCHTOTARGETW, + EmfRecordTypeCreateColorSpaceW = 122, // EMR_CREATECOLORSPACEW, + EmfRecordTypeMax = 122, + EmfRecordTypeMin = 1, + + // That is the END of the GDI EMF records. + + // Now we start the list of EMF+ records. We leave quite + // a bit of room here for the addition of any new GDI + // records that may be added later. + + EmfPlusRecordTypeInvalid = GDIP_EMFPLUS_RECORD_BASE, + EmfPlusRecordTypeHeader, + EmfPlusRecordTypeEndOfFile, + + EmfPlusRecordTypeComment, + + EmfPlusRecordTypeGetDC, + + EmfPlusRecordTypeMultiFormatStart, + EmfPlusRecordTypeMultiFormatSection, + EmfPlusRecordTypeMultiFormatEnd, + + // For all persistent objects + + EmfPlusRecordTypeObject, + + // Drawing Records + + EmfPlusRecordTypeClear, + EmfPlusRecordTypeFillRects, + EmfPlusRecordTypeDrawRects, + EmfPlusRecordTypeFillPolygon, + EmfPlusRecordTypeDrawLines, + EmfPlusRecordTypeFillEllipse, + EmfPlusRecordTypeDrawEllipse, + EmfPlusRecordTypeFillPie, + EmfPlusRecordTypeDrawPie, + EmfPlusRecordTypeDrawArc, + EmfPlusRecordTypeFillRegion, + EmfPlusRecordTypeFillPath, + EmfPlusRecordTypeDrawPath, + EmfPlusRecordTypeFillClosedCurve, + EmfPlusRecordTypeDrawClosedCurve, + EmfPlusRecordTypeDrawCurve, + EmfPlusRecordTypeDrawBeziers, + EmfPlusRecordTypeDrawImage, + EmfPlusRecordTypeDrawImagePoints, + EmfPlusRecordTypeDrawString, + + // Graphics State Records + + EmfPlusRecordTypeSetRenderingOrigin, + EmfPlusRecordTypeSetAntiAliasMode, + EmfPlusRecordTypeSetTextRenderingHint, + EmfPlusRecordTypeSetTextContrast, + EmfPlusRecordTypeSetInterpolationMode, + EmfPlusRecordTypeSetPixelOffsetMode, + EmfPlusRecordTypeSetCompositingMode, + EmfPlusRecordTypeSetCompositingQuality, + EmfPlusRecordTypeSave, + EmfPlusRecordTypeRestore, + EmfPlusRecordTypeBeginContainer, + EmfPlusRecordTypeBeginContainerNoParams, + EmfPlusRecordTypeEndContainer, + EmfPlusRecordTypeSetWorldTransform, + EmfPlusRecordTypeResetWorldTransform, + EmfPlusRecordTypeMultiplyWorldTransform, + EmfPlusRecordTypeTranslateWorldTransform, + EmfPlusRecordTypeScaleWorldTransform, + EmfPlusRecordTypeRotateWorldTransform, + EmfPlusRecordTypeSetPageTransform, + EmfPlusRecordTypeResetClip, + EmfPlusRecordTypeSetClipRect, + EmfPlusRecordTypeSetClipPath, + EmfPlusRecordTypeSetClipRegion, + EmfPlusRecordTypeOffsetClip, + + EmfPlusRecordTypeDrawDriverString, + + EmfPlusRecordTotal, + + EmfPlusRecordTypeMax = EmfPlusRecordTotal-1, + EmfPlusRecordTypeMin = EmfPlusRecordTypeHeader + ); + TEmfPlusRecordType = EmfPlusRecordType; +{$ELSE} +type + {$EXTERNALSYM EmfPlusRecordType} + EmfPlusRecordType = Integer; + // Since we have to enumerate GDI records right along with GDI+ records, + // We list all the GDI records here so that they can be part of the + // same enumeration type which is used in the enumeration callback. + const + WmfRecordTypeSetBkColor = (META_SETBKCOLOR or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetBkMode = (META_SETBKMODE or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetMapMode = (META_SETMAPMODE or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetROP2 = (META_SETROP2 or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetRelAbs = (META_SETRELABS or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetPolyFillMode = (META_SETPOLYFILLMODE or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetStretchBltMode = (META_SETSTRETCHBLTMODE or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetTextCharExtra = (META_SETTEXTCHAREXTRA or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetTextColor = (META_SETTEXTCOLOR or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetTextJustification = (META_SETTEXTJUSTIFICATION or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetWindowOrg = (META_SETWINDOWORG or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetWindowExt = (META_SETWINDOWEXT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetViewportOrg = (META_SETVIEWPORTORG or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetViewportExt = (META_SETVIEWPORTEXT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeOffsetWindowOrg = (META_OFFSETWINDOWORG or GDIP_WMF_RECORD_BASE); + WmfRecordTypeScaleWindowExt = (META_SCALEWINDOWEXT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeOffsetViewportOrg = (META_OFFSETVIEWPORTORG or GDIP_WMF_RECORD_BASE); + WmfRecordTypeScaleViewportExt = (META_SCALEVIEWPORTEXT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeLineTo = (META_LINETO or GDIP_WMF_RECORD_BASE); + WmfRecordTypeMoveTo = (META_MOVETO or GDIP_WMF_RECORD_BASE); + WmfRecordTypeExcludeClipRect = (META_EXCLUDECLIPRECT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeIntersectClipRect = (META_INTERSECTCLIPRECT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeArc = (META_ARC or GDIP_WMF_RECORD_BASE); + WmfRecordTypeEllipse = (META_ELLIPSE or GDIP_WMF_RECORD_BASE); + WmfRecordTypeFloodFill = (META_FLOODFILL or GDIP_WMF_RECORD_BASE); + WmfRecordTypePie = (META_PIE or GDIP_WMF_RECORD_BASE); + WmfRecordTypeRectangle = (META_RECTANGLE or GDIP_WMF_RECORD_BASE); + WmfRecordTypeRoundRect = (META_ROUNDRECT or GDIP_WMF_RECORD_BASE); + WmfRecordTypePatBlt = (META_PATBLT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSaveDC = (META_SAVEDC or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetPixel = (META_SETPIXEL or GDIP_WMF_RECORD_BASE); + WmfRecordTypeOffsetClipRgn = (META_OFFSETCLIPRGN or GDIP_WMF_RECORD_BASE); + WmfRecordTypeTextOut = (META_TEXTOUT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeBitBlt = (META_BITBLT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeStretchBlt = (META_STRETCHBLT or GDIP_WMF_RECORD_BASE); + WmfRecordTypePolygon = (META_POLYGON or GDIP_WMF_RECORD_BASE); + WmfRecordTypePolyline = (META_POLYLINE or GDIP_WMF_RECORD_BASE); + WmfRecordTypeEscape = (META_ESCAPE or GDIP_WMF_RECORD_BASE); + WmfRecordTypeRestoreDC = (META_RESTOREDC or GDIP_WMF_RECORD_BASE); + WmfRecordTypeFillRegion = (META_FILLREGION or GDIP_WMF_RECORD_BASE); + WmfRecordTypeFrameRegion = (META_FRAMEREGION or GDIP_WMF_RECORD_BASE); + WmfRecordTypeInvertRegion = (META_INVERTREGION or GDIP_WMF_RECORD_BASE); + WmfRecordTypePaintRegion = (META_PAINTREGION or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSelectClipRegion = (META_SELECTCLIPREGION or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSelectObject = (META_SELECTOBJECT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetTextAlign = (META_SETTEXTALIGN or GDIP_WMF_RECORD_BASE); + WmfRecordTypeDrawText = ($062F or GDIP_WMF_RECORD_BASE); // META_DRAWTEXT + WmfRecordTypeChord = (META_CHORD or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetMapperFlags = (META_SETMAPPERFLAGS or GDIP_WMF_RECORD_BASE); + WmfRecordTypeExtTextOut = (META_EXTTEXTOUT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetDIBToDev = (META_SETDIBTODEV or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSelectPalette = (META_SELECTPALETTE or GDIP_WMF_RECORD_BASE); + WmfRecordTypeRealizePalette = (META_REALIZEPALETTE or GDIP_WMF_RECORD_BASE); + WmfRecordTypeAnimatePalette = (META_ANIMATEPALETTE or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetPalEntries = (META_SETPALENTRIES or GDIP_WMF_RECORD_BASE); + WmfRecordTypePolyPolygon = (META_POLYPOLYGON or GDIP_WMF_RECORD_BASE); + WmfRecordTypeResizePalette = (META_RESIZEPALETTE or GDIP_WMF_RECORD_BASE); + WmfRecordTypeDIBBitBlt = (META_DIBBITBLT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeDIBStretchBlt = (META_DIBSTRETCHBLT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeDIBCreatePatternBrush = (META_DIBCREATEPATTERNBRUSH or GDIP_WMF_RECORD_BASE); + WmfRecordTypeStretchDIB = (META_STRETCHDIB or GDIP_WMF_RECORD_BASE); + WmfRecordTypeExtFloodFill = (META_EXTFLOODFILL or GDIP_WMF_RECORD_BASE); + WmfRecordTypeSetLayout = ($0149 or GDIP_WMF_RECORD_BASE); // META_SETLAYOUT + WmfRecordTypeResetDC = ($014C or GDIP_WMF_RECORD_BASE); // META_RESETDC + WmfRecordTypeStartDoc = ($014D or GDIP_WMF_RECORD_BASE); // META_STARTDOC + WmfRecordTypeStartPage = ($004F or GDIP_WMF_RECORD_BASE); // META_STARTPAGE + WmfRecordTypeEndPage = ($0050 or GDIP_WMF_RECORD_BASE); // META_ENDPAGE + WmfRecordTypeAbortDoc = ($0052 or GDIP_WMF_RECORD_BASE); // META_ABORTDOC + WmfRecordTypeEndDoc = ($005E or GDIP_WMF_RECORD_BASE); // META_ENDDOC + WmfRecordTypeDeleteObject = (META_DELETEOBJECT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeCreatePalette = (META_CREATEPALETTE or GDIP_WMF_RECORD_BASE); + WmfRecordTypeCreateBrush = ($00F8 or GDIP_WMF_RECORD_BASE); // META_CREATEBRUSH + WmfRecordTypeCreatePatternBrush = (META_CREATEPATTERNBRUSH or GDIP_WMF_RECORD_BASE); + WmfRecordTypeCreatePenIndirect = (META_CREATEPENINDIRECT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeCreateFontIndirect = (META_CREATEFONTINDIRECT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeCreateBrushIndirect = (META_CREATEBRUSHINDIRECT or GDIP_WMF_RECORD_BASE); + WmfRecordTypeCreateBitmapIndirect = ($02FD or GDIP_WMF_RECORD_BASE); // META_CREATEBITMAPINDIRECT + WmfRecordTypeCreateBitmap = ($06FE or GDIP_WMF_RECORD_BASE); // META_CREATEBITMAP + WmfRecordTypeCreateRegion = (META_CREATEREGION or GDIP_WMF_RECORD_BASE); + + EmfRecordTypeHeader = EMR_HEADER; + EmfRecordTypePolyBezier = EMR_POLYBEZIER; + EmfRecordTypePolygon = EMR_POLYGON; + EmfRecordTypePolyline = EMR_POLYLINE; + EmfRecordTypePolyBezierTo = EMR_POLYBEZIERTO; + EmfRecordTypePolyLineTo = EMR_POLYLINETO; + EmfRecordTypePolyPolyline = EMR_POLYPOLYLINE; + EmfRecordTypePolyPolygon = EMR_POLYPOLYGON; + EmfRecordTypeSetWindowExtEx = EMR_SETWINDOWEXTEX; + EmfRecordTypeSetWindowOrgEx = EMR_SETWINDOWORGEX; + EmfRecordTypeSetViewportExtEx = EMR_SETVIEWPORTEXTEX; + EmfRecordTypeSetViewportOrgEx = EMR_SETVIEWPORTORGEX; + EmfRecordTypeSetBrushOrgEx = EMR_SETBRUSHORGEX; + EmfRecordTypeEOF = EMR_EOF; + EmfRecordTypeSetPixelV = EMR_SETPIXELV; + EmfRecordTypeSetMapperFlags = EMR_SETMAPPERFLAGS; + EmfRecordTypeSetMapMode = EMR_SETMAPMODE; + EmfRecordTypeSetBkMode = EMR_SETBKMODE; + EmfRecordTypeSetPolyFillMode = EMR_SETPOLYFILLMODE; + EmfRecordTypeSetROP2 = EMR_SETROP2; + EmfRecordTypeSetStretchBltMode = EMR_SETSTRETCHBLTMODE; + EmfRecordTypeSetTextAlign = EMR_SETTEXTALIGN; + EmfRecordTypeSetColorAdjustment = EMR_SETCOLORADJUSTMENT; + EmfRecordTypeSetTextColor = EMR_SETTEXTCOLOR; + EmfRecordTypeSetBkColor = EMR_SETBKCOLOR; + EmfRecordTypeOffsetClipRgn = EMR_OFFSETCLIPRGN; + EmfRecordTypeMoveToEx = EMR_MOVETOEX; + EmfRecordTypeSetMetaRgn = EMR_SETMETARGN; + EmfRecordTypeExcludeClipRect = EMR_EXCLUDECLIPRECT; + EmfRecordTypeIntersectClipRect = EMR_INTERSECTCLIPRECT; + EmfRecordTypeScaleViewportExtEx = EMR_SCALEVIEWPORTEXTEX; + EmfRecordTypeScaleWindowExtEx = EMR_SCALEWINDOWEXTEX; + EmfRecordTypeSaveDC = EMR_SAVEDC; + EmfRecordTypeRestoreDC = EMR_RESTOREDC; + EmfRecordTypeSetWorldTransform = EMR_SETWORLDTRANSFORM; + EmfRecordTypeModifyWorldTransform = EMR_MODIFYWORLDTRANSFORM; + EmfRecordTypeSelectObject = EMR_SELECTOBJECT; + EmfRecordTypeCreatePen = EMR_CREATEPEN; + EmfRecordTypeCreateBrushIndirect = EMR_CREATEBRUSHINDIRECT; + EmfRecordTypeDeleteObject = EMR_DELETEOBJECT; + EmfRecordTypeAngleArc = EMR_ANGLEARC; + EmfRecordTypeEllipse = EMR_ELLIPSE; + EmfRecordTypeRectangle = EMR_RECTANGLE; + EmfRecordTypeRoundRect = EMR_ROUNDRECT; + EmfRecordTypeArc = EMR_ARC; + EmfRecordTypeChord = EMR_CHORD; + EmfRecordTypePie = EMR_PIE; + EmfRecordTypeSelectPalette = EMR_SELECTPALETTE; + EmfRecordTypeCreatePalette = EMR_CREATEPALETTE; + EmfRecordTypeSetPaletteEntries = EMR_SETPALETTEENTRIES; + EmfRecordTypeResizePalette = EMR_RESIZEPALETTE; + EmfRecordTypeRealizePalette = EMR_REALIZEPALETTE; + EmfRecordTypeExtFloodFill = EMR_EXTFLOODFILL; + EmfRecordTypeLineTo = EMR_LINETO; + EmfRecordTypeArcTo = EMR_ARCTO; + EmfRecordTypePolyDraw = EMR_POLYDRAW; + EmfRecordTypeSetArcDirection = EMR_SETARCDIRECTION; + EmfRecordTypeSetMiterLimit = EMR_SETMITERLIMIT; + EmfRecordTypeBeginPath = EMR_BEGINPATH; + EmfRecordTypeEndPath = EMR_ENDPATH; + EmfRecordTypeCloseFigure = EMR_CLOSEFIGURE; + EmfRecordTypeFillPath = EMR_FILLPATH; + EmfRecordTypeStrokeAndFillPath = EMR_STROKEANDFILLPATH; + EmfRecordTypeStrokePath = EMR_STROKEPATH; + EmfRecordTypeFlattenPath = EMR_FLATTENPATH; + EmfRecordTypeWidenPath = EMR_WIDENPATH; + EmfRecordTypeSelectClipPath = EMR_SELECTCLIPPATH; + EmfRecordTypeAbortPath = EMR_ABORTPATH; + EmfRecordTypeReserved_069 = 69; // Not Used + EmfRecordTypeGdiComment = EMR_GDICOMMENT; + EmfRecordTypeFillRgn = EMR_FILLRGN; + EmfRecordTypeFrameRgn = EMR_FRAMERGN; + EmfRecordTypeInvertRgn = EMR_INVERTRGN; + EmfRecordTypePaintRgn = EMR_PAINTRGN; + EmfRecordTypeExtSelectClipRgn = EMR_EXTSELECTCLIPRGN; + EmfRecordTypeBitBlt = EMR_BITBLT; + EmfRecordTypeStretchBlt = EMR_STRETCHBLT; + EmfRecordTypeMaskBlt = EMR_MASKBLT; + EmfRecordTypePlgBlt = EMR_PLGBLT; + EmfRecordTypeSetDIBitsToDevice = EMR_SETDIBITSTODEVICE; + EmfRecordTypeStretchDIBits = EMR_STRETCHDIBITS; + EmfRecordTypeExtCreateFontIndirect = EMR_EXTCREATEFONTINDIRECTW; + EmfRecordTypeExtTextOutA = EMR_EXTTEXTOUTA; + EmfRecordTypeExtTextOutW = EMR_EXTTEXTOUTW; + EmfRecordTypePolyBezier16 = EMR_POLYBEZIER16; + EmfRecordTypePolygon16 = EMR_POLYGON16; + EmfRecordTypePolyline16 = EMR_POLYLINE16; + EmfRecordTypePolyBezierTo16 = EMR_POLYBEZIERTO16; + EmfRecordTypePolylineTo16 = EMR_POLYLINETO16; + EmfRecordTypePolyPolyline16 = EMR_POLYPOLYLINE16; + EmfRecordTypePolyPolygon16 = EMR_POLYPOLYGON16; + EmfRecordTypePolyDraw16 = EMR_POLYDRAW16; + EmfRecordTypeCreateMonoBrush = EMR_CREATEMONOBRUSH; + EmfRecordTypeCreateDIBPatternBrushPt = EMR_CREATEDIBPATTERNBRUSHPT; + EmfRecordTypeExtCreatePen = EMR_EXTCREATEPEN; + EmfRecordTypePolyTextOutA = EMR_POLYTEXTOUTA; + EmfRecordTypePolyTextOutW = EMR_POLYTEXTOUTW; + EmfRecordTypeSetICMMode = 98; // EMR_SETICMMODE, + EmfRecordTypeCreateColorSpace = 99; // EMR_CREATECOLORSPACE, + EmfRecordTypeSetColorSpace = 100; // EMR_SETCOLORSPACE, + EmfRecordTypeDeleteColorSpace = 101; // EMR_DELETECOLORSPACE, + EmfRecordTypeGLSRecord = 102; // EMR_GLSRECORD, + EmfRecordTypeGLSBoundedRecord = 103; // EMR_GLSBOUNDEDRECORD, + EmfRecordTypePixelFormat = 104; // EMR_PIXELFORMAT, + EmfRecordTypeDrawEscape = 105; // EMR_RESERVED_105, + EmfRecordTypeExtEscape = 106; // EMR_RESERVED_106, + EmfRecordTypeStartDoc = 107; // EMR_RESERVED_107, + EmfRecordTypeSmallTextOut = 108; // EMR_RESERVED_108, + EmfRecordTypeForceUFIMapping = 109; // EMR_RESERVED_109, + EmfRecordTypeNamedEscape = 110; // EMR_RESERVED_110, + EmfRecordTypeColorCorrectPalette = 111; // EMR_COLORCORRECTPALETTE, + EmfRecordTypeSetICMProfileA = 112; // EMR_SETICMPROFILEA, + EmfRecordTypeSetICMProfileW = 113; // EMR_SETICMPROFILEW, + EmfRecordTypeAlphaBlend = 114; // EMR_ALPHABLEND, + EmfRecordTypeSetLayout = 115; // EMR_SETLAYOUT, + EmfRecordTypeTransparentBlt = 116; // EMR_TRANSPARENTBLT, + EmfRecordTypeReserved_117 = 117; // Not Used + EmfRecordTypeGradientFill = 118; // EMR_GRADIENTFILL, + EmfRecordTypeSetLinkedUFIs = 119; // EMR_RESERVED_119, + EmfRecordTypeSetTextJustification = 120; // EMR_RESERVED_120, + EmfRecordTypeColorMatchToTargetW = 121; // EMR_COLORMATCHTOTARGETW, + EmfRecordTypeCreateColorSpaceW = 122; // EMR_CREATECOLORSPACEW, + EmfRecordTypeMax = 122; + EmfRecordTypeMin = 1; + + // That is the END of the GDI EMF records. + + // Now we start the list of EMF+ records. We leave quite + // a bit of room here for the addition of any new GDI + // records that may be added later. + + EmfPlusRecordTypeInvalid = GDIP_EMFPLUS_RECORD_BASE; + EmfPlusRecordTypeHeader = GDIP_EMFPLUS_RECORD_BASE + 1; + EmfPlusRecordTypeEndOfFile = GDIP_EMFPLUS_RECORD_BASE + 2; + + EmfPlusRecordTypeComment = GDIP_EMFPLUS_RECORD_BASE + 3; + + EmfPlusRecordTypeGetDC = GDIP_EMFPLUS_RECORD_BASE + 4; + + EmfPlusRecordTypeMultiFormatStart = GDIP_EMFPLUS_RECORD_BASE + 5; + EmfPlusRecordTypeMultiFormatSection = GDIP_EMFPLUS_RECORD_BASE + 6; + EmfPlusRecordTypeMultiFormatEnd = GDIP_EMFPLUS_RECORD_BASE + 7; + + // For all persistent objects + + EmfPlusRecordTypeObject = GDIP_EMFPLUS_RECORD_BASE + 8; + + // Drawing Records + + EmfPlusRecordTypeClear = GDIP_EMFPLUS_RECORD_BASE + 9; + EmfPlusRecordTypeFillRects = GDIP_EMFPLUS_RECORD_BASE + 10; + EmfPlusRecordTypeDrawRects = GDIP_EMFPLUS_RECORD_BASE + 11; + EmfPlusRecordTypeFillPolygon = GDIP_EMFPLUS_RECORD_BASE + 12; + EmfPlusRecordTypeDrawLines = GDIP_EMFPLUS_RECORD_BASE + 13; + EmfPlusRecordTypeFillEllipse = GDIP_EMFPLUS_RECORD_BASE + 14; + EmfPlusRecordTypeDrawEllipse = GDIP_EMFPLUS_RECORD_BASE + 15; + EmfPlusRecordTypeFillPie = GDIP_EMFPLUS_RECORD_BASE + 16; + EmfPlusRecordTypeDrawPie = GDIP_EMFPLUS_RECORD_BASE + 17; + EmfPlusRecordTypeDrawArc = GDIP_EMFPLUS_RECORD_BASE + 18; + EmfPlusRecordTypeFillRegion = GDIP_EMFPLUS_RECORD_BASE + 19; + EmfPlusRecordTypeFillPath = GDIP_EMFPLUS_RECORD_BASE + 20; + EmfPlusRecordTypeDrawPath = GDIP_EMFPLUS_RECORD_BASE + 21; + EmfPlusRecordTypeFillClosedCurve = GDIP_EMFPLUS_RECORD_BASE + 22; + EmfPlusRecordTypeDrawClosedCurve = GDIP_EMFPLUS_RECORD_BASE + 23; + EmfPlusRecordTypeDrawCurve = GDIP_EMFPLUS_RECORD_BASE + 24; + EmfPlusRecordTypeDrawBeziers = GDIP_EMFPLUS_RECORD_BASE + 25; + EmfPlusRecordTypeDrawImage = GDIP_EMFPLUS_RECORD_BASE + 26; + EmfPlusRecordTypeDrawImagePoints = GDIP_EMFPLUS_RECORD_BASE + 27; + EmfPlusRecordTypeDrawString = GDIP_EMFPLUS_RECORD_BASE + 28; + + // Graphics State Records + + EmfPlusRecordTypeSetRenderingOrigin = GDIP_EMFPLUS_RECORD_BASE + 29; + EmfPlusRecordTypeSetAntiAliasMode = GDIP_EMFPLUS_RECORD_BASE + 30; + EmfPlusRecordTypeSetTextRenderingHint = GDIP_EMFPLUS_RECORD_BASE + 31; + EmfPlusRecordTypeSetTextContrast = GDIP_EMFPLUS_RECORD_BASE + 32; + EmfPlusRecordTypeSetInterpolationMode = GDIP_EMFPLUS_RECORD_BASE + 33; + EmfPlusRecordTypeSetPixelOffsetMode = GDIP_EMFPLUS_RECORD_BASE + 34; + EmfPlusRecordTypeSetCompositingMode = GDIP_EMFPLUS_RECORD_BASE + 35; + EmfPlusRecordTypeSetCompositingQuality = GDIP_EMFPLUS_RECORD_BASE + 36; + EmfPlusRecordTypeSave = GDIP_EMFPLUS_RECORD_BASE + 37; + EmfPlusRecordTypeRestore = GDIP_EMFPLUS_RECORD_BASE + 38; + EmfPlusRecordTypeBeginContainer = GDIP_EMFPLUS_RECORD_BASE + 39; + EmfPlusRecordTypeBeginContainerNoParams = GDIP_EMFPLUS_RECORD_BASE + 40; + EmfPlusRecordTypeEndContainer = GDIP_EMFPLUS_RECORD_BASE + 41; + EmfPlusRecordTypeSetWorldTransform = GDIP_EMFPLUS_RECORD_BASE + 42; + EmfPlusRecordTypeResetWorldTransform = GDIP_EMFPLUS_RECORD_BASE + 43; + EmfPlusRecordTypeMultiplyWorldTransform = GDIP_EMFPLUS_RECORD_BASE + 44; + EmfPlusRecordTypeTranslateWorldTransform = GDIP_EMFPLUS_RECORD_BASE + 45; + EmfPlusRecordTypeScaleWorldTransform = GDIP_EMFPLUS_RECORD_BASE + 46; + EmfPlusRecordTypeRotateWorldTransform = GDIP_EMFPLUS_RECORD_BASE + 47; + EmfPlusRecordTypeSetPageTransform = GDIP_EMFPLUS_RECORD_BASE + 48; + EmfPlusRecordTypeResetClip = GDIP_EMFPLUS_RECORD_BASE + 49; + EmfPlusRecordTypeSetClipRect = GDIP_EMFPLUS_RECORD_BASE + 50; + EmfPlusRecordTypeSetClipPath = GDIP_EMFPLUS_RECORD_BASE + 51; + EmfPlusRecordTypeSetClipRegion = GDIP_EMFPLUS_RECORD_BASE + 52; + EmfPlusRecordTypeOffsetClip = GDIP_EMFPLUS_RECORD_BASE + 53; + + EmfPlusRecordTypeDrawDriverString = GDIP_EMFPLUS_RECORD_BASE + 54; + + EmfPlusRecordTotal = GDIP_EMFPLUS_RECORD_BASE + 55; + + EmfPlusRecordTypeMax = EmfPlusRecordTotal-1; + EmfPlusRecordTypeMin = EmfPlusRecordTypeHeader; + +type + TEmfPlusRecordType = EmfPlusRecordType; +{$ENDIF} +//--------------------------------------------------------------------------- +// StringFormatFlags +//--------------------------------------------------------------------------- + +//--------------------------------------------------------------------------- +// String format flags +// +// DirectionRightToLeft - For horizontal text, the reading order is +// right to left. This value is called +// the base embedding level by the Unicode +// bidirectional engine. +// For vertical text, columns are read from +// right to left. +// By default, horizontal or vertical text is +// read from left to right. +// +// DirectionVertical - Individual lines of text are vertical. In +// each line, characters progress from top to +// bottom. +// By default, lines of text are horizontal, +// each new line below the previous line. +// +// NoFitBlackBox - Allows parts of glyphs to overhang the +// bounding rectangle. +// By default glyphs are first aligned +// inside the margines, then any glyphs which +// still overhang the bounding box are +// repositioned to avoid any overhang. +// For example when an italic +// lower case letter f in a font such as +// Garamond is aligned at the far left of a +// rectangle, the lower part of the f will +// reach slightly further left than the left +// edge of the rectangle. Setting this flag +// will ensure the character aligns visually +// with the lines above and below, but may +// cause some pixels outside the formatting +// rectangle to be clipped or painted. +// +// DisplayFormatControl - Causes control characters such as the +// left-to-right mark to be shown in the +// output with a representative glyph. +// +// NoFontFallback - Disables fallback to alternate fonts for +// characters not supported in the requested +// font. Any missing characters will be +// be displayed with the fonts missing glyph, +// usually an open square. +// +// NoWrap - Disables wrapping of text between lines +// when formatting within a rectangle. +// NoWrap is implied when a point is passed +// instead of a rectangle, or when the +// specified rectangle has a zero line length. +// +// NoClip - By default text is clipped to the +// formatting rectangle. Setting NoClip +// allows overhanging pixels to affect the +// device outside the formatting rectangle. +// Pixels at the end of the line may be +// affected if the glyphs overhang their +// cells, and either the NoFitBlackBox flag +// has been set, or the glyph extends to far +// to be fitted. +// Pixels above/before the first line or +// below/after the last line may be affected +// if the glyphs extend beyond their cell +// ascent / descent. This can occur rarely +// with unusual diacritic mark combinations. + +//--------------------------------------------------------------------------- + + {$EXTERNALSYM StringFormatFlags} + StringFormatFlags = Integer; + const + StringFormatFlagsDirectionRightToLeft = $00000001; + StringFormatFlagsDirectionVertical = $00000002; + StringFormatFlagsNoFitBlackBox = $00000004; + StringFormatFlagsDisplayFormatControl = $00000020; + StringFormatFlagsNoFontFallback = $00000400; + StringFormatFlagsMeasureTrailingSpaces = $00000800; + StringFormatFlagsNoWrap = $00001000; + StringFormatFlagsLineLimit = $00002000; + + StringFormatFlagsNoClip = $00004000; + +Type + TStringFormatFlags = StringFormatFlags; + +//--------------------------------------------------------------------------- +// StringTrimming +//--------------------------------------------------------------------------- + + {$EXTERNALSYM StringTrimming} + StringTrimming = ( + StringTrimmingNone, + StringTrimmingCharacter, + StringTrimmingWord, + StringTrimmingEllipsisCharacter, + StringTrimmingEllipsisWord, + StringTrimmingEllipsisPath + ); + TStringTrimming = StringTrimming; + +//--------------------------------------------------------------------------- +// National language digit substitution +//--------------------------------------------------------------------------- + + {$EXTERNALSYM StringDigitSubstitute} + StringDigitSubstitute = ( + StringDigitSubstituteUser, // As NLS setting + StringDigitSubstituteNone, + StringDigitSubstituteNational, + StringDigitSubstituteTraditional + ); + TStringDigitSubstitute = StringDigitSubstitute; + PStringDigitSubstitute = ^TStringDigitSubstitute; + +//--------------------------------------------------------------------------- +// Hotkey prefix interpretation +//--------------------------------------------------------------------------- + + {$EXTERNALSYM HotkeyPrefix} + HotkeyPrefix = ( + HotkeyPrefixNone, + HotkeyPrefixShow, + HotkeyPrefixHide + ); + THotkeyPrefix = HotkeyPrefix; + +//--------------------------------------------------------------------------- +// String alignment flags +//--------------------------------------------------------------------------- + + {$EXTERNALSYM StringAlignment} + StringAlignment = ( + // Left edge for left-to-right text, + // right for right-to-left text, + // and top for vertical + StringAlignmentNear, + StringAlignmentCenter, + StringAlignmentFar + ); + TStringAlignment = StringAlignment; + +//--------------------------------------------------------------------------- +// DriverStringOptions +//--------------------------------------------------------------------------- + + {$EXTERNALSYM DriverStringOptions} + DriverStringOptions = Integer; + const + DriverStringOptionsCmapLookup = 1; + DriverStringOptionsVertical = 2; + DriverStringOptionsRealizedAdvance = 4; + DriverStringOptionsLimitSubpixel = 8; + +type + TDriverStringOptions = DriverStringOptions; + +//--------------------------------------------------------------------------- +// Flush Intention flags +//--------------------------------------------------------------------------- + + {$EXTERNALSYM FlushIntention} + FlushIntention = ( + FlushIntentionFlush, // Flush all batched rendering operations + FlushIntentionSync // Flush all batched rendering operations + // and wait for them to complete + ); + TFlushIntention = FlushIntention; + +//--------------------------------------------------------------------------- +// Image encoder parameter related types +//--------------------------------------------------------------------------- + + {$EXTERNALSYM EncoderParameterValueType} + EncoderParameterValueType = Integer; + const + EncoderParameterValueTypeByte : Integer = 1; // 8-bit unsigned int + EncoderParameterValueTypeASCII : Integer = 2; // 8-bit byte containing one 7-bit ASCII + // code. NULL terminated. + EncoderParameterValueTypeShort : Integer = 3; // 16-bit unsigned int + EncoderParameterValueTypeLong : Integer = 4; // 32-bit unsigned int + EncoderParameterValueTypeRational : Integer = 5; // Two Longs. The first Long is the + // numerator, the second Long expresses the + // denomintor. + EncoderParameterValueTypeLongRange : Integer = 6; // Two longs which specify a range of + // integer values. The first Long specifies + // the lower end and the second one + // specifies the higher end. All values + // are inclusive at both ends + EncoderParameterValueTypeUndefined : Integer = 7; // 8-bit byte that can take any value + // depending on field definition + EncoderParameterValueTypeRationalRange : Integer = 8; // Two Rationals. The first Rational + // specifies the lower end and the second + // specifies the higher end. All values + // are inclusive at both ends +type + TEncoderParameterValueType = EncoderParameterValueType; + +//--------------------------------------------------------------------------- +// Image encoder value types +//--------------------------------------------------------------------------- + + {$EXTERNALSYM EncoderValue} + EncoderValue = ( + EncoderValueColorTypeCMYK, + EncoderValueColorTypeYCCK, + EncoderValueCompressionLZW, + EncoderValueCompressionCCITT3, + EncoderValueCompressionCCITT4, + EncoderValueCompressionRle, + EncoderValueCompressionNone, + EncoderValueScanMethodInterlaced, + EncoderValueScanMethodNonInterlaced, + EncoderValueVersionGif87, + EncoderValueVersionGif89, + EncoderValueRenderProgressive, + EncoderValueRenderNonProgressive, + EncoderValueTransformRotate90, + EncoderValueTransformRotate180, + EncoderValueTransformRotate270, + EncoderValueTransformFlipHorizontal, + EncoderValueTransformFlipVertical, + EncoderValueMultiFrame, + EncoderValueLastFrame, + EncoderValueFlush, + EncoderValueFrameDimensionTime, + EncoderValueFrameDimensionResolution, + EncoderValueFrameDimensionPage + ); + TEncoderValue = EncoderValue; + +//--------------------------------------------------------------------------- +// Conversion of Emf To WMF Bits flags +//--------------------------------------------------------------------------- +{$IFDEF DELPHI6_UP} + {$EXTERNALSYM EmfToWmfBitsFlags} + EmfToWmfBitsFlags = ( + EmfToWmfBitsFlagsDefault = $00000000, + EmfToWmfBitsFlagsEmbedEmf = $00000001, + EmfToWmfBitsFlagsIncludePlaceable = $00000002, + EmfToWmfBitsFlagsNoXORClip = $00000004 + ); + TEmfToWmfBitsFlags = EmfToWmfBitsFlags; +{$ELSE} + {$EXTERNALSYM EmfToWmfBitsFlags} + EmfToWmfBitsFlags = Integer; + const + EmfToWmfBitsFlagsDefault = $00000000; + EmfToWmfBitsFlagsEmbedEmf = $00000001; + EmfToWmfBitsFlagsIncludePlaceable = $00000002; + EmfToWmfBitsFlagsNoXORClip = $00000004; + +type + TEmfToWmfBitsFlags = EmfToWmfBitsFlags; +{$ENDIF} +(**************************************************************************\ +* +* GDI+ Types +* +\**************************************************************************) + +//-------------------------------------------------------------------------- +// Callback functions +//-------------------------------------------------------------------------- + + {$EXTERNALSYM ImageAbort} + ImageAbort = function: BOOL; stdcall; + {$EXTERNALSYM DrawImageAbort} + DrawImageAbort = ImageAbort; + {$EXTERNALSYM GetThumbnailImageAbort} + GetThumbnailImageAbort = ImageAbort; + + + // Callback for EnumerateMetafile methods. The parameters are: + + // recordType WMF, EMF, or EMF+ record type + // flags (always 0 for WMF/EMF records) + // dataSize size of the record data (in bytes), or 0 if no data + // data pointer to the record data, or NULL if no data + // callbackData pointer to callbackData, if any + + // This method can then call Metafile::PlayRecord to play the + // record that was just enumerated. If this method returns + // FALSE, the enumeration process is aborted. Otherwise, it continues. + + {$EXTERNALSYM EnumerateMetafileProc} + EnumerateMetafileProc = function(recordType: EmfPlusRecordType; flags: UINT; + dataSize: UINT; data: PBYTE; callbackData: pointer): BOOL; stdcall; + +//-------------------------------------------------------------------------- +// Primitive data types +// +// NOTE: +// Types already defined in standard header files: +// INT8 +// UINT8 +// INT16 +// UINT16 +// INT32 +// UINT32 +// INT64 +// UINT64 +// +// Avoid using the following types: +// LONG - use INT +// ULONG - use UINT +// DWORD - use UINT32 +//-------------------------------------------------------------------------- + +const + { from float.h } + FLT_MAX = 3.402823466e+38; // max value + FLT_MIN = 1.175494351e-38; // min positive value + + REAL_MAX = FLT_MAX; + {$EXTERNALSYM REAL_MAX} + REAL_MIN = FLT_MIN; + {$EXTERNALSYM REAL_MIN} + REAL_TOLERANCE = (FLT_MIN * 100); + {$EXTERNALSYM REAL_TOLERANCE} + REAL_EPSILON = 1.192092896e-07; // FLT_EPSILON + {$EXTERNALSYM REAL_EPSILON} + +//-------------------------------------------------------------------------- +// Status return values from GDI+ methods +//-------------------------------------------------------------------------- +type + {$EXTERNALSYM Status} + Status = ( + Ok, + GenericError, + InvalidParameter, + OutOfMemory, + ObjectBusy, + InsufficientBuffer, + NotImplemented, + Win32Error, + WrongState, + Aborted, + FileNotFound, + ValueOverflow, + AccessDenied, + UnknownImageFormat, + FontFamilyNotFound, + FontStyleNotFound, + NotTrueTypeFont, + UnsupportedGdiplusVersion, + GdiplusNotInitialized, + PropertyNotFound, + PropertyNotSupported + ); + TStatus = Status; + +//-------------------------------------------------------------------------- +// Represents a dimension in a 2D coordinate system (floating-point coordinates) +//-------------------------------------------------------------------------- + +type + PGPSizeF = ^TGPSizeF; + TGPSizeF = packed record + Width : Single; + Height : Single; + end; + + function MakeSize(Width, Height: Single): TGPSizeF; overload; + +//-------------------------------------------------------------------------- +// Represents a dimension in a 2D coordinate system (integer coordinates) +//-------------------------------------------------------------------------- + +type + PGPSize = ^TGPSize; + TGPSize = packed record + Width : Integer; + Height : Integer; + end; + + function MakeSize(Width, Height: Integer): TGPSize; overload; + +//-------------------------------------------------------------------------- +// Represents a location in a 2D coordinate system (floating-point coordinates) +//-------------------------------------------------------------------------- + +type + PGPPointF = ^TGPPointF; + TGPPointF = packed record + X : Single; + Y : Single; + end; + TPointFDynArray = array of TGPPointF; + + function MakePoint(X, Y: Single): TGPPointF; overload; + +//-------------------------------------------------------------------------- +// Represents a location in a 2D coordinate system (integer coordinates) +//-------------------------------------------------------------------------- + +type + PGPPoint = ^TGPPoint; + TGPPoint = packed record + X : Integer; + Y : Integer; + end; + TPointDynArray = array of TGPPoint; + + function MakePoint(X, Y: Integer): TGPPoint; overload; + +//-------------------------------------------------------------------------- +// Represents a rectangle in a 2D coordinate system (floating-point coordinates) +//-------------------------------------------------------------------------- + +type + PGPRectF = ^TGPRectF; + TGPRectF = packed record + X : Single; + Y : Single; + Width : Single; + Height: Single; + end; + TRectFDynArray = array of TGPRectF; + + function MakeRect(x, y, width, height: Single): TGPRectF; overload; + function MakeRect(location: TGPPointF; size: TGPSizeF): TGPRectF; overload; + +type + PGPRect = ^TGPRect; + TGPRect = packed record + X : Integer; + Y : Integer; + Width : Integer; + Height: Integer; + end; + TRectDynArray = array of TGPRect; + + function MakeRect(x, y, width, height: Integer): TGPRect; overload; + function MakeRect(location: TGPPoint; size: TGPSize): TGPRect; overload; + function MakeRect(const Rect: TRect): TGPRect; overload; + +type + TPathData = packed class + public + Count : Integer; + Points : PGPPointF; + Types : PBYTE; + constructor Create; + destructor destroy; override; + end; + + PCharacterRange = ^TCharacterRange; + TCharacterRange = packed record + First : Integer; + Length : Integer; + end; + + function MakeCharacterRange(First, Length: Integer): TCharacterRange; + +(************************************************************************** +* +* GDI+ Startup and Shutdown APIs +* +**************************************************************************) +type + {$EXTERNALSYM DebugEventLevel} + DebugEventLevel = ( + DebugEventLevelFatal, + DebugEventLevelWarning + ); + TDebugEventLevel = DebugEventLevel; + + // Callback function that GDI+ can call, on debug builds, for assertions + // and warnings. + + {$EXTERNALSYM DebugEventProc} + DebugEventProc = procedure(level: DebugEventLevel; message: PChar); stdcall; + + // Notification functions which the user must call appropriately if + // "SuppressBackgroundThread" (below) is set. + + {$EXTERNALSYM NotificationHookProc} + NotificationHookProc = function(out token: ULONG): Status; stdcall; + {$EXTERNALSYM NotificationUnhookProc} + NotificationUnhookProc = procedure(token: ULONG); stdcall; + + // Input structure for GdiplusStartup + + {$EXTERNALSYM GdiplusStartupInput} + GdiplusStartupInput = packed record + GdiplusVersion : Cardinal; // Must be 1 + DebugEventCallback : DebugEventProc; // Ignored on free builds + SuppressBackgroundThread: BOOL; // FALSE unless you're prepared to call + // the hook/unhook functions properly + SuppressExternalCodecs : BOOL; // FALSE unless you want GDI+ only to use + end; // its internal image codecs. + TGdiplusStartupInput = GdiplusStartupInput; + PGdiplusStartupInput = ^TGdiplusStartupInput; + + // Output structure for GdiplusStartup() + + {$EXTERNALSYM GdiplusStartupOutput} + GdiplusStartupOutput = packed record + // The following 2 fields are NULL if SuppressBackgroundThread is FALSE. + // Otherwise, they are functions which must be called appropriately to + // replace the background thread. + // + // These should be called on the application's main message loop - i.e. + // a message loop which is active for the lifetime of GDI+. + // "NotificationHook" should be called before starting the loop, + // and "NotificationUnhook" should be called after the loop ends. + + NotificationHook : NotificationHookProc; + NotificationUnhook: NotificationUnhookProc; + end; + TGdiplusStartupOutput = GdiplusStartupOutput; + PGdiplusStartupOutput = ^TGdiplusStartupOutput; + + // GDI+ initialization. Must not be called from DllMain - can cause deadlock. + // + // Must be called before GDI+ API's or constructors are used. + // + // token - may not be NULL - accepts a token to be passed in the corresponding + // GdiplusShutdown call. + // input - may not be NULL + // output - may be NULL only if input->SuppressBackgroundThread is FALSE. + + {$EXTERNALSYM GdiplusStartup} + function GdiplusStartup(out token: ULONG; input: PGdiplusStartupInput; + output: PGdiplusStartupOutput): Status; stdcall; + + // GDI+ termination. Must be called before GDI+ is unloaded. + // Must not be called from DllMain - can cause deadlock. + // + // GDI+ API's may not be called after GdiplusShutdown. Pay careful attention + // to GDI+ object destructors. + + {$EXTERNALSYM GdiplusShutdown} + procedure GdiplusShutdown(token: ULONG); stdcall; + + +(**************************************************************************\ +* +* Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved. +* Module Name: +* Gdiplus Pixel Formats +* Abstract: +* GDI+ Pixel Formats +* +\**************************************************************************) + +type + PARGB = ^ARGB; + ARGB = DWORD; + {$EXTERNALSYM ARGB} + ARGB64 = Int64; + {$EXTERNALSYM ARGB64} + +const + ALPHA_SHIFT = 24; + {$EXTERNALSYM ALPHA_SHIFT} + RED_SHIFT = 16; + {$EXTERNALSYM RED_SHIFT} + GREEN_SHIFT = 8; + {$EXTERNALSYM GREEN_SHIFT} + BLUE_SHIFT = 0; + {$EXTERNALSYM BLUE_SHIFT} + ALPHA_MASK = (ARGB($ff) shl ALPHA_SHIFT); + {$EXTERNALSYM ALPHA_MASK} + + // In-memory pixel data formats: + // bits 0-7 = format index + // bits 8-15 = pixel size (in bits) + // bits 16-23 = flags + // bits 24-31 = reserved + +type + PixelFormat = Integer; + {$EXTERNALSYM PixelFormat} + TPixelFormat = PixelFormat; + +const + PixelFormatIndexed = $00010000; // Indexes into a palette + {$EXTERNALSYM PixelFormatIndexed} + PixelFormatGDI = $00020000; // Is a GDI-supported format + {$EXTERNALSYM PixelFormatGDI} + PixelFormatAlpha = $00040000; // Has an alpha component + {$EXTERNALSYM PixelFormatAlpha} + PixelFormatPAlpha = $00080000; // Pre-multiplied alpha + {$EXTERNALSYM PixelFormatPAlpha} + PixelFormatExtended = $00100000; // Extended color 16 bits/channel + {$EXTERNALSYM PixelFormatExtended} + PixelFormatCanonical = $00200000; + {$EXTERNALSYM PixelFormatCanonical} + + PixelFormatUndefined = 0; + {$EXTERNALSYM PixelFormatUndefined} + PixelFormatDontCare = 0; + {$EXTERNALSYM PixelFormatDontCare} + + PixelFormat1bppIndexed = (1 or ( 1 shl 8) or PixelFormatIndexed or PixelFormatGDI); + {$EXTERNALSYM PixelFormat1bppIndexed} + PixelFormat4bppIndexed = (2 or ( 4 shl 8) or PixelFormatIndexed or PixelFormatGDI); + {$EXTERNALSYM PixelFormat4bppIndexed} + PixelFormat8bppIndexed = (3 or ( 8 shl 8) or PixelFormatIndexed or PixelFormatGDI); + {$EXTERNALSYM PixelFormat8bppIndexed} + PixelFormat16bppGrayScale = (4 or (16 shl 8) or PixelFormatExtended); + {$EXTERNALSYM PixelFormat16bppGrayScale} + PixelFormat16bppRGB555 = (5 or (16 shl 8) or PixelFormatGDI); + {$EXTERNALSYM PixelFormat16bppRGB555} + PixelFormat16bppRGB565 = (6 or (16 shl 8) or PixelFormatGDI); + {$EXTERNALSYM PixelFormat16bppRGB565} + PixelFormat16bppARGB1555 = (7 or (16 shl 8) or PixelFormatAlpha or PixelFormatGDI); + {$EXTERNALSYM PixelFormat16bppARGB1555} + PixelFormat24bppRGB = (8 or (24 shl 8) or PixelFormatGDI); + {$EXTERNALSYM PixelFormat24bppRGB} + PixelFormat32bppRGB = (9 or (32 shl 8) or PixelFormatGDI); + {$EXTERNALSYM PixelFormat32bppRGB} + PixelFormat32bppARGB = (10 or (32 shl 8) or PixelFormatAlpha or PixelFormatGDI or PixelFormatCanonical); + {$EXTERNALSYM PixelFormat32bppARGB} + PixelFormat32bppPARGB = (11 or (32 shl 8) or PixelFormatAlpha or PixelFormatPAlpha or PixelFormatGDI); + {$EXTERNALSYM PixelFormat32bppPARGB} + PixelFormat48bppRGB = (12 or (48 shl 8) or PixelFormatExtended); + {$EXTERNALSYM PixelFormat48bppRGB} + PixelFormat64bppARGB = (13 or (64 shl 8) or PixelFormatAlpha or PixelFormatCanonical or PixelFormatExtended); + {$EXTERNALSYM PixelFormat64bppARGB} + PixelFormat64bppPARGB = (14 or (64 shl 8) or PixelFormatAlpha or PixelFormatPAlpha or PixelFormatExtended); + {$EXTERNALSYM PixelFormat64bppPARGB} + PixelFormatMax = 15; + {$EXTERNALSYM PixelFormatMax} + +{$EXTERNALSYM GetPixelFormatSize} +function GetPixelFormatSize(pixfmt: PixelFormat): UINT; +{$EXTERNALSYM IsIndexedPixelFormat} +function IsIndexedPixelFormat(pixfmt: PixelFormat): BOOL; +{$EXTERNALSYM IsAlphaPixelFormat} +function IsAlphaPixelFormat(pixfmt: PixelFormat): BOOL; +{$EXTERNALSYM IsExtendedPixelFormat} +function IsExtendedPixelFormat(pixfmt: PixelFormat): BOOL; + +//-------------------------------------------------------------------------- +// Determine if the Pixel Format is Canonical format: +// PixelFormat32bppARGB +// PixelFormat32bppPARGB +// PixelFormat64bppARGB +// PixelFormat64bppPARGB +//-------------------------------------------------------------------------- + +{$EXTERNALSYM IsCanonicalPixelFormat} +function IsCanonicalPixelFormat(pixfmt: PixelFormat): BOOL; + +{$IFDEF DELPHI6_UP} +type + {$EXTERNALSYM PaletteFlags} + PaletteFlags = ( + PaletteFlagsHasAlpha = $0001, + PaletteFlagsGrayScale = $0002, + PaletteFlagsHalftone = $0004 + ); + TPaletteFlags = PaletteFlags; +{$ELSE} +type + {$EXTERNALSYM PaletteFlags} + PaletteFlags = Integer; + const + PaletteFlagsHasAlpha = $0001; + PaletteFlagsGrayScale = $0002; + PaletteFlagsHalftone = $0004; + +type + TPaletteFlags = PaletteFlags; +{$ENDIF} + + {$EXTERNALSYM ColorPalette} + ColorPalette = packed record + Flags : UINT ; // Palette flags + Count : UINT ; // Number of color entries + Entries: array [0..0] of ARGB ; // Palette color entries + end; + + TColorPalette = ColorPalette; + PColorPalette = ^TColorPalette; + +(**************************************************************************\ +* +* GDI+ Color Object +* +\**************************************************************************) + +//---------------------------------------------------------------------------- +// Color mode +//---------------------------------------------------------------------------- + + {$EXTERNALSYM ColorMode} + ColorMode = ( + ColorModeARGB32, + ColorModeARGB64 + ); + TColorMode = ColorMode; + +//---------------------------------------------------------------------------- +// Color Channel flags +//---------------------------------------------------------------------------- + + {$EXTERNALSYM ColorChannelFlags} + ColorChannelFlags = ( + ColorChannelFlagsC, + ColorChannelFlagsM, + ColorChannelFlagsY, + ColorChannelFlagsK, + ColorChannelFlagsLast + ); + TColorChannelFlags = ColorChannelFlags; + +//---------------------------------------------------------------------------- +// Color +//---------------------------------------------------------------------------- + + // Common color constants +const + aclAliceBlue = $FFF0F8FF; + aclAntiqueWhite = $FFFAEBD7; + aclAqua = $FF00FFFF; + aclAquamarine = $FF7FFFD4; + aclAzure = $FFF0FFFF; + aclBeige = $FFF5F5DC; + aclBisque = $FFFFE4C4; + aclBlack = $FF000000; + aclBlanchedAlmond = $FFFFEBCD; + aclBlue = $FF0000FF; + aclBlueViolet = $FF8A2BE2; + aclBrown = $FFA52A2A; + aclBurlyWood = $FFDEB887; + aclCadetBlue = $FF5F9EA0; + aclChartreuse = $FF7FFF00; + aclChocolate = $FFD2691E; + aclCoral = $FFFF7F50; + aclCornflowerBlue = $FF6495ED; + aclCornsilk = $FFFFF8DC; + aclCrimson = $FFDC143C; + aclCyan = $FF00FFFF; + aclDarkBlue = $FF00008B; + aclDarkCyan = $FF008B8B; + aclDarkGoldenrod = $FFB8860B; + aclDarkGray = $FFA9A9A9; + aclDarkGreen = $FF006400; + aclDarkKhaki = $FFBDB76B; + aclDarkMagenta = $FF8B008B; + aclDarkOliveGreen = $FF556B2F; + aclDarkOrange = $FFFF8C00; + aclDarkOrchid = $FF9932CC; + aclDarkRed = $FF8B0000; + aclDarkSalmon = $FFE9967A; + aclDarkSeaGreen = $FF8FBC8B; + aclDarkSlateBlue = $FF483D8B; + aclDarkSlateGray = $FF2F4F4F; + aclDarkTurquoise = $FF00CED1; + aclDarkViolet = $FF9400D3; + aclDeepPink = $FFFF1493; + aclDeepSkyBlue = $FF00BFFF; + aclDimGray = $FF696969; + aclDodgerBlue = $FF1E90FF; + aclFirebrick = $FFB22222; + aclFloralWhite = $FFFFFAF0; + aclForestGreen = $FF228B22; + aclFuchsia = $FFFF00FF; + aclGainsboro = $FFDCDCDC; + aclGhostWhite = $FFF8F8FF; + aclGold = $FFFFD700; + aclGoldenrod = $FFDAA520; + aclGray = $FF808080; + aclGreen = $FF008000; + aclGreenYellow = $FFADFF2F; + aclHoneydew = $FFF0FFF0; + aclHotPink = $FFFF69B4; + aclIndianRed = $FFCD5C5C; + aclIndigo = $FF4B0082; + aclIvory = $FFFFFFF0; + aclKhaki = $FFF0E68C; + aclLavender = $FFE6E6FA; + aclLavenderBlush = $FFFFF0F5; + aclLawnGreen = $FF7CFC00; + aclLemonChiffon = $FFFFFACD; + aclLightBlue = $FFADD8E6; + aclLightCoral = $FFF08080; + aclLightCyan = $FFE0FFFF; + aclLightGoldenrodYellow = $FFFAFAD2; + aclLightGray = $FFD3D3D3; + aclLightGreen = $FF90EE90; + aclLightPink = $FFFFB6C1; + aclLightSalmon = $FFFFA07A; + aclLightSeaGreen = $FF20B2AA; + aclLightSkyBlue = $FF87CEFA; + aclLightSlateGray = $FF778899; + aclLightSteelBlue = $FFB0C4DE; + aclLightYellow = $FFFFFFE0; + aclLime = $FF00FF00; + aclLimeGreen = $FF32CD32; + aclLinen = $FFFAF0E6; + aclMagenta = $FFFF00FF; + aclMaroon = $FF800000; + aclMediumAquamarine = $FF66CDAA; + aclMediumBlue = $FF0000CD; + aclMediumOrchid = $FFBA55D3; + aclMediumPurple = $FF9370DB; + aclMediumSeaGreen = $FF3CB371; + aclMediumSlateBlue = $FF7B68EE; + aclMediumSpringGreen = $FF00FA9A; + aclMediumTurquoise = $FF48D1CC; + aclMediumVioletRed = $FFC71585; + aclMidnightBlue = $FF191970; + aclMintCream = $FFF5FFFA; + aclMistyRose = $FFFFE4E1; + aclMoccasin = $FFFFE4B5; + aclNavajoWhite = $FFFFDEAD; + aclNavy = $FF000080; + aclOldLace = $FFFDF5E6; + aclOlive = $FF808000; + aclOliveDrab = $FF6B8E23; + aclOrange = $FFFFA500; + aclOrangeRed = $FFFF4500; + aclOrchid = $FFDA70D6; + aclPaleGoldenrod = $FFEEE8AA; + aclPaleGreen = $FF98FB98; + aclPaleTurquoise = $FFAFEEEE; + aclPaleVioletRed = $FFDB7093; + aclPapayaWhip = $FFFFEFD5; + aclPeachPuff = $FFFFDAB9; + aclPeru = $FFCD853F; + aclPink = $FFFFC0CB; + aclPlum = $FFDDA0DD; + aclPowderBlue = $FFB0E0E6; + aclPurple = $FF800080; + aclRed = $FFFF0000; + aclRosyBrown = $FFBC8F8F; + aclRoyalBlue = $FF4169E1; + aclSaddleBrown = $FF8B4513; + aclSalmon = $FFFA8072; + aclSandyBrown = $FFF4A460; + aclSeaGreen = $FF2E8B57; + aclSeaShell = $FFFFF5EE; + aclSienna = $FFA0522D; + aclSilver = $FFC0C0C0; + aclSkyBlue = $FF87CEEB; + aclSlateBlue = $FF6A5ACD; + aclSlateGray = $FF708090; + aclSnow = $FFFFFAFA; + aclSpringGreen = $FF00FF7F; + aclSteelBlue = $FF4682B4; + aclTan = $FFD2B48C; + aclTeal = $FF008080; + aclThistle = $FFD8BFD8; + aclTomato = $FFFF6347; + aclTransparent = $00FFFFFF; + aclTurquoise = $FF40E0D0; + aclViolet = $FFEE82EE; + aclWheat = $FFF5DEB3; + aclWhite = $FFFFFFFF; + aclWhiteSmoke = $FFF5F5F5; + aclYellow = $FFFFFF00; + aclYellowGreen = $FF9ACD32; + + // Shift count and bit mask for A, R, G, B components + AlphaShift = 24; + {$EXTERNALSYM AlphaShift} + RedShift = 16; + {$EXTERNALSYM RedShift} + GreenShift = 8; + {$EXTERNALSYM GreenShift} + BlueShift = 0; + {$EXTERNALSYM BlueShift} + + AlphaMask = $ff000000; + {$EXTERNALSYM AlphaMask} + RedMask = $00ff0000; + {$EXTERNALSYM RedMask} + GreenMask = $0000ff00; + {$EXTERNALSYM GreenMask} + BlueMask = $000000ff; + {$EXTERNALSYM BlueMask} + + +type +{ TGPColor = class + protected + Argb: ARGB; + public + constructor Create; overload; + constructor Create(r, g, b: Byte); overload; + constructor Create(a, r, g, b: Byte); overload; + constructor Create(Value: ARGB); overload; + function GetAlpha: BYTE; + function GetA: BYTE; + function GetRed: BYTE; + function GetR: BYTE; + function GetGreen: Byte; + function GetG: Byte; + function GetBlue: Byte; + function GetB: Byte; + function GetValue: ARGB; + procedure SetValue(Value: ARGB); + procedure SetFromCOLORREF(rgb: COLORREF); + function ToCOLORREF: COLORREF; + function MakeARGB(a, r, g, b: Byte): ARGB; + end; } + + PGPColor = ^TGPColor; + TGPColor = ARGB; + TColorDynArray = array of TGPColor; + + function MakeColor(r, g, b: Byte): ARGB; overload; + function MakeColor(a, r, g, b: Byte): ARGB; overload; + function GetAlpha(color: ARGB): BYTE; + function GetRed(color: ARGB): BYTE; + function GetGreen(color: ARGB): BYTE; + function GetBlue(color: ARGB): BYTE; + function ColorRefToARGB(rgb: COLORREF): ARGB; + function ARGBToColorRef(Color: ARGB): COLORREF; + + +(**************************************************************************\ +* +* GDI+ Metafile Related Structures +* +\**************************************************************************) + +type + { from Windef.h } + RECTL = Windows.TRect; + SIZEL = Windows.TSize; + + {$EXTERNALSYM ENHMETAHEADER3} + ENHMETAHEADER3 = packed record + iType : DWORD; // Record type EMR_HEADER + nSize : DWORD; // Record size in bytes. This may be greater + // than the sizeof(ENHMETAHEADER). + rclBounds : RECTL; // Inclusive-inclusive bounds in device units + rclFrame : RECTL; // Inclusive-inclusive Picture Frame .01mm unit + dSignature : DWORD; // Signature. Must be ENHMETA_SIGNATURE. + nVersion : DWORD; // Version number + nBytes : DWORD; // Size of the metafile in bytes + nRecords : DWORD; // Number of records in the metafile + nHandles : WORD; // Number of handles in the handle table + // Handle index zero is reserved. + sReserved : WORD; // Reserved. Must be zero. + nDescription : DWORD; // Number of chars in the unicode desc string + // This is 0 if there is no description string + offDescription : DWORD; // Offset to the metafile description record. + // This is 0 if there is no description string + nPalEntries : DWORD; // Number of entries in the metafile palette. + szlDevice : SIZEL; // Size of the reference device in pels + szlMillimeters : SIZEL; // Size of the reference device in millimeters + end; + TENHMETAHEADER3 = ENHMETAHEADER3; + PENHMETAHEADER3 = ^TENHMETAHEADER3; + + // Placeable WMFs + + // Placeable Metafiles were created as a non-standard way of specifying how + // a metafile is mapped and scaled on an output device. + // Placeable metafiles are quite wide-spread, but not directly supported by + // the Windows API. To playback a placeable metafile using the Windows API, + // you will first need to strip the placeable metafile header from the file. + // This is typically performed by copying the metafile to a temporary file + // starting at file offset 22 (0x16). The contents of the temporary file may + // then be used as input to the Windows GetMetaFile(), PlayMetaFile(), + // CopyMetaFile(), etc. GDI functions. + + // Each placeable metafile begins with a 22-byte header, + // followed by a standard metafile: + + {$EXTERNALSYM PWMFRect16} + PWMFRect16 = packed record + Left : INT16; + Top : INT16; + Right : INT16; + Bottom : INT16; + end; + TPWMFRect16 = PWMFRect16; + PPWMFRect16 = ^TPWMFRect16; + + {$EXTERNALSYM WmfPlaceableFileHeader} + WmfPlaceableFileHeader = packed record + Key : UINT32; // GDIP_WMF_PLACEABLEKEY + Hmf : INT16; // Metafile HANDLE number (always 0) + BoundingBox : PWMFRect16; // Coordinates in metafile units + Inch : INT16; // Number of metafile units per inch + Reserved : UINT32; // Reserved (always 0) + Checksum : INT16; // Checksum value for previous 10 WORDs + end; + TWmfPlaceableFileHeader = WmfPlaceableFileHeader; + PWmfPlaceableFileHeader = ^TWmfPlaceableFileHeader; + + // Key contains a special identification value that indicates the presence + // of a placeable metafile header and is always 0x9AC6CDD7. + + // Handle is used to stored the handle of the metafile in memory. When written + // to disk, this field is not used and will always contains the value 0. + + // Left, Top, Right, and Bottom contain the coordinates of the upper-left + // and lower-right corners of the image on the output device. These are + // measured in twips. + + // A twip (meaning "twentieth of a point") is the logical unit of measurement + // used in Windows Metafiles. A twip is equal to 1/1440 of an inch. Thus 720 + // twips equal 1/2 inch, while 32,768 twips is 22.75 inches. + + // Inch contains the number of twips per inch used to represent the image. + // Normally, there are 1440 twips per inch; however, this number may be + // changed to scale the image. A value of 720 indicates that the image is + // double its normal size, or scaled to a factor of 2:1. A value of 360 + // indicates a scale of 4:1, while a value of 2880 indicates that the image + // is scaled down in size by a factor of two. A value of 1440 indicates + // a 1:1 scale ratio. + + // Reserved is not used and is always set to 0. + + // Checksum contains a checksum value for the previous 10 WORDs in the header. + // This value can be used in an attempt to detect if the metafile has become + // corrupted. The checksum is calculated by XORing each WORD value to an + // initial value of 0. + + // If the metafile was recorded with a reference Hdc that was a display. + +const + GDIP_EMFPLUSFLAGS_DISPLAY = $00000001; + {$EXTERNALSYM GDIP_EMFPLUSFLAGS_DISPLAY} + +type + TMetafileHeader = packed class + public + Type_ : TMetafileType; + Size : UINT; // Size of the metafile (in bytes) + Version : UINT; // EMF+, EMF, or WMF version + EmfPlusFlags : UINT; + DpiX : Single; + DpiY : Single; + X : Integer; // Bounds in device units + Y : Integer; + Width : Integer; + Height : Integer; + Header : record + case integer of + 0: (WmfHeader: TMETAHEADER;); + 1: (EmfHeader: TENHMETAHEADER3); + end; + EmfPlusHeaderSize : Integer; // size of the EMF+ header in file + LogicalDpiX : Integer; // Logical Dpi of reference Hdc + LogicalDpiY : Integer; // usually valid only for EMF+ + public + property GetType: TMetafileType read Type_; + property GetMetafileSize: UINT read Size; + // If IsEmfPlus, this is the EMF+ version; else it is the WMF or EMF ver + property GetVersion: UINT read Version; + // Get the EMF+ flags associated with the metafile + property GetEmfPlusFlags: UINT read EmfPlusFlags; + property GetDpiX: Single read DpiX; + property GetDpiY: Single read DpiY; + procedure GetBounds(out Rect: TGPRect); + // Is it any type of WMF (standard or Placeable Metafile)? + function IsWmf: BOOL; + // Is this an Placeable Metafile? + function IsWmfPlaceable: BOOL; + // Is this an EMF (not an EMF+)? + function IsEmf: BOOL; + // Is this an EMF or EMF+ file? + function IsEmfOrEmfPlus: BOOL; + // Is this an EMF+ file? + function IsEmfPlus: BOOL; + // Is this an EMF+ dual (has dual, down-level records) file? + function IsEmfPlusDual: BOOL; + // Is this an EMF+ only (no dual records) file? + function IsEmfPlusOnly: BOOL; + // If it's an EMF+ file, was it recorded against a display Hdc? + function IsDisplay: BOOL; + // Get the WMF header of the metafile (if it is a WMF) + function GetWmfHeader: PMetaHeader; + // Get the EMF header of the metafile (if it is an EMF) + function GetEmfHeader: PENHMETAHEADER3; + end; + +(**************************************************************************\ +* +* GDI+ Imaging GUIDs +* +\**************************************************************************) + +//--------------------------------------------------------------------------- +// Image file format identifiers +//--------------------------------------------------------------------------- + +const + ImageFormatUndefined : TGUID = '{b96b3ca9-0728-11d3-9d7b-0000f81ef32e}'; + {$EXTERNALSYM ImageFormatUndefined} + ImageFormatMemoryBMP : TGUID = '{b96b3caa-0728-11d3-9d7b-0000f81ef32e}'; + {$EXTERNALSYM ImageFormatMemoryBMP} + ImageFormatBMP : TGUID = '{b96b3cab-0728-11d3-9d7b-0000f81ef32e}'; + {$EXTERNALSYM ImageFormatBMP} + ImageFormatEMF : TGUID = '{b96b3cac-0728-11d3-9d7b-0000f81ef32e}'; + {$EXTERNALSYM ImageFormatEMF} + ImageFormatWMF : TGUID = '{b96b3cad-0728-11d3-9d7b-0000f81ef32e}'; + {$EXTERNALSYM ImageFormatWMF} + ImageFormatJPEG : TGUID = '{b96b3cae-0728-11d3-9d7b-0000f81ef32e}'; + {$EXTERNALSYM ImageFormatJPEG} + ImageFormatPNG : TGUID = '{b96b3caf-0728-11d3-9d7b-0000f81ef32e}'; + {$EXTERNALSYM ImageFormatPNG} + ImageFormatGIF : TGUID = '{b96b3cb0-0728-11d3-9d7b-0000f81ef32e}'; + {$EXTERNALSYM ImageFormatGIF} + ImageFormatTIFF : TGUID = '{b96b3cb1-0728-11d3-9d7b-0000f81ef32e}'; + {$EXTERNALSYM ImageFormatTIFF} + ImageFormatEXIF : TGUID = '{b96b3cb2-0728-11d3-9d7b-0000f81ef32e}'; + {$EXTERNALSYM ImageFormatEXIF} + ImageFormatIcon : TGUID = '{b96b3cb5-0728-11d3-9d7b-0000f81ef32e}'; + {$EXTERNALSYM ImageFormatIcon} + +//--------------------------------------------------------------------------- +// Predefined multi-frame dimension IDs +//--------------------------------------------------------------------------- + + FrameDimensionTime : TGUID = '{6aedbd6d-3fb5-418a-83a6-7f45229dc872}'; + {$EXTERNALSYM FrameDimensionTime} + FrameDimensionResolution : TGUID = '{84236f7b-3bd3-428f-8dab-4ea1439ca315}'; + {$EXTERNALSYM FrameDimensionResolution} + FrameDimensionPage : TGUID = '{7462dc86-6180-4c7e-8e3f-ee7333a7a483}'; + {$EXTERNALSYM FrameDimensionPage} + +//--------------------------------------------------------------------------- +// Property sets +//--------------------------------------------------------------------------- + + FormatIDImageInformation : TGUID = '{e5836cbe-5eef-4f1d-acde-ae4c43b608ce}'; + {$EXTERNALSYM FormatIDImageInformation} + FormatIDJpegAppHeaders : TGUID = '{1c4afdcd-6177-43cf-abc7-5f51af39ee85}'; + {$EXTERNALSYM FormatIDJpegAppHeaders} + +//--------------------------------------------------------------------------- +// Encoder parameter sets +//--------------------------------------------------------------------------- + + EncoderCompression : TGUID = '{e09d739d-ccd4-44ee-8eba-3fbf8be4fc58}'; + {$EXTERNALSYM EncoderCompression} + EncoderColorDepth : TGUID = '{66087055-ad66-4c7c-9a18-38a2310b8337}'; + {$EXTERNALSYM EncoderColorDepth} + EncoderScanMethod : TGUID = '{3a4e2661-3109-4e56-8536-42c156e7dcfa}'; + {$EXTERNALSYM EncoderScanMethod} + EncoderVersion : TGUID = '{24d18c76-814a-41a4-bf53-1c219cccf797}'; + {$EXTERNALSYM EncoderVersion} + EncoderRenderMethod : TGUID = '{6d42c53a-229a-4825-8bb7-5c99e2b9a8b8}'; + {$EXTERNALSYM EncoderRenderMethod} + EncoderQuality : TGUID = '{1d5be4b5-fa4a-452d-9cdd-5db35105e7eb}'; + {$EXTERNALSYM EncoderQuality} + EncoderTransformation : TGUID = '{8d0eb2d1-a58e-4ea8-aa14-108074b7b6f9}'; + {$EXTERNALSYM EncoderTransformation} + EncoderLuminanceTable : TGUID = '{edb33bce-0266-4a77-b904-27216099e717}'; + {$EXTERNALSYM EncoderLuminanceTable} + EncoderChrominanceTable : TGUID = '{f2e455dc-09b3-4316-8260-676ada32481c}'; + {$EXTERNALSYM EncoderChrominanceTable} + EncoderSaveFlag : TGUID = '{292266fc-ac40-47bf-8cfc-a85b89a655de}'; + {$EXTERNALSYM EncoderSaveFlag} + + CodecIImageBytes : TGUID = '{025d1823-6c7d-447b-bbdb-a3cbc3dfa2fc}'; + {$EXTERNALSYM CodecIImageBytes} + +type + {$EXTERNALSYM IImageBytes} + IImageBytes = Interface(IUnknown) + ['{025D1823-6C7D-447B-BBDB-A3CBC3DFA2FC}'] + // Return total number of bytes in the IStream + function CountBytes(out pcb: UINT): HRESULT; stdcall; + // Locks "cb" bytes, starting from "ulOffset" in the stream, and returns the + // pointer to the beginning of the locked memory chunk in "ppvBytes" + function LockBytes(cb: UINT; ulOffset: ULONG; out ppvBytes: pointer): HRESULT; stdcall; + // Unlocks "cb" bytes, pointed by "pvBytes", starting from "ulOffset" in the + // stream + function UnlockBytes(pvBytes: pointer; cb: UINT; ulOffset: ULONG): HRESULT; stdcall; + end; + +//-------------------------------------------------------------------------- +// ImageCodecInfo structure +//-------------------------------------------------------------------------- + + {$EXTERNALSYM ImageCodecInfo} + ImageCodecInfo = packed record + Clsid : TGUID; + FormatID : TGUID; + CodecName : PWCHAR; + DllName : PWCHAR; + FormatDescription : PWCHAR; + FilenameExtension : PWCHAR; + MimeType : PWCHAR; + Flags : DWORD; + Version : DWORD; + SigCount : DWORD; + SigSize : DWORD; + SigPattern : PBYTE; + SigMask : PBYTE; + end; + TImageCodecInfo = ImageCodecInfo; + PImageCodecInfo = ^TImageCodecInfo; + +//-------------------------------------------------------------------------- +// Information flags about image codecs +//-------------------------------------------------------------------------- +{$IFDEF DELPHI6_UP} + {$EXTERNALSYM ImageCodecFlags} + ImageCodecFlags = ( + ImageCodecFlagsEncoder = $00000001, + ImageCodecFlagsDecoder = $00000002, + ImageCodecFlagsSupportBitmap = $00000004, + ImageCodecFlagsSupportVector = $00000008, + ImageCodecFlagsSeekableEncode = $00000010, + ImageCodecFlagsBlockingDecode = $00000020, + + ImageCodecFlagsBuiltin = $00010000, + ImageCodecFlagsSystem = $00020000, + ImageCodecFlagsUser = $00040000 + ); + TImageCodecFlags = ImageCodecFlags; +{$ELSE} + {$EXTERNALSYM ImageCodecFlags} + ImageCodecFlags = Integer; + const + ImageCodecFlagsEncoder = $00000001; + ImageCodecFlagsDecoder = $00000002; + ImageCodecFlagsSupportBitmap = $00000004; + ImageCodecFlagsSupportVector = $00000008; + ImageCodecFlagsSeekableEncode = $00000010; + ImageCodecFlagsBlockingDecode = $00000020; + + ImageCodecFlagsBuiltin = $00010000; + ImageCodecFlagsSystem = $00020000; + ImageCodecFlagsUser = $00040000; + +type + TImageCodecFlags = ImageCodecFlags; +{$ENDIF} +//--------------------------------------------------------------------------- +// Access modes used when calling Image::LockBits +//--------------------------------------------------------------------------- + + {$EXTERNALSYM ImageLockMode} + ImageLockMode = Integer; + const + ImageLockModeRead = $0001; + ImageLockModeWrite = $0002; + ImageLockModeUserInputBuf = $0004; +type + TImageLockMode = ImageLockMode; + +//--------------------------------------------------------------------------- +// Information about image pixel data +//--------------------------------------------------------------------------- + + {$EXTERNALSYM BitmapData} + BitmapData = packed record + Width : UINT; + Height : UINT; + Stride : Integer; + PixelFormat : PixelFormat; + Scan0 : Pointer; + Reserved : UINT; + end; + TBitmapData = BitmapData; + PBitmapData = ^TBitmapData; + +//--------------------------------------------------------------------------- +// Image flags +//--------------------------------------------------------------------------- +{$IFDEF DELPHI6_UP} + {$EXTERNALSYM ImageFlags} + ImageFlags = ( + ImageFlagsNone = 0, + + // Low-word: shared with SINKFLAG_x + + ImageFlagsScalable = $0001, + ImageFlagsHasAlpha = $0002, + ImageFlagsHasTranslucent = $0004, + ImageFlagsPartiallyScalable = $0008, + + // Low-word: color space definition + + ImageFlagsColorSpaceRGB = $0010, + ImageFlagsColorSpaceCMYK = $0020, + ImageFlagsColorSpaceGRAY = $0040, + ImageFlagsColorSpaceYCBCR = $0080, + ImageFlagsColorSpaceYCCK = $0100, + + // Low-word: image size info + + ImageFlagsHasRealDPI = $1000, + ImageFlagsHasRealPixelSize = $2000, + + // High-word + + ImageFlagsReadOnly = $00010000, + ImageFlagsCaching = $00020000 + ); + TImageFlags = ImageFlags; +{$ELSE} + {$EXTERNALSYM ImageFlags} + ImageFlags = Integer; + const + ImageFlagsNone = 0; + + // Low-word: shared with SINKFLAG_x + + ImageFlagsScalable = $0001; + ImageFlagsHasAlpha = $0002; + ImageFlagsHasTranslucent = $0004; + ImageFlagsPartiallyScalable = $0008; + + // Low-word: color space definition + + ImageFlagsColorSpaceRGB = $0010; + ImageFlagsColorSpaceCMYK = $0020; + ImageFlagsColorSpaceGRAY = $0040; + ImageFlagsColorSpaceYCBCR = $0080; + ImageFlagsColorSpaceYCCK = $0100; + + // Low-word: image size info + + ImageFlagsHasRealDPI = $1000; + ImageFlagsHasRealPixelSize = $2000; + + // High-word + + ImageFlagsReadOnly = $00010000; + ImageFlagsCaching = $00020000; + +type + TImageFlags = ImageFlags; +{$ENDIF} + + +{$IFDEF DELPHI6_UP} + {$EXTERNALSYM RotateFlipType} + RotateFlipType = ( + RotateNoneFlipNone = 0, + Rotate90FlipNone = 1, + Rotate180FlipNone = 2, + Rotate270FlipNone = 3, + + RotateNoneFlipX = 4, + Rotate90FlipX = 5, + Rotate180FlipX = 6, + Rotate270FlipX = 7, + + RotateNoneFlipY = Rotate180FlipX, + Rotate90FlipY = Rotate270FlipX, + Rotate180FlipY = RotateNoneFlipX, + Rotate270FlipY = Rotate90FlipX, + + RotateNoneFlipXY = Rotate180FlipNone, + Rotate90FlipXY = Rotate270FlipNone, + Rotate180FlipXY = RotateNoneFlipNone, + Rotate270FlipXY = Rotate90FlipNone + ); + TRotateFlipType = RotateFlipType; +{$ELSE} + {$EXTERNALSYM RotateFlipType} + RotateFlipType = ( + RotateNoneFlipNone, // = 0, + Rotate90FlipNone, // = 1, + Rotate180FlipNone, // = 2, + Rotate270FlipNone, // = 3, + + RotateNoneFlipX, // = 4, + Rotate90FlipX, // = 5, + Rotate180FlipX, // = 6, + Rotate270FlipX // = 7, + ); + const + RotateNoneFlipY = Rotate180FlipX; + Rotate90FlipY = Rotate270FlipX; + Rotate180FlipY = RotateNoneFlipX; + Rotate270FlipY = Rotate90FlipX; + + RotateNoneFlipXY = Rotate180FlipNone; + Rotate90FlipXY = Rotate270FlipNone; + Rotate180FlipXY = RotateNoneFlipNone; + Rotate270FlipXY = Rotate90FlipNone; + +type + TRotateFlipType = RotateFlipType; +{$ENDIF} + +//--------------------------------------------------------------------------- +// Encoder Parameter structure +//--------------------------------------------------------------------------- + + {$EXTERNALSYM EncoderParameter} + EncoderParameter = packed record + Guid : TGUID; // GUID of the parameter + NumberOfValues : ULONG; // Number of the parameter values + Type_ : ULONG; // Value type, like ValueTypeLONG etc. + Value : Pointer; // A pointer to the parameter values + end; + TEncoderParameter = EncoderParameter; + PEncoderParameter = ^TEncoderParameter; + +//--------------------------------------------------------------------------- +// Encoder Parameters structure +//--------------------------------------------------------------------------- + + {$EXTERNALSYM EncoderParameters} + EncoderParameters = packed record + Count : UINT; // Number of parameters in this structure + Parameter : array[0..0] of TEncoderParameter; // Parameter values + end; + TEncoderParameters = EncoderParameters; + PEncoderParameters = ^TEncoderParameters; + +//--------------------------------------------------------------------------- +// Property Item +//--------------------------------------------------------------------------- + + {$EXTERNALSYM PropertyItem} + PropertyItem = record // NOT PACKED !! + id : PROPID; // ID of this property + length : ULONG; // Length of the property value, in bytes + type_ : WORD; // Type of the value, as one of TAG_TYPE_XXX + value : Pointer; // property value + end; + TPropertyItem = PropertyItem; + PPropertyItem = ^TPropertyItem; + +//--------------------------------------------------------------------------- +// Image property types +//--------------------------------------------------------------------------- + +const + PropertyTagTypeByte : Integer = 1; + {$EXTERNALSYM PropertyTagTypeByte} + PropertyTagTypeASCII : Integer = 2; + {$EXTERNALSYM PropertyTagTypeASCII} + PropertyTagTypeShort : Integer = 3; + {$EXTERNALSYM PropertyTagTypeShort} + PropertyTagTypeLong : Integer = 4; + {$EXTERNALSYM PropertyTagTypeLong} + PropertyTagTypeRational : Integer = 5; + {$EXTERNALSYM PropertyTagTypeRational} + PropertyTagTypeUndefined : Integer = 7; + {$EXTERNALSYM PropertyTagTypeUndefined} + PropertyTagTypeSLONG : Integer = 9; + {$EXTERNALSYM PropertyTagTypeSLONG} + PropertyTagTypeSRational : Integer = 10; + {$EXTERNALSYM PropertyTagTypeSRational} + +//--------------------------------------------------------------------------- +// Image property ID tags +//--------------------------------------------------------------------------- + + PropertyTagExifIFD = $8769; + {$EXTERNALSYM PropertyTagExifIFD} + PropertyTagGpsIFD = $8825; + {$EXTERNALSYM PropertyTagGpsIFD} + + PropertyTagNewSubfileType = $00FE; + {$EXTERNALSYM PropertyTagNewSubfileType} + PropertyTagSubfileType = $00FF; + {$EXTERNALSYM PropertyTagSubfileType} + PropertyTagImageWidth = $0100; + {$EXTERNALSYM PropertyTagImageWidth} + PropertyTagImageHeight = $0101; + {$EXTERNALSYM PropertyTagImageHeight} + PropertyTagBitsPerSample = $0102; + {$EXTERNALSYM PropertyTagBitsPerSample} + PropertyTagCompression = $0103; + {$EXTERNALSYM PropertyTagCompression} + PropertyTagPhotometricInterp = $0106; + {$EXTERNALSYM PropertyTagPhotometricInterp} + PropertyTagThreshHolding = $0107; + {$EXTERNALSYM PropertyTagThreshHolding} + PropertyTagCellWidth = $0108; + {$EXTERNALSYM PropertyTagCellWidth} + PropertyTagCellHeight = $0109; + {$EXTERNALSYM PropertyTagCellHeight} + PropertyTagFillOrder = $010A; + {$EXTERNALSYM PropertyTagFillOrder} + PropertyTagDocumentName = $010D; + {$EXTERNALSYM PropertyTagDocumentName} + PropertyTagImageDescription = $010E; + {$EXTERNALSYM PropertyTagImageDescription} + PropertyTagEquipMake = $010F; + {$EXTERNALSYM PropertyTagEquipMake} + PropertyTagEquipModel = $0110; + {$EXTERNALSYM PropertyTagEquipModel} + PropertyTagStripOffsets = $0111; + {$EXTERNALSYM PropertyTagStripOffsets} + PropertyTagOrientation = $0112; + {$EXTERNALSYM PropertyTagOrientation} + PropertyTagSamplesPerPixel = $0115; + {$EXTERNALSYM PropertyTagSamplesPerPixel} + PropertyTagRowsPerStrip = $0116; + {$EXTERNALSYM PropertyTagRowsPerStrip} + PropertyTagStripBytesCount = $0117; + {$EXTERNALSYM PropertyTagStripBytesCount} + PropertyTagMinSampleValue = $0118; + {$EXTERNALSYM PropertyTagMinSampleValue} + PropertyTagMaxSampleValue = $0119; + {$EXTERNALSYM PropertyTagMaxSampleValue} + PropertyTagXResolution = $011A; // Image resolution in width direction + {$EXTERNALSYM PropertyTagXResolution} + PropertyTagYResolution = $011B; // Image resolution in height direction + {$EXTERNALSYM PropertyTagYResolution} + PropertyTagPlanarConfig = $011C; // Image data arrangement + {$EXTERNALSYM PropertyTagPlanarConfig} + PropertyTagPageName = $011D; + {$EXTERNALSYM PropertyTagPageName} + PropertyTagXPosition = $011E; + {$EXTERNALSYM PropertyTagXPosition} + PropertyTagYPosition = $011F; + {$EXTERNALSYM PropertyTagYPosition} + PropertyTagFreeOffset = $0120; + {$EXTERNALSYM PropertyTagFreeOffset} + PropertyTagFreeByteCounts = $0121; + {$EXTERNALSYM PropertyTagFreeByteCounts} + PropertyTagGrayResponseUnit = $0122; + {$EXTERNALSYM PropertyTagGrayResponseUnit} + PropertyTagGrayResponseCurve = $0123; + {$EXTERNALSYM PropertyTagGrayResponseCurve} + PropertyTagT4Option = $0124; + {$EXTERNALSYM PropertyTagT4Option} + PropertyTagT6Option = $0125; + {$EXTERNALSYM PropertyTagT6Option} + PropertyTagResolutionUnit = $0128; // Unit of X and Y resolution + {$EXTERNALSYM PropertyTagResolutionUnit} + PropertyTagPageNumber = $0129; + {$EXTERNALSYM PropertyTagPageNumber} + PropertyTagTransferFuncition = $012D; + {$EXTERNALSYM PropertyTagTransferFuncition} + PropertyTagSoftwareUsed = $0131; + {$EXTERNALSYM PropertyTagSoftwareUsed} + PropertyTagDateTime = $0132; + {$EXTERNALSYM PropertyTagDateTime} + PropertyTagArtist = $013B; + {$EXTERNALSYM PropertyTagArtist} + PropertyTagHostComputer = $013C; + {$EXTERNALSYM PropertyTagHostComputer} + PropertyTagPredictor = $013D; + {$EXTERNALSYM PropertyTagPredictor} + PropertyTagWhitePoint = $013E; + {$EXTERNALSYM PropertyTagWhitePoint} + PropertyTagPrimaryChromaticities = $013F; + {$EXTERNALSYM PropertyTagPrimaryChromaticities} + PropertyTagColorMap = $0140; + {$EXTERNALSYM PropertyTagColorMap} + PropertyTagHalftoneHints = $0141; + {$EXTERNALSYM PropertyTagHalftoneHints} + PropertyTagTileWidth = $0142; + {$EXTERNALSYM PropertyTagTileWidth} + PropertyTagTileLength = $0143; + {$EXTERNALSYM PropertyTagTileLength} + PropertyTagTileOffset = $0144; + {$EXTERNALSYM PropertyTagTileOffset} + PropertyTagTileByteCounts = $0145; + {$EXTERNALSYM PropertyTagTileByteCounts} + PropertyTagInkSet = $014C; + {$EXTERNALSYM PropertyTagInkSet} + PropertyTagInkNames = $014D; + {$EXTERNALSYM PropertyTagInkNames} + PropertyTagNumberOfInks = $014E; + {$EXTERNALSYM PropertyTagNumberOfInks} + PropertyTagDotRange = $0150; + {$EXTERNALSYM PropertyTagDotRange} + PropertyTagTargetPrinter = $0151; + {$EXTERNALSYM PropertyTagTargetPrinter} + PropertyTagExtraSamples = $0152; + {$EXTERNALSYM PropertyTagExtraSamples} + PropertyTagSampleFormat = $0153; + {$EXTERNALSYM PropertyTagSampleFormat} + PropertyTagSMinSampleValue = $0154; + {$EXTERNALSYM PropertyTagSMinSampleValue} + PropertyTagSMaxSampleValue = $0155; + {$EXTERNALSYM PropertyTagSMaxSampleValue} + PropertyTagTransferRange = $0156; + {$EXTERNALSYM PropertyTagTransferRange} + + PropertyTagJPEGProc = $0200; + {$EXTERNALSYM PropertyTagJPEGProc} + PropertyTagJPEGInterFormat = $0201; + {$EXTERNALSYM PropertyTagJPEGInterFormat} + PropertyTagJPEGInterLength = $0202; + {$EXTERNALSYM PropertyTagJPEGInterLength} + PropertyTagJPEGRestartInterval = $0203; + {$EXTERNALSYM PropertyTagJPEGRestartInterval} + PropertyTagJPEGLosslessPredictors = $0205; + {$EXTERNALSYM PropertyTagJPEGLosslessPredictors} + PropertyTagJPEGPointTransforms = $0206; + {$EXTERNALSYM PropertyTagJPEGPointTransforms} + PropertyTagJPEGQTables = $0207; + {$EXTERNALSYM PropertyTagJPEGQTables} + PropertyTagJPEGDCTables = $0208; + {$EXTERNALSYM PropertyTagJPEGDCTables} + PropertyTagJPEGACTables = $0209; + {$EXTERNALSYM PropertyTagJPEGACTables} + + PropertyTagYCbCrCoefficients = $0211; + {$EXTERNALSYM PropertyTagYCbCrCoefficients} + PropertyTagYCbCrSubsampling = $0212; + {$EXTERNALSYM PropertyTagYCbCrSubsampling} + PropertyTagYCbCrPositioning = $0213; + {$EXTERNALSYM PropertyTagYCbCrPositioning} + PropertyTagREFBlackWhite = $0214; + {$EXTERNALSYM PropertyTagREFBlackWhite} + + PropertyTagICCProfile = $8773; // This TAG is defined by ICC + {$EXTERNALSYM PropertyTagICCProfile} + // for embedded ICC in TIFF + PropertyTagGamma = $0301; + {$EXTERNALSYM PropertyTagGamma} + PropertyTagICCProfileDescriptor = $0302; + {$EXTERNALSYM PropertyTagICCProfileDescriptor} + PropertyTagSRGBRenderingIntent = $0303; + {$EXTERNALSYM PropertyTagSRGBRenderingIntent} + + PropertyTagImageTitle = $0320; + {$EXTERNALSYM PropertyTagImageTitle} + PropertyTagCopyright = $8298; + {$EXTERNALSYM PropertyTagCopyright} + +// Extra TAGs (Like Adobe Image Information tags etc.) + + PropertyTagResolutionXUnit = $5001; + {$EXTERNALSYM PropertyTagResolutionXUnit} + PropertyTagResolutionYUnit = $5002; + {$EXTERNALSYM PropertyTagResolutionYUnit} + PropertyTagResolutionXLengthUnit = $5003; + {$EXTERNALSYM PropertyTagResolutionXLengthUnit} + PropertyTagResolutionYLengthUnit = $5004; + {$EXTERNALSYM PropertyTagResolutionYLengthUnit} + PropertyTagPrintFlags = $5005; + {$EXTERNALSYM PropertyTagPrintFlags} + PropertyTagPrintFlagsVersion = $5006; + {$EXTERNALSYM PropertyTagPrintFlagsVersion} + PropertyTagPrintFlagsCrop = $5007; + {$EXTERNALSYM PropertyTagPrintFlagsCrop} + PropertyTagPrintFlagsBleedWidth = $5008; + {$EXTERNALSYM PropertyTagPrintFlagsBleedWidth} + PropertyTagPrintFlagsBleedWidthScale = $5009; + {$EXTERNALSYM PropertyTagPrintFlagsBleedWidthScale} + PropertyTagHalftoneLPI = $500A; + {$EXTERNALSYM PropertyTagHalftoneLPI} + PropertyTagHalftoneLPIUnit = $500B; + {$EXTERNALSYM PropertyTagHalftoneLPIUnit} + PropertyTagHalftoneDegree = $500C; + {$EXTERNALSYM PropertyTagHalftoneDegree} + PropertyTagHalftoneShape = $500D; + {$EXTERNALSYM PropertyTagHalftoneShape} + PropertyTagHalftoneMisc = $500E; + {$EXTERNALSYM PropertyTagHalftoneMisc} + PropertyTagHalftoneScreen = $500F; + {$EXTERNALSYM PropertyTagHalftoneScreen} + PropertyTagJPEGQuality = $5010; + {$EXTERNALSYM PropertyTagJPEGQuality} + PropertyTagGridSize = $5011; + {$EXTERNALSYM PropertyTagGridSize} + PropertyTagThumbnailFormat = $5012; // 1 = JPEG, 0 = RAW RGB + {$EXTERNALSYM PropertyTagThumbnailFormat} + PropertyTagThumbnailWidth = $5013; + {$EXTERNALSYM PropertyTagThumbnailWidth} + PropertyTagThumbnailHeight = $5014; + {$EXTERNALSYM PropertyTagThumbnailHeight} + PropertyTagThumbnailColorDepth = $5015; + {$EXTERNALSYM PropertyTagThumbnailColorDepth} + PropertyTagThumbnailPlanes = $5016; + {$EXTERNALSYM PropertyTagThumbnailPlanes} + PropertyTagThumbnailRawBytes = $5017; + {$EXTERNALSYM PropertyTagThumbnailRawBytes} + PropertyTagThumbnailSize = $5018; + {$EXTERNALSYM PropertyTagThumbnailSize} + PropertyTagThumbnailCompressedSize = $5019; + {$EXTERNALSYM PropertyTagThumbnailCompressedSize} + PropertyTagColorTransferFunction = $501A; + {$EXTERNALSYM PropertyTagColorTransferFunction} + PropertyTagThumbnailData = $501B; // RAW thumbnail bits in + {$EXTERNALSYM PropertyTagThumbnailData} + // JPEG format or RGB format + // depends on + // PropertyTagThumbnailFormat + + // Thumbnail related TAGs + + PropertyTagThumbnailImageWidth = $5020; // Thumbnail width + {$EXTERNALSYM PropertyTagThumbnailImageWidth} + PropertyTagThumbnailImageHeight = $5021; // Thumbnail height + {$EXTERNALSYM PropertyTagThumbnailImageHeight} + PropertyTagThumbnailBitsPerSample = $5022; // Number of bits per + {$EXTERNALSYM PropertyTagThumbnailBitsPerSample} + // component + PropertyTagThumbnailCompression = $5023; // Compression Scheme + {$EXTERNALSYM PropertyTagThumbnailCompression} + PropertyTagThumbnailPhotometricInterp = $5024; // Pixel composition + {$EXTERNALSYM PropertyTagThumbnailPhotometricInterp} + PropertyTagThumbnailImageDescription = $5025; // Image Tile + {$EXTERNALSYM PropertyTagThumbnailImageDescription} + PropertyTagThumbnailEquipMake = $5026; // Manufacturer of Image + {$EXTERNALSYM PropertyTagThumbnailEquipMake} + // Input equipment + PropertyTagThumbnailEquipModel = $5027; // Model of Image input + {$EXTERNALSYM PropertyTagThumbnailEquipModel} + // equipment + PropertyTagThumbnailStripOffsets = $5028; // Image data location + {$EXTERNALSYM PropertyTagThumbnailStripOffsets} + PropertyTagThumbnailOrientation = $5029; // Orientation of image + {$EXTERNALSYM PropertyTagThumbnailOrientation} + PropertyTagThumbnailSamplesPerPixel = $502A; // Number of components + {$EXTERNALSYM PropertyTagThumbnailSamplesPerPixel} + PropertyTagThumbnailRowsPerStrip = $502B; // Number of rows per strip + {$EXTERNALSYM PropertyTagThumbnailRowsPerStrip} + PropertyTagThumbnailStripBytesCount = $502C; // Bytes per compressed + {$EXTERNALSYM PropertyTagThumbnailStripBytesCount} + // strip + PropertyTagThumbnailResolutionX = $502D; // Resolution in width + {$EXTERNALSYM PropertyTagThumbnailResolutionX} + // direction + PropertyTagThumbnailResolutionY = $502E; // Resolution in height + {$EXTERNALSYM PropertyTagThumbnailResolutionY} + // direction + PropertyTagThumbnailPlanarConfig = $502F; // Image data arrangement + {$EXTERNALSYM PropertyTagThumbnailPlanarConfig} + PropertyTagThumbnailResolutionUnit = $5030; // Unit of X and Y + {$EXTERNALSYM PropertyTagThumbnailResolutionUnit} + // Resolution + PropertyTagThumbnailTransferFunction = $5031; // Transfer function + {$EXTERNALSYM PropertyTagThumbnailTransferFunction} + PropertyTagThumbnailSoftwareUsed = $5032; // Software used + {$EXTERNALSYM PropertyTagThumbnailSoftwareUsed} + PropertyTagThumbnailDateTime = $5033; // File change date and + {$EXTERNALSYM PropertyTagThumbnailDateTime} + // time + PropertyTagThumbnailArtist = $5034; // Person who created the + {$EXTERNALSYM PropertyTagThumbnailArtist} + // image + PropertyTagThumbnailWhitePoint = $5035; // White point chromaticity + {$EXTERNALSYM PropertyTagThumbnailWhitePoint} + PropertyTagThumbnailPrimaryChromaticities = $5036; + {$EXTERNALSYM PropertyTagThumbnailPrimaryChromaticities} + // Chromaticities of + // primaries + PropertyTagThumbnailYCbCrCoefficients = $5037; // Color space transforma- + {$EXTERNALSYM PropertyTagThumbnailYCbCrCoefficients} + // tion coefficients + PropertyTagThumbnailYCbCrSubsampling = $5038; // Subsampling ratio of Y + {$EXTERNALSYM PropertyTagThumbnailYCbCrSubsampling} + // to C + PropertyTagThumbnailYCbCrPositioning = $5039; // Y and C position + {$EXTERNALSYM PropertyTagThumbnailYCbCrPositioning} + PropertyTagThumbnailRefBlackWhite = $503A; // Pair of black and white + {$EXTERNALSYM PropertyTagThumbnailRefBlackWhite} + // reference values + PropertyTagThumbnailCopyRight = $503B; // CopyRight holder + {$EXTERNALSYM PropertyTagThumbnailCopyRight} + + PropertyTagLuminanceTable = $5090; + {$EXTERNALSYM PropertyTagLuminanceTable} + PropertyTagChrominanceTable = $5091; + {$EXTERNALSYM PropertyTagChrominanceTable} + + PropertyTagFrameDelay = $5100; + {$EXTERNALSYM PropertyTagFrameDelay} + PropertyTagLoopCount = $5101; + {$EXTERNALSYM PropertyTagLoopCount} + + PropertyTagPixelUnit = $5110; // Unit specifier for pixel/unit + {$EXTERNALSYM PropertyTagPixelUnit} + PropertyTagPixelPerUnitX = $5111; // Pixels per unit in X + {$EXTERNALSYM PropertyTagPixelPerUnitX} + PropertyTagPixelPerUnitY = $5112; // Pixels per unit in Y + {$EXTERNALSYM PropertyTagPixelPerUnitY} + PropertyTagPaletteHistogram = $5113; // Palette histogram + {$EXTERNALSYM PropertyTagPaletteHistogram} + + // EXIF specific tag + + PropertyTagExifExposureTime = $829A; + {$EXTERNALSYM PropertyTagExifExposureTime} + PropertyTagExifFNumber = $829D; + {$EXTERNALSYM PropertyTagExifFNumber} + + PropertyTagExifExposureProg = $8822; + {$EXTERNALSYM PropertyTagExifExposureProg} + PropertyTagExifSpectralSense = $8824; + {$EXTERNALSYM PropertyTagExifSpectralSense} + PropertyTagExifISOSpeed = $8827; + {$EXTERNALSYM PropertyTagExifISOSpeed} + PropertyTagExifOECF = $8828; + {$EXTERNALSYM PropertyTagExifOECF} + + PropertyTagExifVer = $9000; + {$EXTERNALSYM PropertyTagExifVer} + PropertyTagExifDTOrig = $9003; // Date & time of original + {$EXTERNALSYM PropertyTagExifDTOrig} + PropertyTagExifDTDigitized = $9004; // Date & time of digital data generation + {$EXTERNALSYM PropertyTagExifDTDigitized} + + PropertyTagExifCompConfig = $9101; + {$EXTERNALSYM PropertyTagExifCompConfig} + PropertyTagExifCompBPP = $9102; + {$EXTERNALSYM PropertyTagExifCompBPP} + + PropertyTagExifShutterSpeed = $9201; + {$EXTERNALSYM PropertyTagExifShutterSpeed} + PropertyTagExifAperture = $9202; + {$EXTERNALSYM PropertyTagExifAperture} + PropertyTagExifBrightness = $9203; + {$EXTERNALSYM PropertyTagExifBrightness} + PropertyTagExifExposureBias = $9204; + {$EXTERNALSYM PropertyTagExifExposureBias} + PropertyTagExifMaxAperture = $9205; + {$EXTERNALSYM PropertyTagExifMaxAperture} + PropertyTagExifSubjectDist = $9206; + {$EXTERNALSYM PropertyTagExifSubjectDist} + PropertyTagExifMeteringMode = $9207; + {$EXTERNALSYM PropertyTagExifMeteringMode} + PropertyTagExifLightSource = $9208; + {$EXTERNALSYM PropertyTagExifLightSource} + PropertyTagExifFlash = $9209; + {$EXTERNALSYM PropertyTagExifFlash} + PropertyTagExifFocalLength = $920A; + {$EXTERNALSYM PropertyTagExifFocalLength} + PropertyTagExifMakerNote = $927C; + {$EXTERNALSYM PropertyTagExifMakerNote} + PropertyTagExifUserComment = $9286; + {$EXTERNALSYM PropertyTagExifUserComment} + PropertyTagExifDTSubsec = $9290; // Date & Time subseconds + {$EXTERNALSYM PropertyTagExifDTSubsec} + PropertyTagExifDTOrigSS = $9291; // Date & Time original subseconds + {$EXTERNALSYM PropertyTagExifDTOrigSS} + PropertyTagExifDTDigSS = $9292; // Date & TIme digitized subseconds + {$EXTERNALSYM PropertyTagExifDTDigSS} + + PropertyTagExifFPXVer = $A000; + {$EXTERNALSYM PropertyTagExifFPXVer} + PropertyTagExifColorSpace = $A001; + {$EXTERNALSYM PropertyTagExifColorSpace} + PropertyTagExifPixXDim = $A002; + {$EXTERNALSYM PropertyTagExifPixXDim} + PropertyTagExifPixYDim = $A003; + {$EXTERNALSYM PropertyTagExifPixYDim} + PropertyTagExifRelatedWav = $A004; // related sound file + {$EXTERNALSYM PropertyTagExifRelatedWav} + PropertyTagExifInterop = $A005; + {$EXTERNALSYM PropertyTagExifInterop} + PropertyTagExifFlashEnergy = $A20B; + {$EXTERNALSYM PropertyTagExifFlashEnergy} + PropertyTagExifSpatialFR = $A20C; // Spatial Frequency Response + {$EXTERNALSYM PropertyTagExifSpatialFR} + PropertyTagExifFocalXRes = $A20E; // Focal Plane X Resolution + {$EXTERNALSYM PropertyTagExifFocalXRes} + PropertyTagExifFocalYRes = $A20F; // Focal Plane Y Resolution + {$EXTERNALSYM PropertyTagExifFocalYRes} + PropertyTagExifFocalResUnit = $A210; // Focal Plane Resolution Unit + {$EXTERNALSYM PropertyTagExifFocalResUnit} + PropertyTagExifSubjectLoc = $A214; + {$EXTERNALSYM PropertyTagExifSubjectLoc} + PropertyTagExifExposureIndex = $A215; + {$EXTERNALSYM PropertyTagExifExposureIndex} + PropertyTagExifSensingMethod = $A217; + {$EXTERNALSYM PropertyTagExifSensingMethod} + PropertyTagExifFileSource = $A300; + {$EXTERNALSYM PropertyTagExifFileSource} + PropertyTagExifSceneType = $A301; + {$EXTERNALSYM PropertyTagExifSceneType} + PropertyTagExifCfaPattern = $A302; + {$EXTERNALSYM PropertyTagExifCfaPattern} + + PropertyTagGpsVer = $0000; + {$EXTERNALSYM PropertyTagGpsVer} + PropertyTagGpsLatitudeRef = $0001; + {$EXTERNALSYM PropertyTagGpsLatitudeRef} + PropertyTagGpsLatitude = $0002; + {$EXTERNALSYM PropertyTagGpsLatitude} + PropertyTagGpsLongitudeRef = $0003; + {$EXTERNALSYM PropertyTagGpsLongitudeRef} + PropertyTagGpsLongitude = $0004; + {$EXTERNALSYM PropertyTagGpsLongitude} + PropertyTagGpsAltitudeRef = $0005; + {$EXTERNALSYM PropertyTagGpsAltitudeRef} + PropertyTagGpsAltitude = $0006; + {$EXTERNALSYM PropertyTagGpsAltitude} + PropertyTagGpsGpsTime = $0007; + {$EXTERNALSYM PropertyTagGpsGpsTime} + PropertyTagGpsGpsSatellites = $0008; + {$EXTERNALSYM PropertyTagGpsGpsSatellites} + PropertyTagGpsGpsStatus = $0009; + {$EXTERNALSYM PropertyTagGpsGpsStatus} + PropertyTagGpsGpsMeasureMode = $00A; + {$EXTERNALSYM PropertyTagGpsGpsMeasureMode} + PropertyTagGpsGpsDop = $000B; // Measurement precision + {$EXTERNALSYM PropertyTagGpsGpsDop} + PropertyTagGpsSpeedRef = $000C; + {$EXTERNALSYM PropertyTagGpsSpeedRef} + PropertyTagGpsSpeed = $000D; + {$EXTERNALSYM PropertyTagGpsSpeed} + PropertyTagGpsTrackRef = $000E; + {$EXTERNALSYM PropertyTagGpsTrackRef} + PropertyTagGpsTrack = $000F; + {$EXTERNALSYM PropertyTagGpsTrack} + PropertyTagGpsImgDirRef = $0010; + {$EXTERNALSYM PropertyTagGpsImgDirRef} + PropertyTagGpsImgDir = $0011; + {$EXTERNALSYM PropertyTagGpsImgDir} + PropertyTagGpsMapDatum = $0012; + {$EXTERNALSYM PropertyTagGpsMapDatum} + PropertyTagGpsDestLatRef = $0013; + {$EXTERNALSYM PropertyTagGpsDestLatRef} + PropertyTagGpsDestLat = $0014; + {$EXTERNALSYM PropertyTagGpsDestLat} + PropertyTagGpsDestLongRef = $0015; + {$EXTERNALSYM PropertyTagGpsDestLongRef} + PropertyTagGpsDestLong = $0016; + {$EXTERNALSYM PropertyTagGpsDestLong} + PropertyTagGpsDestBearRef = $0017; + {$EXTERNALSYM PropertyTagGpsDestBearRef} + PropertyTagGpsDestBear = $0018; + {$EXTERNALSYM PropertyTagGpsDestBear} + PropertyTagGpsDestDistRef = $0019; + {$EXTERNALSYM PropertyTagGpsDestDistRef} + PropertyTagGpsDestDist = $001A; + {$EXTERNALSYM PropertyTagGpsDestDist} + +(**************************************************************************\ +* +* GDI+ Color Matrix object, used with Graphics.DrawImage +* +\**************************************************************************) + +//---------------------------------------------------------------------------- +// Color matrix +//---------------------------------------------------------------------------- + +type + {$EXTERNALSYM ColorMatrix} + ColorMatrix = packed array[0..4, 0..4] of Single; + TColorMatrix = ColorMatrix; + PColorMatrix = ^TColorMatrix; + +//---------------------------------------------------------------------------- +// Color Matrix flags +//---------------------------------------------------------------------------- + + {$EXTERNALSYM ColorMatrixFlags} + ColorMatrixFlags = ( + ColorMatrixFlagsDefault, + ColorMatrixFlagsSkipGrays, + ColorMatrixFlagsAltGray + ); + TColorMatrixFlags = ColorMatrixFlags; + +//---------------------------------------------------------------------------- +// Color Adjust Type +//---------------------------------------------------------------------------- + + {$EXTERNALSYM ColorAdjustType} + ColorAdjustType = ( + ColorAdjustTypeDefault, + ColorAdjustTypeBitmap, + ColorAdjustTypeBrush, + ColorAdjustTypePen, + ColorAdjustTypeText, + ColorAdjustTypeCount, + ColorAdjustTypeAny // Reserved + ); + TColorAdjustType = ColorAdjustType; + +//---------------------------------------------------------------------------- +// Color Map +//---------------------------------------------------------------------------- + + {$EXTERNALSYM ColorMap} + ColorMap = packed record + oldColor: TGPColor; + newColor: TGPColor; + end; + TColorMap = ColorMap; + PColorMap = ^TColorMap; + +//--------------------------------------------------------------------------- +// Private GDI+ classes for internal type checking +//--------------------------------------------------------------------------- + + GpGraphics = Pointer; + + GpBrush = Pointer; + GpTexture = Pointer; + GpSolidFill = Pointer; + GpLineGradient = Pointer; + GpPathGradient = Pointer; + GpHatch = Pointer; + + GpPen = Pointer; + GpCustomLineCap = Pointer; + GpAdjustableArrowCap = Pointer; + + GpImage = Pointer; + GpBitmap = Pointer; + GpMetafile = Pointer; + GpImageAttributes = Pointer; + + GpPath = Pointer; + GpRegion = Pointer; + GpPathIterator = Pointer; + + GpFontFamily = Pointer; + GpFont = Pointer; + GpStringFormat = Pointer; + GpFontCollection = Pointer; + GpCachedBitmap = Pointer; + + GpStatus = TStatus; + GpFillMode = TFillMode; + GpWrapMode = TWrapMode; + GpUnit = TUnit; + GpCoordinateSpace = TCoordinateSpace; + GpPointF = PGPPointF; + GpPoint = PGPPoint; + GpRectF = PGPRectF; + GpRect = PGPRect; + GpSizeF = PGPSizeF; + GpHatchStyle = THatchStyle; + GpDashStyle = TDashStyle; + GpLineCap = TLineCap; + GpDashCap = TDashCap; + + GpPenAlignment = TPenAlignment; + + GpLineJoin = TLineJoin; + GpPenType = TPenType; + + GpMatrix = Pointer; + GpBrushType = TBrushType; + GpMatrixOrder = TMatrixOrder; + GpFlushIntention = TFlushIntention; + GpPathData = TPathData; + +(**************************************************************************\ +* +* Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved. +* Module Name: +* GdiplusFlat.h +* Abstract: +* Private GDI+ header file. +* +\**************************************************************************) + + function GdipCreatePath(brushMode: GPFILLMODE; + out path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreatePath} + + function GdipCreatePath2(v1: GPPOINTF; v2: PBYTE; v3: Integer; v4: GPFILLMODE; + out path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreatePath2} + + function GdipCreatePath2I(v1: GPPOINT; v2: PBYTE; v3: Integer; v4: GPFILLMODE; + out path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreatePath2I} + + function GdipClonePath(path: GPPATH; + out clonePath: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipClonePath} + + function GdipDeletePath(path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDeletePath} + + function GdipResetPath(path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipResetPath} + + function GdipGetPointCount(path: GPPATH; + out count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPointCount} + + function GdipGetPathTypes(path: GPPATH; types: PBYTE; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathTypes} + + function GdipGetPathPoints(v1: GPPATH; points: GPPOINTF; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathPoints} + + function GdipGetPathPointsI(v1: GPPATH; points: GPPOINT; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathPointsI} + + function GdipGetPathFillMode(path: GPPATH; + var fillmode: GPFILLMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathFillMode} + + function GdipSetPathFillMode(path: GPPATH; + fillmode: GPFILLMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPathFillMode} + + function GdipGetPathData(path: GPPATH; + pathData: Pointer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathData} + + function GdipStartPathFigure(path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipStartPathFigure} + + function GdipClosePathFigure(path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipClosePathFigure} + + function GdipClosePathFigures(path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipClosePathFigures} + + function GdipSetPathMarker(path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPathMarker} + + function GdipClearPathMarkers(path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipClearPathMarkers} + + function GdipReversePath(path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipReversePath} + + function GdipGetPathLastPoint(path: GPPATH; + lastPoint: GPPOINTF): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathLastPoint} + + function GdipAddPathLine(path: GPPATH; + x1, y1, x2, y2: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathLine} + + function GdipAddPathLine2(path: GPPATH; points: GPPOINTF; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathLine2} + + function GdipAddPathArc(path: GPPATH; x, y, width, height, startAngle, + sweepAngle: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathArc} + + function GdipAddPathBezier(path: GPPATH; + x1, y1, x2, y2, x3, y3, x4, y4: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathBezier} + + function GdipAddPathBeziers(path: GPPATH; points: GPPOINTF; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathBeziers} + + function GdipAddPathCurve(path: GPPATH; points: GPPOINTF; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathCurve} + + function GdipAddPathCurve2(path: GPPATH; points: GPPOINTF; count: Integer; + tension: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathCurve2} + + function GdipAddPathCurve3(path: GPPATH; points: GPPOINTF; count: Integer; + offset: Integer; numberOfSegments: Integer; + tension: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathCurve3} + + function GdipAddPathClosedCurve(path: GPPATH; points: GPPOINTF; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathClosedCurve} + + function GdipAddPathClosedCurve2(path: GPPATH; points: GPPOINTF; + count: Integer; tension: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathClosedCurve2} + + function GdipAddPathRectangle(path: GPPATH; x: Single; y: Single; + width: Single; height: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathRectangle} + + function GdipAddPathRectangles(path: GPPATH; rects: GPRECTF; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathRectangles} + + function GdipAddPathEllipse(path: GPPATH; x: Single; y: Single; + width: Single; height: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathEllipse} + + function GdipAddPathPie(path: GPPATH; x: Single; y: Single; width: Single; + height: Single; startAngle: Single; sweepAngle: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathPie} + + function GdipAddPathPolygon(path: GPPATH; points: GPPOINTF; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathPolygon} + + function GdipAddPathPath(path: GPPATH; addingPath: GPPATH; + connect: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathPath} + + function GdipAddPathString(path: GPPATH; string_: PWCHAR; length: Integer; + family: GPFONTFAMILY; style: Integer; emSize: Single; layoutRect: PGPRectF; + format: GPSTRINGFORMAT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathString} + + function GdipAddPathStringI(path: GPPATH; string_: PWCHAR; length: Integer; + family: GPFONTFAMILY; style: Integer; emSize: Single; layoutRect: PGPRect; + format: GPSTRINGFORMAT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathStringI} + + function GdipAddPathLineI(path: GPPATH; x1: Integer; y1: Integer; x2: Integer; + y2: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathLineI} + + function GdipAddPathLine2I(path: GPPATH; points: GPPOINT; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathLine2I} + + function GdipAddPathArcI(path: GPPATH; x: Integer; y: Integer; width: Integer; + height: Integer; startAngle: Single; sweepAngle: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathArcI} + + function GdipAddPathBezierI(path: GPPATH; x1: Integer; y1: Integer; + x2: Integer; y2: Integer; x3: Integer; y3: Integer; x4: Integer; + y4: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathBezierI} + + function GdipAddPathBeziersI(path: GPPATH; points: GPPOINT; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathBeziersI} + + function GdipAddPathCurveI(path: GPPATH; points: GPPOINT; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathCurveI} + + function GdipAddPathCurve2I(path: GPPATH; points: GPPOINT; count: Integer; + tension: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathCurve2I} + + function GdipAddPathCurve3I(path: GPPATH; points: GPPOINT; count: Integer; + offset: Integer; numberOfSegments: Integer; + tension: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathCurve3I} + + function GdipAddPathClosedCurveI(path: GPPATH; points: GPPOINT; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathClosedCurveI} + + function GdipAddPathClosedCurve2I(path: GPPATH; points: GPPOINT; + count: Integer; tension: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathClosedCurve2I} + + function GdipAddPathRectangleI(path: GPPATH; x: Integer; y: Integer; + width: Integer; height: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathRectangleI} + + function GdipAddPathRectanglesI(path: GPPATH; rects: GPRECT; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathRectanglesI} + + function GdipAddPathEllipseI(path: GPPATH; x: Integer; y: Integer; + width: Integer; height: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathEllipseI} + + function GdipAddPathPieI(path: GPPATH; x: Integer; y: Integer; width: Integer; + height: Integer; startAngle: Single; sweepAngle: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathPieI} + + function GdipAddPathPolygonI(path: GPPATH; points: GPPOINT; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipAddPathPolygonI} + + function GdipFlattenPath(path: GPPATH; matrix: GPMATRIX; + flatness: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFlattenPath} + + function GdipWindingModeOutline(path: GPPATH; matrix: GPMATRIX; + flatness: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipWindingModeOutline} + + function GdipWidenPath(nativePath: GPPATH; pen: GPPEN; matrix: GPMATRIX; + flatness: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipWidenPath} + + function GdipWarpPath(path: GPPATH; matrix: GPMATRIX; points: GPPOINTF; + count: Integer; srcx: Single; srcy: Single; srcwidth: Single; + srcheight: Single; warpMode: WARPMODE; flatness: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipWarpPath} + + function GdipTransformPath(path: GPPATH; matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTransformPath} + + function GdipGetPathWorldBounds(path: GPPATH; bounds: GPRECTF; + matrix: GPMATRIX; pen: GPPEN): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathWorldBounds} + + function GdipGetPathWorldBoundsI(path: GPPATH; bounds: GPRECT; + matrix: GPMATRIX; pen: GPPEN): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathWorldBoundsI} + + function GdipIsVisiblePathPoint(path: GPPATH; x: Single; y: Single; + graphics: GPGRAPHICS; out result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsVisiblePathPoint} + + function GdipIsVisiblePathPointI(path: GPPATH; x: Integer; y: Integer; + graphics: GPGRAPHICS; out result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsVisiblePathPointI} + + function GdipIsOutlineVisiblePathPoint(path: GPPATH; x: Single; y: Single; + pen: GPPEN; graphics: GPGRAPHICS; out result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsOutlineVisiblePathPoint} + + function GdipIsOutlineVisiblePathPointI(path: GPPATH; x: Integer; y: Integer; + pen: GPPEN; graphics: GPGRAPHICS; out result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsOutlineVisiblePathPointI} + +//---------------------------------------------------------------------------- +// PathIterator APIs +//---------------------------------------------------------------------------- + + function GdipCreatePathIter(out iterator: GPPATHITERATOR; + path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreatePathIter} + + function GdipDeletePathIter(iterator: GPPATHITERATOR): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDeletePathIter} + + function GdipPathIterNextSubpath(iterator: GPPATHITERATOR; + var resultCount: Integer; var startIndex: Integer; var endIndex: Integer; + out isClosed: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipPathIterNextSubpath} + + function GdipPathIterNextSubpathPath(iterator: GPPATHITERATOR; + var resultCount: Integer; path: GPPATH; + out isClosed: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipPathIterNextSubpathPath} + + function GdipPathIterNextPathType(iterator: GPPATHITERATOR; + var resultCount: Integer; pathType: PBYTE; var startIndex: Integer; + var endIndex: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipPathIterNextPathType} + + function GdipPathIterNextMarker(iterator: GPPATHITERATOR; + var resultCount: Integer; var startIndex: Integer; + var endIndex: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipPathIterNextMarker} + + function GdipPathIterNextMarkerPath(iterator: GPPATHITERATOR; + var resultCount: Integer; path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipPathIterNextMarkerPath} + + function GdipPathIterGetCount(iterator: GPPATHITERATOR; + out count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipPathIterGetCount} + + function GdipPathIterGetSubpathCount(iterator: GPPATHITERATOR; + out count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipPathIterGetSubpathCount} + + function GdipPathIterIsValid(iterator: GPPATHITERATOR; + out valid: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipPathIterIsValid} + + function GdipPathIterHasCurve(iterator: GPPATHITERATOR; + out hasCurve: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipPathIterHasCurve} + + function GdipPathIterRewind(iterator: GPPATHITERATOR): GPSTATUS; stdcall; + {$EXTERNALSYM GdipPathIterRewind} + + function GdipPathIterEnumerate(iterator: GPPATHITERATOR; + var resultCount: Integer; points: GPPOINTF; types: PBYTE; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipPathIterEnumerate} + + function GdipPathIterCopyData(iterator: GPPATHITERATOR; + var resultCount: Integer; points: GPPOINTF; types: PBYTE; + startIndex: Integer; endIndex: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipPathIterCopyData} + +//---------------------------------------------------------------------------- +// Matrix APIs +//---------------------------------------------------------------------------- + + function GdipCreateMatrix(out matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateMatrix} + + function GdipCreateMatrix2(m11: Single; m12: Single; m21: Single; m22: Single; + dx: Single; dy: Single; out matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateMatrix2} + + function GdipCreateMatrix3(rect: GPRECTF; dstplg: GPPOINTF; + out matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateMatrix3} + + function GdipCreateMatrix3I(rect: GPRECT; dstplg: GPPOINT; + out matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateMatrix3I} + + function GdipCloneMatrix(matrix: GPMATRIX; + out cloneMatrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCloneMatrix} + + function GdipDeleteMatrix(matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDeleteMatrix} + + function GdipSetMatrixElements(matrix: GPMATRIX; m11: Single; m12: Single; + m21: Single; m22: Single; dx: Single; dy: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetMatrixElements} + + function GdipMultiplyMatrix(matrix: GPMATRIX; matrix2: GPMATRIX; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipMultiplyMatrix} + + function GdipTranslateMatrix(matrix: GPMATRIX; offsetX: Single; + offsetY: Single; order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTranslateMatrix} + + function GdipScaleMatrix(matrix: GPMATRIX; scaleX: Single; scaleY: Single; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipScaleMatrix} + + function GdipRotateMatrix(matrix: GPMATRIX; angle: Single; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipRotateMatrix} + + function GdipShearMatrix(matrix: GPMATRIX; shearX: Single; shearY: Single; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipShearMatrix} + + function GdipInvertMatrix(matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipInvertMatrix} + + function GdipTransformMatrixPoints(matrix: GPMATRIX; pts: GPPOINTF; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTransformMatrixPoints} + + function GdipTransformMatrixPointsI(matrix: GPMATRIX; pts: GPPOINT; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTransformMatrixPointsI} + + function GdipVectorTransformMatrixPoints(matrix: GPMATRIX; pts: GPPOINTF; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipVectorTransformMatrixPoints} + + function GdipVectorTransformMatrixPointsI(matrix: GPMATRIX; pts: GPPOINT; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipVectorTransformMatrixPointsI} + + function GdipGetMatrixElements(matrix: GPMATRIX; + matrixOut: PSingle): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetMatrixElements} + + function GdipIsMatrixInvertible(matrix: GPMATRIX; + out result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsMatrixInvertible} + + function GdipIsMatrixIdentity(matrix: GPMATRIX; + out result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsMatrixIdentity} + + function GdipIsMatrixEqual(matrix: GPMATRIX; matrix2: GPMATRIX; + out result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsMatrixEqual} + +//---------------------------------------------------------------------------- +// Region APIs +//---------------------------------------------------------------------------- + + function GdipCreateRegion(out region: GPREGION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateRegion} + + function GdipCreateRegionRect(rect: GPRECTF; + out region: GPREGION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateRegionRect} + + function GdipCreateRegionRectI(rect: GPRECT; + out region: GPREGION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateRegionRectI} + + function GdipCreateRegionPath(path: GPPATH; + out region: GPREGION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateRegionPath} + + function GdipCreateRegionRgnData(regionData: PBYTE; size: Integer; + out region: GPREGION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateRegionRgnData} + + function GdipCreateRegionHrgn(hRgn: HRGN; + out region: GPREGION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateRegionHrgn} + + function GdipCloneRegion(region: GPREGION; + out cloneRegion: GPREGION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCloneRegion} + + function GdipDeleteRegion(region: GPREGION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDeleteRegion} + + function GdipSetInfinite(region: GPREGION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetInfinite} + + function GdipSetEmpty(region: GPREGION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetEmpty} + + function GdipCombineRegionRect(region: GPREGION; rect: GPRECTF; + combineMode: COMBINEMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCombineRegionRect} + + function GdipCombineRegionRectI(region: GPREGION; rect: GPRECT; + combineMode: COMBINEMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCombineRegionRectI} + + function GdipCombineRegionPath(region: GPREGION; path: GPPATH; + combineMode: COMBINEMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCombineRegionPath} + + function GdipCombineRegionRegion(region: GPREGION; region2: GPREGION; + combineMode: COMBINEMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCombineRegionRegion} + + function GdipTranslateRegion(region: GPREGION; dx: Single; + dy: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTranslateRegion} + + function GdipTranslateRegionI(region: GPREGION; dx: Integer; + dy: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTranslateRegionI} + + function GdipTransformRegion(region: GPREGION; + matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTransformRegion} + + function GdipGetRegionBounds(region: GPREGION; graphics: GPGRAPHICS; + rect: GPRECTF): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetRegionBounds} + + function GdipGetRegionBoundsI(region: GPREGION; graphics: GPGRAPHICS; + rect: GPRECT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetRegionBoundsI} + + function GdipGetRegionHRgn(region: GPREGION; graphics: GPGRAPHICS; + out hRgn: HRGN): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetRegionHRgn} + + function GdipIsEmptyRegion(region: GPREGION; graphics: GPGRAPHICS; + out result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsEmptyRegion} + + function GdipIsInfiniteRegion(region: GPREGION; graphics: GPGRAPHICS; + out result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsInfiniteRegion} + + function GdipIsEqualRegion(region: GPREGION; region2: GPREGION; + graphics: GPGRAPHICS; out result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsEqualRegion} + + function GdipGetRegionDataSize(region: GPREGION; + out bufferSize: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetRegionDataSize} + + function GdipGetRegionData(region: GPREGION; buffer: PBYTE; + bufferSize: UINT; sizeFilled: PUINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetRegionData} + + function GdipIsVisibleRegionPoint(region: GPREGION; x: Single; y: Single; + graphics: GPGRAPHICS; out result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsVisibleRegionPoint} + + function GdipIsVisibleRegionPointI(region: GPREGION; x: Integer; y: Integer; + graphics: GPGRAPHICS; out result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsVisibleRegionPointI} + + function GdipIsVisibleRegionRect(region: GPREGION; x: Single; y: Single; + width: Single; height: Single; graphics: GPGRAPHICS; + out result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsVisibleRegionRect} + + function GdipIsVisibleRegionRectI(region: GPREGION; x: Integer; y: Integer; + width: Integer; height: Integer; graphics: GPGRAPHICS; + out result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsVisibleRegionRectI} + + function GdipGetRegionScansCount(region: GPREGION; out count: UINT; + matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetRegionScansCount} + + function GdipGetRegionScans(region: GPREGION; rects: GPRECTF; + out count: Integer; matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetRegionScans} + + function GdipGetRegionScansI(region: GPREGION; rects: GPRECT; + out count: Integer; matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetRegionScansI} + +//---------------------------------------------------------------------------- +// Brush APIs +//---------------------------------------------------------------------------- + + function GdipCloneBrush(brush: GPBRUSH; + out cloneBrush: GPBRUSH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCloneBrush} + + function GdipDeleteBrush(brush: GPBRUSH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDeleteBrush} + + function GdipGetBrushType(brush: GPBRUSH; + out type_: GPBRUSHTYPE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetBrushType} + +//---------------------------------------------------------------------------- +// HatchBrush APIs +//---------------------------------------------------------------------------- + + function GdipCreateHatchBrush(hatchstyle: Integer; forecol: ARGB; + backcol: ARGB; out brush: GPHATCH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateHatchBrush} + + function GdipGetHatchStyle(brush: GPHATCH; + out hatchstyle: GPHATCHSTYLE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetHatchStyle} + + function GdipGetHatchForegroundColor(brush: GPHATCH; + out forecol: ARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetHatchForegroundColor} + + function GdipGetHatchBackgroundColor(brush: GPHATCH; + out backcol: ARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetHatchBackgroundColor} + +//---------------------------------------------------------------------------- +// TextureBrush APIs +//---------------------------------------------------------------------------- + + + function GdipCreateTexture(image: GPIMAGE; wrapmode: GPWRAPMODE; + var texture: GPTEXTURE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateTexture} + + function GdipCreateTexture2(image: GPIMAGE; wrapmode: GPWRAPMODE; + x: Single; y: Single; width: Single; height: Single; + out texture: GPTEXTURE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateTexture2} + + function GdipCreateTextureIA(image: GPIMAGE; + imageAttributes: GPIMAGEATTRIBUTES; x: Single; y: Single; width: Single; + height: Single; out texture: GPTEXTURE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateTextureIA} + + function GdipCreateTexture2I(image: GPIMAGE; wrapmode: GPWRAPMODE; x: Integer; + y: Integer; width: Integer; height: Integer; + out texture: GPTEXTURE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateTexture2I} + + function GdipCreateTextureIAI(image: GPIMAGE; + imageAttributes: GPIMAGEATTRIBUTES; x: Integer; y: Integer; width: Integer; + height: Integer; out texture: GPTEXTURE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateTextureIAI} + + function GdipGetTextureTransform(brush: GPTEXTURE; + matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetTextureTransform} + + function GdipSetTextureTransform(brush: GPTEXTURE; + matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetTextureTransform} + + function GdipResetTextureTransform(brush: GPTEXTURE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipResetTextureTransform} + + function GdipMultiplyTextureTransform(brush: GPTEXTURE; matrix: GPMATRIX; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipMultiplyTextureTransform} + + function GdipTranslateTextureTransform(brush: GPTEXTURE; dx: Single; + dy: Single; order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTranslateTextureTransform} + + function GdipScaleTextureTransform(brush: GPTEXTURE; sx: Single; sy: Single; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipScaleTextureTransform} + + function GdipRotateTextureTransform(brush: GPTEXTURE; angle: Single; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipRotateTextureTransform} + + function GdipSetTextureWrapMode(brush: GPTEXTURE; + wrapmode: GPWRAPMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetTextureWrapMode} + + function GdipGetTextureWrapMode(brush: GPTEXTURE; + var wrapmode: GPWRAPMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetTextureWrapMode} + + function GdipGetTextureImage(brush: GPTEXTURE; + out image: GPIMAGE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetTextureImage} + +//---------------------------------------------------------------------------- +// SolidBrush APIs +//---------------------------------------------------------------------------- + + function GdipCreateSolidFill(color: ARGB; + out brush: GPSOLIDFILL): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateSolidFill} + + function GdipSetSolidFillColor(brush: GPSOLIDFILL; + color: ARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetSolidFillColor} + + function GdipGetSolidFillColor(brush: GPSOLIDFILL; + out color: ARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetSolidFillColor} + +//---------------------------------------------------------------------------- +// LineBrush APIs +//---------------------------------------------------------------------------- + + function GdipCreateLineBrush(point1: GPPOINTF; point2: GPPOINTF; color1: ARGB; + color2: ARGB; wrapMode: GPWRAPMODE; + out lineGradient: GPLINEGRADIENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateLineBrush} + + function GdipCreateLineBrushI(point1: GPPOINT; point2: GPPOINT; color1: ARGB; + color2: ARGB; wrapMode: GPWRAPMODE; + out lineGradient: GPLINEGRADIENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateLineBrushI} + + function GdipCreateLineBrushFromRect(rect: GPRECTF; color1: ARGB; + color2: ARGB; mode: LINEARGRADIENTMODE; wrapMode: GPWRAPMODE; + out lineGradient: GPLINEGRADIENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateLineBrushFromRect} + + function GdipCreateLineBrushFromRectI(rect: GPRECT; color1: ARGB; + color2: ARGB; mode: LINEARGRADIENTMODE; wrapMode: GPWRAPMODE; + out lineGradient: GPLINEGRADIENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateLineBrushFromRectI} + + function GdipCreateLineBrushFromRectWithAngle(rect: GPRECTF; color1: ARGB; + color2: ARGB; angle: Single; isAngleScalable: Bool; wrapMode: GPWRAPMODE; + out lineGradient: GPLINEGRADIENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateLineBrushFromRectWithAngle} + + function GdipCreateLineBrushFromRectWithAngleI(rect: GPRECT; color1: ARGB; + color2: ARGB; angle: Single; isAngleScalable: Bool; wrapMode: GPWRAPMODE; + out lineGradient: GPLINEGRADIENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateLineBrushFromRectWithAngleI} + + function GdipSetLineColors(brush: GPLINEGRADIENT; color1: ARGB; + color2: ARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetLineColors} + + function GdipGetLineColors(brush: GPLINEGRADIENT; + colors: PARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetLineColors} + + function GdipGetLineRect(brush: GPLINEGRADIENT; + rect: GPRECTF): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetLineRect} + + function GdipGetLineRectI(brush: GPLINEGRADIENT; + rect: GPRECT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetLineRectI} + + function GdipSetLineGammaCorrection(brush: GPLINEGRADIENT; + useGammaCorrection: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetLineGammaCorrection} + + function GdipGetLineGammaCorrection(brush: GPLINEGRADIENT; + out useGammaCorrection: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetLineGammaCorrection} + + function GdipGetLineBlendCount(brush: GPLINEGRADIENT; + out count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetLineBlendCount} + + function GdipGetLineBlend(brush: GPLINEGRADIENT; blend: PSingle; + positions: PSingle; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetLineBlend} + + function GdipSetLineBlend(brush: GPLINEGRADIENT; blend: PSingle; + positions: PSingle; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetLineBlend} + + function GdipGetLinePresetBlendCount(brush: GPLINEGRADIENT; + out count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetLinePresetBlendCount} + + function GdipGetLinePresetBlend(brush: GPLINEGRADIENT; blend: PARGB; + positions: PSingle; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetLinePresetBlend} + + function GdipSetLinePresetBlend(brush: GPLINEGRADIENT; blend: PARGB; + positions: PSingle; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetLinePresetBlend} + + function GdipSetLineSigmaBlend(brush: GPLINEGRADIENT; focus: Single; + scale: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetLineSigmaBlend} + + function GdipSetLineLinearBlend(brush: GPLINEGRADIENT; focus: Single; + scale: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetLineLinearBlend} + + function GdipSetLineWrapMode(brush: GPLINEGRADIENT; + wrapmode: GPWRAPMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetLineWrapMode} + + function GdipGetLineWrapMode(brush: GPLINEGRADIENT; + out wrapmode: GPWRAPMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetLineWrapMode} + + function GdipGetLineTransform(brush: GPLINEGRADIENT; + matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetLineTransform} + + function GdipSetLineTransform(brush: GPLINEGRADIENT; + matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetLineTransform} + + function GdipResetLineTransform(brush: GPLINEGRADIENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipResetLineTransform} + + function GdipMultiplyLineTransform(brush: GPLINEGRADIENT; matrix: GPMATRIX; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipMultiplyLineTransform} + + function GdipTranslateLineTransform(brush: GPLINEGRADIENT; dx: Single; + dy: Single; order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTranslateLineTransform} + + function GdipScaleLineTransform(brush: GPLINEGRADIENT; sx: Single; sy: Single; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipScaleLineTransform} + + function GdipRotateLineTransform(brush: GPLINEGRADIENT; angle: Single; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipRotateLineTransform} + +//---------------------------------------------------------------------------- +// PathGradientBrush APIs +//---------------------------------------------------------------------------- + + function GdipCreatePathGradient(points: GPPOINTF; count: Integer; + wrapMode: GPWRAPMODE; out polyGradient: GPPATHGRADIENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreatePathGradient} + + function GdipCreatePathGradientI(points: GPPOINT; count: Integer; + wrapMode: GPWRAPMODE; out polyGradient: GPPATHGRADIENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreatePathGradientI} + + function GdipCreatePathGradientFromPath(path: GPPATH; + out polyGradient: GPPATHGRADIENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreatePathGradientFromPath} + + function GdipGetPathGradientCenterColor(brush: GPPATHGRADIENT; + out colors: ARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientCenterColor} + + function GdipSetPathGradientCenterColor(brush: GPPATHGRADIENT; + colors: ARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPathGradientCenterColor} + + function GdipGetPathGradientSurroundColorsWithCount(brush: GPPATHGRADIENT; + color: PARGB; var count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientSurroundColorsWithCount} + + function GdipSetPathGradientSurroundColorsWithCount(brush: GPPATHGRADIENT; + color: PARGB; var count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPathGradientSurroundColorsWithCount} + + function GdipGetPathGradientPath(brush: GPPATHGRADIENT; + path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientPath} + + function GdipSetPathGradientPath(brush: GPPATHGRADIENT; + path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPathGradientPath} + + function GdipGetPathGradientCenterPoint(brush: GPPATHGRADIENT; + points: GPPOINTF): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientCenterPoint} + + function GdipGetPathGradientCenterPointI(brush: GPPATHGRADIENT; + points: GPPOINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientCenterPointI} + + function GdipSetPathGradientCenterPoint(brush: GPPATHGRADIENT; + points: GPPOINTF): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPathGradientCenterPoint} + + function GdipSetPathGradientCenterPointI(brush: GPPATHGRADIENT; + points: GPPOINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPathGradientCenterPointI} + + function GdipGetPathGradientRect(brush: GPPATHGRADIENT; + rect: GPRECTF): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientRect} + + function GdipGetPathGradientRectI(brush: GPPATHGRADIENT; + rect: GPRECT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientRectI} + + function GdipGetPathGradientPointCount(brush: GPPATHGRADIENT; + var count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientPointCount} + + function GdipGetPathGradientSurroundColorCount(brush: GPPATHGRADIENT; + var count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientSurroundColorCount} + + function GdipSetPathGradientGammaCorrection(brush: GPPATHGRADIENT; + useGammaCorrection: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPathGradientGammaCorrection} + + function GdipGetPathGradientGammaCorrection(brush: GPPATHGRADIENT; + var useGammaCorrection: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientGammaCorrection} + + function GdipGetPathGradientBlendCount(brush: GPPATHGRADIENT; + var count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientBlendCount} + + function GdipGetPathGradientBlend(brush: GPPATHGRADIENT; + blend: PSingle; positions: PSingle; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientBlend} + + function GdipSetPathGradientBlend(brush: GPPATHGRADIENT; + blend: PSingle; positions: PSingle; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPathGradientBlend} + + function GdipGetPathGradientPresetBlendCount(brush: GPPATHGRADIENT; + var count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientPresetBlendCount} + + function GdipGetPathGradientPresetBlend(brush: GPPATHGRADIENT; + blend: PARGB; positions: PSingle; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientPresetBlend} + + function GdipSetPathGradientPresetBlend(brush: GPPATHGRADIENT; + blend: PARGB; positions: PSingle; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPathGradientPresetBlend} + + function GdipSetPathGradientSigmaBlend(brush: GPPATHGRADIENT; + focus: Single; scale: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPathGradientSigmaBlend} + + function GdipSetPathGradientLinearBlend(brush: GPPATHGRADIENT; + focus: Single; scale: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPathGradientLinearBlend} + + function GdipGetPathGradientWrapMode(brush: GPPATHGRADIENT; + var wrapmode: GPWRAPMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientWrapMode} + + function GdipSetPathGradientWrapMode(brush: GPPATHGRADIENT; + wrapmode: GPWRAPMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPathGradientWrapMode} + + function GdipGetPathGradientTransform(brush: GPPATHGRADIENT; + matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientTransform} + + function GdipSetPathGradientTransform(brush: GPPATHGRADIENT; + matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPathGradientTransform} + + function GdipResetPathGradientTransform( + brush: GPPATHGRADIENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipResetPathGradientTransform} + + function GdipMultiplyPathGradientTransform(brush: GPPATHGRADIENT; + matrix: GPMATRIX; order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipMultiplyPathGradientTransform} + + function GdipTranslatePathGradientTransform(brush: GPPATHGRADIENT; + dx: Single; dy: Single; order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTranslatePathGradientTransform} + + function GdipScalePathGradientTransform(brush: GPPATHGRADIENT; + sx: Single; sy: Single; order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipScalePathGradientTransform} + + function GdipRotatePathGradientTransform(brush: GPPATHGRADIENT; + angle: Single; order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipRotatePathGradientTransform} + + function GdipGetPathGradientFocusScales(brush: GPPATHGRADIENT; + var xScale: Single; var yScale: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPathGradientFocusScales} + + function GdipSetPathGradientFocusScales(brush: GPPATHGRADIENT; + xScale: Single; yScale: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPathGradientFocusScales} + +//---------------------------------------------------------------------------- +// Pen APIs +//---------------------------------------------------------------------------- + + function GdipCreatePen1(color: ARGB; width: Single; unit_: GPUNIT; + out pen: GPPEN): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreatePen1} + + function GdipCreatePen2(brush: GPBRUSH; width: Single; unit_: GPUNIT; + out pen: GPPEN): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreatePen2} + + function GdipClonePen(pen: GPPEN; out clonepen: GPPEN): GPSTATUS; stdcall; + {$EXTERNALSYM GdipClonePen} + + function GdipDeletePen(pen: GPPEN): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDeletePen} + + function GdipSetPenWidth(pen: GPPEN; width: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenWidth} + + function GdipGetPenWidth(pen: GPPEN; out width: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenWidth} + + function GdipSetPenUnit(pen: GPPEN; unit_: GPUNIT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenUnit} + + function GdipGetPenUnit(pen: GPPEN; var unit_: GPUNIT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenUnit} + + function GdipSetPenLineCap197819(pen: GPPEN; startCap: GPLINECAP; + endCap: GPLINECAP; dashCap: GPDASHCAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenLineCap197819} + + function GdipSetPenStartCap(pen: GPPEN; + startCap: GPLINECAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenStartCap} + + function GdipSetPenEndCap(pen: GPPEN; endCap: GPLINECAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenEndCap} + + function GdipSetPenDashCap197819(pen: GPPEN; + dashCap: GPDASHCAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenDashCap197819} + + function GdipGetPenStartCap(pen: GPPEN; + out startCap: GPLINECAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenStartCap} + + function GdipGetPenEndCap(pen: GPPEN; + out endCap: GPLINECAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenEndCap} + + function GdipGetPenDashCap197819(pen: GPPEN; + out dashCap: GPDASHCAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenDashCap197819} + + function GdipSetPenLineJoin(pen: GPPEN; + lineJoin: GPLINEJOIN): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenLineJoin} + + function GdipGetPenLineJoin(pen: GPPEN; + var lineJoin: GPLINEJOIN): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenLineJoin} + + function GdipSetPenCustomStartCap(pen: GPPEN; + customCap: GPCUSTOMLINECAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenCustomStartCap} + + function GdipGetPenCustomStartCap(pen: GPPEN; + out customCap: GPCUSTOMLINECAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenCustomStartCap} + + function GdipSetPenCustomEndCap(pen: GPPEN; + customCap: GPCUSTOMLINECAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenCustomEndCap} + + function GdipGetPenCustomEndCap(pen: GPPEN; + out customCap: GPCUSTOMLINECAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenCustomEndCap} + + function GdipSetPenMiterLimit(pen: GPPEN; + miterLimit: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenMiterLimit} + + function GdipGetPenMiterLimit(pen: GPPEN; + out miterLimit: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenMiterLimit} + + function GdipSetPenMode(pen: GPPEN; + penMode: GPPENALIGNMENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenMode} + + function GdipGetPenMode(pen: GPPEN; + var penMode: GPPENALIGNMENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenMode} + + function GdipSetPenTransform(pen: GPPEN; + matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenTransform} + + function GdipGetPenTransform(pen: GPPEN; + matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenTransform} + + function GdipResetPenTransform(pen: GPPEN): GPSTATUS; stdcall; + {$EXTERNALSYM GdipResetPenTransform} + + function GdipMultiplyPenTransform(pen: GPPEN; matrix: GPMATRIX; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipMultiplyPenTransform} + + function GdipTranslatePenTransform(pen: GPPEN; dx: Single; dy: Single; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTranslatePenTransform} + + function GdipScalePenTransform(pen: GPPEN; sx: Single; sy: Single; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipScalePenTransform} + + function GdipRotatePenTransform(pen: GPPEN; angle: Single; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipRotatePenTransform} + + function GdipSetPenColor(pen: GPPEN; argb: ARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenColor} + + function GdipGetPenColor(pen: GPPEN; out argb: ARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenColor} + + function GdipSetPenBrushFill(pen: GPPEN; brush: GPBRUSH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenBrushFill} + + function GdipGetPenBrushFill(pen: GPPEN; + out brush: GPBRUSH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenBrushFill} + + function GdipGetPenFillType(pen: GPPEN; + out type_: GPPENTYPE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenFillType} + + function GdipGetPenDashStyle(pen: GPPEN; + out dashstyle: GPDASHSTYLE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenDashStyle} + + function GdipSetPenDashStyle(pen: GPPEN; + dashstyle: GPDASHSTYLE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenDashStyle} + + function GdipGetPenDashOffset(pen: GPPEN; + out offset: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenDashOffset} + + function GdipSetPenDashOffset(pen: GPPEN; offset: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenDashOffset} + + function GdipGetPenDashCount(pen: GPPEN; + var count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenDashCount} + + function GdipSetPenDashArray(pen: GPPEN; dash: PSingle; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenDashArray} + + function GdipGetPenDashArray(pen: GPPEN; dash: PSingle; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenDashArray} + + function GdipGetPenCompoundCount(pen: GPPEN; + out count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenCompoundCount} + + function GdipSetPenCompoundArray(pen: GPPEN; dash: PSingle; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPenCompoundArray} + + function GdipGetPenCompoundArray(pen: GPPEN; dash: PSingle; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPenCompoundArray} + +//---------------------------------------------------------------------------- +// CustomLineCap APIs +//---------------------------------------------------------------------------- + + function GdipCreateCustomLineCap(fillPath: GPPATH; strokePath: GPPATH; + baseCap: GPLINECAP; baseInset: Single; + out customCap: GPCUSTOMLINECAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateCustomLineCap} + + function GdipDeleteCustomLineCap( + customCap: GPCUSTOMLINECAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDeleteCustomLineCap} + + function GdipCloneCustomLineCap(customCap: GPCUSTOMLINECAP; + out clonedCap: GPCUSTOMLINECAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCloneCustomLineCap} + + function GdipGetCustomLineCapType(customCap: GPCUSTOMLINECAP; + var capType: CUSTOMLINECAPTYPE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetCustomLineCapType} + + function GdipSetCustomLineCapStrokeCaps(customCap: GPCUSTOMLINECAP; + startCap: GPLINECAP; endCap: GPLINECAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetCustomLineCapStrokeCaps} + + function GdipGetCustomLineCapStrokeCaps(customCap: GPCUSTOMLINECAP; + var startCap: GPLINECAP; var endCap: GPLINECAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetCustomLineCapStrokeCaps} + + function GdipSetCustomLineCapStrokeJoin(customCap: GPCUSTOMLINECAP; + lineJoin: GPLINEJOIN): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetCustomLineCapStrokeJoin} + + function GdipGetCustomLineCapStrokeJoin(customCap: GPCUSTOMLINECAP; + var lineJoin: GPLINEJOIN): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetCustomLineCapStrokeJoin} + + function GdipSetCustomLineCapBaseCap(customCap: GPCUSTOMLINECAP; + baseCap: GPLINECAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetCustomLineCapBaseCap} + + function GdipGetCustomLineCapBaseCap(customCap: GPCUSTOMLINECAP; + var baseCap: GPLINECAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetCustomLineCapBaseCap} + + function GdipSetCustomLineCapBaseInset(customCap: GPCUSTOMLINECAP; + inset: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetCustomLineCapBaseInset} + + function GdipGetCustomLineCapBaseInset(customCap: GPCUSTOMLINECAP; + var inset: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetCustomLineCapBaseInset} + + function GdipSetCustomLineCapWidthScale(customCap: GPCUSTOMLINECAP; + widthScale: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetCustomLineCapWidthScale} + + function GdipGetCustomLineCapWidthScale(customCap: GPCUSTOMLINECAP; + var widthScale: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetCustomLineCapWidthScale} + +//---------------------------------------------------------------------------- +// AdjustableArrowCap APIs +//---------------------------------------------------------------------------- + + function GdipCreateAdjustableArrowCap(height: Single; + width: Single; + isFilled: Bool; + out cap: GPADJUSTABLEARROWCAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateAdjustableArrowCap} + + function GdipSetAdjustableArrowCapHeight(cap: GPADJUSTABLEARROWCAP; + height: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetAdjustableArrowCapHeight} + + function GdipGetAdjustableArrowCapHeight(cap: GPADJUSTABLEARROWCAP; + var height: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetAdjustableArrowCapHeight} + + function GdipSetAdjustableArrowCapWidth(cap: GPADJUSTABLEARROWCAP; + width: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetAdjustableArrowCapWidth} + + function GdipGetAdjustableArrowCapWidth(cap: GPADJUSTABLEARROWCAP; + var width: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetAdjustableArrowCapWidth} + + function GdipSetAdjustableArrowCapMiddleInset(cap: GPADJUSTABLEARROWCAP; + middleInset: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetAdjustableArrowCapMiddleInset} + + function GdipGetAdjustableArrowCapMiddleInset(cap: GPADJUSTABLEARROWCAP; + var middleInset: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetAdjustableArrowCapMiddleInset} + + function GdipSetAdjustableArrowCapFillState(cap: GPADJUSTABLEARROWCAP; + fillState: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetAdjustableArrowCapFillState} + + function GdipGetAdjustableArrowCapFillState(cap: GPADJUSTABLEARROWCAP; + var fillState: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetAdjustableArrowCapFillState} + +//---------------------------------------------------------------------------- +// Image APIs +//---------------------------------------------------------------------------- + + function GdipLoadImageFromStream(stream: ISTREAM; + out image: GPIMAGE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipLoadImageFromStream} + + function GdipLoadImageFromFile(filename: PWCHAR; + out image: GPIMAGE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipLoadImageFromFile} + + function GdipLoadImageFromStreamICM(stream: ISTREAM; + out image: GPIMAGE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipLoadImageFromStreamICM} + + function GdipLoadImageFromFileICM(filename: PWCHAR; + out image: GPIMAGE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipLoadImageFromFileICM} + + function GdipCloneImage(image: GPIMAGE; + out cloneImage: GPIMAGE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCloneImage} + + function GdipDisposeImage(image: GPIMAGE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDisposeImage} + + function GdipSaveImageToFile(image: GPIMAGE; + filename: PWCHAR; + clsidEncoder: PGUID; + encoderParams: PENCODERPARAMETERS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSaveImageToFile} + + function GdipSaveImageToStream(image: GPIMAGE; + stream: ISTREAM; + clsidEncoder: PGUID; + encoderParams: PENCODERPARAMETERS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSaveImageToStream} + + function GdipSaveAdd(image: GPIMAGE; + encoderParams: PENCODERPARAMETERS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSaveAdd} + + function GdipSaveAddImage(image: GPIMAGE; + newImage: GPIMAGE; + encoderParams: PENCODERPARAMETERS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSaveAddImage} + + function GdipGetImageGraphicsContext(image: GPIMAGE; + out graphics: GPGRAPHICS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageGraphicsContext} + + function GdipGetImageBounds(image: GPIMAGE; + srcRect: GPRECTF; + var srcUnit: GPUNIT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageBounds} + + function GdipGetImageDimension(image: GPIMAGE; + var width: Single; + var height: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageDimension} + + function GdipGetImageType(image: GPIMAGE; + var type_: IMAGETYPE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageType} + + function GdipGetImageWidth(image: GPIMAGE; + var width: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageWidth} + + function GdipGetImageHeight(image: GPIMAGE; + var height: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageHeight} + + function GdipGetImageHorizontalResolution(image: GPIMAGE; + var resolution: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageHorizontalResolution} + + function GdipGetImageVerticalResolution(image: GPIMAGE; + var resolution: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageVerticalResolution} + + function GdipGetImageFlags(image: GPIMAGE; + var flags: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageFlags} + + function GdipGetImageRawFormat(image: GPIMAGE; + format: PGUID): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageRawFormat} + + function GdipGetImagePixelFormat(image: GPIMAGE; + out format: TPIXELFORMAT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImagePixelFormat} + + function GdipGetImageThumbnail(image: GPIMAGE; thumbWidth: UINT; + thumbHeight: UINT; out thumbImage: GPIMAGE; + callback: GETTHUMBNAILIMAGEABORT; callbackData: Pointer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageThumbnail} + + function GdipGetEncoderParameterListSize(image: GPIMAGE; + clsidEncoder: PGUID; out size: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetEncoderParameterListSize} + + function GdipGetEncoderParameterList(image: GPIMAGE; clsidEncoder: PGUID; + size: UINT; buffer: PENCODERPARAMETERS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetEncoderParameterList} + + function GdipImageGetFrameDimensionsCount(image: GPIMAGE; + var count: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipImageGetFrameDimensionsCount} + + function GdipImageGetFrameDimensionsList(image: GPIMAGE; dimensionIDs: PGUID; + count: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipImageGetFrameDimensionsList} + + function GdipImageGetFrameCount(image: GPIMAGE; dimensionID: PGUID; + var count: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipImageGetFrameCount} + + function GdipImageSelectActiveFrame(image: GPIMAGE; dimensionID: PGUID; + frameIndex: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipImageSelectActiveFrame} + + function GdipImageRotateFlip(image: GPIMAGE; + rfType: ROTATEFLIPTYPE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipImageRotateFlip} + + function GdipGetImagePalette(image: GPIMAGE; palette: PCOLORPALETTE; + size: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImagePalette} + + function GdipSetImagePalette(image: GPIMAGE; + palette: PCOLORPALETTE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetImagePalette} + + function GdipGetImagePaletteSize(image: GPIMAGE; + var size: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImagePaletteSize} + + function GdipGetPropertyCount(image: GPIMAGE; + var numOfProperty: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPropertyCount} + + function GdipGetPropertyIdList(image: GPIMAGE; numOfProperty: UINT; + list: PPROPID): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPropertyIdList} + + function GdipGetPropertyItemSize(image: GPIMAGE; propId: PROPID; + var size: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPropertyItemSize} + + function GdipGetPropertyItem(image: GPIMAGE; propId: PROPID; propSize: UINT; + buffer: PPROPERTYITEM): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPropertyItem} + + function GdipGetPropertySize(image: GPIMAGE; var totalBufferSize: UINT; + var numProperties: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPropertySize} + + function GdipGetAllPropertyItems(image: GPIMAGE; totalBufferSize: UINT; + numProperties: UINT; allItems: PPROPERTYITEM): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetAllPropertyItems} + + function GdipRemovePropertyItem(image: GPIMAGE; + propId: PROPID): GPSTATUS; stdcall; + {$EXTERNALSYM GdipRemovePropertyItem} + + function GdipSetPropertyItem(image: GPIMAGE; + item: PPROPERTYITEM): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPropertyItem} + + function GdipImageForceValidation(image: GPIMAGE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipImageForceValidation} + +//---------------------------------------------------------------------------- +// Bitmap APIs +//---------------------------------------------------------------------------- + + function GdipCreateBitmapFromStream(stream: ISTREAM; + out bitmap: GPBITMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateBitmapFromStream} + + function GdipCreateBitmapFromFile(filename: PWCHAR; + out bitmap: GPBITMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateBitmapFromFile} + + function GdipCreateBitmapFromStreamICM(stream: ISTREAM; + out bitmap: GPBITMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateBitmapFromStreamICM} + + function GdipCreateBitmapFromFileICM(filename: PWCHAR; + var bitmap: GPBITMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateBitmapFromFileICM} + + function GdipCreateBitmapFromScan0(width: Integer; height: Integer; + stride: Integer; format: PIXELFORMAT; scan0: PBYTE; + out bitmap: GPBITMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateBitmapFromScan0} + + function GdipCreateBitmapFromGraphics(width: Integer; height: Integer; + target: GPGRAPHICS; out bitmap: GPBITMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateBitmapFromGraphics} + + function GdipCreateBitmapFromDirectDrawSurface(surface: IDIRECTDRAWSURFACE7; + out bitmap: GPBITMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateBitmapFromDirectDrawSurface} + + function GdipCreateBitmapFromGdiDib(gdiBitmapInfo: PBitmapInfo; + gdiBitmapData: Pointer; out bitmap: GPBITMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateBitmapFromGdiDib} + + function GdipCreateBitmapFromHBITMAP(hbm: HBITMAP; hpal: HPALETTE; + out bitmap: GPBITMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateBitmapFromHBITMAP} + + function GdipCreateHBITMAPFromBitmap(bitmap: GPBITMAP; out hbmReturn: HBITMAP; + background: ARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateHBITMAPFromBitmap} + + function GdipCreateBitmapFromHICON(hicon: HICON; + out bitmap: GPBITMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateBitmapFromHICON} + + function GdipCreateHICONFromBitmap(bitmap: GPBITMAP; + out hbmReturn: HICON): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateHICONFromBitmap} + + function GdipCreateBitmapFromResource(hInstance: HMODULE; + lpBitmapName: PWCHAR; out bitmap: GPBITMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateBitmapFromResource} + + function GdipCloneBitmapArea(x: Single; y: Single; width: Single; + height: Single; format: PIXELFORMAT; srcBitmap: GPBITMAP; + out dstBitmap: GPBITMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCloneBitmapArea} + + function GdipCloneBitmapAreaI(x: Integer; y: Integer; width: Integer; + height: Integer; format: PIXELFORMAT; srcBitmap: GPBITMAP; + out dstBitmap: GPBITMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCloneBitmapAreaI} + + function GdipBitmapLockBits(bitmap: GPBITMAP; rect: GPRECT; flags: UINT; + format: PIXELFORMAT; lockedBitmapData: PBITMAPDATA): GPSTATUS; stdcall; + {$EXTERNALSYM GdipBitmapLockBits} + + function GdipBitmapUnlockBits(bitmap: GPBITMAP; + lockedBitmapData: PBITMAPDATA): GPSTATUS; stdcall; + {$EXTERNALSYM GdipBitmapUnlockBits} + + function GdipBitmapGetPixel(bitmap: GPBITMAP; x: Integer; y: Integer; + var color: ARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipBitmapGetPixel} + + function GdipBitmapSetPixel(bitmap: GPBITMAP; x: Integer; y: Integer; + color: ARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipBitmapSetPixel} + + function GdipBitmapSetResolution(bitmap: GPBITMAP; xdpi: Single; + ydpi: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipBitmapSetResolution} + +//---------------------------------------------------------------------------- +// ImageAttributes APIs +//---------------------------------------------------------------------------- + + function GdipCreateImageAttributes( + out imageattr: GPIMAGEATTRIBUTES): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateImageAttributes} + + function GdipCloneImageAttributes(imageattr: GPIMAGEATTRIBUTES; + out cloneImageattr: GPIMAGEATTRIBUTES): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCloneImageAttributes} + + function GdipDisposeImageAttributes( + imageattr: GPIMAGEATTRIBUTES): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDisposeImageAttributes} + + function GdipSetImageAttributesToIdentity(imageattr: GPIMAGEATTRIBUTES; + type_: COLORADJUSTTYPE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetImageAttributesToIdentity} + + function GdipResetImageAttributes(imageattr: GPIMAGEATTRIBUTES; + type_: COLORADJUSTTYPE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipResetImageAttributes} + + function GdipSetImageAttributesColorMatrix(imageattr: GPIMAGEATTRIBUTES; + type_: COLORADJUSTTYPE; enableFlag: Bool; colorMatrix: PCOLORMATRIX; + grayMatrix: PCOLORMATRIX; flags: COLORMATRIXFLAGS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetImageAttributesColorMatrix} + + function GdipSetImageAttributesThreshold(imageattr: GPIMAGEATTRIBUTES; + type_: COLORADJUSTTYPE; enableFlag: Bool; + threshold: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetImageAttributesThreshold} + + function GdipSetImageAttributesGamma(imageattr: GPIMAGEATTRIBUTES; + type_: COLORADJUSTTYPE; enableFlag: Bool; gamma: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetImageAttributesGamma} + + function GdipSetImageAttributesNoOp(imageattr: GPIMAGEATTRIBUTES; + type_: COLORADJUSTTYPE; enableFlag: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetImageAttributesNoOp} + + function GdipSetImageAttributesColorKeys(imageattr: GPIMAGEATTRIBUTES; + type_: COLORADJUSTTYPE; enableFlag: Bool; colorLow: ARGB; + colorHigh: ARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetImageAttributesColorKeys} + + function GdipSetImageAttributesOutputChannel(imageattr: GPIMAGEATTRIBUTES; + type_: COLORADJUSTTYPE; enableFlag: Bool; + channelFlags: COLORCHANNELFLAGS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetImageAttributesOutputChannel} + + function GdipSetImageAttributesOutputChannelColorProfile(imageattr: GPIMAGEATTRIBUTES; + type_: COLORADJUSTTYPE; enableFlag: Bool; + colorProfileFilename: PWCHAR): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetImageAttributesOutputChannelColorProfile} + + function GdipSetImageAttributesRemapTable(imageattr: GPIMAGEATTRIBUTES; + type_: COLORADJUSTTYPE; enableFlag: Bool; mapSize: UINT; + map: PCOLORMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetImageAttributesRemapTable} + + function GdipSetImageAttributesWrapMode(imageAttr: GPIMAGEATTRIBUTES; + wrap: WRAPMODE; argb: ARGB; clamp: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetImageAttributesWrapMode} + + function GdipSetImageAttributesICMMode(imageAttr: GPIMAGEATTRIBUTES; + on_: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetImageAttributesICMMode} + + function GdipGetImageAttributesAdjustedPalette(imageAttr: GPIMAGEATTRIBUTES; + colorPalette: PCOLORPALETTE; + colorAdjustType: COLORADJUSTTYPE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageAttributesAdjustedPalette} + +//---------------------------------------------------------------------------- +// Graphics APIs +//---------------------------------------------------------------------------- + + function GdipFlush(graphics: GPGRAPHICS; + intention: GPFLUSHINTENTION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFlush} + + function GdipCreateFromHDC(hdc: HDC; + out graphics: GPGRAPHICS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateFromHDC} + + function GdipCreateFromHDC2(hdc: HDC; hDevice: THandle; + out graphics: GPGRAPHICS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateFromHDC2} + + function GdipCreateFromHWND(hwnd: HWND; + out graphics: GPGRAPHICS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateFromHWND} + + function GdipCreateFromHWNDICM(hwnd: HWND; + out graphics: GPGRAPHICS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateFromHWNDICM} + + function GdipDeleteGraphics(graphics: GPGRAPHICS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDeleteGraphics} + + function GdipGetDC(graphics: GPGRAPHICS; var hdc: HDC): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetDC} + + function GdipReleaseDC(graphics: GPGRAPHICS; hdc: HDC): GPSTATUS; stdcall; + {$EXTERNALSYM GdipReleaseDC} + + function GdipSetCompositingMode(graphics: GPGRAPHICS; + compositingMode: COMPOSITINGMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetCompositingMode} + + function GdipGetCompositingMode(graphics: GPGRAPHICS; + var compositingMode: COMPOSITINGMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetCompositingMode} + + function GdipSetRenderingOrigin(graphics: GPGRAPHICS; x: Integer; + y: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetRenderingOrigin} + + function GdipGetRenderingOrigin(graphics: GPGRAPHICS; var x: Integer; + var y: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetRenderingOrigin} + + function GdipSetCompositingQuality(graphics: GPGRAPHICS; + compositingQuality: COMPOSITINGQUALITY): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetCompositingQuality} + + function GdipGetCompositingQuality(graphics: GPGRAPHICS; + var compositingQuality: COMPOSITINGQUALITY): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetCompositingQuality} + + function GdipSetSmoothingMode(graphics: GPGRAPHICS; + smoothingMode: SMOOTHINGMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetSmoothingMode} + + function GdipGetSmoothingMode(graphics: GPGRAPHICS; + var smoothingMode: SMOOTHINGMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetSmoothingMode} + + function GdipSetPixelOffsetMode(graphics: GPGRAPHICS; + pixelOffsetMode: PIXELOFFSETMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPixelOffsetMode} + + function GdipGetPixelOffsetMode(graphics: GPGRAPHICS; + var pixelOffsetMode: PIXELOFFSETMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPixelOffsetMode} + + function GdipSetTextRenderingHint(graphics: GPGRAPHICS; + mode: TEXTRENDERINGHINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetTextRenderingHint} + + function GdipGetTextRenderingHint(graphics: GPGRAPHICS; + var mode: TEXTRENDERINGHINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetTextRenderingHint} + + function GdipSetTextContrast(graphics: GPGRAPHICS; + contrast: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetTextContrast} + + function GdipGetTextContrast(graphics: GPGRAPHICS; + var contrast: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetTextContrast} + + function GdipSetInterpolationMode(graphics: GPGRAPHICS; + interpolationMode: INTERPOLATIONMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetInterpolationMode} + + function GdipGetInterpolationMode(graphics: GPGRAPHICS; + var interpolationMode: INTERPOLATIONMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetInterpolationMode} + + function GdipSetWorldTransform(graphics: GPGRAPHICS; + matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetWorldTransform} + + function GdipResetWorldTransform(graphics: GPGRAPHICS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipResetWorldTransform} + + function GdipMultiplyWorldTransform(graphics: GPGRAPHICS; matrix: GPMATRIX; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipMultiplyWorldTransform} + + function GdipTranslateWorldTransform(graphics: GPGRAPHICS; dx: Single; + dy: Single; order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTranslateWorldTransform} + + function GdipScaleWorldTransform(graphics: GPGRAPHICS; sx: Single; sy: Single; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipScaleWorldTransform} + + function GdipRotateWorldTransform(graphics: GPGRAPHICS; angle: Single; + order: GPMATRIXORDER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipRotateWorldTransform} + + function GdipGetWorldTransform(graphics: GPGRAPHICS; + matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetWorldTransform} + + function GdipResetPageTransform(graphics: GPGRAPHICS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipResetPageTransform} + + function GdipGetPageUnit(graphics: GPGRAPHICS; + var unit_: GPUNIT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPageUnit} + + function GdipGetPageScale(graphics: GPGRAPHICS; + var scale: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetPageScale} + + function GdipSetPageUnit(graphics: GPGRAPHICS; + unit_: GPUNIT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPageUnit} + + function GdipSetPageScale(graphics: GPGRAPHICS; + scale: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetPageScale} + + function GdipGetDpiX(graphics: GPGRAPHICS; + var dpi: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetDpiX} + + function GdipGetDpiY(graphics: GPGRAPHICS; + var dpi: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetDpiY} + + function GdipTransformPoints(graphics: GPGRAPHICS; + destSpace: GPCOORDINATESPACE; srcSpace: GPCOORDINATESPACE; + points: GPPOINTF; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTransformPoints} + + function GdipTransformPointsI(graphics: GPGRAPHICS; + destSpace: GPCOORDINATESPACE; srcSpace: GPCOORDINATESPACE; + points: GPPOINT; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTransformPointsI} + + function GdipGetNearestColor(graphics: GPGRAPHICS; + argb: PARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetNearestColor} + +// Creates the Win9x Halftone Palette (even on NT) with correct Desktop colors + + function GdipCreateHalftonePalette: HPALETTE; stdcall; + {$EXTERNALSYM GdipCreateHalftonePalette} + + function GdipDrawLine(graphics: GPGRAPHICS; pen: GPPEN; x1: Single; + y1: Single; x2: Single; y2: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawLine} + + function GdipDrawLineI(graphics: GPGRAPHICS; pen: GPPEN; x1: Integer; + y1: Integer; x2: Integer; y2: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawLineI} + + function GdipDrawLines(graphics: GPGRAPHICS; pen: GPPEN; points: GPPOINTF; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawLines} + + function GdipDrawLinesI(graphics: GPGRAPHICS; pen: GPPEN; points: GPPOINT; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawLinesI} + + function GdipDrawArc(graphics: GPGRAPHICS; pen: GPPEN; x: Single; y: Single; + width: Single; height: Single; startAngle: Single; + sweepAngle: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawArc} + + function GdipDrawArcI(graphics: GPGRAPHICS; pen: GPPEN; x: Integer; + y: Integer; width: Integer; height: Integer; startAngle: Single; + sweepAngle: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawArcI} + + function GdipDrawBezier(graphics: GPGRAPHICS; pen: GPPEN; x1: Single; + y1: Single; x2: Single; y2: Single; x3: Single; y3: Single; x4: Single; + y4: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawBezier} + + function GdipDrawBezierI(graphics: GPGRAPHICS; pen: GPPEN; x1: Integer; + y1: Integer; x2: Integer; y2: Integer; x3: Integer; y3: Integer; + x4: Integer; y4: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawBezierI} + + function GdipDrawBeziers(graphics: GPGRAPHICS; pen: GPPEN; points: GPPOINTF; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawBeziers} + + function GdipDrawBeziersI(graphics: GPGRAPHICS; pen: GPPEN; points: GPPOINT; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawBeziersI} + + function GdipDrawRectangle(graphics: GPGRAPHICS; pen: GPPEN; x: Single; + y: Single; width: Single; height: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawRectangle} + + function GdipDrawRectangleI(graphics: GPGRAPHICS; pen: GPPEN; x: Integer; + y: Integer; width: Integer; height: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawRectangleI} + + function GdipDrawRectangles(graphics: GPGRAPHICS; pen: GPPEN; rects: GPRECTF; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawRectangles} + + function GdipDrawRectanglesI(graphics: GPGRAPHICS; pen: GPPEN; rects: GPRECT; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawRectanglesI} + + function GdipDrawEllipse(graphics: GPGRAPHICS; pen: GPPEN; x: Single; + y: Single; width: Single; height: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawEllipse} + + function GdipDrawEllipseI(graphics: GPGRAPHICS; pen: GPPEN; x: Integer; + y: Integer; width: Integer; height: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawEllipseI} + + function GdipDrawPie(graphics: GPGRAPHICS; pen: GPPEN; x: Single; y: Single; + width: Single; height: Single; startAngle: Single; + sweepAngle: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawPie} + + function GdipDrawPieI(graphics: GPGRAPHICS; pen: GPPEN; x: Integer; + y: Integer; width: Integer; height: Integer; startAngle: Single; + sweepAngle: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawPieI} + + function GdipDrawPolygon(graphics: GPGRAPHICS; pen: GPPEN; points: GPPOINTF; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawPolygon} + + function GdipDrawPolygonI(graphics: GPGRAPHICS; pen: GPPEN; points: GPPOINT; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawPolygonI} + + function GdipDrawPath(graphics: GPGRAPHICS; pen: GPPEN; + path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawPath} + + function GdipDrawCurve(graphics: GPGRAPHICS; pen: GPPEN; points: GPPOINTF; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawCurve} + + function GdipDrawCurveI(graphics: GPGRAPHICS; pen: GPPEN; points: GPPOINT; + count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawCurveI} + + function GdipDrawCurve2(graphics: GPGRAPHICS; pen: GPPEN; points: GPPOINTF; + count: Integer; tension: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawCurve2} + + function GdipDrawCurve2I(graphics: GPGRAPHICS; pen: GPPEN; points: GPPOINT; + count: Integer; tension: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawCurve2I} + + function GdipDrawCurve3(graphics: GPGRAPHICS; pen: GPPEN; points: GPPOINTF; + count: Integer; offset: Integer; numberOfSegments: Integer; + tension: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawCurve3} + + function GdipDrawCurve3I(graphics: GPGRAPHICS; pen: GPPEN; points: GPPOINT; + count: Integer; offset: Integer; numberOfSegments: Integer; + tension: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawCurve3I} + + function GdipDrawClosedCurve(graphics: GPGRAPHICS; pen: GPPEN; + points: GPPOINTF; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawClosedCurve} + + function GdipDrawClosedCurveI(graphics: GPGRAPHICS; pen: GPPEN; + points: GPPOINT; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawClosedCurveI} + + function GdipDrawClosedCurve2(graphics: GPGRAPHICS; pen: GPPEN; + points: GPPOINTF; count: Integer; tension: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawClosedCurve2} + + function GdipDrawClosedCurve2I(graphics: GPGRAPHICS; pen: GPPEN; + points: GPPOINT; count: Integer; tension: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawClosedCurve2I} + + function GdipGraphicsClear(graphics: GPGRAPHICS; + color: ARGB): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGraphicsClear} + + function GdipFillRectangle(graphics: GPGRAPHICS; brush: GPBRUSH; x: Single; + y: Single; width: Single; height: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillRectangle} + + function GdipFillRectangleI(graphics: GPGRAPHICS; brush: GPBRUSH; x: Integer; + y: Integer; width: Integer; height: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillRectangleI} + + function GdipFillRectangles(graphics: GPGRAPHICS; brush: GPBRUSH; + rects: GPRECTF; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillRectangles} + + function GdipFillRectanglesI(graphics: GPGRAPHICS; brush: GPBRUSH; + rects: GPRECT; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillRectanglesI} + + function GdipFillPolygon(graphics: GPGRAPHICS; brush: GPBRUSH; + points: GPPOINTF; count: Integer; fillMode: GPFILLMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillPolygon} + + function GdipFillPolygonI(graphics: GPGRAPHICS; brush: GPBRUSH; + points: GPPOINT; count: Integer; fillMode: GPFILLMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillPolygonI} + + function GdipFillPolygon2(graphics: GPGRAPHICS; brush: GPBRUSH; + points: GPPOINTF; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillPolygon2} + + function GdipFillPolygon2I(graphics: GPGRAPHICS; brush: GPBRUSH; + points: GPPOINT; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillPolygon2I} + + function GdipFillEllipse(graphics: GPGRAPHICS; brush: GPBRUSH; x: Single; + y: Single; width: Single; height: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillEllipse} + + function GdipFillEllipseI(graphics: GPGRAPHICS; brush: GPBRUSH; x: Integer; + y: Integer; width: Integer; height: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillEllipseI} + + function GdipFillPie(graphics: GPGRAPHICS; brush: GPBRUSH; x: Single; + y: Single; width: Single; height: Single; startAngle: Single; + sweepAngle: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillPie} + + function GdipFillPieI(graphics: GPGRAPHICS; brush: GPBRUSH; x: Integer; + y: Integer; width: Integer; height: Integer; startAngle: Single; + sweepAngle: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillPieI} + + function GdipFillPath(graphics: GPGRAPHICS; brush: GPBRUSH; + path: GPPATH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillPath} + + function GdipFillClosedCurve(graphics: GPGRAPHICS; brush: GPBRUSH; + points: GPPOINTF; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillClosedCurve} + + function GdipFillClosedCurveI(graphics: GPGRAPHICS; brush: GPBRUSH; + points: GPPOINT; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillClosedCurveI} + + function GdipFillClosedCurve2(graphics: GPGRAPHICS; brush: GPBRUSH; + points: GPPOINTF; count: Integer; tension: Single; + fillMode: GPFILLMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillClosedCurve2} + + function GdipFillClosedCurve2I(graphics: GPGRAPHICS; brush: GPBRUSH; + points: GPPOINT; count: Integer; tension: Single; + fillMode: GPFILLMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillClosedCurve2I} + + function GdipFillRegion(graphics: GPGRAPHICS; brush: GPBRUSH; + region: GPREGION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFillRegion} + + function GdipDrawImage(graphics: GPGRAPHICS; image: GPIMAGE; x: Single; + y: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawImage} + + function GdipDrawImageI(graphics: GPGRAPHICS; image: GPIMAGE; x: Integer; + y: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawImageI} + + function GdipDrawImageRect(graphics: GPGRAPHICS; image: GPIMAGE; x: Single; + y: Single; width: Single; height: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawImageRect} + + function GdipDrawImageRectI(graphics: GPGRAPHICS; image: GPIMAGE; x: Integer; + y: Integer; width: Integer; height: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawImageRectI} + + function GdipDrawImagePoints(graphics: GPGRAPHICS; image: GPIMAGE; + dstpoints: GPPOINTF; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawImagePoints} + + function GdipDrawImagePointsI(graphics: GPGRAPHICS; image: GPIMAGE; + dstpoints: GPPOINT; count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawImagePointsI} + + function GdipDrawImagePointRect(graphics: GPGRAPHICS; image: GPIMAGE; + x: Single; y: Single; srcx: Single; srcy: Single; srcwidth: Single; + srcheight: Single; srcUnit: GPUNIT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawImagePointRect} + + function GdipDrawImagePointRectI(graphics: GPGRAPHICS; image: GPIMAGE; + x: Integer; y: Integer; srcx: Integer; srcy: Integer; srcwidth: Integer; + srcheight: Integer; srcUnit: GPUNIT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawImagePointRectI} + + function GdipDrawImageRectRect(graphics: GPGRAPHICS; image: GPIMAGE; + dstx: Single; dsty: Single; dstwidth: Single; dstheight: Single; + srcx: Single; srcy: Single; srcwidth: Single; srcheight: Single; + srcUnit: GPUNIT; imageAttributes: GPIMAGEATTRIBUTES; + callback: DRAWIMAGEABORT; callbackData: Pointer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawImageRectRect} + + function GdipDrawImageRectRectI(graphics: GPGRAPHICS; image: GPIMAGE; + dstx: Integer; dsty: Integer; dstwidth: Integer; dstheight: Integer; + srcx: Integer; srcy: Integer; srcwidth: Integer; srcheight: Integer; + srcUnit: GPUNIT; imageAttributes: GPIMAGEATTRIBUTES; + callback: DRAWIMAGEABORT; callbackData: Pointer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawImageRectRectI} + + function GdipDrawImagePointsRect(graphics: GPGRAPHICS; image: GPIMAGE; + points: GPPOINTF; count: Integer; srcx: Single; srcy: Single; + srcwidth: Single; srcheight: Single; srcUnit: GPUNIT; + imageAttributes: GPIMAGEATTRIBUTES; callback: DRAWIMAGEABORT; + callbackData: Pointer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawImagePointsRect} + + function GdipDrawImagePointsRectI(graphics: GPGRAPHICS; image: GPIMAGE; + points: GPPOINT; count: Integer; srcx: Integer; srcy: Integer; + srcwidth: Integer; srcheight: Integer; srcUnit: GPUNIT; + imageAttributes: GPIMAGEATTRIBUTES; callback: DRAWIMAGEABORT; + callbackData: Pointer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawImagePointsRectI} + + function GdipEnumerateMetafileDestPoint(graphics: GPGRAPHICS; + metafile: GPMETAFILE; destPoint: PGPPointF; callback: ENUMERATEMETAFILEPROC; + callbackData: Pointer; + imageAttributes: GPIMAGEATTRIBUTES): GPSTATUS; stdcall; + {$EXTERNALSYM GdipEnumerateMetafileDestPoint} + + function GdipEnumerateMetafileDestPointI(graphics: GPGRAPHICS; + metafile: GPMETAFILE; destPoint: PGPPoint; callback: ENUMERATEMETAFILEPROC; + callbackData: Pointer; + imageAttributes: GPIMAGEATTRIBUTES): GPSTATUS; stdcall; + {$EXTERNALSYM GdipEnumerateMetafileDestPointI} + + function GdipEnumerateMetafileDestRect(graphics: GPGRAPHICS; + metafile: GPMETAFILE; destRect: PGPRectF; callback: ENUMERATEMETAFILEPROC; + callbackData: Pointer; + imageAttributes: GPIMAGEATTRIBUTES): GPSTATUS; stdcall; + {$EXTERNALSYM GdipEnumerateMetafileDestRect} + + function GdipEnumerateMetafileDestRectI(graphics: GPGRAPHICS; + metafile: GPMETAFILE; destRect: PGPRect; callback: ENUMERATEMETAFILEPROC; + callbackData: Pointer; + imageAttributes: GPIMAGEATTRIBUTES): GPSTATUS; stdcall; + {$EXTERNALSYM GdipEnumerateMetafileDestRectI} + + function GdipEnumerateMetafileDestPoints(graphics: GPGRAPHICS; + metafile: GPMETAFILE; destPoints: PGPPointF; count: Integer; + callback: ENUMERATEMETAFILEPROC; callbackData: Pointer; + imageAttributes: GPIMAGEATTRIBUTES): GPSTATUS; stdcall; + {$EXTERNALSYM GdipEnumerateMetafileDestPoints} + + function GdipEnumerateMetafileDestPointsI(graphics: GPGRAPHICS; + metafile: GPMETAFILE; destPoints: PGPPoint; count: Integer; + callback: ENUMERATEMETAFILEPROC; callbackData: Pointer; + imageAttributes: GPIMAGEATTRIBUTES): GPSTATUS; stdcall; + {$EXTERNALSYM GdipEnumerateMetafileDestPointsI} + + function GdipEnumerateMetafileSrcRectDestPoint(graphics: GPGRAPHICS; + metafile: GPMETAFILE; destPoint: PGPPointF; srcRect: PGPRectF; srcUnit: TUNIT; + callback: ENUMERATEMETAFILEPROC; callbackData: Pointer; + imageAttributes: GPIMAGEATTRIBUTES): GPSTATUS; stdcall; + {$EXTERNALSYM GdipEnumerateMetafileSrcRectDestPoint} + + function GdipEnumerateMetafileSrcRectDestPointI(graphics: GPGRAPHICS; + metafile: GPMETAFILE; destPoint: PGPPoint; srcRect: PGPRect; srcUnit: TUNIT; + callback: ENUMERATEMETAFILEPROC; callbackData: Pointer; + imageAttributes: GPIMAGEATTRIBUTES): GPSTATUS; stdcall; + {$EXTERNALSYM GdipEnumerateMetafileSrcRectDestPointI} + + function GdipEnumerateMetafileSrcRectDestRect(graphics: GPGRAPHICS; + metafile: GPMETAFILE; destRect: PGPRectF; srcRect: PGPRectF; srcUnit: TUNIT; + callback: ENUMERATEMETAFILEPROC; callbackData: Pointer; + imageAttributes: GPIMAGEATTRIBUTES): GPSTATUS; stdcall; + {$EXTERNALSYM GdipEnumerateMetafileSrcRectDestRect} + + function GdipEnumerateMetafileSrcRectDestRectI(graphics: GPGRAPHICS; + metafile: GPMETAFILE; destRect: PGPRect; srcRect: PGPRect; srcUnit: TUNIT; + callback: ENUMERATEMETAFILEPROC; callbackData: Pointer; + imageAttributes: GPIMAGEATTRIBUTES): GPSTATUS; stdcall; + {$EXTERNALSYM GdipEnumerateMetafileSrcRectDestRectI} + + function GdipEnumerateMetafileSrcRectDestPoints(graphics: GPGRAPHICS; + metafile: GPMETAFILE; destPoints: PGPPointF; count: Integer; srcRect: PGPRectF; + srcUnit: TUNIT; callback: ENUMERATEMETAFILEPROC; callbackData: Pointer; + imageAttributes: GPIMAGEATTRIBUTES): GPSTATUS; stdcall; + {$EXTERNALSYM GdipEnumerateMetafileSrcRectDestPoints} + + function GdipEnumerateMetafileSrcRectDestPointsI(graphics: GPGRAPHICS; + metafile: GPMETAFILE; destPoints: PGPPoint; count: Integer; srcRect: PGPRect; + srcUnit: TUNIT; callback: ENUMERATEMETAFILEPROC; callbackData: Pointer; + imageAttributes: GPIMAGEATTRIBUTES): GPSTATUS; stdcall; + {$EXTERNALSYM GdipEnumerateMetafileSrcRectDestPointsI} + + function GdipPlayMetafileRecord(metafile: GPMETAFILE; + recordType: EMFPLUSRECORDTYPE; flags: UINT; dataSize: UINT; + data: PBYTE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipPlayMetafileRecord} + + function GdipSetClipGraphics(graphics: GPGRAPHICS; srcgraphics: GPGRAPHICS; + combineMode: COMBINEMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetClipGraphics} + + function GdipSetClipRect(graphics: GPGRAPHICS; x: Single; y: Single; + width: Single; height: Single; combineMode: COMBINEMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetClipRect} + + function GdipSetClipRectI(graphics: GPGRAPHICS; x: Integer; y: Integer; + width: Integer; height: Integer; + combineMode: COMBINEMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetClipRectI} + + function GdipSetClipPath(graphics: GPGRAPHICS; path: GPPATH; + combineMode: COMBINEMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetClipPath} + + function GdipSetClipRegion(graphics: GPGRAPHICS; region: GPREGION; + combineMode: COMBINEMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetClipRegion} + + function GdipSetClipHrgn(graphics: GPGRAPHICS; hRgn: HRGN; + combineMode: COMBINEMODE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetClipHrgn} + + function GdipResetClip(graphics: GPGRAPHICS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipResetClip} + + function GdipTranslateClip(graphics: GPGRAPHICS; dx: Single; + dy: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTranslateClip} + + function GdipTranslateClipI(graphics: GPGRAPHICS; dx: Integer; + dy: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipTranslateClipI} + + function GdipGetClip(graphics: GPGRAPHICS; + region: GPREGION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetClip} + + function GdipGetClipBounds(graphics: GPGRAPHICS; + rect: GPRECTF): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetClipBounds} + + function GdipGetClipBoundsI(graphics: GPGRAPHICS; + rect: GPRECT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetClipBoundsI} + + function GdipIsClipEmpty(graphics: GPGRAPHICS; + result: PBool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsClipEmpty} + + function GdipGetVisibleClipBounds(graphics: GPGRAPHICS; + rect: GPRECTF): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetVisibleClipBounds} + + function GdipGetVisibleClipBoundsI(graphics: GPGRAPHICS; + rect: GPRECT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetVisibleClipBoundsI} + + function GdipIsVisibleClipEmpty(graphics: GPGRAPHICS; + var result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsVisibleClipEmpty} + + function GdipIsVisiblePoint(graphics: GPGRAPHICS; x: Single; y: Single; + var result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsVisiblePoint} + + function GdipIsVisiblePointI(graphics: GPGRAPHICS; x: Integer; y: Integer; + var result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsVisiblePointI} + + function GdipIsVisibleRect(graphics: GPGRAPHICS; x: Single; y: Single; + width: Single; height: Single; var result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsVisibleRect} + + function GdipIsVisibleRectI(graphics: GPGRAPHICS; x: Integer; y: Integer; + width: Integer; height: Integer; var result: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsVisibleRectI} + + function GdipSaveGraphics(graphics: GPGRAPHICS; + var state: GRAPHICSSTATE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSaveGraphics} + + function GdipRestoreGraphics(graphics: GPGRAPHICS; + state: GRAPHICSSTATE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipRestoreGraphics} + + function GdipBeginContainer(graphics: GPGRAPHICS; dstrect: GPRECTF; + srcrect: GPRECTF; unit_: GPUNIT; + var state: GRAPHICSCONTAINER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipBeginContainer} + + function GdipBeginContainerI(graphics: GPGRAPHICS; dstrect: GPRECT; + srcrect: GPRECT; unit_: GPUNIT; + var state: GRAPHICSCONTAINER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipBeginContainerI} + + function GdipBeginContainer2(graphics: GPGRAPHICS; + var state: GRAPHICSCONTAINER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipBeginContainer2} + + function GdipEndContainer(graphics: GPGRAPHICS; + state: GRAPHICSCONTAINER): GPSTATUS; stdcall; + {$EXTERNALSYM GdipEndContainer} + + function GdipGetMetafileHeaderFromWmf(hWmf: HMETAFILE; + wmfPlaceableFileHeader: PWMFPLACEABLEFILEHEADER; + header: Pointer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetMetafileHeaderFromWmf} + + function GdipGetMetafileHeaderFromEmf(hEmf: HENHMETAFILE; + header: Pointer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetMetafileHeaderFromEmf} + + function GdipGetMetafileHeaderFromFile(filename: PWCHAR; + header: Pointer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetMetafileHeaderFromFile} + + function GdipGetMetafileHeaderFromStream(stream: ISTREAM; + header: Pointer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetMetafileHeaderFromStream} + + function GdipGetMetafileHeaderFromMetafile(metafile: GPMETAFILE; + header: Pointer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetMetafileHeaderFromMetafile} + + function GdipGetHemfFromMetafile(metafile: GPMETAFILE; + var hEmf: HENHMETAFILE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetHemfFromMetafile} + + function GdipCreateStreamOnFile(filename: PWCHAR; access: UINT; + out stream: ISTREAM): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateStreamOnFile} + + function GdipCreateMetafileFromWmf(hWmf: HMETAFILE; deleteWmf: Bool; + wmfPlaceableFileHeader: PWMFPLACEABLEFILEHEADER; + out metafile: GPMETAFILE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateMetafileFromWmf} + + function GdipCreateMetafileFromEmf(hEmf: HENHMETAFILE; deleteEmf: Bool; + out metafile: GPMETAFILE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateMetafileFromEmf} + + function GdipCreateMetafileFromFile(file_: PWCHAR; + out metafile: GPMETAFILE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateMetafileFromFile} + + function GdipCreateMetafileFromWmfFile(file_: PWCHAR; + wmfPlaceableFileHeader: PWMFPLACEABLEFILEHEADER; + out metafile: GPMETAFILE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateMetafileFromWmfFile} + + function GdipCreateMetafileFromStream(stream: ISTREAM; + out metafile: GPMETAFILE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateMetafileFromStream} + + function GdipRecordMetafile(referenceHdc: HDC; type_: EMFTYPE; + frameRect: GPRECTF; frameUnit: METAFILEFRAMEUNIT; + description: PWCHAR; out metafile: GPMETAFILE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipRecordMetafile} + + function GdipRecordMetafileI(referenceHdc: HDC; type_: EMFTYPE; + frameRect: GPRECT; frameUnit: METAFILEFRAMEUNIT; description: PWCHAR; + out metafile: GPMETAFILE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipRecordMetafileI} + + function GdipRecordMetafileFileName(fileName: PWCHAR; referenceHdc: HDC; + type_: EMFTYPE; frameRect: GPRECTF; frameUnit: METAFILEFRAMEUNIT; + description: PWCHAR; out metafile: GPMETAFILE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipRecordMetafileFileName} + + function GdipRecordMetafileFileNameI(fileName: PWCHAR; referenceHdc: HDC; + type_: EMFTYPE; frameRect: GPRECT; frameUnit: METAFILEFRAMEUNIT; + description: PWCHAR; out metafile: GPMETAFILE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipRecordMetafileFileNameI} + + function GdipRecordMetafileStream(stream: ISTREAM; referenceHdc: HDC; + type_: EMFTYPE; frameRect: GPRECTF; frameUnit: METAFILEFRAMEUNIT; + description: PWCHAR; out metafile: GPMETAFILE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipRecordMetafileStream} + + function GdipRecordMetafileStreamI(stream: ISTREAM; referenceHdc: HDC; + type_: EMFTYPE; frameRect: GPRECT; frameUnit: METAFILEFRAMEUNIT; + description: PWCHAR; out metafile: GPMETAFILE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipRecordMetafileStreamI} + + function GdipSetMetafileDownLevelRasterizationLimit(metafile: GPMETAFILE; + metafileRasterizationLimitDpi: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetMetafileDownLevelRasterizationLimit} + + function GdipGetMetafileDownLevelRasterizationLimit(metafile: GPMETAFILE; + var metafileRasterizationLimitDpi: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetMetafileDownLevelRasterizationLimit} + + function GdipGetImageDecodersSize(out numDecoders: UINT; + out size: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageDecodersSize} + + function GdipGetImageDecoders(numDecoders: UINT; size: UINT; + decoders: PIMAGECODECINFO): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageDecoders} + + function GdipGetImageEncodersSize(out numEncoders: UINT; + out size: UINT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageEncodersSize} + + function GdipGetImageEncoders(numEncoders: UINT; size: UINT; + encoders: PIMAGECODECINFO): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetImageEncoders} + + function GdipComment(graphics: GPGRAPHICS; sizeData: UINT; + data: PBYTE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipComment} + +//---------------------------------------------------------------------------- +// FontFamily APIs +//---------------------------------------------------------------------------- + + function GdipCreateFontFamilyFromName(name: PWCHAR; + fontCollection: GPFONTCOLLECTION; + out FontFamily: GPFONTFAMILY): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateFontFamilyFromName} + + function GdipDeleteFontFamily(FontFamily: GPFONTFAMILY): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDeleteFontFamily} + + function GdipCloneFontFamily(FontFamily: GPFONTFAMILY; + out clonedFontFamily: GPFONTFAMILY): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCloneFontFamily} + + function GdipGetGenericFontFamilySansSerif( + out nativeFamily: GPFONTFAMILY): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetGenericFontFamilySansSerif} + + function GdipGetGenericFontFamilySerif( + out nativeFamily: GPFONTFAMILY): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetGenericFontFamilySerif} + + function GdipGetGenericFontFamilyMonospace( + out nativeFamily: GPFONTFAMILY): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetGenericFontFamilyMonospace} + + function GdipGetFamilyName(family: GPFONTFAMILY; name: PWideChar; + language: LANGID): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetFamilyName} + + function GdipIsStyleAvailable(family: GPFONTFAMILY; style: Integer; + var IsStyleAvailable: Bool): GPSTATUS; stdcall; + {$EXTERNALSYM GdipIsStyleAvailable} + + function GdipFontCollectionEnumerable(fontCollection: GPFONTCOLLECTION; + graphics: GPGRAPHICS; var numFound: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFontCollectionEnumerable} + + function GdipFontCollectionEnumerate(fontCollection: GPFONTCOLLECTION; + numSought: Integer; gpfamilies: array of GPFONTFAMILY; + var numFound: Integer; graphics: GPGRAPHICS): GPSTATUS; stdcall; + {$EXTERNALSYM GdipFontCollectionEnumerate} + + function GdipGetEmHeight(family: GPFONTFAMILY; style: Integer; + out EmHeight: UINT16): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetEmHeight} + + function GdipGetCellAscent(family: GPFONTFAMILY; style: Integer; + var CellAscent: UINT16): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetCellAscent} + + function GdipGetCellDescent(family: GPFONTFAMILY; style: Integer; + var CellDescent: UINT16): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetCellDescent} + + function GdipGetLineSpacing(family: GPFONTFAMILY; style: Integer; + var LineSpacing: UINT16): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetLineSpacing} + +//---------------------------------------------------------------------------- +// Font APIs +//---------------------------------------------------------------------------- + + function GdipCreateFontFromDC(hdc: HDC; out font: GPFONT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateFontFromDC} + + function GdipCreateFontFromLogfontA(hdc: HDC; logfont: PLOGFONTA; + out font: GPFONT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateFontFromLogfontA} + + function GdipCreateFontFromLogfontW(hdc: HDC; logfont: PLOGFONTW; + out font: GPFONT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateFontFromLogfontW} + + function GdipCreateFont(fontFamily: GPFONTFAMILY; emSize: Single; + style: Integer; unit_: Integer; out font: GPFONT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateFont} + + function GdipCloneFont(font: GPFONT; + out cloneFont: GPFONT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCloneFont} + + function GdipDeleteFont(font: GPFONT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDeleteFont} + + function GdipGetFamily(font: GPFONT; + out family: GPFONTFAMILY): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetFamily} + + function GdipGetFontStyle(font: GPFONT; + var style: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetFontStyle} + + function GdipGetFontSize(font: GPFONT; var size: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetFontSize} + + function GdipGetFontUnit(font: GPFONT; var unit_: TUNIT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetFontUnit} + + function GdipGetFontHeight(font: GPFONT; graphics: GPGRAPHICS; + var height: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetFontHeight} + + function GdipGetFontHeightGivenDPI(font: GPFONT; dpi: Single; + var height: Single): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetFontHeightGivenDPI} + + function GdipGetLogFontA(font: GPFONT; graphics: GPGRAPHICS; + var logfontA: LOGFONTA): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetLogFontA} + + function GdipGetLogFontW(font: GPFONT; graphics: GPGRAPHICS; + var logfontW: LOGFONTW): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetLogFontW} + + function GdipNewInstalledFontCollection( + out fontCollection: GPFONTCOLLECTION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipNewInstalledFontCollection} + + function GdipNewPrivateFontCollection( + out fontCollection: GPFONTCOLLECTION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipNewPrivateFontCollection} + + function GdipDeletePrivateFontCollection( + out fontCollection: GPFONTCOLLECTION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDeletePrivateFontCollection} + + function GdipGetFontCollectionFamilyCount(fontCollection: GPFONTCOLLECTION; + var numFound: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetFontCollectionFamilyCount} + + function GdipGetFontCollectionFamilyList(fontCollection: GPFONTCOLLECTION; + numSought: Integer; gpfamilies: GPFONTFAMILY; + var numFound: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetFontCollectionFamilyList} + + function GdipPrivateAddFontFile(fontCollection: GPFONTCOLLECTION; + filename: PWCHAR): GPSTATUS; stdcall; + {$EXTERNALSYM GdipPrivateAddFontFile} + + function GdipPrivateAddMemoryFont(fontCollection: GPFONTCOLLECTION; + memory: Pointer; length: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipPrivateAddMemoryFont} + +//---------------------------------------------------------------------------- +// Text APIs +//---------------------------------------------------------------------------- + + function GdipDrawString(graphics: GPGRAPHICS; string_: PWCHAR; + length: Integer; font: GPFONT; layoutRect: PGPRectF; + stringFormat: GPSTRINGFORMAT; brush: GPBRUSH): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawString} + + function GdipMeasureString(graphics: GPGRAPHICS; string_: PWCHAR; + length: Integer; font: GPFONT; layoutRect: PGPRectF; + stringFormat: GPSTRINGFORMAT; boundingBox: PGPRectF; + codepointsFitted: PInteger; linesFilled: PInteger): GPSTATUS; stdcall; + {$EXTERNALSYM GdipMeasureString} + + function GdipMeasureCharacterRanges(graphics: GPGRAPHICS; string_: PWCHAR; + length: Integer; font: GPFONT; layoutRect: PGPRectF; + stringFormat: GPSTRINGFORMAT; regionCount: Integer; + const regions: GPREGION): GPSTATUS; stdcall; + {$EXTERNALSYM GdipMeasureCharacterRanges} + + function GdipDrawDriverString(graphics: GPGRAPHICS; const text: PUINT16; + length: Integer; const font: GPFONT; const brush: GPBRUSH; + const positions: PGPPointF; flags: Integer; + const matrix: GPMATRIX): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawDriverString} + + function GdipMeasureDriverString(graphics: GPGRAPHICS; text: PUINT16; + length: Integer; font: GPFONT; positions: PGPPointF; flags: Integer; + matrix: GPMATRIX; boundingBox: PGPRectF): GPSTATUS; stdcall; + {$EXTERNALSYM GdipMeasureDriverString} + +//---------------------------------------------------------------------------- +// String format APIs +//---------------------------------------------------------------------------- + + function GdipCreateStringFormat(formatAttributes: Integer; language: LANGID; + out format: GPSTRINGFORMAT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateStringFormat} + + function GdipStringFormatGetGenericDefault( + out format: GPSTRINGFORMAT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipStringFormatGetGenericDefault} + + function GdipStringFormatGetGenericTypographic( + out format: GPSTRINGFORMAT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipStringFormatGetGenericTypographic} + + function GdipDeleteStringFormat(format: GPSTRINGFORMAT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDeleteStringFormat} + + function GdipCloneStringFormat(format: GPSTRINGFORMAT; + out newFormat: GPSTRINGFORMAT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCloneStringFormat} + + function GdipSetStringFormatFlags(format: GPSTRINGFORMAT; + flags: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetStringFormatFlags} + + function GdipGetStringFormatFlags(format: GPSTRINGFORMAT; + out flags: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetStringFormatFlags} + + function GdipSetStringFormatAlign(format: GPSTRINGFORMAT; + align: STRINGALIGNMENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetStringFormatAlign} + + function GdipGetStringFormatAlign(format: GPSTRINGFORMAT; + out align: STRINGALIGNMENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetStringFormatAlign} + + function GdipSetStringFormatLineAlign(format: GPSTRINGFORMAT; + align: STRINGALIGNMENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetStringFormatLineAlign} + + function GdipGetStringFormatLineAlign(format: GPSTRINGFORMAT; + out align: STRINGALIGNMENT): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetStringFormatLineAlign} + + function GdipSetStringFormatTrimming(format: GPSTRINGFORMAT; + trimming: STRINGTRIMMING): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetStringFormatTrimming} + + function GdipGetStringFormatTrimming(format: GPSTRINGFORMAT; + out trimming: STRINGTRIMMING): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetStringFormatTrimming} + + function GdipSetStringFormatHotkeyPrefix(format: GPSTRINGFORMAT; + hotkeyPrefix: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetStringFormatHotkeyPrefix} + + function GdipGetStringFormatHotkeyPrefix(format: GPSTRINGFORMAT; + out hotkeyPrefix: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetStringFormatHotkeyPrefix} + + function GdipSetStringFormatTabStops(format: GPSTRINGFORMAT; + firstTabOffset: Single; count: Integer; + tabStops: PSingle): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetStringFormatTabStops} + + function GdipGetStringFormatTabStops(format: GPSTRINGFORMAT; + count: Integer; firstTabOffset: PSingle; + tabStops: PSingle): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetStringFormatTabStops} + + function GdipGetStringFormatTabStopCount(format: GPSTRINGFORMAT; + out count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetStringFormatTabStopCount} + + function GdipSetStringFormatDigitSubstitution(format: GPSTRINGFORMAT; + language: LANGID; + substitute: STRINGDIGITSUBSTITUTE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetStringFormatDigitSubstitution} + + function GdipGetStringFormatDigitSubstitution(format: GPSTRINGFORMAT; + language: PUINT; substitute: PSTRINGDIGITSUBSTITUTE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetStringFormatDigitSubstitution} + + function GdipGetStringFormatMeasurableCharacterRangeCount(format: GPSTRINGFORMAT; + out count: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipGetStringFormatMeasurableCharacterRangeCount} + + function GdipSetStringFormatMeasurableCharacterRanges(format: GPSTRINGFORMAT; + rangeCount: Integer; ranges: PCHARACTERRANGE): GPSTATUS; stdcall; + {$EXTERNALSYM GdipSetStringFormatMeasurableCharacterRanges} + +//---------------------------------------------------------------------------- +// Cached Bitmap APIs +//---------------------------------------------------------------------------- + + function GdipCreateCachedBitmap(bitmap: GPBITMAP; graphics: GPGRAPHICS; + out cachedBitmap: GPCACHEDBITMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipCreateCachedBitmap} + + function GdipDeleteCachedBitmap( + cachedBitmap: GPCACHEDBITMAP): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDeleteCachedBitmap} + + function GdipDrawCachedBitmap(graphics: GPGRAPHICS; + cachedBitmap: GPCACHEDBITMAP; x: Integer; + y: Integer): GPSTATUS; stdcall; + {$EXTERNALSYM GdipDrawCachedBitmap} + + function GdipEmfToWmfBits(hemf: HENHMETAFILE; cbData16: UINT; pData16: PBYTE; + iMapMode: Integer; eFlags: Integer): UINT; stdcall; + {$EXTERNALSYM GdipEmfToWmfBits} + +implementation + + function GdipAlloc; external WINGDIPDLL name 'GdipAlloc'; + procedure GdipFree; external WINGDIPDLL name 'GdipFree'; + function GdiplusStartup; external WINGDIPDLL name 'GdiplusStartup'; + procedure GdiplusShutdown; external WINGDIPDLL name 'GdiplusShutdown'; + + function GdipCreatePath; external WINGDIPDLL name 'GdipCreatePath'; + function GdipCreatePath2; external WINGDIPDLL name 'GdipCreatePath2'; + function GdipCreatePath2I; external WINGDIPDLL name 'GdipCreatePath2I'; + function GdipClonePath; external WINGDIPDLL name 'GdipClonePath'; + function GdipDeletePath; external WINGDIPDLL name 'GdipDeletePath'; + function GdipResetPath; external WINGDIPDLL name 'GdipResetPath'; + function GdipGetPointCount; external WINGDIPDLL name 'GdipGetPointCount'; + function GdipGetPathTypes; external WINGDIPDLL name 'GdipGetPathTypes'; + function GdipGetPathPoints; external WINGDIPDLL name 'GdipGetPathPoints'; + function GdipGetPathPointsI; external WINGDIPDLL name 'GdipGetPathPointsI'; + function GdipGetPathFillMode; external WINGDIPDLL name 'GdipGetPathFillMode'; + function GdipSetPathFillMode; external WINGDIPDLL name 'GdipSetPathFillMode'; + function GdipGetPathData; external WINGDIPDLL name 'GdipGetPathData'; + function GdipStartPathFigure; external WINGDIPDLL name 'GdipStartPathFigure'; + function GdipClosePathFigure; external WINGDIPDLL name 'GdipClosePathFigure'; + function GdipClosePathFigures; external WINGDIPDLL name 'GdipClosePathFigures'; + function GdipSetPathMarker; external WINGDIPDLL name 'GdipSetPathMarker'; + function GdipClearPathMarkers; external WINGDIPDLL name 'GdipClearPathMarkers'; + function GdipReversePath; external WINGDIPDLL name 'GdipReversePath'; + function GdipGetPathLastPoint; external WINGDIPDLL name 'GdipGetPathLastPoint'; + function GdipAddPathLine; external WINGDIPDLL name 'GdipAddPathLine'; + function GdipAddPathLine2; external WINGDIPDLL name 'GdipAddPathLine2'; + function GdipAddPathArc; external WINGDIPDLL name 'GdipAddPathArc'; + function GdipAddPathBezier; external WINGDIPDLL name 'GdipAddPathBezier'; + function GdipAddPathBeziers; external WINGDIPDLL name 'GdipAddPathBeziers'; + function GdipAddPathCurve; external WINGDIPDLL name 'GdipAddPathCurve'; + function GdipAddPathCurve2; external WINGDIPDLL name 'GdipAddPathCurve2'; + function GdipAddPathCurve3; external WINGDIPDLL name 'GdipAddPathCurve3'; + function GdipAddPathClosedCurve; external WINGDIPDLL name 'GdipAddPathClosedCurve'; + function GdipAddPathClosedCurve2; external WINGDIPDLL name 'GdipAddPathClosedCurve2'; + function GdipAddPathRectangle; external WINGDIPDLL name 'GdipAddPathRectangle'; + function GdipAddPathRectangles; external WINGDIPDLL name 'GdipAddPathRectangles'; + function GdipAddPathEllipse; external WINGDIPDLL name 'GdipAddPathEllipse'; + function GdipAddPathPie; external WINGDIPDLL name 'GdipAddPathPie'; + function GdipAddPathPolygon; external WINGDIPDLL name 'GdipAddPathPolygon'; + function GdipAddPathPath; external WINGDIPDLL name 'GdipAddPathPath'; + function GdipAddPathString; external WINGDIPDLL name 'GdipAddPathString'; + function GdipAddPathStringI; external WINGDIPDLL name 'GdipAddPathStringI'; + function GdipAddPathLineI; external WINGDIPDLL name 'GdipAddPathLineI'; + function GdipAddPathLine2I; external WINGDIPDLL name 'GdipAddPathLine2I'; + function GdipAddPathArcI; external WINGDIPDLL name 'GdipAddPathArcI'; + function GdipAddPathBezierI; external WINGDIPDLL name 'GdipAddPathBezierI'; + function GdipAddPathBeziersI; external WINGDIPDLL name 'GdipAddPathBeziersI'; + function GdipAddPathCurveI; external WINGDIPDLL name 'GdipAddPathCurveI'; + function GdipAddPathCurve2I; external WINGDIPDLL name 'GdipAddPathCurve2I'; + function GdipAddPathCurve3I; external WINGDIPDLL name 'GdipAddPathCurve3I'; + function GdipAddPathClosedCurveI; external WINGDIPDLL name 'GdipAddPathClosedCurveI'; + function GdipAddPathClosedCurve2I; external WINGDIPDLL name 'GdipAddPathClosedCurve2I'; + function GdipAddPathRectangleI; external WINGDIPDLL name 'GdipAddPathRectangleI'; + function GdipAddPathRectanglesI; external WINGDIPDLL name 'GdipAddPathRectanglesI'; + function GdipAddPathEllipseI; external WINGDIPDLL name 'GdipAddPathEllipseI'; + function GdipAddPathPieI; external WINGDIPDLL name 'GdipAddPathPieI'; + function GdipAddPathPolygonI; external WINGDIPDLL name 'GdipAddPathPolygonI'; + function GdipFlattenPath; external WINGDIPDLL name 'GdipFlattenPath'; + function GdipWindingModeOutline; external WINGDIPDLL name 'GdipWindingModeOutline'; + function GdipWidenPath; external WINGDIPDLL name 'GdipWidenPath'; + function GdipWarpPath; external WINGDIPDLL name 'GdipWarpPath'; + function GdipTransformPath; external WINGDIPDLL name 'GdipTransformPath'; + function GdipGetPathWorldBounds; external WINGDIPDLL name 'GdipGetPathWorldBounds'; + function GdipGetPathWorldBoundsI; external WINGDIPDLL name 'GdipGetPathWorldBoundsI'; + function GdipIsVisiblePathPoint; external WINGDIPDLL name 'GdipIsVisiblePathPoint'; + function GdipIsVisiblePathPointI; external WINGDIPDLL name 'GdipIsVisiblePathPointI'; + function GdipIsOutlineVisiblePathPoint; external WINGDIPDLL name 'GdipIsOutlineVisiblePathPoint'; + function GdipIsOutlineVisiblePathPointI; external WINGDIPDLL name 'GdipIsOutlineVisiblePathPointI'; + function GdipCreatePathIter; external WINGDIPDLL name 'GdipCreatePathIter'; + function GdipDeletePathIter; external WINGDIPDLL name 'GdipDeletePathIter'; + function GdipPathIterNextSubpath; external WINGDIPDLL name 'GdipPathIterNextSubpath'; + function GdipPathIterNextSubpathPath; external WINGDIPDLL name 'GdipPathIterNextSubpathPath'; + function GdipPathIterNextPathType; external WINGDIPDLL name 'GdipPathIterNextPathType'; + function GdipPathIterNextMarker; external WINGDIPDLL name 'GdipPathIterNextMarker'; + function GdipPathIterNextMarkerPath; external WINGDIPDLL name 'GdipPathIterNextMarkerPath'; + function GdipPathIterGetCount; external WINGDIPDLL name 'GdipPathIterGetCount'; + function GdipPathIterGetSubpathCount; external WINGDIPDLL name 'GdipPathIterGetSubpathCount'; + function GdipPathIterIsValid; external WINGDIPDLL name 'GdipPathIterIsValid'; + function GdipPathIterHasCurve; external WINGDIPDLL name 'GdipPathIterHasCurve'; + function GdipPathIterRewind; external WINGDIPDLL name 'GdipPathIterRewind'; + function GdipPathIterEnumerate; external WINGDIPDLL name 'GdipPathIterEnumerate'; + function GdipPathIterCopyData; external WINGDIPDLL name 'GdipPathIterCopyData'; + function GdipCreateMatrix; external WINGDIPDLL name 'GdipCreateMatrix'; + function GdipCreateMatrix2; external WINGDIPDLL name 'GdipCreateMatrix2'; + function GdipCreateMatrix3; external WINGDIPDLL name 'GdipCreateMatrix3'; + function GdipCreateMatrix3I; external WINGDIPDLL name 'GdipCreateMatrix3I'; + function GdipCloneMatrix; external WINGDIPDLL name 'GdipCloneMatrix'; + function GdipDeleteMatrix; external WINGDIPDLL name 'GdipDeleteMatrix'; + function GdipSetMatrixElements; external WINGDIPDLL name 'GdipSetMatrixElements'; + function GdipMultiplyMatrix; external WINGDIPDLL name 'GdipMultiplyMatrix'; + function GdipTranslateMatrix; external WINGDIPDLL name 'GdipTranslateMatrix'; + function GdipScaleMatrix; external WINGDIPDLL name 'GdipScaleMatrix'; + function GdipRotateMatrix; external WINGDIPDLL name 'GdipRotateMatrix'; + function GdipShearMatrix; external WINGDIPDLL name 'GdipShearMatrix'; + function GdipInvertMatrix; external WINGDIPDLL name 'GdipInvertMatrix'; + function GdipTransformMatrixPoints; external WINGDIPDLL name 'GdipTransformMatrixPoints'; + function GdipTransformMatrixPointsI; external WINGDIPDLL name 'GdipTransformMatrixPointsI'; + function GdipVectorTransformMatrixPoints; external WINGDIPDLL name 'GdipVectorTransformMatrixPoints'; + function GdipVectorTransformMatrixPointsI; external WINGDIPDLL name 'GdipVectorTransformMatrixPointsI'; + function GdipGetMatrixElements; external WINGDIPDLL name 'GdipGetMatrixElements'; + function GdipIsMatrixInvertible; external WINGDIPDLL name 'GdipIsMatrixInvertible'; + function GdipIsMatrixIdentity; external WINGDIPDLL name 'GdipIsMatrixIdentity'; + function GdipIsMatrixEqual; external WINGDIPDLL name 'GdipIsMatrixEqual'; + function GdipCreateRegion; external WINGDIPDLL name 'GdipCreateRegion'; + function GdipCreateRegionRect; external WINGDIPDLL name 'GdipCreateRegionRect'; + function GdipCreateRegionRectI; external WINGDIPDLL name 'GdipCreateRegionRectI'; + function GdipCreateRegionPath; external WINGDIPDLL name 'GdipCreateRegionPath'; + function GdipCreateRegionRgnData; external WINGDIPDLL name 'GdipCreateRegionRgnData'; + function GdipCreateRegionHrgn; external WINGDIPDLL name 'GdipCreateRegionHrgn'; + function GdipCloneRegion; external WINGDIPDLL name 'GdipCloneRegion'; + function GdipDeleteRegion; external WINGDIPDLL name 'GdipDeleteRegion'; + function GdipSetInfinite; external WINGDIPDLL name 'GdipSetInfinite'; + function GdipSetEmpty; external WINGDIPDLL name 'GdipSetEmpty'; + function GdipCombineRegionRect; external WINGDIPDLL name 'GdipCombineRegionRect'; + function GdipCombineRegionRectI; external WINGDIPDLL name 'GdipCombineRegionRectI'; + function GdipCombineRegionPath; external WINGDIPDLL name 'GdipCombineRegionPath'; + function GdipCombineRegionRegion; external WINGDIPDLL name 'GdipCombineRegionRegion'; + function GdipTranslateRegion; external WINGDIPDLL name 'GdipTranslateRegion'; + function GdipTranslateRegionI; external WINGDIPDLL name 'GdipTranslateRegionI'; + function GdipTransformRegion; external WINGDIPDLL name 'GdipTransformRegion'; + function GdipGetRegionBounds; external WINGDIPDLL name 'GdipGetRegionBounds'; + function GdipGetRegionBoundsI; external WINGDIPDLL name 'GdipGetRegionBoundsI'; + function GdipGetRegionHRgn; external WINGDIPDLL name 'GdipGetRegionHRgn'; + function GdipIsEmptyRegion; external WINGDIPDLL name 'GdipIsEmptyRegion'; + function GdipIsInfiniteRegion; external WINGDIPDLL name 'GdipIsInfiniteRegion'; + function GdipIsEqualRegion; external WINGDIPDLL name 'GdipIsEqualRegion'; + function GdipGetRegionDataSize; external WINGDIPDLL name 'GdipGetRegionDataSize'; + function GdipGetRegionData; external WINGDIPDLL name 'GdipGetRegionData'; + function GdipIsVisibleRegionPoint; external WINGDIPDLL name 'GdipIsVisibleRegionPoint'; + function GdipIsVisibleRegionPointI; external WINGDIPDLL name 'GdipIsVisibleRegionPointI'; + function GdipIsVisibleRegionRect; external WINGDIPDLL name 'GdipIsVisibleRegionRect'; + function GdipIsVisibleRegionRectI; external WINGDIPDLL name 'GdipIsVisibleRegionRectI'; + function GdipGetRegionScansCount; external WINGDIPDLL name 'GdipGetRegionScansCount'; + function GdipGetRegionScans; external WINGDIPDLL name 'GdipGetRegionScans'; + function GdipGetRegionScansI; external WINGDIPDLL name 'GdipGetRegionScansI'; + function GdipCloneBrush; external WINGDIPDLL name 'GdipCloneBrush'; + function GdipDeleteBrush; external WINGDIPDLL name 'GdipDeleteBrush'; + function GdipGetBrushType; external WINGDIPDLL name 'GdipGetBrushType'; + function GdipCreateHatchBrush; external WINGDIPDLL name 'GdipCreateHatchBrush'; + function GdipGetHatchStyle; external WINGDIPDLL name 'GdipGetHatchStyle'; + function GdipGetHatchForegroundColor; external WINGDIPDLL name 'GdipGetHatchForegroundColor'; + function GdipGetHatchBackgroundColor; external WINGDIPDLL name 'GdipGetHatchBackgroundColor'; + function GdipCreateTexture; external WINGDIPDLL name 'GdipCreateTexture'; + function GdipCreateTexture2; external WINGDIPDLL name 'GdipCreateTexture2'; + function GdipCreateTextureIA; external WINGDIPDLL name 'GdipCreateTextureIA'; + function GdipCreateTexture2I; external WINGDIPDLL name 'GdipCreateTexture2I'; + function GdipCreateTextureIAI; external WINGDIPDLL name 'GdipCreateTextureIAI'; + function GdipGetTextureTransform; external WINGDIPDLL name 'GdipGetTextureTransform'; + function GdipSetTextureTransform; external WINGDIPDLL name 'GdipSetTextureTransform'; + function GdipResetTextureTransform; external WINGDIPDLL name 'GdipResetTextureTransform'; + function GdipMultiplyTextureTransform; external WINGDIPDLL name 'GdipMultiplyTextureTransform'; + function GdipTranslateTextureTransform; external WINGDIPDLL name 'GdipTranslateTextureTransform'; + function GdipScaleTextureTransform; external WINGDIPDLL name 'GdipScaleTextureTransform'; + function GdipRotateTextureTransform; external WINGDIPDLL name 'GdipRotateTextureTransform'; + function GdipSetTextureWrapMode; external WINGDIPDLL name 'GdipSetTextureWrapMode'; + function GdipGetTextureWrapMode; external WINGDIPDLL name 'GdipGetTextureWrapMode'; + function GdipGetTextureImage; external WINGDIPDLL name 'GdipGetTextureImage'; + function GdipCreateSolidFill; external WINGDIPDLL name 'GdipCreateSolidFill'; + function GdipSetSolidFillColor; external WINGDIPDLL name 'GdipSetSolidFillColor'; + function GdipGetSolidFillColor; external WINGDIPDLL name 'GdipGetSolidFillColor'; + function GdipCreateLineBrush; external WINGDIPDLL name 'GdipCreateLineBrush'; + function GdipCreateLineBrushI; external WINGDIPDLL name 'GdipCreateLineBrushI'; + function GdipCreateLineBrushFromRect; external WINGDIPDLL name 'GdipCreateLineBrushFromRect'; + function GdipCreateLineBrushFromRectI; external WINGDIPDLL name 'GdipCreateLineBrushFromRectI'; + function GdipCreateLineBrushFromRectWithAngle; external WINGDIPDLL name 'GdipCreateLineBrushFromRectWithAngle'; + function GdipCreateLineBrushFromRectWithAngleI; external WINGDIPDLL name 'GdipCreateLineBrushFromRectWithAngleI'; + function GdipSetLineColors; external WINGDIPDLL name 'GdipSetLineColors'; + function GdipGetLineColors; external WINGDIPDLL name 'GdipGetLineColors'; + function GdipGetLineRect; external WINGDIPDLL name 'GdipGetLineRect'; + function GdipGetLineRectI; external WINGDIPDLL name 'GdipGetLineRectI'; + function GdipSetLineGammaCorrection; external WINGDIPDLL name 'GdipSetLineGammaCorrection'; + function GdipGetLineGammaCorrection; external WINGDIPDLL name 'GdipGetLineGammaCorrection'; + function GdipGetLineBlendCount; external WINGDIPDLL name 'GdipGetLineBlendCount'; + function GdipGetLineBlend; external WINGDIPDLL name 'GdipGetLineBlend'; + function GdipSetLineBlend; external WINGDIPDLL name 'GdipSetLineBlend'; + function GdipGetLinePresetBlendCount; external WINGDIPDLL name 'GdipGetLinePresetBlendCount'; + function GdipGetLinePresetBlend; external WINGDIPDLL name 'GdipGetLinePresetBlend'; + function GdipSetLinePresetBlend; external WINGDIPDLL name 'GdipSetLinePresetBlend'; + function GdipSetLineSigmaBlend; external WINGDIPDLL name 'GdipSetLineSigmaBlend'; + function GdipSetLineLinearBlend; external WINGDIPDLL name 'GdipSetLineLinearBlend'; + function GdipSetLineWrapMode; external WINGDIPDLL name 'GdipSetLineWrapMode'; + function GdipGetLineWrapMode; external WINGDIPDLL name 'GdipGetLineWrapMode'; + function GdipGetLineTransform; external WINGDIPDLL name 'GdipGetLineTransform'; + function GdipSetLineTransform; external WINGDIPDLL name 'GdipSetLineTransform'; + function GdipResetLineTransform; external WINGDIPDLL name 'GdipResetLineTransform'; + function GdipMultiplyLineTransform; external WINGDIPDLL name 'GdipMultiplyLineTransform'; + function GdipTranslateLineTransform; external WINGDIPDLL name 'GdipTranslateLineTransform'; + function GdipScaleLineTransform; external WINGDIPDLL name 'GdipScaleLineTransform'; + function GdipRotateLineTransform; external WINGDIPDLL name 'GdipRotateLineTransform'; + function GdipCreatePathGradient; external WINGDIPDLL name 'GdipCreatePathGradient'; + function GdipCreatePathGradientI; external WINGDIPDLL name 'GdipCreatePathGradientI'; + function GdipCreatePathGradientFromPath; external WINGDIPDLL name 'GdipCreatePathGradientFromPath'; + function GdipGetPathGradientCenterColor; external WINGDIPDLL name 'GdipGetPathGradientCenterColor'; + function GdipSetPathGradientCenterColor; external WINGDIPDLL name 'GdipSetPathGradientCenterColor'; + function GdipGetPathGradientSurroundColorsWithCount; external WINGDIPDLL name 'GdipGetPathGradientSurroundColorsWithCount'; + function GdipSetPathGradientSurroundColorsWithCount; external WINGDIPDLL name 'GdipSetPathGradientSurroundColorsWithCount'; + function GdipGetPathGradientPath; external WINGDIPDLL name 'GdipGetPathGradientPath'; + function GdipSetPathGradientPath; external WINGDIPDLL name 'GdipSetPathGradientPath'; + function GdipGetPathGradientCenterPoint; external WINGDIPDLL name 'GdipGetPathGradientCenterPoint'; + function GdipGetPathGradientCenterPointI; external WINGDIPDLL name 'GdipGetPathGradientCenterPointI'; + function GdipSetPathGradientCenterPoint; external WINGDIPDLL name 'GdipSetPathGradientCenterPoint'; + function GdipSetPathGradientCenterPointI; external WINGDIPDLL name 'GdipSetPathGradientCenterPointI'; + function GdipGetPathGradientRect; external WINGDIPDLL name 'GdipGetPathGradientRect'; + function GdipGetPathGradientRectI; external WINGDIPDLL name 'GdipGetPathGradientRectI'; + function GdipGetPathGradientPointCount; external WINGDIPDLL name 'GdipGetPathGradientPointCount'; + function GdipGetPathGradientSurroundColorCount; external WINGDIPDLL name 'GdipGetPathGradientSurroundColorCount'; + function GdipSetPathGradientGammaCorrection; external WINGDIPDLL name 'GdipSetPathGradientGammaCorrection'; + function GdipGetPathGradientGammaCorrection; external WINGDIPDLL name 'GdipGetPathGradientGammaCorrection'; + function GdipGetPathGradientBlendCount; external WINGDIPDLL name 'GdipGetPathGradientBlendCount'; + function GdipGetPathGradientBlend; external WINGDIPDLL name 'GdipGetPathGradientBlend'; + function GdipSetPathGradientBlend; external WINGDIPDLL name 'GdipSetPathGradientBlend'; + function GdipGetPathGradientPresetBlendCount; external WINGDIPDLL name 'GdipGetPathGradientPresetBlendCount'; + function GdipGetPathGradientPresetBlend; external WINGDIPDLL name 'GdipGetPathGradientPresetBlend'; + function GdipSetPathGradientPresetBlend; external WINGDIPDLL name 'GdipSetPathGradientPresetBlend'; + function GdipSetPathGradientSigmaBlend; external WINGDIPDLL name 'GdipSetPathGradientSigmaBlend'; + function GdipSetPathGradientLinearBlend; external WINGDIPDLL name 'GdipSetPathGradientLinearBlend'; + function GdipGetPathGradientWrapMode; external WINGDIPDLL name 'GdipGetPathGradientWrapMode'; + function GdipSetPathGradientWrapMode; external WINGDIPDLL name 'GdipSetPathGradientWrapMode'; + function GdipGetPathGradientTransform; external WINGDIPDLL name 'GdipGetPathGradientTransform'; + function GdipSetPathGradientTransform; external WINGDIPDLL name 'GdipSetPathGradientTransform'; + function GdipResetPathGradientTransform; external WINGDIPDLL name 'GdipResetPathGradientTransform'; + function GdipMultiplyPathGradientTransform; external WINGDIPDLL name 'GdipMultiplyPathGradientTransform'; + function GdipTranslatePathGradientTransform; external WINGDIPDLL name 'GdipTranslatePathGradientTransform'; + function GdipScalePathGradientTransform; external WINGDIPDLL name 'GdipScalePathGradientTransform'; + function GdipRotatePathGradientTransform; external WINGDIPDLL name 'GdipRotatePathGradientTransform'; + function GdipGetPathGradientFocusScales; external WINGDIPDLL name 'GdipGetPathGradientFocusScales'; + function GdipSetPathGradientFocusScales; external WINGDIPDLL name 'GdipSetPathGradientFocusScales'; + function GdipCreatePen1; external WINGDIPDLL name 'GdipCreatePen1'; + function GdipCreatePen2; external WINGDIPDLL name 'GdipCreatePen2'; + function GdipClonePen; external WINGDIPDLL name 'GdipClonePen'; + function GdipDeletePen; external WINGDIPDLL name 'GdipDeletePen'; + function GdipSetPenWidth; external WINGDIPDLL name 'GdipSetPenWidth'; + function GdipGetPenWidth; external WINGDIPDLL name 'GdipGetPenWidth'; + function GdipSetPenUnit; external WINGDIPDLL name 'GdipSetPenUnit'; + function GdipGetPenUnit; external WINGDIPDLL name 'GdipGetPenUnit'; + function GdipSetPenLineCap197819; external WINGDIPDLL name 'GdipSetPenLineCap197819'; + function GdipSetPenStartCap; external WINGDIPDLL name 'GdipSetPenStartCap'; + function GdipSetPenEndCap; external WINGDIPDLL name 'GdipSetPenEndCap'; + function GdipSetPenDashCap197819; external WINGDIPDLL name 'GdipSetPenDashCap197819'; + function GdipGetPenStartCap; external WINGDIPDLL name 'GdipGetPenStartCap'; + function GdipGetPenEndCap; external WINGDIPDLL name 'GdipGetPenEndCap'; + function GdipGetPenDashCap197819; external WINGDIPDLL name 'GdipGetPenDashCap197819'; + function GdipSetPenLineJoin; external WINGDIPDLL name 'GdipSetPenLineJoin'; + function GdipGetPenLineJoin; external WINGDIPDLL name 'GdipGetPenLineJoin'; + function GdipSetPenCustomStartCap; external WINGDIPDLL name 'GdipSetPenCustomStartCap'; + function GdipGetPenCustomStartCap; external WINGDIPDLL name 'GdipGetPenCustomStartCap'; + function GdipSetPenCustomEndCap; external WINGDIPDLL name 'GdipSetPenCustomEndCap'; + function GdipGetPenCustomEndCap; external WINGDIPDLL name 'GdipGetPenCustomEndCap'; + function GdipSetPenMiterLimit; external WINGDIPDLL name 'GdipSetPenMiterLimit'; + function GdipGetPenMiterLimit; external WINGDIPDLL name 'GdipGetPenMiterLimit'; + function GdipSetPenMode; external WINGDIPDLL name 'GdipSetPenMode'; + function GdipGetPenMode; external WINGDIPDLL name 'GdipGetPenMode'; + function GdipSetPenTransform; external WINGDIPDLL name 'GdipSetPenTransform'; + function GdipGetPenTransform; external WINGDIPDLL name 'GdipGetPenTransform'; + function GdipResetPenTransform; external WINGDIPDLL name 'GdipResetPenTransform'; + function GdipMultiplyPenTransform; external WINGDIPDLL name 'GdipMultiplyPenTransform'; + function GdipTranslatePenTransform; external WINGDIPDLL name 'GdipTranslatePenTransform'; + function GdipScalePenTransform; external WINGDIPDLL name 'GdipScalePenTransform'; + function GdipRotatePenTransform; external WINGDIPDLL name 'GdipRotatePenTransform'; + function GdipSetPenColor; external WINGDIPDLL name 'GdipSetPenColor'; + function GdipGetPenColor; external WINGDIPDLL name 'GdipGetPenColor'; + function GdipSetPenBrushFill; external WINGDIPDLL name 'GdipSetPenBrushFill'; + function GdipGetPenBrushFill; external WINGDIPDLL name 'GdipGetPenBrushFill'; + function GdipGetPenFillType; external WINGDIPDLL name 'GdipGetPenFillType'; + function GdipGetPenDashStyle; external WINGDIPDLL name 'GdipGetPenDashStyle'; + function GdipSetPenDashStyle; external WINGDIPDLL name 'GdipSetPenDashStyle'; + function GdipGetPenDashOffset; external WINGDIPDLL name 'GdipGetPenDashOffset'; + function GdipSetPenDashOffset; external WINGDIPDLL name 'GdipSetPenDashOffset'; + function GdipGetPenDashCount; external WINGDIPDLL name 'GdipGetPenDashCount'; + function GdipSetPenDashArray; external WINGDIPDLL name 'GdipSetPenDashArray'; + function GdipGetPenDashArray; external WINGDIPDLL name 'GdipGetPenDashArray'; + function GdipGetPenCompoundCount; external WINGDIPDLL name 'GdipGetPenCompoundCount'; + function GdipSetPenCompoundArray; external WINGDIPDLL name 'GdipSetPenCompoundArray'; + function GdipGetPenCompoundArray; external WINGDIPDLL name 'GdipGetPenCompoundArray'; + function GdipCreateCustomLineCap; external WINGDIPDLL name 'GdipCreateCustomLineCap'; + function GdipDeleteCustomLineCap; external WINGDIPDLL name 'GdipDeleteCustomLineCap'; + function GdipCloneCustomLineCap; external WINGDIPDLL name 'GdipCloneCustomLineCap'; + function GdipGetCustomLineCapType; external WINGDIPDLL name 'GdipGetCustomLineCapType'; + function GdipSetCustomLineCapStrokeCaps; external WINGDIPDLL name 'GdipSetCustomLineCapStrokeCaps'; + function GdipGetCustomLineCapStrokeCaps; external WINGDIPDLL name 'GdipGetCustomLineCapStrokeCaps'; + function GdipSetCustomLineCapStrokeJoin; external WINGDIPDLL name 'GdipSetCustomLineCapStrokeJoin'; + function GdipGetCustomLineCapStrokeJoin; external WINGDIPDLL name 'GdipGetCustomLineCapStrokeJoin'; + function GdipSetCustomLineCapBaseCap; external WINGDIPDLL name 'GdipSetCustomLineCapBaseCap'; + function GdipGetCustomLineCapBaseCap; external WINGDIPDLL name 'GdipGetCustomLineCapBaseCap'; + function GdipSetCustomLineCapBaseInset; external WINGDIPDLL name 'GdipSetCustomLineCapBaseInset'; + function GdipGetCustomLineCapBaseInset; external WINGDIPDLL name 'GdipGetCustomLineCapBaseInset'; + function GdipSetCustomLineCapWidthScale; external WINGDIPDLL name 'GdipSetCustomLineCapWidthScale'; + function GdipGetCustomLineCapWidthScale; external WINGDIPDLL name 'GdipGetCustomLineCapWidthScale'; + function GdipCreateAdjustableArrowCap; external WINGDIPDLL name 'GdipCreateAdjustableArrowCap'; + function GdipSetAdjustableArrowCapHeight; external WINGDIPDLL name 'GdipSetAdjustableArrowCapHeight'; + function GdipGetAdjustableArrowCapHeight; external WINGDIPDLL name 'GdipGetAdjustableArrowCapHeight'; + function GdipSetAdjustableArrowCapWidth; external WINGDIPDLL name 'GdipSetAdjustableArrowCapWidth'; + function GdipGetAdjustableArrowCapWidth; external WINGDIPDLL name 'GdipGetAdjustableArrowCapWidth'; + function GdipSetAdjustableArrowCapMiddleInset; external WINGDIPDLL name 'GdipSetAdjustableArrowCapMiddleInset'; + function GdipGetAdjustableArrowCapMiddleInset; external WINGDIPDLL name 'GdipGetAdjustableArrowCapMiddleInset'; + function GdipSetAdjustableArrowCapFillState; external WINGDIPDLL name 'GdipSetAdjustableArrowCapFillState'; + function GdipGetAdjustableArrowCapFillState; external WINGDIPDLL name 'GdipGetAdjustableArrowCapFillState'; + function GdipLoadImageFromStream; external WINGDIPDLL name 'GdipLoadImageFromStream'; + function GdipLoadImageFromFile; external WINGDIPDLL name 'GdipLoadImageFromFile'; + function GdipLoadImageFromStreamICM; external WINGDIPDLL name 'GdipLoadImageFromStreamICM'; + function GdipLoadImageFromFileICM; external WINGDIPDLL name 'GdipLoadImageFromFileICM'; + function GdipCloneImage; external WINGDIPDLL name 'GdipCloneImage'; + function GdipDisposeImage; external WINGDIPDLL name 'GdipDisposeImage'; + function GdipSaveImageToFile; external WINGDIPDLL name 'GdipSaveImageToFile'; + function GdipSaveImageToStream; external WINGDIPDLL name 'GdipSaveImageToStream'; + function GdipSaveAdd; external WINGDIPDLL name 'GdipSaveAdd'; + function GdipSaveAddImage; external WINGDIPDLL name 'GdipSaveAddImage'; + function GdipGetImageGraphicsContext; external WINGDIPDLL name 'GdipGetImageGraphicsContext'; + function GdipGetImageBounds; external WINGDIPDLL name 'GdipGetImageBounds'; + function GdipGetImageDimension; external WINGDIPDLL name 'GdipGetImageDimension'; + function GdipGetImageType; external WINGDIPDLL name 'GdipGetImageType'; + function GdipGetImageWidth; external WINGDIPDLL name 'GdipGetImageWidth'; + function GdipGetImageHeight; external WINGDIPDLL name 'GdipGetImageHeight'; + function GdipGetImageHorizontalResolution; external WINGDIPDLL name 'GdipGetImageHorizontalResolution'; + function GdipGetImageVerticalResolution; external WINGDIPDLL name 'GdipGetImageVerticalResolution'; + function GdipGetImageFlags; external WINGDIPDLL name 'GdipGetImageFlags'; + function GdipGetImageRawFormat; external WINGDIPDLL name 'GdipGetImageRawFormat'; + function GdipGetImagePixelFormat; external WINGDIPDLL name 'GdipGetImagePixelFormat'; + function GdipGetImageThumbnail; external WINGDIPDLL name 'GdipGetImageThumbnail'; + function GdipGetEncoderParameterListSize; external WINGDIPDLL name 'GdipGetEncoderParameterListSize'; + function GdipGetEncoderParameterList; external WINGDIPDLL name 'GdipGetEncoderParameterList'; + function GdipImageGetFrameDimensionsCount; external WINGDIPDLL name 'GdipImageGetFrameDimensionsCount'; + function GdipImageGetFrameDimensionsList; external WINGDIPDLL name 'GdipImageGetFrameDimensionsList'; + function GdipImageGetFrameCount; external WINGDIPDLL name 'GdipImageGetFrameCount'; + function GdipImageSelectActiveFrame; external WINGDIPDLL name 'GdipImageSelectActiveFrame'; + function GdipImageRotateFlip; external WINGDIPDLL name 'GdipImageRotateFlip'; + function GdipGetImagePalette; external WINGDIPDLL name 'GdipGetImagePalette'; + function GdipSetImagePalette; external WINGDIPDLL name 'GdipSetImagePalette'; + function GdipGetImagePaletteSize; external WINGDIPDLL name 'GdipGetImagePaletteSize'; + function GdipGetPropertyCount; external WINGDIPDLL name 'GdipGetPropertyCount'; + function GdipGetPropertyIdList; external WINGDIPDLL name 'GdipGetPropertyIdList'; + function GdipGetPropertyItemSize; external WINGDIPDLL name 'GdipGetPropertyItemSize'; + function GdipGetPropertyItem; external WINGDIPDLL name 'GdipGetPropertyItem'; + function GdipGetPropertySize; external WINGDIPDLL name 'GdipGetPropertySize'; + function GdipGetAllPropertyItems; external WINGDIPDLL name 'GdipGetAllPropertyItems'; + function GdipRemovePropertyItem; external WINGDIPDLL name 'GdipRemovePropertyItem'; + function GdipSetPropertyItem; external WINGDIPDLL name 'GdipSetPropertyItem'; + function GdipImageForceValidation; external WINGDIPDLL name 'GdipImageForceValidation'; + function GdipCreateBitmapFromStream; external WINGDIPDLL name 'GdipCreateBitmapFromStream'; + function GdipCreateBitmapFromFile; external WINGDIPDLL name 'GdipCreateBitmapFromFile'; + function GdipCreateBitmapFromStreamICM; external WINGDIPDLL name 'GdipCreateBitmapFromStreamICM'; + function GdipCreateBitmapFromFileICM; external WINGDIPDLL name 'GdipCreateBitmapFromFileICM'; + function GdipCreateBitmapFromScan0; external WINGDIPDLL name 'GdipCreateBitmapFromScan0'; + function GdipCreateBitmapFromGraphics; external WINGDIPDLL name 'GdipCreateBitmapFromGraphics'; + function GdipCreateBitmapFromDirectDrawSurface; external WINGDIPDLL name 'GdipCreateBitmapFromDirectDrawSurface'; + function GdipCreateBitmapFromGdiDib; external WINGDIPDLL name 'GdipCreateBitmapFromGdiDib'; + function GdipCreateBitmapFromHBITMAP; external WINGDIPDLL name 'GdipCreateBitmapFromHBITMAP'; + function GdipCreateHBITMAPFromBitmap; external WINGDIPDLL name 'GdipCreateHBITMAPFromBitmap'; + function GdipCreateBitmapFromHICON; external WINGDIPDLL name 'GdipCreateBitmapFromHICON'; + function GdipCreateHICONFromBitmap; external WINGDIPDLL name 'GdipCreateHICONFromBitmap'; + function GdipCreateBitmapFromResource; external WINGDIPDLL name 'GdipCreateBitmapFromResource'; + function GdipCloneBitmapArea; external WINGDIPDLL name 'GdipCloneBitmapArea'; + function GdipCloneBitmapAreaI; external WINGDIPDLL name 'GdipCloneBitmapAreaI'; + function GdipBitmapLockBits; external WINGDIPDLL name 'GdipBitmapLockBits'; + function GdipBitmapUnlockBits; external WINGDIPDLL name 'GdipBitmapUnlockBits'; + function GdipBitmapGetPixel; external WINGDIPDLL name 'GdipBitmapGetPixel'; + function GdipBitmapSetPixel; external WINGDIPDLL name 'GdipBitmapSetPixel'; + function GdipBitmapSetResolution; external WINGDIPDLL name 'GdipBitmapSetResolution'; + function GdipCreateImageAttributes; external WINGDIPDLL name 'GdipCreateImageAttributes'; + function GdipCloneImageAttributes; external WINGDIPDLL name 'GdipCloneImageAttributes'; + function GdipDisposeImageAttributes; external WINGDIPDLL name 'GdipDisposeImageAttributes'; + function GdipSetImageAttributesToIdentity; external WINGDIPDLL name 'GdipSetImageAttributesToIdentity'; + function GdipResetImageAttributes; external WINGDIPDLL name 'GdipResetImageAttributes'; + function GdipSetImageAttributesColorMatrix; external WINGDIPDLL name 'GdipSetImageAttributesColorMatrix'; + function GdipSetImageAttributesThreshold; external WINGDIPDLL name 'GdipSetImageAttributesThreshold'; + function GdipSetImageAttributesGamma; external WINGDIPDLL name 'GdipSetImageAttributesGamma'; + function GdipSetImageAttributesNoOp; external WINGDIPDLL name 'GdipSetImageAttributesNoOp'; + function GdipSetImageAttributesColorKeys; external WINGDIPDLL name 'GdipSetImageAttributesColorKeys'; + function GdipSetImageAttributesOutputChannel; external WINGDIPDLL name 'GdipSetImageAttributesOutputChannel'; + function GdipSetImageAttributesOutputChannelColorProfile; external WINGDIPDLL name 'GdipSetImageAttributesOutputChannelColorProfile'; + function GdipSetImageAttributesRemapTable; external WINGDIPDLL name 'GdipSetImageAttributesRemapTable'; + function GdipSetImageAttributesWrapMode; external WINGDIPDLL name 'GdipSetImageAttributesWrapMode'; + function GdipSetImageAttributesICMMode; external WINGDIPDLL name 'GdipSetImageAttributesICMMode'; + function GdipGetImageAttributesAdjustedPalette; external WINGDIPDLL name 'GdipGetImageAttributesAdjustedPalette'; + function GdipFlush; external WINGDIPDLL name 'GdipFlush'; + function GdipCreateFromHDC; external WINGDIPDLL name 'GdipCreateFromHDC'; + function GdipCreateFromHDC2; external WINGDIPDLL name 'GdipCreateFromHDC2'; + function GdipCreateFromHWND; external WINGDIPDLL name 'GdipCreateFromHWND'; + function GdipCreateFromHWNDICM; external WINGDIPDLL name 'GdipCreateFromHWNDICM'; + function GdipDeleteGraphics; external WINGDIPDLL name 'GdipDeleteGraphics'; + function GdipGetDC; external WINGDIPDLL name 'GdipGetDC'; + function GdipReleaseDC; external WINGDIPDLL name 'GdipReleaseDC'; + function GdipSetCompositingMode; external WINGDIPDLL name 'GdipSetCompositingMode'; + function GdipGetCompositingMode; external WINGDIPDLL name 'GdipGetCompositingMode'; + function GdipSetRenderingOrigin; external WINGDIPDLL name 'GdipSetRenderingOrigin'; + function GdipGetRenderingOrigin; external WINGDIPDLL name 'GdipGetRenderingOrigin'; + function GdipSetCompositingQuality; external WINGDIPDLL name 'GdipSetCompositingQuality'; + function GdipGetCompositingQuality; external WINGDIPDLL name 'GdipGetCompositingQuality'; + function GdipSetSmoothingMode; external WINGDIPDLL name 'GdipSetSmoothingMode'; + function GdipGetSmoothingMode; external WINGDIPDLL name 'GdipGetSmoothingMode'; + function GdipSetPixelOffsetMode; external WINGDIPDLL name 'GdipSetPixelOffsetMode'; + function GdipGetPixelOffsetMode; external WINGDIPDLL name 'GdipGetPixelOffsetMode'; + function GdipSetTextRenderingHint; external WINGDIPDLL name 'GdipSetTextRenderingHint'; + function GdipGetTextRenderingHint; external WINGDIPDLL name 'GdipGetTextRenderingHint'; + function GdipSetTextContrast; external WINGDIPDLL name 'GdipSetTextContrast'; + function GdipGetTextContrast; external WINGDIPDLL name 'GdipGetTextContrast'; + function GdipSetInterpolationMode; external WINGDIPDLL name 'GdipSetInterpolationMode'; + function GdipGetInterpolationMode; external WINGDIPDLL name 'GdipGetInterpolationMode'; + function GdipSetWorldTransform; external WINGDIPDLL name 'GdipSetWorldTransform'; + function GdipResetWorldTransform; external WINGDIPDLL name 'GdipResetWorldTransform'; + function GdipMultiplyWorldTransform; external WINGDIPDLL name 'GdipMultiplyWorldTransform'; + function GdipTranslateWorldTransform; external WINGDIPDLL name 'GdipTranslateWorldTransform'; + function GdipScaleWorldTransform; external WINGDIPDLL name 'GdipScaleWorldTransform'; + function GdipRotateWorldTransform; external WINGDIPDLL name 'GdipRotateWorldTransform'; + function GdipGetWorldTransform; external WINGDIPDLL name 'GdipGetWorldTransform'; + function GdipResetPageTransform; external WINGDIPDLL name 'GdipResetPageTransform'; + function GdipGetPageUnit; external WINGDIPDLL name 'GdipGetPageUnit'; + function GdipGetPageScale; external WINGDIPDLL name 'GdipGetPageScale'; + function GdipSetPageUnit; external WINGDIPDLL name 'GdipSetPageUnit'; + function GdipSetPageScale; external WINGDIPDLL name 'GdipSetPageScale'; + function GdipGetDpiX; external WINGDIPDLL name 'GdipGetDpiX'; + function GdipGetDpiY; external WINGDIPDLL name 'GdipGetDpiY'; + function GdipTransformPoints; external WINGDIPDLL name 'GdipTransformPoints'; + function GdipTransformPointsI; external WINGDIPDLL name 'GdipTransformPointsI'; + function GdipGetNearestColor; external WINGDIPDLL name 'GdipGetNearestColor'; + function GdipCreateHalftonePalette; external WINGDIPDLL name 'GdipCreateHalftonePalette'; + function GdipDrawLine; external WINGDIPDLL name 'GdipDrawLine'; + function GdipDrawLineI; external WINGDIPDLL name 'GdipDrawLineI'; + function GdipDrawLines; external WINGDIPDLL name 'GdipDrawLines'; + function GdipDrawLinesI; external WINGDIPDLL name 'GdipDrawLinesI'; + function GdipDrawArc; external WINGDIPDLL name 'GdipDrawArc'; + function GdipDrawArcI; external WINGDIPDLL name 'GdipDrawArcI'; + function GdipDrawBezier; external WINGDIPDLL name 'GdipDrawBezier'; + function GdipDrawBezierI; external WINGDIPDLL name 'GdipDrawBezierI'; + function GdipDrawBeziers; external WINGDIPDLL name 'GdipDrawBeziers'; + function GdipDrawBeziersI; external WINGDIPDLL name 'GdipDrawBeziersI'; + function GdipDrawRectangle; external WINGDIPDLL name 'GdipDrawRectangle'; + function GdipDrawRectangleI; external WINGDIPDLL name 'GdipDrawRectangleI'; + function GdipDrawRectangles; external WINGDIPDLL name 'GdipDrawRectangles'; + function GdipDrawRectanglesI; external WINGDIPDLL name 'GdipDrawRectanglesI'; + function GdipDrawEllipse; external WINGDIPDLL name 'GdipDrawEllipse'; + function GdipDrawEllipseI; external WINGDIPDLL name 'GdipDrawEllipseI'; + function GdipDrawPie; external WINGDIPDLL name 'GdipDrawPie'; + function GdipDrawPieI; external WINGDIPDLL name 'GdipDrawPieI'; + function GdipDrawPolygon; external WINGDIPDLL name 'GdipDrawPolygon'; + function GdipDrawPolygonI; external WINGDIPDLL name 'GdipDrawPolygonI'; + function GdipDrawPath; external WINGDIPDLL name 'GdipDrawPath'; + function GdipDrawCurve; external WINGDIPDLL name 'GdipDrawCurve'; + function GdipDrawCurveI; external WINGDIPDLL name 'GdipDrawCurveI'; + function GdipDrawCurve2; external WINGDIPDLL name 'GdipDrawCurve2'; + function GdipDrawCurve2I; external WINGDIPDLL name 'GdipDrawCurve2I'; + function GdipDrawCurve3; external WINGDIPDLL name 'GdipDrawCurve3'; + function GdipDrawCurve3I; external WINGDIPDLL name 'GdipDrawCurve3I'; + function GdipDrawClosedCurve; external WINGDIPDLL name 'GdipDrawClosedCurve'; + function GdipDrawClosedCurveI; external WINGDIPDLL name 'GdipDrawClosedCurveI'; + function GdipDrawClosedCurve2; external WINGDIPDLL name 'GdipDrawClosedCurve2'; + function GdipDrawClosedCurve2I; external WINGDIPDLL name 'GdipDrawClosedCurve2I'; + function GdipGraphicsClear; external WINGDIPDLL name 'GdipGraphicsClear'; + function GdipFillRectangle; external WINGDIPDLL name 'GdipFillRectangle'; + function GdipFillRectangleI; external WINGDIPDLL name 'GdipFillRectangleI'; + function GdipFillRectangles; external WINGDIPDLL name 'GdipFillRectangles'; + function GdipFillRectanglesI; external WINGDIPDLL name 'GdipFillRectanglesI'; + function GdipFillPolygon; external WINGDIPDLL name 'GdipFillPolygon'; + function GdipFillPolygonI; external WINGDIPDLL name 'GdipFillPolygonI'; + function GdipFillPolygon2; external WINGDIPDLL name 'GdipFillPolygon2'; + function GdipFillPolygon2I; external WINGDIPDLL name 'GdipFillPolygon2I'; + function GdipFillEllipse; external WINGDIPDLL name 'GdipFillEllipse'; + function GdipFillEllipseI; external WINGDIPDLL name 'GdipFillEllipseI'; + function GdipFillPie; external WINGDIPDLL name 'GdipFillPie'; + function GdipFillPieI; external WINGDIPDLL name 'GdipFillPieI'; + function GdipFillPath; external WINGDIPDLL name 'GdipFillPath'; + function GdipFillClosedCurve; external WINGDIPDLL name 'GdipFillClosedCurve'; + function GdipFillClosedCurveI; external WINGDIPDLL name 'GdipFillClosedCurveI'; + function GdipFillClosedCurve2; external WINGDIPDLL name 'GdipFillClosedCurve2'; + function GdipFillClosedCurve2I; external WINGDIPDLL name 'GdipFillClosedCurve2I'; + function GdipFillRegion; external WINGDIPDLL name 'GdipFillRegion'; + function GdipDrawImage; external WINGDIPDLL name 'GdipDrawImage'; + function GdipDrawImageI; external WINGDIPDLL name 'GdipDrawImageI'; + function GdipDrawImageRect; external WINGDIPDLL name 'GdipDrawImageRect'; + function GdipDrawImageRectI; external WINGDIPDLL name 'GdipDrawImageRectI'; + function GdipDrawImagePoints; external WINGDIPDLL name 'GdipDrawImagePoints'; + function GdipDrawImagePointsI; external WINGDIPDLL name 'GdipDrawImagePointsI'; + function GdipDrawImagePointRect; external WINGDIPDLL name 'GdipDrawImagePointRect'; + function GdipDrawImagePointRectI; external WINGDIPDLL name 'GdipDrawImagePointRectI'; + function GdipDrawImageRectRect; external WINGDIPDLL name 'GdipDrawImageRectRect'; + function GdipDrawImageRectRectI; external WINGDIPDLL name 'GdipDrawImageRectRectI'; + function GdipDrawImagePointsRect; external WINGDIPDLL name 'GdipDrawImagePointsRect'; + function GdipDrawImagePointsRectI; external WINGDIPDLL name 'GdipDrawImagePointsRectI'; + function GdipEnumerateMetafileDestPoint; external WINGDIPDLL name 'GdipEnumerateMetafileDestPoint'; + function GdipEnumerateMetafileDestPointI; external WINGDIPDLL name 'GdipEnumerateMetafileDestPointI'; + function GdipEnumerateMetafileDestRect; external WINGDIPDLL name 'GdipEnumerateMetafileDestRect'; + function GdipEnumerateMetafileDestRectI; external WINGDIPDLL name 'GdipEnumerateMetafileDestRectI'; + function GdipEnumerateMetafileDestPoints; external WINGDIPDLL name 'GdipEnumerateMetafileDestPoints'; + function GdipEnumerateMetafileDestPointsI; external WINGDIPDLL name 'GdipEnumerateMetafileDestPointsI'; + function GdipEnumerateMetafileSrcRectDestPoint; external WINGDIPDLL name 'GdipEnumerateMetafileSrcRectDestPoint'; + function GdipEnumerateMetafileSrcRectDestPointI; external WINGDIPDLL name 'GdipEnumerateMetafileSrcRectDestPointI'; + function GdipEnumerateMetafileSrcRectDestRect; external WINGDIPDLL name 'GdipEnumerateMetafileSrcRectDestRect'; + function GdipEnumerateMetafileSrcRectDestRectI; external WINGDIPDLL name 'GdipEnumerateMetafileSrcRectDestRectI'; + function GdipEnumerateMetafileSrcRectDestPoints; external WINGDIPDLL name 'GdipEnumerateMetafileSrcRectDestPoints'; + function GdipEnumerateMetafileSrcRectDestPointsI; external WINGDIPDLL name 'GdipEnumerateMetafileSrcRectDestPointsI'; + function GdipPlayMetafileRecord; external WINGDIPDLL name 'GdipPlayMetafileRecord'; + function GdipSetClipGraphics; external WINGDIPDLL name 'GdipSetClipGraphics'; + function GdipSetClipRect; external WINGDIPDLL name 'GdipSetClipRect'; + function GdipSetClipRectI; external WINGDIPDLL name 'GdipSetClipRectI'; + function GdipSetClipPath; external WINGDIPDLL name 'GdipSetClipPath'; + function GdipSetClipRegion; external WINGDIPDLL name 'GdipSetClipRegion'; + function GdipSetClipHrgn; external WINGDIPDLL name 'GdipSetClipHrgn'; + function GdipResetClip; external WINGDIPDLL name 'GdipResetClip'; + function GdipTranslateClip; external WINGDIPDLL name 'GdipTranslateClip'; + function GdipTranslateClipI; external WINGDIPDLL name 'GdipTranslateClipI'; + function GdipGetClip; external WINGDIPDLL name 'GdipGetClip'; + function GdipGetClipBounds; external WINGDIPDLL name 'GdipGetClipBounds'; + function GdipGetClipBoundsI; external WINGDIPDLL name 'GdipGetClipBoundsI'; + function GdipIsClipEmpty; external WINGDIPDLL name 'GdipIsClipEmpty'; + function GdipGetVisibleClipBounds; external WINGDIPDLL name 'GdipGetVisibleClipBounds'; + function GdipGetVisibleClipBoundsI; external WINGDIPDLL name 'GdipGetVisibleClipBoundsI'; + function GdipIsVisibleClipEmpty; external WINGDIPDLL name 'GdipIsVisibleClipEmpty'; + function GdipIsVisiblePoint; external WINGDIPDLL name 'GdipIsVisiblePoint'; + function GdipIsVisiblePointI; external WINGDIPDLL name 'GdipIsVisiblePointI'; + function GdipIsVisibleRect; external WINGDIPDLL name 'GdipIsVisibleRect'; + function GdipIsVisibleRectI; external WINGDIPDLL name 'GdipIsVisibleRectI'; + function GdipSaveGraphics; external WINGDIPDLL name 'GdipSaveGraphics'; + function GdipRestoreGraphics; external WINGDIPDLL name 'GdipRestoreGraphics'; + function GdipBeginContainer; external WINGDIPDLL name 'GdipBeginContainer'; + function GdipBeginContainerI; external WINGDIPDLL name 'GdipBeginContainerI'; + function GdipBeginContainer2; external WINGDIPDLL name 'GdipBeginContainer2'; + function GdipEndContainer; external WINGDIPDLL name 'GdipEndContainer'; + function GdipGetMetafileHeaderFromWmf; external WINGDIPDLL name 'GdipGetMetafileHeaderFromWmf'; + function GdipGetMetafileHeaderFromEmf; external WINGDIPDLL name 'GdipGetMetafileHeaderFromEmf'; + function GdipGetMetafileHeaderFromFile; external WINGDIPDLL name 'GdipGetMetafileHeaderFromFile'; + function GdipGetMetafileHeaderFromStream; external WINGDIPDLL name 'GdipGetMetafileHeaderFromStream'; + function GdipGetMetafileHeaderFromMetafile; external WINGDIPDLL name 'GdipGetMetafileHeaderFromMetafile'; + function GdipGetHemfFromMetafile; external WINGDIPDLL name 'GdipGetHemfFromMetafile'; + function GdipCreateStreamOnFile; external WINGDIPDLL name 'GdipCreateStreamOnFile'; + function GdipCreateMetafileFromWmf; external WINGDIPDLL name 'GdipCreateMetafileFromWmf'; + function GdipCreateMetafileFromEmf; external WINGDIPDLL name 'GdipCreateMetafileFromEmf'; + function GdipCreateMetafileFromFile; external WINGDIPDLL name 'GdipCreateMetafileFromFile'; + function GdipCreateMetafileFromWmfFile; external WINGDIPDLL name 'GdipCreateMetafileFromWmfFile'; + function GdipCreateMetafileFromStream; external WINGDIPDLL name 'GdipCreateMetafileFromStream'; + function GdipRecordMetafile; external WINGDIPDLL name 'GdipRecordMetafile'; + function GdipRecordMetafileI; external WINGDIPDLL name 'GdipRecordMetafileI'; + function GdipRecordMetafileFileName; external WINGDIPDLL name 'GdipRecordMetafileFileName'; + function GdipRecordMetafileFileNameI; external WINGDIPDLL name 'GdipRecordMetafileFileNameI'; + function GdipRecordMetafileStream; external WINGDIPDLL name 'GdipRecordMetafileStream'; + function GdipRecordMetafileStreamI; external WINGDIPDLL name 'GdipRecordMetafileStreamI'; + function GdipSetMetafileDownLevelRasterizationLimit; external WINGDIPDLL name 'GdipSetMetafileDownLevelRasterizationLimit'; + function GdipGetMetafileDownLevelRasterizationLimit; external WINGDIPDLL name 'GdipGetMetafileDownLevelRasterizationLimit'; + function GdipGetImageDecodersSize; external WINGDIPDLL name 'GdipGetImageDecodersSize'; + function GdipGetImageDecoders; external WINGDIPDLL name 'GdipGetImageDecoders'; + function GdipGetImageEncodersSize; external WINGDIPDLL name 'GdipGetImageEncodersSize'; + function GdipGetImageEncoders; external WINGDIPDLL name 'GdipGetImageEncoders'; + function GdipComment; external WINGDIPDLL name 'GdipComment'; + function GdipCreateFontFamilyFromName; external WINGDIPDLL name 'GdipCreateFontFamilyFromName'; + function GdipDeleteFontFamily; external WINGDIPDLL name 'GdipDeleteFontFamily'; + function GdipCloneFontFamily; external WINGDIPDLL name 'GdipCloneFontFamily'; + function GdipGetGenericFontFamilySansSerif; external WINGDIPDLL name 'GdipGetGenericFontFamilySansSerif'; + function GdipGetGenericFontFamilySerif; external WINGDIPDLL name 'GdipGetGenericFontFamilySerif'; + function GdipGetGenericFontFamilyMonospace; external WINGDIPDLL name 'GdipGetGenericFontFamilyMonospace'; + function GdipGetFamilyName; external WINGDIPDLL name 'GdipGetFamilyName'; + function GdipIsStyleAvailable; external WINGDIPDLL name 'GdipIsStyleAvailable'; + function GdipFontCollectionEnumerable; external WINGDIPDLL name 'GdipFontCollectionEnumerable'; + function GdipFontCollectionEnumerate; external WINGDIPDLL name 'GdipFontCollectionEnumerate'; + function GdipGetEmHeight; external WINGDIPDLL name 'GdipGetEmHeight'; + function GdipGetCellAscent; external WINGDIPDLL name 'GdipGetCellAscent'; + function GdipGetCellDescent; external WINGDIPDLL name 'GdipGetCellDescent'; + function GdipGetLineSpacing; external WINGDIPDLL name 'GdipGetLineSpacing'; + function GdipCreateFontFromDC; external WINGDIPDLL name 'GdipCreateFontFromDC'; + function GdipCreateFontFromLogfontA; external WINGDIPDLL name 'GdipCreateFontFromLogfontA'; + function GdipCreateFontFromLogfontW; external WINGDIPDLL name 'GdipCreateFontFromLogfontW'; + function GdipCreateFont; external WINGDIPDLL name 'GdipCreateFont'; + function GdipCloneFont; external WINGDIPDLL name 'GdipCloneFont'; + function GdipDeleteFont; external WINGDIPDLL name 'GdipDeleteFont'; + function GdipGetFamily; external WINGDIPDLL name 'GdipGetFamily'; + function GdipGetFontStyle; external WINGDIPDLL name 'GdipGetFontStyle'; + function GdipGetFontSize; external WINGDIPDLL name 'GdipGetFontSize'; + function GdipGetFontUnit; external WINGDIPDLL name 'GdipGetFontUnit'; + function GdipGetFontHeight; external WINGDIPDLL name 'GdipGetFontHeight'; + function GdipGetFontHeightGivenDPI; external WINGDIPDLL name 'GdipGetFontHeightGivenDPI'; + function GdipGetLogFontA; external WINGDIPDLL name 'GdipGetLogFontA'; + function GdipGetLogFontW; external WINGDIPDLL name 'GdipGetLogFontW'; + function GdipNewInstalledFontCollection; external WINGDIPDLL name 'GdipNewInstalledFontCollection'; + function GdipNewPrivateFontCollection; external WINGDIPDLL name 'GdipNewPrivateFontCollection'; + function GdipDeletePrivateFontCollection; external WINGDIPDLL name 'GdipDeletePrivateFontCollection'; + function GdipGetFontCollectionFamilyCount; external WINGDIPDLL name 'GdipGetFontCollectionFamilyCount'; + function GdipGetFontCollectionFamilyList; external WINGDIPDLL name 'GdipGetFontCollectionFamilyList'; + function GdipPrivateAddFontFile; external WINGDIPDLL name 'GdipPrivateAddFontFile'; + function GdipPrivateAddMemoryFont; external WINGDIPDLL name 'GdipPrivateAddMemoryFont'; + function GdipDrawString; external WINGDIPDLL name 'GdipDrawString'; + function GdipMeasureString; external WINGDIPDLL name 'GdipMeasureString'; + function GdipMeasureCharacterRanges; external WINGDIPDLL name 'GdipMeasureCharacterRanges'; + function GdipDrawDriverString; external WINGDIPDLL name 'GdipDrawDriverString'; + function GdipMeasureDriverString; external WINGDIPDLL name 'GdipMeasureDriverString'; + function GdipCreateStringFormat; external WINGDIPDLL name 'GdipCreateStringFormat'; + function GdipStringFormatGetGenericDefault; external WINGDIPDLL name 'GdipStringFormatGetGenericDefault'; + function GdipStringFormatGetGenericTypographic; external WINGDIPDLL name 'GdipStringFormatGetGenericTypographic'; + function GdipDeleteStringFormat; external WINGDIPDLL name 'GdipDeleteStringFormat'; + function GdipCloneStringFormat; external WINGDIPDLL name 'GdipCloneStringFormat'; + function GdipSetStringFormatFlags; external WINGDIPDLL name 'GdipSetStringFormatFlags'; + function GdipGetStringFormatFlags; external WINGDIPDLL name 'GdipGetStringFormatFlags'; + function GdipSetStringFormatAlign; external WINGDIPDLL name 'GdipSetStringFormatAlign'; + function GdipGetStringFormatAlign; external WINGDIPDLL name 'GdipGetStringFormatAlign'; + function GdipSetStringFormatLineAlign; external WINGDIPDLL name 'GdipSetStringFormatLineAlign'; + function GdipGetStringFormatLineAlign; external WINGDIPDLL name 'GdipGetStringFormatLineAlign'; + function GdipSetStringFormatTrimming; external WINGDIPDLL name 'GdipSetStringFormatTrimming'; + function GdipGetStringFormatTrimming; external WINGDIPDLL name 'GdipGetStringFormatTrimming'; + function GdipSetStringFormatHotkeyPrefix; external WINGDIPDLL name 'GdipSetStringFormatHotkeyPrefix'; + function GdipGetStringFormatHotkeyPrefix; external WINGDIPDLL name 'GdipGetStringFormatHotkeyPrefix'; + function GdipSetStringFormatTabStops; external WINGDIPDLL name 'GdipSetStringFormatTabStops'; + function GdipGetStringFormatTabStops; external WINGDIPDLL name 'GdipGetStringFormatTabStops'; + function GdipGetStringFormatTabStopCount; external WINGDIPDLL name 'GdipGetStringFormatTabStopCount'; + function GdipSetStringFormatDigitSubstitution; external WINGDIPDLL name 'GdipSetStringFormatDigitSubstitution'; + function GdipGetStringFormatDigitSubstitution; external WINGDIPDLL name 'GdipGetStringFormatDigitSubstitution'; + function GdipGetStringFormatMeasurableCharacterRangeCount; external WINGDIPDLL name 'GdipGetStringFormatMeasurableCharacterRangeCount'; + function GdipSetStringFormatMeasurableCharacterRanges; external WINGDIPDLL name 'GdipSetStringFormatMeasurableCharacterRanges'; + function GdipCreateCachedBitmap; external WINGDIPDLL name 'GdipCreateCachedBitmap'; + function GdipDeleteCachedBitmap; external WINGDIPDLL name 'GdipDeleteCachedBitmap'; + function GdipDrawCachedBitmap; external WINGDIPDLL name 'GdipDrawCachedBitmap'; + function GdipEmfToWmfBits; external WINGDIPDLL name 'GdipEmfToWmfBits'; + +// ----------------------------------------------------------------------------- +// TGdiplusBase class +// ----------------------------------------------------------------------------- + + class function TGdiplusBase.NewInstance: TObject; + begin + Result := InitInstance(GdipAlloc(ULONG(instanceSize))); + end; + + procedure TGdiplusBase.FreeInstance; + begin + CleanupInstance; + GdipFree(Self); + end; + +// ----------------------------------------------------------------------------- +// macros +// ----------------------------------------------------------------------------- + +function ObjectTypeIsValid(type_: ObjectType): BOOL; +begin + result := ((type_ >= ObjectTypeMin) and (type_ <= ObjectTypeMax)); +end; + +function GDIP_WMF_RECORD_TO_EMFPLUS(n: integer): Integer; +begin + result := (n or GDIP_WMF_RECORD_BASE); +end; + +function GDIP_EMFPLUS_RECORD_TO_WMF(n: integer): Integer; +begin + result := n and (not GDIP_WMF_RECORD_BASE); +end; + +function GDIP_IS_WMF_RECORDTYPE(n: integer): BOOL; +begin + result := ((n and GDIP_WMF_RECORD_BASE) <> 0); +end; + + +//-------------------------------------------------------------------------- +// TGPPoint Util +//-------------------------------------------------------------------------- + + function MakePoint(X, Y: Integer): TGPPoint; + begin + result.X := X; + result.Y := Y; + end; + + function MakePoint(X, Y: Single): TGPPointF; + begin + Result.X := X; + result.Y := Y; + end; + +//-------------------------------------------------------------------------- +// TGPSize Util +//-------------------------------------------------------------------------- + + function MakeSize(Width, Height: Single): TGPSizeF; + begin + result.Width := Width; + result.Height := Height; + end; + + function MakeSize(Width, Height: Integer): TGPSize; + begin + result.Width := Width; + result.Height := Height; + end; + +//-------------------------------------------------------------------------- +// TCharacterRange Util +//-------------------------------------------------------------------------- + + function MakeCharacterRange(First, Length: Integer): TCharacterRange; + begin + result.First := First; + result.Length := Length; + end; + +// ----------------------------------------------------------------------------- +// RectF class +// ----------------------------------------------------------------------------- + + function MakeRect(x, y, width, height: Single): TGPRectF; overload; + begin + Result.X := x; + Result.Y := y; + Result.Width := width; + Result.Height := height; + end; + + function MakeRect(location: TGPPointF; size: TGPSizeF): TGPRectF; overload; + begin + Result.X := location.X; + Result.Y := location.Y; + Result.Width := size.Width; + Result.Height := size.Height; + end; + +// ----------------------------------------------------------------------------- +// Rect class +// ----------------------------------------------------------------------------- + + function MakeRect(x, y, width, height: Integer): TGPRect; overload; + begin + Result.X := x; + Result.Y := y; + Result.Width := width; + Result.Height := height; + end; + + function MakeRect(location: TGPPoint; size: TGPSize): TGPRect; overload; + begin + Result.X := location.X; + Result.Y := location.Y; + Result.Width := size.Width; + Result.Height := size.Height; + end; + + function MakeRect(const Rect: TRect): TGPRect; + begin + Result.X := rect.Left; + Result.Y := Rect.Top; + Result.Width := Rect.Right-Rect.Left; + Result.Height:= Rect.Bottom-Rect.Top; + end; + +// ----------------------------------------------------------------------------- +// PathData class +// ----------------------------------------------------------------------------- + + constructor TPathData.Create; + begin + Count := 0; + Points := nil; + Types := nil; + end; + + destructor TPathData.destroy; + begin + if assigned(Points) then freemem(Points); + if assigned(Types) then freemem(Types); + end; + + +function GetPixelFormatSize(pixfmt: PixelFormat): UINT; +begin + result := (pixfmt shr 8) and $ff; +end; + +function IsIndexedPixelFormat(pixfmt: PixelFormat): BOOL; +begin + result := (pixfmt and PixelFormatIndexed) <> 0; +end; + +function IsAlphaPixelFormat(pixfmt: PixelFormat): BOOL; +begin + result := (pixfmt and PixelFormatAlpha) <> 0; +end; + +function IsExtendedPixelFormat(pixfmt: PixelFormat): BOOL; +begin + result := (pixfmt and PixelFormatExtended) <> 0; +end; + +function IsCanonicalPixelFormat(pixfmt: PixelFormat): BOOL; +begin + result := (pixfmt and PixelFormatCanonical) <> 0; +end; + +// ----------------------------------------------------------------------------- +// Color class +// ----------------------------------------------------------------------------- + +{ constructor TGPColor.Create; + begin + Argb := DWORD(Black); + end; + + // Construct an opaque Color object with + // the specified Red, Green, Blue values. + // + // Color values are not premultiplied. + + constructor TGPColor.Create(r, g, b: Byte); + begin + Argb := MakeARGB(255, r, g, b); + end; + + constructor TGPColor.Create(a, r, g, b: Byte); + begin + Argb := MakeARGB(a, r, g, b); + end; + + constructor TGPColor.Create(Value: ARGB); + begin + Argb := Value; + end; + + function TGPColor.GetAlpha: BYTE; + begin + result := BYTE(Argb shr AlphaShift); + end; + + function TGPColor.GetA: BYTE; + begin + result := GetAlpha; + end; + + function TGPColor.GetRed: BYTE; + begin + result := BYTE(Argb shr RedShift); + end; + + function TGPColor.GetR: BYTE; + begin + result := GetRed; + end; + + function TGPColor.GetGreen: Byte; + begin + result := BYTE(Argb shr GreenShift); + end; + + function TGPColor.GetG: Byte; + begin + result := GetGreen; + end; + + function TGPColor.GetBlue: Byte; + begin + result := BYTE(Argb shr BlueShift); + end; + + function TGPColor.GetB: Byte; + begin + result := GetBlue; + end; + + function TGPColor.GetValue: ARGB; + begin + result := Argb; + end; + + procedure TGPColor.SetValue(Value: ARGB); + begin + Argb := Value; + end; + + procedure TGPColor.SetFromCOLORREF(rgb: COLORREF); + begin + Argb := MakeARGB(255, GetRValue(rgb), GetGValue(rgb), GetBValue(rgb)); + end; + + function TGPColor.ToCOLORREF: COLORREF; + begin + result := RGB(GetRed, GetGreen, GetBlue); + end; + + function TGPColor.MakeARGB(a, r, g, b: Byte): ARGB; + begin + result := ((DWORD(b) shl BlueShift) or + (DWORD(g) shl GreenShift) or + (DWORD(r) shl RedShift) or + (DWORD(a) shl AlphaShift)); + end; } + + function MakeColor(r, g, b: Byte): ARGB; overload; + begin + result := MakeColor(255, r, g, b); + end; + + function MakeColor(a, r, g, b: Byte): ARGB; overload; + begin + result := ((DWORD(b) shl BlueShift) or + (DWORD(g) shl GreenShift) or + (DWORD(r) shl RedShift) or + (DWORD(a) shl AlphaShift)); + end; + + function GetAlpha(color: ARGB): BYTE; + begin + result := BYTE(color shr AlphaShift); + end; + + function GetRed(color: ARGB): BYTE; + begin + result := BYTE(color shr RedShift); + end; + + function GetGreen(color: ARGB): BYTE; + begin + result := BYTE(color shr GreenShift); + end; + + function GetBlue(color: ARGB): BYTE; + begin + result := BYTE(color shr BlueShift); + end; + + function ColorRefToARGB(rgb: COLORREF): ARGB; + begin + result := MakeColor(255, GetRValue(rgb), GetGValue(rgb), GetBValue(rgb)); + end; + + function ARGBToColorRef(Color: ARGB): COLORREF; + begin + result := RGB(GetRed(Color), GetGreen(Color), GetBlue(Color)); + end; + + +// ----------------------------------------------------------------------------- +// MetafileHeader class +// ----------------------------------------------------------------------------- + + procedure TMetafileHeader.GetBounds(out Rect: TGPRect); + begin + rect.X := X; + rect.Y := Y; + rect.Width := Width; + rect.Height := Height; + end; + + function TMetafileHeader.IsWmf: BOOL; + begin + result := ((Type_ = MetafileTypeWmf) or (Type_ = MetafileTypeWmfPlaceable)); + end; + + function TMetafileHeader.IsWmfPlaceable: BOOL; + begin + result := (Type_ = MetafileTypeWmfPlaceable); + end; + + function TMetafileHeader.IsEmf: BOOL; + begin + result := (Type_ = MetafileTypeEmf); + end; + + function TMetafileHeader.IsEmfOrEmfPlus: BOOL; + begin + result := (Type_ >= MetafileTypeEmf); + end; + + function TMetafileHeader.IsEmfPlus: BOOL; + begin + result := (Type_ >= MetafileTypeEmfPlusOnly) + end; + + function TMetafileHeader.IsEmfPlusDual: BOOL; + begin + result := (Type_ = MetafileTypeEmfPlusDual) + end; + + function TMetafileHeader.IsEmfPlusOnly: BOOL; + begin + result := (Type_ = MetafileTypeEmfPlusOnly) + end; + + function TMetafileHeader.IsDisplay: BOOL; + begin + result := (IsEmfPlus and ((EmfPlusFlags and GDIP_EMFPLUSFLAGS_DISPLAY) <> 0)); + end; + + function TMetafileHeader.GetWmfHeader: PMetaHeader; + begin + if IsWmf then result := @Header.WmfHeader + else result := nil; + end; + + function TMetafileHeader.GetEmfHeader: PENHMETAHEADER3; + begin + if IsEmfOrEmfPlus then result := @Header.EmfHeader + else result := nil; + end; + +end. + + + diff --git a/thirparty/GDIPObj.pas b/thirparty/GDIPObj.pas new file mode 100644 index 0000000..26316f9 --- /dev/null +++ b/thirparty/GDIPObj.pas @@ -0,0 +1,8003 @@ + {******************************************************************} + { 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; + function GetLogFontW(g: TGPGraphics; out logfontW: TLogFontW): TStatus; + function Clone: TGPFont; + destructor Destroy; override; + function IsAvailable: BOOL; + function GetStyle: Integer; + function GetSize: Single; + function GetUnit: TUnit; + function GetLastStatus: TStatus; + function GetHeight(graphics: TGPGraphics): Single; overload; + function GetHeight(dpi: Single): Single; overload; + function GetFamily(family: TGPFontFamily): TStatus; + end; + +//-------------------------------------------------------------------------- +// Abstract base class for Image and Metafile +//-------------------------------------------------------------------------- + + TGPImage = class(TGdiplusBase) + protected + nativeImage: GpImage; + lastResult: TStatus; + loadStatus: TStatus; + procedure SetNativeImage(nativeImage: GpImage); + function SetStatus(status: TStatus): TStatus; + constructor Create(nativeImage: GpImage; status: TStatus); reintroduce; overload; + public + constructor Create(filename: WideString; useEmbeddedColorManagement: BOOL = FALSE); reintroduce; overload; + constructor Create(stream: IStream; useEmbeddedColorManagement: BOOL = FALSE); reintroduce; overload; + function FromFile(filename: WideString; useEmbeddedColorManagement: BOOL = FALSE): TGPImage; + function FromStream(stream: IStream; useEmbeddedColorManagement: BOOL = FALSE): TGPImage; + destructor Destroy; override; + function Clone: TGPImage; + function Save(filename: WideString; const clsidEncoder: TGUID; + encoderParams: PEncoderParameters = nil): TStatus; overload; + function Save(stream: IStream; const clsidEncoder: TGUID; + encoderParams: PEncoderParameters = nil): TStatus; overload; + function SaveAdd(encoderParams: PEncoderParameters): TStatus; overload; + function SaveAdd(newImage: TGPImage; encoderParams: PEncoderParameters): TStatus; overload; + function GetType: TImageType; + function GetPhysicalDimension(out size: TGPSizeF): TStatus; + function GetBounds(out srcRect: TGPRectF; out srcUnit: TUnit): TStatus; + function GetWidth: UINT; + function GetHeight: UINT; + function GetHorizontalResolution: Single; + function GetVerticalResolution: Single; + function GetFlags: UINT; + function GetRawFormat(out format: TGUID): TStatus; + function GetPixelFormat: TPixelFormat; + function GetPaletteSize: Integer; + function GetPalette(palette: PColorPalette; size: Integer): TStatus; + function SetPalette(palette: PColorPalette): TStatus; + function GetThumbnailImage(thumbWidth, thumbHeight: UINT; + callback: GetThumbnailImageAbort = nil; callbackData: pointer = nil): TGPImage; + function GetFrameDimensionsCount: UINT; + function GetFrameDimensionsList(dimensionIDs: PGUID; count: UINT): TStatus; + function GetFrameCount(const dimensionID: TGUID): UINT; + function SelectActiveFrame(const dimensionID: TGUID; frameIndex: UINT): TStatus; + function RotateFlip(rotateFlipType: TRotateFlipType): TStatus; + function GetPropertyCount: UINT; + function GetPropertyIdList(numOfProperty: UINT; list: PPropID): TStatus; + function GetPropertyItemSize(propId: PROPID): UINT; + function GetPropertyItem(propId: PROPID; propSize: UINT; buffer: PPropertyItem): TStatus; + function GetPropertySize(out totalBufferSize, numProperties : UINT): TStatus; + function GetAllPropertyItems(totalBufferSize, numProperties: UINT; + allItems: PPROPERTYITEM): TStatus; + function RemovePropertyItem(propId: TPROPID): TStatus; + function SetPropertyItem(const item: TPropertyItem): TStatus; + function GetEncoderParameterListSize(const clsidEncoder: TGUID): UINT; + function GetEncoderParameterList(const clsidEncoder: TGUID; size: UINT; + buffer: PEncoderParameters): TStatus; + function GetLastStatus: TStatus; + end; + + TGPBitmap = class(TGPImage) + protected + constructor Create(nativeBitmap: GpBitmap); reintroduce; overload; + public + constructor Create(filename: WideString; useEmbeddedColorManagement: BOOL = FALSE); reintroduce; overload; + constructor Create(stream: IStream; useEmbeddedColorManagement: BOOL = FALSE); reintroduce; overload; + function FromFile(filename: WideString; useEmbeddedColorManagement: BOOL = FALSE): TGPBitmap; + function FromStream(stream: IStream; useEmbeddedColorManagement: BOOL = FALSE): TGPBitmap; + constructor Create(width, height, stride: Integer; format: TPixelFormat; scan0: PBYTE); reintroduce; overload; + constructor Create(width, height: Integer; format: TPixelFormat = PixelFormat32bppARGB); reintroduce; overload; + constructor Create(width, height: Integer; target: TGPGraphics); reintroduce; overload; + function Clone(rect: TGPRect; format: TPixelFormat): TGPBitmap; overload; + function Clone(x, y, width, height: Integer; format: TPixelFormat): TGPBitmap; overload; + function Clone(rect: TGPRectF; format: TPixelFormat): TGPBitmap; overload; + function Clone(x, y, width, height: Single; format: TPixelFormat): TGPBitmap; overload; + function LockBits(rect: TGPRect; flags: UINT; format: TPixelFormat; out lockedBitmapData: TBitmapData): TStatus; + function UnlockBits(var lockedBitmapData: TBitmapData): TStatus; + function GetPixel(x, y: Integer; out color: TGPColor): TStatus; + function SetPixel(x, y: Integer; color: TGPColor): TStatus; + function SetResolution(xdpi, ydpi: Single): TStatus; + constructor Create(surface: IDirectDrawSurface7); reintroduce; overload; + constructor Create(var gdiBitmapInfo: TBITMAPINFO; gdiBitmapData: Pointer); reintroduce; overload; + constructor Create(hbm: HBITMAP; hpal: HPALETTE); reintroduce; overload; + constructor Create(hicon: HICON); reintroduce; overload; + constructor Create(hInstance: HMODULE; bitmapName: WideString); reintroduce; overload; + function FromDirectDrawSurface7(surface: IDirectDrawSurface7): TGPBitmap; + function FromBITMAPINFO(var gdiBitmapInfo: TBITMAPINFO; gdiBitmapData: Pointer): TGPBitmap; + function FromHBITMAP(hbm: HBITMAP; hpal: HPALETTE): TGPBitmap; + function FromHICON(hicon: HICON): TGPBitmap; + function FromResource(hInstance: HMODULE; bitmapName: WideString): TGPBitmap; + function GetHBITMAP(colorBackground: TGPColor; out hbmReturn: HBITMAP): TStatus; + function GetHICON(out hicon: HICON): TStatus; + end; + + TGPCustomLineCap = class(TGdiplusBase) + protected + nativeCap: GpCustomLineCap; + lastResult: TStatus; + procedure SetNativeCap(nativeCap: GpCustomLineCap); + function SetStatus(status: TStatus): TStatus; + constructor Create(nativeCap: GpCustomLineCap; + status: TStatus); reintroduce; overload; + public + constructor Create; reintroduce; overload; + constructor Create(fillPath, strokePath: TGPGraphicsPath; + baseCap: TLineCap = LineCapFlat; + baseInset: Single = 0); reintroduce; overload; + destructor Destroy; override; + function Clone: TGPCustomLineCap; + function SetStrokeCap(strokeCap: TLineCap): TStatus; + function SetStrokeCaps(startCap, endCap: TLineCap): TStatus; + function GetStrokeCaps(out startCap, endCap: TLineCap): TStatus; + function SetStrokeJoin(lineJoin: TLineJoin): TStatus; + function GetStrokeJoin: TLineJoin; + function SetBaseCap(baseCap: TLineCap): TStatus; + function GetBaseCap: TLineCap; + function SetBaseInset(inset: Single): TStatus; + function GetBaseInset: Single; + function SetWidthScale(widthScale: Single): TStatus; + function GetWidthScale: Single; + function GetLastStatus: TStatus; + end; + + TGPCachedBitmap = class(TGdiplusBase) + protected + nativeCachedBitmap: GpCachedBitmap; + lastResult: TStatus; + public + constructor Create(bitmap: TGPBitmap; graphics: TGPGraphics); reintroduce; + destructor Destroy; override; + function GetLastStatus: TStatus; + end; + +(**************************************************************************\ +* +* GDI+ Image Attributes used with Graphics.DrawImage +* +* There are 5 possible sets of color adjustments: +* ColorAdjustDefault, +* ColorAdjustBitmap, +* ColorAdjustBrush, +* ColorAdjustPen, +* ColorAdjustText, +* +* Bitmaps, Brushes, Pens, and Text will all use any color adjustments +* that have been set into the default ImageAttributes until their own +* color adjustments have been set. So as soon as any "Set" method is +* called for Bitmaps, Brushes, Pens, or Text, then they start from +* scratch with only the color adjustments that have been set for them. +* Calling Reset removes any individual color adjustments for a type +* and makes it revert back to using all the default color adjustments +* (if any). The SetToIdentity method is a way to force a type to +* have no color adjustments at all, regardless of what previous adjustments +* have been set for the defaults or for that type. +* +\********************************************************************F******) + + TGPImageAttributes = class(TGdiplusBase) + protected + nativeImageAttr: GpImageAttributes; + lastResult: TStatus; + procedure SetNativeImageAttr(nativeImageAttr: GpImageAttributes); + function SetStatus(status: TStatus): TStatus; + constructor Create(imageAttr: GpImageAttributes; + status: GpStatus); reintroduce; overload; + public + constructor Create; reintroduce; overload; + destructor Destroy; override; + function Clone: TGPImageAttributes; + function SetToIdentity(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function Reset(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function SetColorMatrix(const colorMatrix: TColorMatrix; + mode: TColorMatrixFlags = ColorMatrixFlagsDefault; + type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function ClearColorMatrix(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function SetColorMatrices(const colorMatrix: TColorMatrix; const grayMatrix: TColorMatrix; + mode: TColorMatrixFlags = ColorMatrixFlagsDefault; + type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function ClearColorMatrices(Type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function SetThreshold(threshold: Single; type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function ClearThreshold(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function SetGamma(gamma: Single; type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function ClearGamma( type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function SetNoOp(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function ClearNoOp(Type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function SetColorKey(colorLow, colorHigh: TGPColor; type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function ClearColorKey(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function SetOutputChannel(channelFlags: TColorChannelFlags; type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function ClearOutputChannel(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function SetOutputChannelColorProfile(colorProfileFilename: WideString; + type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function ClearOutputChannelColorProfile(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function SetRemapTable(mapSize: Cardinal; map: PColorMap; type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function ClearRemapTable(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + function SetBrushRemapTable(mapSize: Cardinal; map: PColorMap): TStatus; + function ClearBrushRemapTable: TStatus; + function SetWrapMode(wrap: TWrapMode; color: TGPColor = aclBlack; clamp: BOOL = FALSE): TStatus; + // The flags of the palette are ignored. + function GetAdjustedPalette(colorPalette: PColorPalette; colorAdjustType: TColorAdjustType): TStatus; + function GetLastStatus: TStatus; + end; + +(**************************************************************************\ +* +* GDI+ Matrix class +* +\**************************************************************************) + + TMatrixArray = array[0..5] of Single; + + TGPMatrix = class(TGdiplusBase) + protected + nativeMatrix: GpMatrix; + lastResult: GpStatus ; + procedure SetNativeMatrix(nativeMatrix: GpMatrix); + function SetStatus(status: GpStatus): TStatus; + constructor Create(nativeMatrix: GpMatrix); reintroduce; overload; + public + // Default constructor is set to identity matrix. + constructor Create; reintroduce; overload; + constructor Create(m11, m12, m21, m22, dx, dy: Single); reintroduce; overload; + constructor Create(const rect: TGPRectF; const dstplg: TGPPointF); reintroduce; overload; + constructor Create(const rect: TGPRect; const dstplg: TGPPoint); reintroduce; overload; + destructor Destroy; override; + function Clone: TGPMatrix; + function GetElements(const m: TMatrixArray): TStatus; + function SetElements(m11, m12, m21, m22, dx, dy: Single): TStatus; + function OffsetX: Single; + function OffsetY: Single; + function Reset: TStatus; + function Multiply(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus; // ok + function Translate(offsetX, offsetY: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; // ok + function Scale(scaleX, scaleY: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; // ok + function Rotate(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; // ok + function RotateAt(angle: Single; const center: TGPPointF; order: TMatrixOrder = MatrixOrderPrepend): TStatus; // ok + function Shear(shearX, shearY: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; // ok + function Invert: TStatus; // ok + + function TransformPoints(pts: PGPPointF; count: Integer = 1): TStatus; overload; + function TransformPoints(pts: PGPPoint; count: Integer = 1): TStatus; overload; + + function TransformVectors(pts: PGPPointF; count: Integer = 1): TStatus; overload; + function TransformVectors(pts: PGPPoint; count: Integer = 1): TStatus; overload; + + function IsInvertible: BOOL; + function IsIdentity: BOOL; + function Equals(matrix: TGPMatrix): BOOL; + function GetLastStatus: TStatus; + end; + +(**************************************************************************\ +* +* GDI+ Brush class +* +\**************************************************************************) + + //-------------------------------------------------------------------------- + // Abstract base class for various brush types + //-------------------------------------------------------------------------- + + TGPBrush = class(TGdiplusBase) + protected + nativeBrush: GpBrush; + lastResult: TStatus; + procedure SetNativeBrush(nativeBrush: GpBrush); + function SetStatus(status: TStatus): TStatus; + constructor Create(nativeBrush: GpBrush; status: TStatus); overload; + public + constructor Create; overload; + destructor Destroy; override; + function Clone: TGPBrush; virtual; + function GetType: TBrushType; + function GetLastStatus: TStatus; + end; + + //-------------------------------------------------------------------------- + // Solid Fill Brush Object + //-------------------------------------------------------------------------- + + TGPSolidBrush = class(TGPBrush) + public + constructor Create(color: TGPColor); reintroduce; overload; + constructor Create; reintroduce; overload; + function GetColor(out color: TGPColor): TStatus; + function SetColor(color: TGPColor): TStatus; + end; + + //-------------------------------------------------------------------------- + // Texture Brush Fill Object + //-------------------------------------------------------------------------- + + TGPTextureBrush = class(TGPBrush) + public + constructor Create(image: TGPImage; wrapMode: TWrapMode = WrapModeTile); reintroduce; overload; + constructor Create(image: TGPImage; wrapMode: TWrapMode; dstRect: TGPRectF); reintroduce; overload; + constructor Create(image: TGPImage; dstRect: TGPRectF; imageAttributes: TGPImageAttributes = nil); reintroduce; overload; + constructor Create(image: TGPImage; dstRect: TGPRect; imageAttributes: TGPImageAttributes = nil); reintroduce; overload; + constructor Create(image: TGPImage; wrapMode: TWrapMode; dstRect: TGPRect); reintroduce; overload; + constructor Create(image: TGPImage; wrapMode: TWrapMode; dstX, dstY, dstWidth, + dstHeight: Single); reintroduce; overload; + constructor Create(image: TGPImage; wrapMode: TWrapMode; dstX, dstY, dstWidth, + dstHeight: Integer); reintroduce; overload; + constructor Create; reintroduce; overload; + function SetTransform(matrix: TGPMatrix): TStatus; + function GetTransform(matrix: TGPMatrix): TStatus; + function ResetTransform: TStatus; + function MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function TranslateTransform(dx, dy: Single; order: MatrixOrder = MatrixOrderPrepend): TStatus; + function ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function SetWrapMode(wrapMode: TWrapMode): TStatus; + function GetWrapMode: TWrapMode; + function GetImage: TGPImage; + end; + + //-------------------------------------------------------------------------- + // Linear Gradient Brush Object + //-------------------------------------------------------------------------- + + TGPLinearGradientBrush = class(TGPBrush) + public + constructor Create; reintroduce; overload; + constructor Create(const point1, point2: TGPPointF; color1, + color2: TGPColor); reintroduce; overload; + constructor Create(const point1, point2: TGPPoint; color1, + color2: TGPColor); reintroduce; overload; + constructor Create(rect: TGPRectF; color1, color2: TGPColor; + mode: TLinearGradientMode); reintroduce; overload; + constructor Create(rect: TGPRect; color1, color2: TGPColor; + mode: TLinearGradientMode); reintroduce; overload; + constructor Create(rect: TGPRectF; color1, color2: TGPColor; angle: Single; + isAngleScalable: BOOL = FALSE); overload; + constructor Create(rect: TGPRect; color1, color2: TGPColor; angle: Single; + isAngleScalable: BOOL = FALSE); overload; + function SetLinearColors(color1, color2: TGPColor): TStatus; + function GetLinearColors(out color1, color2: TGPColor): TStatus; + function GetRectangle(out rect: TGPRectF): TStatus; overload; + function GetRectangle(out rect: TGPRect): TStatus; overload; + function SetGammaCorrection(useGammaCorrection: BOOL): TStatus; + function GetGammaCorrection: BOOL; + function GetBlendCount: Integer; + function SetBlend(blendFactors, blendPositions: PSingle; count: Integer): TStatus; + function GetBlend(blendFactors, blendPositions: PSingle; count: Integer): TStatus; + function GetInterpolationColorCount: Integer; + function SetInterpolationColors(presetColors: PGPColor; blendPositions: PSingle; count: Integer): TStatus; + function GetInterpolationColors(presetColors: PGPColor; blendPositions: PSingle; count: Integer): TStatus; + function SetBlendBellShape(focus: Single; scale: Single = 1.0): TStatus; + function SetBlendTriangularShape(focus: Single; scale: Single = 1.0): TStatus; + function SetTransform(matrix: TGPMatrix): TStatus; + function GetTransform(matrix: TGPMatrix): TStatus; + function ResetTransform: TStatus; + function MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function TranslateTransform(dx, dy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function SetWrapMode(wrapMode: TWrapMode): TStatus; + function GetWrapMode: TWrapMode; + end; + + //-------------------------------------------------------------------------- + // Hatch Brush Object + //-------------------------------------------------------------------------- + + TGPHatchBrush = class(TGPBrush) + public + constructor Create; reintroduce; overload; + constructor Create(hatchStyle: THatchStyle; foreColor: TGPColor; backColor: TGPColor = aclBlack); reintroduce; overload; // ok + function GetHatchStyle: THatchStyle; + function GetForegroundColor(out color: TGPColor): TStatus; + function GetBackgroundColor(out color: TGPColor): TStatus; + end; + +(**************************************************************************\ +* +* GDI+ Pen class +* +\**************************************************************************) + +//-------------------------------------------------------------------------- +// Pen class +//-------------------------------------------------------------------------- + + TGPPen = class(TGdiplusBase) + protected + nativePen: GpPen; + lastResult: TStatus; + procedure SetNativePen(nativePen: GpPen); + function SetStatus(status: TStatus): TStatus; + constructor Create(nativePen: GpPen; status: TStatus); reintroduce; overload; + public + constructor Create(color: TGPColor; width: Single = 1.0); reintroduce; overload; + constructor Create(brush: TGPBrush; width: Single = 1.0); reintroduce; overload; + destructor Destroy; override; + function Clone: TGPPen; + function SetWidth(width: Single): TStatus; + function GetWidth: Single; + // Set/get line caps: start, end, and dash + // Line cap and join APIs by using LineCap and LineJoin enums. + function SetLineCap(startCap, endCap: TLineCap; dashCap: TDashCap): TStatus; + function SetStartCap(startCap: TLineCap): TStatus; + function SetEndCap(endCap: TLineCap): TStatus; + function SetDashCap(dashCap: TDashCap): TStatus; + function GetStartCap: TLineCap; + function GetEndCap: TLineCap; + function GetDashCap: TDashCap; + function SetLineJoin(lineJoin: TLineJoin): TStatus; + function GetLineJoin: TLineJoin; + function SetCustomStartCap(customCap: TGPCustomLineCap): TStatus; + function GetCustomStartCap(customCap: TGPCustomLineCap): TStatus; + function SetCustomEndCap(customCap: TGPCustomLineCap): TStatus; + function GetCustomEndCap(customCap: TGPCustomLineCap): TStatus; + function SetMiterLimit(miterLimit: Single): TStatus; + function GetMiterLimit: Single; + function SetAlignment(penAlignment: TPenAlignment): TStatus; + function GetAlignment: TPenAlignment; + function SetTransform(matrix: TGPMatrix): TStatus; + function GetTransform(matrix: TGPMatrix): TStatus; + function ResetTransform: TStatus; + function MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function TranslateTransform(dx, dy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function GetPenType: TPenType; + function SetColor(color: TGPColor): TStatus; + function SetBrush(brush: TGPBrush): TStatus; + function GetColor(out Color: TGPColor): TStatus; + function GetBrush: TGPBrush; + function GetDashStyle: TDashStyle; + function SetDashStyle(dashStyle: TDashStyle): TStatus; + function GetDashOffset: Single; + function SetDashOffset(dashOffset: Single): TStatus; + function SetDashPattern(dashArray: PSingle; count: Integer): TStatus; + function GetDashPatternCount: Integer; + function GetDashPattern(dashArray: PSingle; count: Integer): TStatus; + function SetCompoundArray(compoundArray: PSingle; count: Integer): TStatus; + function GetCompoundArrayCount: Integer; + function GetCompoundArray(compoundArray: PSingle; count: Integer): TStatus; + function GetLastStatus: TStatus; + end; + +(**************************************************************************\ +* +* GDI+ StringFormat class +* +\**************************************************************************) + + TGPStringFormat = class(TGdiplusBase) + protected + nativeFormat: GpStringFormat; + lastError: TStatus; + function SetStatus(newStatus: GpStatus): TStatus; + procedure Assign(source: TGPStringFormat); + constructor Create(clonedStringFormat: GpStringFormat; status: TStatus); reintroduce; overload; + public + constructor Create(formatFlags: Integer = 0; language: LANGID = LANG_NEUTRAL); reintroduce; overload; + constructor Create(format: TGPStringFormat); reintroduce; overload; + destructor Destroy; override; + class function GenericDefault: TGPStringFormat; + class function GenericTypographic: TGPStringFormat; + function Clone: TGPStringFormat; + function SetFormatFlags(flags: Integer): TStatus; + function GetFormatFlags: Integer; + function SetAlignment(align: TStringAlignment): TStatus; + function GetAlignment: TStringAlignment; + function SetLineAlignment(align: TStringAlignment): TStatus; + function GetLineAlignment: TStringAlignment; + function SetHotkeyPrefix(hotkeyPrefix: THotkeyPrefix): TStatus; + function GetHotkeyPrefix: THotkeyPrefix; + function SetTabStops(firstTabOffset: Single; count: Integer; tabStops: PSingle): TStatus; + function GetTabStopCount: Integer; + function GetTabStops(count: Integer; firstTabOffset, tabStops: PSingle): TStatus; + function SetDigitSubstitution(language: LANGID; substitute: TStringDigitSubstitute): TStatus; + function GetDigitSubstitutionLanguage: LANGID; + function GetDigitSubstitutionMethod: TStringDigitSubstitute; + function SetTrimming(trimming: TStringTrimming): TStatus; + function GetTrimming: TStringTrimming; + function SetMeasurableCharacterRanges(rangeCount: Integer; ranges: PCharacterRange): TStatus; + function GetMeasurableCharacterRangeCount: Integer; + function GetLastStatus: TStatus; + end; + +(**************************************************************************\ +* +* GDI+ Graphics Path class +* +\**************************************************************************) + + TGPGraphicsPath = class(TGdiplusBase) + protected + nativePath: GpPath; + lastResult: TStatus; + procedure SetNativePath(nativePath: GpPath); + function SetStatus(status: TStatus): TStatus; + constructor Create(nativePath: GpPath); reintroduce; overload; + public + constructor Create(path: TGPGraphicsPath); reintroduce; overload; + constructor Create(fillMode: TFillMode = FillModeAlternate); reintroduce; overload; + constructor Create(points: PGPPointF; types: PBYTE; count: Integer; + fillMode: TFillMode = FillModeAlternate); reintroduce; overload; + constructor Create(points: PGPPoint; types: PBYTE; count: Integer; + fillMode: TFillMode = FillModeAlternate); reintroduce; overload; + destructor Destroy; override; + function Clone: TGPGraphicsPath; + // Reset the path object to empty (and fill mode to FillModeAlternate) + function Reset: TStatus; + function GetFillMode: TFillMode; + function SetFillMode(fillmode: TFillMode): TStatus; + function GetPathData(pathData: TPathData): TStatus; + function StartFigure: TStatus; + function CloseFigure: TStatus; + function CloseAllFigures: TStatus; + function SetMarker: TStatus; + function ClearMarkers: TStatus; + function Reverse: TStatus; + function GetLastPoint(out lastPoint: TGPPointF): TStatus; + + function AddLine(const pt1, pt2: TGPPointF): TStatus; overload; + function AddLine(x1, y1, x2, y2: Single): TStatus; overload; + function AddLines(points: PGPPointF; count: Integer): TStatus; overload; + function AddLine(const pt1, pt2: TGPPoint): TStatus; overload; + function AddLine(x1, y1, x2, y2: Integer): TStatus; overload; + function AddLines(points: PGPPoint; count: Integer): TStatus; overload; + + function AddArc(rect: TGPRectF; startAngle, sweepAngle: Single): TStatus; overload; + function AddArc(x, y, width, height, startAngle, sweepAngle: Single): TStatus; overload; + function AddArc(rect: TGPRect; startAngle, sweepAngle: Single): TStatus; overload; + function AddArc(x, y, width, height: Integer; startAngle, sweepAngle: Single): TStatus; overload; + + function AddBezier(pt1, pt2, pt3, pt4: TGPPointF): TStatus; overload; + function AddBezier(x1, y1, x2, y2, x3, y3, x4, y4: Single): TStatus; overload; + function AddBeziers(points: PGPPointF; count: Integer): TStatus; overload; + function AddBezier(pt1, pt2, pt3, pt4: TGPPoint): TStatus; overload; + function AddBezier(x1, y1, x2, y2, x3, y3, x4, y4: Integer): TStatus; overload; + function AddBeziers(points: PGPPoint; count: Integer): TStatus; overload; + + function AddCurve(points: PGPPointF; count: Integer): TStatus; overload; + function AddCurve(points: PGPPointF; count: Integer; tension: Single): TStatus; overload; + function AddCurve(points: PGPPointF; count, offset, numberOfSegments: Integer; tension: Single): TStatus; overload; + function AddCurve(points: PGPPoint; count: Integer): TStatus; overload; + function AddCurve(points: PGPPoint; count: Integer; tension: Single): TStatus; overload; + function AddCurve(points: PGPPoint; count, offset, numberOfSegments: Integer; tension: Single): TStatus; overload; + + function AddClosedCurve(points: PGPPointF; count: Integer): TStatus; overload; + function AddClosedCurve(points: PGPPointF; count: Integer; tension: Single): TStatus; overload; + function AddClosedCurve(points: PGPPoint; count: Integer): TStatus; overload; + function AddClosedCurve(points: PGPPoint; count: Integer; tension: Single): TStatus; overload; + + function AddRectangle(rect: TGPRectF): TStatus; overload; + function AddRectangles(rects: PGPRectF; count: Integer): TStatus; overload; + function AddRectangle(rect: TGPRect): TStatus; overload; + function AddRectangles(rects: PGPRect; count: Integer): TStatus; overload; + + function AddEllipse(rect: TGPRectF): TStatus; overload; + function AddEllipse(x, y, width, height: Single): TStatus; overload; + function AddEllipse(rect: TGPRect): TStatus; overload; + function AddEllipse(x, y, width, height: Integer): TStatus; overload; + + function AddPie(rect: TGPRectF; startAngle, sweepAngle: Single): TStatus; overload; + function AddPie(x, y, width, height, startAngle, sweepAngle: Single): TStatus; overload; + function AddPie(rect: TGPRect; startAngle, sweepAngle: Single): TStatus; overload; + function AddPie(x, y, width, height: Integer; startAngle, sweepAngle: Single): TStatus; overload; + + function AddPolygon(points: PGPPointF; count: Integer): TStatus; overload; + function AddPolygon(points: PGPPoint; count: Integer): TStatus; overload; + + function AddPath(addingPath: TGPGraphicsPath; connect: Bool): TStatus; + + function AddString(string_: WideString; length: Integer; family : TGPFontFamily; + style : Integer; emSize : Single; origin : TGPPointF; format : TGPStringFormat): TStatus; overload; + function AddString(string_: WideString; length : Integer; family : TGPFontFamily; + style : Integer; emSize : Single; layoutRect: TGPRectF; format : TGPStringFormat): TStatus; overload; + function AddString(string_: WideString; length : Integer; family : TGPFontFamily; + style : Integer; emSize : Single; origin : TGPPoint; format : TGPStringFormat): TStatus; overload; + function AddString(string_: WideString; length : Integer; family : TGPFontFamily; + style : Integer; emSize : Single; layoutRect: TGPRect; format : TGPStringFormat): TStatus; overload; + + function Transform(matrix: TGPMatrix): TStatus; + + // This is not always the tightest bounds. + function GetBounds(out bounds: TGPRectF; matrix: TGPMatrix = nil; pen: TGPPen = nil): TStatus; overload; + function GetBounds(out bounds: TGPRect; matrix: TGPMatrix = nil; pen: TGPPen = nil): TStatus; overload; + // Once flattened, the resultant path is made of line segments and + // the original path information is lost. When matrix is NULL the + // identity matrix is assumed. + function Flatten(matrix: TGPMatrix = nil; flatness: Single = FlatnessDefault): TStatus; + function Widen(pen: TGPPen; matrix: TGPMatrix = nil; flatness: Single = FlatnessDefault): TStatus; + function Outline(matrix: TGPMatrix = nil; flatness: Single = FlatnessDefault): TStatus; + // Once this is called, the resultant path is made of line segments and + // the original path information is lost. When matrix is NULL, the + // identity matrix is assumed. + function Warp(destPoints: PGPPointF; count: Integer; srcRect: TGPRectF; + matrix: TGPMatrix = nil; warpMode: TWarpMode = WarpModePerspective; + flatness: Single = FlatnessDefault): TStatus; + function GetPointCount: Integer; + function GetPathTypes(types: PBYTE; count: Integer): TStatus; + function GetPathPoints(points: PGPPointF; count: Integer): TStatus; overload; + function GetPathPoints(points: PGPPoint; count: Integer): TStatus; overload; + function GetLastStatus: TStatus; + + function IsVisible(point: TGPPointF; g: TGPGraphics = nil): BOOL; overload; + function IsVisible(x, y: Single; g: TGPGraphics = nil): BOOL; overload; + function IsVisible(point: TGPPoint; g : TGPGraphics = nil): BOOL; overload; + function IsVisible(x, y: Integer; g: TGPGraphics = nil): BOOL; overload; + + function IsOutlineVisible(point: TGPPointF; pen: TGPPen; g: TGPGraphics = nil): BOOL; overload; + function IsOutlineVisible(x, y: Single; pen: TGPPen; g: TGPGraphics = nil): BOOL; overload; + function IsOutlineVisible(point: TGPPoint; pen: TGPPen; g: TGPGraphics = nil): BOOL; overload; + function IsOutlineVisible(x, y: Integer; pen: TGPPen; g: TGPGraphics = nil): BOOL; overload; + end; + +//-------------------------------------------------------------------------- +// GraphisPathIterator class +//-------------------------------------------------------------------------- + + TGPGraphicsPathIterator = class(TGdiplusBase) + protected + nativeIterator: GpPathIterator; + lastResult : TStatus; + procedure SetNativeIterator(nativeIterator: GpPathIterator); + function SetStatus(status: TStatus): TStatus; + public + constructor Create(path: TGPGraphicsPath); reintroduce; + destructor Destroy; override; + function NextSubpath(out startIndex, endIndex: Integer; out isClosed: bool): Integer; overload; + function NextSubpath(path: TGPGraphicsPath; out isClosed: BOOL): Integer; overload; + function NextPathType(out pathType: TPathPointType; out startIndex, endIndex: Integer): Integer; + function NextMarker(out startIndex, endIndex: Integer): Integer; overload; + function NextMarker(path: TGPGraphicsPath): Integer; overload; + function GetCount: Integer; + function GetSubpathCount: Integer; + function HasCurve: BOOL; + procedure Rewind; + function Enumerate(points: PGPPointF; types: PBYTE; count: Integer): Integer; + function CopyData(points: PGPPointF; types: PBYTE; startIndex, endIndex: Integer): Integer; + function GetLastStatus: TStatus; + end; + +//-------------------------------------------------------------------------- +// Path Gradient Brush +//-------------------------------------------------------------------------- + + TGPPathGradientBrush = class(TGPBrush) + public + constructor Create(points: PGPPointF; count: Integer; + wrapMode: TWrapMode = WrapModeClamp); reintroduce; overload; + constructor Create(points: PGPPoint; count: Integer; + wrapMode: TWrapMode = WrapModeClamp); reintroduce; overload; + constructor Create(path: TGPGraphicsPath); reintroduce; overload; + constructor Create; reintroduce; overload; + function GetCenterColor(out Color: TGPColor): TStatus; + function SetCenterColor(color: TGPColor): TStatus; + function GetPointCount: Integer; + function GetSurroundColorCount: Integer; + function GetSurroundColors(colors: PARGB; var count: Integer): TStatus; + function SetSurroundColors(colors: PARGB; var count: Integer): TStatus; + function GetGraphicsPath(path: TGPGraphicsPath): TStatus; + function SetGraphicsPath(path: TGPGraphicsPath): TStatus; + function GetCenterPoint(out point: TGPPointF): TStatus; overload; + function GetCenterPoint(out point: TGPPoint): TStatus; overload; + function SetCenterPoint(point: TGPPointF): TStatus; overload; + function SetCenterPoint(point: TGPPoint): TStatus; overload; + function GetRectangle(out rect: TGPRectF): TStatus; overload; + function GetRectangle(out rect: TGPRect): TStatus; overload; + function SetGammaCorrection(useGammaCorrection: BOOL): TStatus; overload; + function GetGammaCorrection: BOOL; overload; + function GetBlendCount: Integer; + function GetBlend(blendFactors, blendPositions: PSingle; count: Integer): TStatus; + function SetBlend(blendFactors, blendPositions: PSingle; count: Integer): TStatus; + function GetInterpolationColorCount: Integer; + function SetInterpolationColors(presetColors: PARGB; blendPositions: PSingle; + count: Integer): TStatus; + function GetInterpolationColors(presetColors: PARGB; + blendPositions: PSingle; count: Integer): TStatus; + function SetBlendBellShape(focus: Single; scale: Single = 1.0): TStatus; + function SetBlendTriangularShape(focus: Single; scale: Single = 1.0): TStatus; + function GetTransform(matrix: TGPMatrix): TStatus; + function SetTransform(matrix: TGPMatrix): TStatus; + function ResetTransform: TStatus; + function MultiplyTransform(matrix: TGPMatrix; + order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function TranslateTransform(dx, dy: Single; + order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function ScaleTransform(sx, sy: Single; + order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function RotateTransform(angle: Single; + order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function GetFocusScales(out xScale, yScale: Single): TStatus; + function SetFocusScales(xScale, yScale: Single): TStatus; + function GetWrapMode: TWrapMode; + function SetWrapMode(wrapMode: TWrapMode): TStatus; + end; + +(**************************************************************************\ +* +* GDI+ Graphics Object +* +\**************************************************************************) + + TGPGraphics = class(TGdiplusBase) + protected + nativeGraphics: GpGraphics; + lastResult: TStatus; + procedure SetNativeGraphics(graphics: GpGraphics); + function SetStatus(status: TStatus): TStatus; + function GetNativeGraphics: GpGraphics; + function GetNativePen(pen: TGPPen): GpPen; + constructor Create(graphics: GpGraphics); reintroduce; overload; + public + function FromHDC(hdc: HDC): TGPGraphics; overload; + function FromHDC(hdc: HDC; hdevice: THANDLE): TGPGraphics; overload; + function FromHWND(hwnd: HWND; icm: BOOL = FALSE): TGPGraphics; + function FromImage(image: TGPImage): TGPGraphics; + constructor Create(hdc: HDC); reintroduce; overload; + constructor Create(hdc: HDC; hdevice: THANDLE); reintroduce; overload; + constructor Create(hwnd: HWND; icm: BOOL{ = FALSE}); reintroduce; overload; + constructor Create(image: TGPImage); reintroduce; overload; + destructor Destroy; override; + procedure Flush(intention: TFlushIntention = FlushIntentionFlush); + //------------------------------------------------------------------------ + // GDI Interop methods + //------------------------------------------------------------------------ + // Locks the graphics until ReleaseDC is called + function GetHDC: HDC; + procedure ReleaseHDC(hdc: HDC); + //------------------------------------------------------------------------ + // Rendering modes + //------------------------------------------------------------------------ + function SetRenderingOrigin(x, y: Integer): TStatus; + function GetRenderingOrigin(out x, y: Integer): TStatus; + function SetCompositingMode(compositingMode: TCompositingMode): TStatus; + function GetCompositingMode: TCompositingMode; + function SetCompositingQuality(compositingQuality: TCompositingQuality): TStatus; + function GetCompositingQuality: TCompositingQuality; + function SetTextRenderingHint(newMode: TTextRenderingHint): TStatus; + function GetTextRenderingHint: TTextRenderingHint; + function SetTextContrast(contrast: UINT): TStatus; // 0..12 + function GetTextContrast: UINT; + function GetInterpolationMode: TInterpolationMode; + function SetInterpolationMode(interpolationMode: TInterpolationMode): TStatus; + function GetSmoothingMode: TSmoothingMode; + function SetSmoothingMode(smoothingMode: TSmoothingMode): TStatus; + function GetPixelOffsetMode: TPixelOffsetMode; + function SetPixelOffsetMode(pixelOffsetMode: TPixelOffsetMode): TStatus; + //------------------------------------------------------------------------ + // Manipulate current world transform + //------------------------------------------------------------------------ + function SetTransform(matrix: TGPMatrix): TStatus; + function ResetTransform: TStatus; + function MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function TranslateTransform(dx, dy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + function GetTransform(matrix: TGPMatrix): TStatus; + function SetPageUnit(unit_: TUnit): TStatus; + function SetPageScale(scale: Single): TStatus; + function GetPageUnit: TUnit; + function GetPageScale: Single; + function GetDpiX: Single; + function GetDpiY: Single; + function TransformPoints(destSpace: TCoordinateSpace; srcSpace: TCoordinateSpace; + pts: PGPPointF; count: Integer): TStatus; overload; + function TransformPoints(destSpace: TCoordinateSpace; srcSpace: TCoordinateSpace; + pts: PGPPoint; count: Integer): TStatus; overload; + //------------------------------------------------------------------------ + // GetNearestColor (for <= 8bpp surfaces). Note: Alpha is ignored. + //------------------------------------------------------------------------ + function GetNearestColor(var color: TGPColor): TStatus; + + // DrawLine(s) + function DrawLine(pen: TGPPen; x1, y1, x2, y2: Single): TStatus; overload; + function DrawLine(pen: TGPPen; const pt1, pt2: TGPPointF): TStatus; overload; + function DrawLines(pen: TGPPen; points: PGPPointF; count: Integer): TStatus; overload; + function DrawLine(pen: TGPPen; x1, y1, x2, y2: Integer): TStatus; overload; + function DrawLine(pen: TGPPen; const pt1, pt2: TGPPoint): TStatus; overload; + function DrawLines(pen: TGPPen; points: PGPPoint; count: Integer): TStatus; overload; + + // DrawArc + function DrawArc(pen: TGPPen; x, y, width, height, startAngle, sweepAngle: Single): TStatus; overload; + function DrawArc(pen: TGPPen; const rect: TGPRectF; startAngle, sweepAngle: Single): TStatus; overload; + function DrawArc(pen: TGPPen; x, y, width, height: Integer; startAngle, sweepAngle: Single): TStatus; overload; + function DrawArc(pen: TGPPen; const rect: TGPRect; startAngle, sweepAngle: Single): TStatus; overload; + + // DrawBezier(s) + function DrawBezier(pen: TGPPen; x1, y1, x2, y2, x3, y3, x4, y4: Single): TStatus; overload; + function DrawBezier(pen: TGPPen; const pt1, pt2, pt3, pt4: TGPPointF): TStatus; overload; + function DrawBeziers(pen: TGPPen; points: PGPPointF; count: Integer): TStatus; overload; + function DrawBezier(pen: TGPPen; x1, y1, x2, y2, x3, y3, x4, y4: Integer): TStatus; overload; + function DrawBezier(pen: TGPPen; const pt1, pt2, pt3, pt4: TGPPoint): TStatus; overload; + function DrawBeziers(pen: TGPPen; points: PGPPoint; count: Integer): TStatus; overload; + + // DrawRectangle(s) + function DrawRectangle(pen: TGPPen; const rect: TGPRectF): TStatus; overload; + function DrawRectangle(pen: TGPPen; x, y, width, height: Single): TStatus; overload; + function DrawRectangles(pen: TGPPen; rects: PGPRectF; count: Integer): TStatus; overload; + function DrawRectangle(pen: TGPPen; const rect: TGPRect): TStatus; overload; + function DrawRectangle(pen: TGPPen; x, y, width, height: Integer): TStatus; overload; + function DrawRectangles(pen: TGPPen; rects: PGPRect; count: Integer): TStatus; overload; + + // DrawEllipse + function DrawEllipse(pen: TGPPen; const rect: TGPRectF): TStatus; overload; + function DrawEllipse(pen: TGPPen; x, y, width, height: Single): TStatus; overload; + function DrawEllipse(pen: TGPPen; const rect: TGPRect): TStatus; overload; + function DrawEllipse(pen: TGPPen; x, y, width, height: Integer): TStatus; overload; + + // DrawPie + function DrawPie(pen: TGPPen; const rect: TGPRectF; startAngle, sweepAngle: Single): TStatus; overload; + function DrawPie(pen: TGPPen; x, y, width, height, startAngle, sweepAngle: Single): TStatus; overload; + function DrawPie(pen: TGPPen; const rect: TGPRect; startAngle, sweepAngle: Single): TStatus; overload; + function DrawPie(pen: TGPPen; x, y, width, height: Integer; startAngle, sweepAngle: Single): TStatus; overload; + + // DrawPolygon + function DrawPolygon(pen: TGPPen; points: PGPPointF; count: Integer): TStatus; overload; + function DrawPolygon(pen: TGPPen; points: PGPPoint; count: Integer): TStatus; overload; + + // DrawPath + function DrawPath(pen: TGPPen; path: TGPGraphicsPath): TStatus; + + // DrawCurve + function DrawCurve(pen: TGPPen; points: PGPPointF; count: Integer): TStatus; overload; + function DrawCurve(pen: TGPPen; points: PGPPointF; count: Integer; tension: Single): TStatus; overload; + function DrawCurve(pen: TGPPen; points: PGPPointF; count, offset, + numberOfSegments: Integer; tension: Single = 0.5): TStatus; overload; + function DrawCurve(pen: TGPPen; points: PGPPoint; count: Integer): TStatus; overload; + function DrawCurve(pen: TGPPen; points: PGPPoint; count: Integer; tension: Single): TStatus; overload; + function DrawCurve(pen: TGPPen; points: PGPPoint; count, offset, numberOfSegments: Integer; + tension: Single = 0.5): TStatus; overload; + + // DrawClosedCurve + function DrawClosedCurve(pen: TGPPen; points: PGPPointF; count: Integer): TStatus; overload; + function DrawClosedCurve(pen: TGPPen; points: PGPPointF; count: Integer; tension: Single): TStatus; overload; + function DrawClosedCurve(pen: TGPPen; points: PGPPoint; count: Integer): TStatus; overload; + function DrawClosedCurve(pen: TGPPen; points: PGPPoint; count: Integer; tension: Single): TStatus; overload; + + // Clear + function Clear(color: TGPColor): TStatus; + + // FillRectangle(s) + function FillRectangle(brush: TGPBrush; const rect: TGPRectF): TStatus; overload; + function FillRectangle(brush: TGPBrush; x, y, width, height: Single): TStatus; overload; + function FillRectangles(brush: TGPBrush; rects: PGPRectF; count: Integer): TStatus; overload; + function FillRectangle(brush: TGPBrush; const rect: TGPRect): TStatus; overload; + function FillRectangle(brush: TGPBrush; x, y, width, height: Integer): TStatus; overload; + function FillRectangles(brush: TGPBrush; rects: PGPRect; count: Integer): TStatus; overload; + + // FillPolygon + function FillPolygon(brush: TGPBrush; points: PGPPointF; count: Integer): TStatus; overload; + function FillPolygon(brush: TGPBrush; points: PGPPointF; count: Integer; fillMode: TFillMode): TStatus; overload; + function FillPolygon(brush: TGPBrush; points: PGPPoint; count: Integer): TStatus; overload; + function FillPolygon(brush: TGPBrush; points: PGPPoint; count: Integer; fillMode: TFillMode): TStatus; overload; + + // FillEllipse + function FillEllipse(brush: TGPBrush; const rect: TGPRectF): TStatus; overload; + function FillEllipse(brush: TGPBrush; x, y, width, height: Single): TStatus; overload; + function FillEllipse(brush: TGPBrush; const rect: TGPRect): TStatus; overload; + function FillEllipse(brush: TGPBrush; x, y, width, height: Integer): TStatus; overload; + + // FillPie + function FillPie(brush: TGPBrush; const rect: TGPRectF; startAngle, sweepAngle: Single): TStatus; overload; + function FillPie(brush: TGPBrush; x, y, width, height, startAngle, sweepAngle: Single): TStatus; overload; + function FillPie(brush: TGPBrush; const rect: TGPRect; startAngle, sweepAngle: Single): TStatus; overload; + function FillPie(brush: TGPBrush; x, y, width, height: Integer; startAngle, sweepAngle: Single): TStatus; overload; + + // FillPath + function FillPath(brush: TGPBrush; path: TGPGraphicsPath): TStatus; + + // FillClosedCurve + function FillClosedCurve(brush: TGPBrush; points: PGPPointF; count: Integer): TStatus; overload; + function FillClosedCurve(brush: TGPBrush; points: PGPPointF; count: Integer; + fillMode: TFillMode; tension: Single = 0.5 ): TStatus; overload; + function FillClosedCurve(brush: TGPBrush; points: PGPPoint; count: Integer): TStatus; overload; + function FillClosedCurve(brush: TGPBrush; points: PGPPoint; count: Integer; + fillMode: TFillMode; tension: Single = 0.5): TStatus; overload; + + // FillRegion + function FillRegion(brush: TGPBrush; region: TGPRegion): TStatus; + + // DrawString + function DrawString(string_: WideString; length: Integer; font: TGPFont; + const layoutRect: TGPRectF; stringFormat: TGPStringFormat; brush: TGPBrush): TStatus; overload; + function DrawString(string_: WideString; length: Integer; font: TGPFont; + const origin: TGPPointF; brush: TGPBrush): TStatus; overload; + function DrawString(string_: WideString; length: Integer; font: TGPFont; + const origin: TGPPointF; stringFormat: TGPStringFormat; brush: TGPBrush): TStatus; overload; + + // MeasureString + function MeasureString(string_: WideString; length: Integer; font: TGPFont; + const layoutRect: TGPRectF; stringFormat: TGPStringFormat; out boundingBox: TGPRectF; + codepointsFitted: PInteger = nil; linesFilled: PInteger = nil): TStatus; overload; + function MeasureString(string_: WideString; length: Integer; font: TGPFont; + const layoutRectSize: TGPSizeF; stringFormat: TGPStringFormat; out size: TGPSizeF; + codepointsFitted: PInteger = nil; linesFilled: PInteger = nil): TStatus; overload; + function MeasureString(string_: WideString ; length: Integer; font: TGPFont; + const origin: TGPPointF; stringFormat: TGPStringFormat; + out boundingBox: TGPRectF): TStatus; overload; + function MeasureString(string_: WideString; length: Integer; font: TGPFont; + const layoutRect: TGPRectF; out boundingBox: TGPRectF): TStatus; overload; + function MeasureString(string_: WideString; length: Integer; font: TGPFont; + const origin: TGPPointF; out boundingBox: TGPRectF): TStatus; overload; + + // MeasureCharacterRanges + function MeasureCharacterRanges(string_: WideString; length: Integer; font: TGPFont; + const layoutRect: TGPRectF; stringFormat: TGPStringFormat; regionCount: Integer; + const regions: array of TGPRegion): TStatus; overload; + + // DrawDriverString + function DrawDriverString(text: PUINT16; length: Integer; font: TGPFont; + brush: TGPBrush; positions: PGPPointF; flags: Integer; matrix: TGPMatrix): TStatus; + + // MeasureDriverString + function MeasureDriverString(text: PUINT16; length: Integer; font: TGPFont; + positions: PGPPointF; flags: Integer; matrix: TGPMatrix; + out boundingBox: TGPRectF): TStatus; + + // Draw a cached bitmap on this graphics destination offset by + // x, y. Note this will fail with WrongState if the CachedBitmap + // native format differs from this Graphics. + function DrawCachedBitmap(cb: TGPCachedBitmap; x, y: Integer): TStatus; + function DrawImage(image: TGPImage; const point: TGPPointF): TStatus; overload; + function DrawImage(image: TGPImage; x, y: Single): TStatus; overload; + function DrawImage(image: TGPImage; const rect: TGPRectF): TStatus; overload; + function DrawImage(image: TGPImage; x, y, width, height: Single): TStatus; overload; + function DrawImage(image: TGPImage; const point: TGPPoint): TStatus; overload; + function DrawImage(image: TGPImage; x, y: Integer): TStatus; overload; + function DrawImage(image: TGPImage; const rect: TGPRect): TStatus; overload; + function DrawImage(image: TGPImage; x, y, width, height: Integer): TStatus; overload; + + // Affine Draw Image + // destPoints.length = 3: rect => parallelogram + // destPoints[0] <=> top-left corner of the source rectangle + // destPoints[1] <=> top-right corner + // destPoints[2] <=> bottom-left corner + // destPoints.length = 4: rect => quad + // destPoints[3] <=> bottom-right corner + function DrawImage(image: TGPImage; destPoints: PGPPointF; count: Integer): TStatus; overload; + function DrawImage(image: TGPImage; destPoints: PGPPoint; count: Integer): TStatus; overload; + function DrawImage(image: TGPImage; x, y, srcx, srcy, srcwidth, srcheight: Single; srcUnit: TUnit): TStatus; overload; + function DrawImage(image: TGPImage; const destRect: TGPRectF; srcx, srcy, + srcwidth, srcheight: Single; srcUnit: TUnit; + imageAttributes: TGPImageAttributes = nil; callback: DrawImageAbort = nil; + callbackData: Pointer = nil): TStatus; overload; + function DrawImage(image: TGPImage; destPoints: PGPPointF; count: Integer; + srcx, srcy, srcwidth, srcheight: Single; srcUnit: TUnit; + imageAttributes: TGPImageAttributes = nil; callback: DrawImageAbort = nil; + callbackData: Pointer = nil): TStatus; overload; + function DrawImage(image: TGPImage; x, y, srcx, srcy, srcwidth, + srcheight: Integer; srcUnit: TUnit): TStatus; overload; + function DrawImage(image: TGPImage; const destRect: TGPRect; srcx, srcy, + srcwidth, srcheight: Integer; srcUnit: TUnit; + imageAttributes: TGPImageAttributes = nil; callback: DrawImageAbort = nil; + callbackData: Pointer = nil): TStatus; overload; + function DrawImage(image: TGPImage; destPoints: PGPPoint; + count, srcx, srcy, srcwidth, srcheight: Integer; srcUnit: TUnit; + imageAttributes: TGPImageAttributes = nil; callback: DrawImageAbort = nil; + callbackData: Pointer = nil): TStatus; overload; + + // The following methods are for playing an EMF+ to a graphics + // via the enumeration interface. Each record of the EMF+ is + // sent to the callback (along with the callbackData). Then + // the callback can invoke the Metafile::PlayRecord method + // to play the particular record. + function EnumerateMetafile(metafile: TGPMetafile; const destPoint: TGPPointF; + callback: EnumerateMetafileProc; callbackData: Pointer = nil; + imageAttributes: TGPImageAttributes = nil): TStatus; overload; + function EnumerateMetafile(metafile: TGPMetafile; const destPoint: TGPPoint; + callback: EnumerateMetafileProc; callbackData: pointer = nil; + imageAttributes: TGPImageAttributes = nil): TStatus; overload; + function EnumerateMetafile(metafile: TGPMetafile; const destRect: TGPRectF; + callback: EnumerateMetafileProc; callbackData: Pointer = nil; + imageAttributes: TGPImageAttributes = nil): TStatus; overload; + function EnumerateMetafile(metafile: TGPMetafile; const destRect: TGPRect; + callback: EnumerateMetafileProc; callbackData: Pointer = nil; + imageAttributes: TGPImageAttributes = nil): TStatus; overload; + function EnumerateMetafile(metafile: TGPMetafile; destPoints: PGPPointF; + count: Integer; callback: EnumerateMetafileProc; callbackData: Pointer = nil; + imageAttributes: TGPImageAttributes = nil): TStatus; overload; + function EnumerateMetafile(metafile: TGPMetafile; destPoints: PGPPoint; + count: Integer; callback: EnumerateMetafileProc; callbackData: Pointer = nil; + imageAttributes: TGPImageAttributes = nil): TStatus; overload; + function EnumerateMetafile(metafile: TGPMetafile; const destPoint: TGPPointF; + const srcRect: TGPRectF; srcUnit: TUnit; callback: EnumerateMetafileProc; + callbackData: pointer = nil; imageAttributes: TGPImageAttributes = nil + ): TStatus; overload; + function EnumerateMetafile(metafile : TGPMetafile; const destPoint : TGPPoint; + const srcRect : TGPRect; srcUnit : TUnit; callback : EnumerateMetafileProc; + callbackData : Pointer = nil; imageAttributes : TGPImageAttributes = nil + ): TStatus; overload; + function EnumerateMetafile(metafile: TGPMetafile; const destRect: TGPRectF; + const srcRect: TGPRectF; srcUnit: TUnit; callback: EnumerateMetafileProc; + callbackData: Pointer = nil; imageAttributes: TGPImageAttributes = nil): TStatus; overload; + function EnumerateMetafile(metafile : TGPMetafile; const destRect, srcRect: TGPRect; + srcUnit : TUnit; callback : EnumerateMetafileProc; callbackData : Pointer = nil; + imageAttributes : TGPImageAttributes = nil): TStatus; overload; + function EnumerateMetafile( metafile: TGPMetafile; destPoints: PGPPointF; + count: Integer; const srcRect: TGPRectF; srcUnit: TUnit; callback: EnumerateMetafileProc; + callbackData: Pointer = nil; imageAttributes: TGPImageAttributes = nil): TStatus; overload; + function EnumerateMetafile(metafile: TGPMetafile; destPoints: PGPPoint; + count: Integer; const srcRect: TGPRect; srcUnit: TUnit; callback: EnumerateMetafileProc; + callbackData: Pointer = nil; imageAttributes: TGPImageAttributes = nil): TStatus; overload; + + // SetClip + function SetClip(g: TGPGraphics; combineMode: TCombineMode = CombineModeReplace): TStatus; overload; + function SetClip(rect: TGPRectF; combineMode: TCombineMode = CombineModeReplace): TStatus; overload; + function SetClip(rect: TGPRect; combineMode: TCombineMode = CombineModeReplace): TStatus; overload; + function SetClip(path: TGPGraphicsPath; combineMode: TCombineMode = CombineModeReplace): TStatus; overload; + function SetClip(region: TGPRegion; combineMode: TCombineMode = CombineModeReplace): TStatus; overload; + // This is different than the other SetClip methods because it assumes + // that the HRGN is already in device units, so it doesn't transform + // the coordinates in the HRGN. + function SetClip(hRgn: HRGN; combineMode: TCombineMode = CombineModeReplace): TStatus; overload; + + // IntersectClip + function IntersectClip(const rect: TGPRectF): TStatus; overload; + function IntersectClip(const rect: TGPRect): TStatus; overload; + function IntersectClip(region: TGPRegion): TStatus; overload; + // ExcludeClip + function ExcludeClip(const rect: TGPRectF): TStatus; overload; + function ExcludeClip(const rect: TGPRect): TStatus; overload; + function ExcludeClip(region: TGPRegion): TStatus; overload; + + function ResetClip: TStatus; + + function TranslateClip(dx, dy: Single): TStatus; overload; + function TranslateClip(dx, dy: Integer): TStatus; overload; + + function GetClip(region: TGPRegion): TStatus; + + function GetClipBounds(out rect: TGPRectF): TStatus; overload; + function GetClipBounds(out rect: TGPRect): TStatus; overload; + + function IsClipEmpty: Bool; + + function GetVisibleClipBounds(out rect: TGPRectF): TStatus; overload; + function GetVisibleClipBounds(out rect: TGPRect): TStatus; overload; + + function IsVisibleClipEmpty: BOOL; + + function IsVisible(x, y: Integer): BOOL; overload; + function IsVisible(const point: TGPPoint): BOOL; overload; + function IsVisible(x, y, width, height: Integer): BOOL; overload; + function IsVisible(const rect: TGPRect): BOOL; overload; + function IsVisible(x, y: Single): BOOL; overload; + function IsVisible(const point: TGPPointF): BOOL; overload; + function IsVisible(x, y, width, height: Single): BOOL; overload; + function IsVisible(const rect: TGPRectF): BOOL; overload; + + function Save: GraphicsState; + function Restore(gstate: GraphicsState): TStatus; + + function BeginContainer(const dstrect,srcrect: TGPRectF; unit_: TUnit): GraphicsContainer; overload; + function BeginContainer(const dstrect, srcrect: TGPRect; unit_: TUnit): GraphicsContainer; overload; + function BeginContainer: GraphicsContainer; overload; + function EndContainer(state: GraphicsContainer): TStatus; + + // Only valid when recording metafiles. + function AddMetafileComment(data: PBYTE; sizeData: UINT): TStatus; + + function GetHalftonePalette: HPALETTE; + function GetLastStatus: TStatus; + end; + + +(**************************************************************************\ +* +* GDI+ CustomLineCap APIs +* +\**************************************************************************) + + TGPAdjustableArrowCap = class(TGPCustomLineCap) + public + constructor Create(height, width: Single; isFilled: Bool = TRUE); + function SetHeight(height: Single): TStatus; + function GetHeight: Single; + function SetWidth(width: Single): TStatus; + function GetWidth: Single; + function SetMiddleInset(middleInset: Single): TStatus; + function GetMiddleInset: Single; + function SetFillState(isFilled: Bool): TStatus; + function IsFilled: BOOL; + end; + +(**************************************************************************\ +* +* GDI+ Metafile class +* +\**************************************************************************) + + TGPMetafile = class(TGPImage) + public + // Playback a metafile from a HMETAFILE + // If deleteWmf is TRUE, then when the metafile is deleted, + // the hWmf will also be deleted. Otherwise, it won't be. + constructor Create(hWmf: HMETAFILE; var wmfPlaceableFileHeader: TWmfPlaceableFileHeader; + deleteWmf: BOOL = FALSE); overload; + // Playback a metafile from a HENHMETAFILE + // If deleteEmf is TRUE, then when the metafile is deleted, + // the hEmf will also be deleted. Otherwise, it won't be. + constructor Create(hEmf: HENHMETAFILE; deleteEmf: BOOL = FALSE); overload; + constructor Create(filename: WideString); overload; + // Playback a WMF metafile from a file. + constructor Create(filename: WideString; var wmfPlaceableFileHeader: TWmfPlaceableFileHeader); overload; + constructor Create(stream: IStream); overload; + // Record a metafile to memory. + constructor Create(referenceHdc: HDC; type_: TEmfType = EmfTypeEmfPlusDual; + description: PWCHAR = nil); overload; + // Record a metafile to memory. + constructor Create(referenceHdc: HDC; frameRect: TGPRectF; + frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi; + type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); overload; + // Record a metafile to memory. + constructor Create(referenceHdc: HDC; frameRect: TGPRect; + frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi; + type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); overload; + constructor Create(fileName: WideString;referenceHdc: HDC; + type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); overload; + constructor Create(fileName: WideString; referenceHdc: HDC; frameRect: TGPRectF; + frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi; + type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); overload; + constructor Create( fileName: WideString; referenceHdc: HDC; frameRect: TGPRect; + frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi; + type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); overload; + constructor Create(stream: IStream; referenceHdc: HDC; + type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); overload; + constructor Create(stream: IStream; referenceHdc: HDC; frameRect: TGPRectF; + frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi; + type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); overload; + constructor Create(stream : IStream; referenceHdc : HDC; frameRect : TGPRect; + frameUnit : TMetafileFrameUnit = MetafileFrameUnitGdi; + type_ : TEmfType = EmfTypeEmfPlusDual; description : PWCHAR = nil); overload; + constructor Create; reintroduce; overload; + function GetMetafileHeader(hWmf: HMETAFILE; var wmfPlaceableFileHeader: TWmfPlaceableFileHeader; + header: TMetafileHeader): TStatus; overload; + function GetMetafileHeader(hEmf: HENHMETAFILE; header: TMetafileHeader): TStatus; overload; // ok + function GetMetafileHeader(filename: WideString; header: TMetafileHeader): TStatus; overload; // ok + function GetMetafileHeader(stream: IStream; header: TMetafileHeader): TStatus; overload; // ok + function GetMetafileHeader(header: TMetafileHeader): TStatus; overload; // ok + // Once this method is called, the Metafile object is in an invalid state + // and can no longer be used. It is the responsiblity of the caller to + // invoke DeleteEnhMetaFile to delete this hEmf. // ok + function GetHENHMETAFILE: HENHMETAFILE; + // Used in conjuction with Graphics::EnumerateMetafile to play an EMF+ + // The data must be DWORD aligned if it's an EMF or EMF+. It must be + // WORD aligned if it's a WMF. + function PlayRecord(recordType: TEmfPlusRecordType; flags, dataSize: UINT; data: PBYTE): TStatus; + // If you're using a printer HDC for the metafile, but you want the + // metafile rasterized at screen resolution, then use this API to set + // the rasterization dpi of the metafile to the screen resolution, + // e.g. 96 dpi or 120 dpi. + function SetDownLevelRasterizationLimit(metafileRasterizationLimitDpi: UINT): TStatus; + function GetDownLevelRasterizationLimit: UINT; + function EmfToWmfBits(hemf: HENHMETAFILE; cbData16: UINT; pData16: PBYTE; + iMapMode: Integer = MM_ANISOTROPIC; eFlags: TEmfToWmfBitsFlags = EmfToWmfBitsFlagsDefault): UINT; + end; + +//////////////////////////////////////////////////////////////////////////////// + +var + GenericSansSerifFontFamily : TGPFontFamily = nil; + GenericSerifFontFamily : TGPFontFamily = nil; + GenericMonospaceFontFamily : TGPFontFamily = nil; + + GenericTypographicStringFormatBuffer: TGPStringFormat = nil; + GenericDefaultStringFormatBuffer : TGPStringFormat = nil; + + StartupInput: TGDIPlusStartupInput; + gdiplusToken: ULONG; + +//////////////////////////////////////////////////////////////////////////////// + +implementation + +(**************************************************************************\ +* +* Image Attributes +* +* Abstract: +* +* GDI+ Image Attributes used with Graphics.DrawImage +* +* There are 5 possible sets of color adjustments: +* ColorAdjustDefault, +* ColorAdjustBitmap, +* ColorAdjustBrush, +* ColorAdjustPen, +* ColorAdjustText, +* +* Bitmaps, Brushes, Pens, and Text will all use any color adjustments +* that have been set into the default ImageAttributes until their own +* color adjustments have been set. So as soon as any "Set" method is +* called for Bitmaps, Brushes, Pens, or Text, then they start from +* scratch with only the color adjustments that have been set for them. +* Calling Reset removes any individual color adjustments for a type +* and makes it revert back to using all the default color adjustments +* (if any). The SetToIdentity method is a way to force a type to +* have no color adjustments at all, regardless of what previous adjustments +* have been set for the defaults or for that type. +* +\********************************************************************F******) + + constructor TGPImageAttributes.Create; + begin + nativeImageAttr := nil; + lastResult := GdipCreateImageAttributes(nativeImageAttr); + end; + + destructor TGPImageAttributes.Destroy; + begin + GdipDisposeImageAttributes(nativeImageAttr); + inherited Destroy; + end; + + function TGPImageAttributes.Clone: TGPImageAttributes; + var clone: GpImageAttributes; + begin + SetStatus(GdipCloneImageAttributes(nativeImageAttr, clone)); + result := TGPImageAttributes.Create(clone, lastResult); + end; + + function TGPImageAttributes.SetToIdentity(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesToIdentity(nativeImageAttr, type_)); + end; + + function TGPImageAttributes.Reset(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipResetImageAttributes(nativeImageAttr, type_)); + end; + + function TGPImageAttributes.SetColorMatrix(const colorMatrix: TColorMatrix; + mode: TColorMatrixFlags = ColorMatrixFlagsDefault; + type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesColorMatrix(nativeImageAttr, + type_, TRUE, @colorMatrix, nil, mode)); + end; + + function TGPImageAttributes.ClearColorMatrix(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesColorMatrix(nativeImageAttr, type_, + FALSE, nil, nil, ColorMatrixFlagsDefault)); + end; + + + function TGPImageAttributes.SetColorMatrices(const colorMatrix: TColorMatrix; + const grayMatrix: TColorMatrix; mode: TColorMatrixFlags = ColorMatrixFlagsDefault; + type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesColorMatrix(nativeImageAttr, type_, + TRUE, @colorMatrix, @grayMatrix, mode)); + end; + + function TGPImageAttributes.ClearColorMatrices(Type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesColorMatrix( nativeImageAttr, + type_, FALSE, nil, nil, ColorMatrixFlagsDefault)); + end; + + function TGPImageAttributes.SetThreshold(threshold: Single; type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesThreshold( nativeImageAttr, type_, + TRUE, threshold)); + end; + + function TGPImageAttributes.ClearThreshold(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesThreshold(nativeImageAttr, type_, + FALSE, 0.0)); + end; + + function TGPImageAttributes.SetGamma(gamma: Single; type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesGamma(nativeImageAttr, type_, TRUE, gamma)); + end; + + function TGPImageAttributes.ClearGamma(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesGamma(nativeImageAttr, type_, FALSE, 0.0)); + end; + + function TGPImageAttributes.SetNoOp(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesNoOp(nativeImageAttr, type_, TRUE)); + end; + + function TGPImageAttributes.ClearNoOp(Type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesNoOp( nativeImageAttr, type_, FALSE)); + end; + + function TGPImageAttributes.SetColorKey(colorLow, colorHigh: TGPColor; + type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesColorKeys(nativeImageAttr, type_, + TRUE, colorLow, colorHigh)); + end; + + function TGPImageAttributes.ClearColorKey(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesColorKeys(nativeImageAttr, type_, + FALSE, 0, 0)); + end; + + function TGPImageAttributes.SetOutputChannel(channelFlags: TColorChannelFlags; + type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesOutputChannel(nativeImageAttr, + type_, TRUE, channelFlags)); + end; + + function TGPImageAttributes.ClearOutputChannel(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesOutputChannel(nativeImageAttr, + type_, FALSE, ColorChannelFlagsLast)); + end; + + function TGPImageAttributes.SetOutputChannelColorProfile(colorProfileFilename: WideString; + type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesOutputChannelColorProfile(nativeImageAttr, + type_, TRUE, PWideChar(colorProfileFilename))); + end; + + function TGPImageAttributes.ClearOutputChannelColorProfile(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesOutputChannelColorProfile(nativeImageAttr, + type_, FALSE, nil)); + end; + + function TGPImageAttributes.SetRemapTable(mapSize: Cardinal; map: PColorMap; + type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesRemapTable(nativeImageAttr, type_, + TRUE, mapSize, map)); + end; + + function TGPImageAttributes.ClearRemapTable(type_: TColorAdjustType = ColorAdjustTypeDefault): TStatus; + begin + result := SetStatus(GdipSetImageAttributesRemapTable(nativeImageAttr, type_, + FALSE, 0, nil)); + end; + + function TGPImageAttributes.SetBrushRemapTable(mapSize: Cardinal; map: PColorMap): TStatus; + begin + result := SetRemapTable(mapSize, map, ColorAdjustTypeBrush); + end; + + function TGPImageAttributes.ClearBrushRemapTable: TStatus; + begin + result := ClearRemapTable(ColorAdjustTypeBrush); + end; + + function TGPImageAttributes.SetWrapMode(wrap: TWrapMode; color: TGPColor = aclBlack; + clamp: BOOL = FALSE): TStatus; + begin + result := SetStatus(GdipSetImageAttributesWrapMode(nativeImageAttr, wrap, color, clamp)); + end; + + // The flags of the palette are ignored. + + function TGPImageAttributes.GetAdjustedPalette(colorPalette: PColorPalette; + colorAdjustType: TColorAdjustType): TStatus; + begin + result := SetStatus(GdipGetImageAttributesAdjustedPalette(nativeImageAttr, + colorPalette, colorAdjustType)); + end; + + function TGPImageAttributes.GetLastStatus: TStatus; + begin + result := lastResult; + lastResult := Ok; + end; + + constructor TGPImageAttributes.Create(imageAttr: GpImageAttributes; status: TStatus); + begin + SetNativeImageAttr(imageAttr); + lastResult := status; + end; + + procedure TGPImageAttributes.SetNativeImageAttr(nativeImageAttr: GpImageAttributes); + begin + self.nativeImageAttr := nativeImageAttr; + end; + + function TGPImageAttributes.SetStatus(status: TStatus): TStatus; + begin + if (status <> Ok) then lastResult := status; + result := status; + end; + +(**************************************************************************\ +* +* GDI+ Matrix class +* +\**************************************************************************) + + // Default constructor is set to identity matrix. + constructor TGPMatrix.Create; + var matrix: GpMatrix; + begin + matrix := nil; + lastResult := GdipCreateMatrix(matrix); + SetNativeMatrix(matrix); + end; + + constructor TGPMatrix.Create(m11, m12, m21, m22, dx, dy: Single); + var matrix: GpMatrix; + begin + matrix := nil; + lastResult := GdipCreateMatrix2(m11, m12, m21, m22, dx, dy, matrix); + SetNativeMatrix(matrix); + end; + + constructor TGPMatrix.Create(const rect: TGPRectF; const dstplg: TGPPointF); + var matrix: GpMatrix; + begin + matrix := nil; + lastResult := GdipCreateMatrix3(@rect, @dstplg, matrix); + SetNativeMatrix(matrix); + end; + + constructor TGPMatrix.Create(const rect: TGPRect; const dstplg: TGPPoint); + var matrix: GpMatrix; + begin + matrix := nil; + lastResult := GdipCreateMatrix3I(@rect, @dstplg, matrix); + SetNativeMatrix(matrix); + end; + + destructor TGPMatrix.Destroy; + begin + GdipDeleteMatrix(nativeMatrix); + end; + + function TGPMatrix.Clone: TGPMatrix; + var cloneMatrix: GpMatrix; + begin + cloneMatrix := nil; + SetStatus(GdipCloneMatrix(nativeMatrix, cloneMatrix)); + if (lastResult <> Ok) then + begin + result := nil; + exit; + end; + result := TGPMatrix.Create(cloneMatrix); + end; + + function TGPMatrix.GetElements(const m: TMatrixArray): TStatus; + begin + result := SetStatus(GdipGetMatrixElements(nativeMatrix, @m)); + end; + + function TGPMatrix.SetElements(m11, m12, m21, m22, dx, dy: Single): TStatus; + begin + result := SetStatus(GdipSetMatrixElements(nativeMatrix, + m11, m12, m21, m22, dx, dy)); + end; + + function TGPMatrix.OffsetX: Single; + var elements: TMatrixArray; + begin + if (GetElements(elements) = Ok) then + result := elements[4] + else + result := 0.0; + end; + + function TGPMatrix.OffsetY: Single; + var elements: TMatrixArray; + begin + if (GetElements(elements) = Ok) then result := elements[5] + else result := 0.0; + end; + + function TGPMatrix.Reset: TStatus; + begin + // set identity matrix elements + result := SetStatus(GdipSetMatrixElements(nativeMatrix, 1.0, 0.0, 0.0, 1.0, + 0.0, 0.0)); + end; + + function TGPMatrix.Multiply(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipMultiplyMatrix(nativeMatrix, matrix.nativeMatrix, order)); + end; + + function TGPMatrix.Translate(offsetX, offsetY: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipTranslateMatrix(nativeMatrix, offsetX, offsetY, order)); + end; + + function TGPMatrix.Scale(scaleX, scaleY: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipScaleMatrix(nativeMatrix, scaleX, scaleY, order)); + end; + + function TGPMatrix.Rotate(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipRotateMatrix(nativeMatrix, angle, order)); + end; + + function TGPMatrix.RotateAt(angle: Single; const center: TGPPointF; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + if(order = MatrixOrderPrepend) then + begin + SetStatus(GdipTranslateMatrix(nativeMatrix, center.X, center.Y, order)); + SetStatus(GdipRotateMatrix(nativeMatrix, angle, order)); + result := SetStatus(GdipTranslateMatrix(nativeMatrix, -center.X, -center.Y, + order)); + end + else + begin + SetStatus(GdipTranslateMatrix(nativeMatrix, - center.X, - center.Y, order)); + SetStatus(GdipRotateMatrix(nativeMatrix, angle, order)); + result := SetStatus(GdipTranslateMatrix(nativeMatrix, center.X, center.Y, + order)); + end; + end; + + function TGPMatrix.Shear(shearX, shearY: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipShearMatrix(nativeMatrix, shearX, shearY, order)); + end; + + function TGPMatrix.Invert: TStatus; + begin + result := SetStatus(GdipInvertMatrix(nativeMatrix)); + end; + + // float version + function TGPMatrix.TransformPoints(pts: PGPPointF; count: Integer = 1): TStatus; + begin + result := SetStatus(GdipTransformMatrixPoints(nativeMatrix, pts, count)); + end; + + function TGPMatrix.TransformPoints(pts: PGPPoint; count: Integer = 1): TStatus; + begin + result := SetStatus(GdipTransformMatrixPointsI(nativeMatrix, pts, count)); + end; + + function TGPMatrix.TransformVectors(pts: PGPPointF; count: Integer = 1): TStatus; + begin + result := SetStatus(GdipVectorTransformMatrixPoints( nativeMatrix, pts, count)); + end; + + function TGPMatrix.TransformVectors(pts: PGPPoint; count: Integer = 1): TStatus; + begin + result := SetStatus(GdipVectorTransformMatrixPointsI(nativeMatrix, pts, count)); + end; + + function TGPMatrix.IsInvertible: BOOL; + begin + result := FALSE; + SetStatus(GdipIsMatrixInvertible(nativeMatrix, result)); + end; + + function TGPMatrix.IsIdentity: BOOL; + begin + result := False; + SetStatus(GdipIsMatrixIdentity(nativeMatrix, result)); + end; + + function TGPMatrix.Equals(matrix: TGPMatrix): BOOL; + begin + result := FALSE; + SetStatus(GdipIsMatrixEqual(nativeMatrix, matrix.nativeMatrix, result)); + end; + + function TGPMatrix.GetLastStatus: TStatus; + begin + result := lastResult; + lastResult := Ok; + end; + + constructor TGPMatrix.Create(nativeMatrix: GpMatrix); + begin + lastResult := Ok; + SetNativeMatrix(nativeMatrix); + end; + + procedure TGPMatrix.SetNativeMatrix(nativeMatrix: GpMatrix); + begin + self.nativeMatrix := nativeMatrix; + end; + + function TGPMatrix.SetStatus(status: TStatus): TStatus; + begin + if (status <> Ok) then lastResult := status; + result := status; + end; + + +(**************************************************************************\ +* +* GDI+ StringFormat class +* +\**************************************************************************) + + constructor TGPStringFormat.Create(formatFlags: Integer = 0; language: LANGID = LANG_NEUTRAL); + begin + nativeFormat := nil; + lastError := GdipCreateStringFormat(formatFlags, language, nativeFormat); + end; + + class function TGPStringFormat.GenericDefault: TGPStringFormat; + begin + if not assigned(GenericDefaultStringFormatBuffer) then + begin + GenericDefaultStringFormatBuffer := TGPStringFormat.Create; + GenericDefaultStringFormatBuffer.lastError := + GdipStringFormatGetGenericDefault(GenericDefaultStringFormatBuffer.nativeFormat); + end; + result := GenericDefaultStringFormatBuffer; + end; + + class function TGPStringFormat.GenericTypographic: TGPStringFormat; + begin + if not assigned(GenericTypographicStringFormatBuffer) then + begin + GenericTypographicStringFormatBuffer := TGPStringFormat.Create; + GenericTypographicStringFormatBuffer.lastError := + GdipStringFormatGetGenericTypographic(GenericTypographicStringFormatBuffer.nativeFormat); + end; + result := GenericTypographicStringFormatBuffer; + end; + + constructor TGPStringFormat.Create(format: TGPStringFormat); + var gpstf: GPSTRINGFORMAT; + begin + nativeFormat := nil; + if assigned(format) then gpstf := format.nativeFormat + else gpstf := nil; + lastError := GdipCloneStringFormat(gpstf, nativeFormat); + end; + + function TGPStringFormat.Clone: TGPStringFormat; + var + clonedStringFormat: GpStringFormat; + begin + clonedStringFormat := nil; + lastError := GdipCloneStringFormat(nativeFormat, clonedStringFormat); + if (lastError = Ok) then + result := TGPStringFormat.Create(clonedStringFormat, lastError) + else + result := nil; + end; + + destructor TGPStringFormat.Destroy; + begin + GdipDeleteStringFormat(nativeFormat); + end; + + function TGPStringFormat.SetFormatFlags(flags: Integer): TStatus; + begin + result := SetStatus(GdipSetStringFormatFlags(nativeFormat, flags)); + end; + + function TGPStringFormat.GetFormatFlags: Integer; + begin + SetStatus(GdipGetStringFormatFlags(nativeFormat, result)); + end; + + function TGPStringFormat.SetAlignment(align: TStringAlignment): TStatus; + begin + result := SetStatus(GdipSetStringFormatAlign(nativeFormat, align)); + end; + + function TGPStringFormat.GetAlignment: TStringAlignment; + begin + SetStatus(GdipGetStringFormatAlign(nativeFormat, result)); + end; + + function TGPStringFormat.SetLineAlignment(align: TStringAlignment): TStatus; + begin + result := SetStatus(GdipSetStringFormatLineAlign(nativeFormat, align)); + end; + + function TGPStringFormat.GetLineAlignment: TStringAlignment; + begin + SetStatus(GdipGetStringFormatLineAlign(nativeFormat, result)); + end; + + function TGPStringFormat.SetHotkeyPrefix(hotkeyPrefix: THotkeyPrefix): TStatus; + begin + result := SetStatus(GdipSetStringFormatHotkeyPrefix(nativeFormat, Integer(hotkeyPrefix))); + end; + + function TGPStringFormat.GetHotkeyPrefix: THotkeyPrefix; + var HotkeyPrefix: Integer; + begin + SetStatus(GdipGetStringFormatHotkeyPrefix(nativeFormat, HotkeyPrefix)); + result := THotkeyPrefix(HotkeyPrefix); + end; + + function TGPStringFormat.SetTabStops(firstTabOffset: Single; count: Integer; tabStops: PSingle): TStatus; + begin + result := SetStatus(GdipSetStringFormatTabStops(nativeFormat, firstTabOffset, count, tabStops)); + end; + + function TGPStringFormat.GetTabStopCount: Integer; + begin + SetStatus(GdipGetStringFormatTabStopCount(nativeFormat, result)); + end; + + function TGPStringFormat.GetTabStops(count: Integer; firstTabOffset, tabStops: PSingle): TStatus; + begin + result := SetStatus(GdipGetStringFormatTabStops(nativeFormat, count, firstTabOffset, tabStops)); + end; + + function TGPStringFormat.SetDigitSubstitution(language: LANGID; substitute: TStringDigitSubstitute): TStatus; + begin + result := SetStatus(GdipSetStringFormatDigitSubstitution(nativeFormat, language, substitute)); + end; + + function TGPStringFormat.GetDigitSubstitutionLanguage: LANGID; + begin + SetStatus(GdipGetStringFormatDigitSubstitution(nativeFormat, @result, nil)); + end; + + function TGPStringFormat.GetDigitSubstitutionMethod: TStringDigitSubstitute; + begin + SetStatus(GdipGetStringFormatDigitSubstitution(nativeFormat, nil, @result)); + end; + + function TGPStringFormat.SetTrimming(trimming: TStringTrimming): TStatus; + begin + result := SetStatus(GdipSetStringFormatTrimming(nativeFormat, trimming)); + end; + + function TGPStringFormat.GetTrimming: TStringTrimming; + begin + SetStatus(GdipGetStringFormatTrimming(nativeFormat, result)); + end; + + function TGPStringFormat.SetMeasurableCharacterRanges(rangeCount: Integer; + ranges: PCharacterRange): TStatus; + begin + result := SetStatus(GdipSetStringFormatMeasurableCharacterRanges(nativeFormat, + rangeCount, ranges)); + end; + + function TGPStringFormat.GetMeasurableCharacterRangeCount: Integer; + begin + SetStatus(GdipGetStringFormatMeasurableCharacterRangeCount(nativeFormat, result)); + end; + + function TGPStringFormat.GetLastStatus: TStatus; + begin + result := lastError; + lastError := Ok; + end; + + function TGPStringFormat.SetStatus(newStatus: GpStatus): TStatus; + begin + if (newStatus <> Ok) then lastError := newStatus; + result := newStatus; + end; + + // operator = + procedure TGPStringFormat.Assign(source: TGPStringFormat); + begin + assert(assigned(source)); + GdipDeleteStringFormat(nativeFormat); + lastError := GdipCloneStringFormat(source.nativeFormat, nativeFormat); + end; + + constructor TGPStringFormat.Create(clonedStringFormat: GpStringFormat; status: TStatus); + begin + lastError := status; + nativeFormat := clonedStringFormat; + end; + + + + // --------------------------------------------------------------------------- + // TAdjustableArrowCap + // --------------------------------------------------------------------------- + + constructor TGPAdjustableArrowCap.Create(height, width: Single; isFilled: Bool = TRUE); + var cap: GpAdjustableArrowCap; + begin + cap := nil; + lastResult := GdipCreateAdjustableArrowCap(height, width, isFilled, cap); + SetNativeCap(cap); + end; + + function TGPAdjustableArrowCap.SetHeight(height: Single): TStatus; + begin + result := SetStatus(GdipSetAdjustableArrowCapHeight(GpAdjustableArrowCap(nativeCap), height)); + end; + + function TGPAdjustableArrowCap.GetHeight: Single; + begin + SetStatus(GdipGetAdjustableArrowCapHeight(GpAdjustableArrowCap(nativeCap), result)); + end; + + function TGPAdjustableArrowCap.SetWidth(width: Single): TStatus; + begin + result := SetStatus(GdipSetAdjustableArrowCapWidth(GpAdjustableArrowCap(nativeCap), width)); + end; + + function TGPAdjustableArrowCap.GetWidth: Single; + begin + SetStatus(GdipGetAdjustableArrowCapWidth(GpAdjustableArrowCap(nativeCap), result)); + end; + + function TGPAdjustableArrowCap.SetMiddleInset(middleInset: Single): TStatus; + begin + result := SetStatus(GdipSetAdjustableArrowCapMiddleInset(GpAdjustableArrowCap(nativeCap), middleInset)); + end; + + function TGPAdjustableArrowCap.GetMiddleInset: Single; + begin + SetStatus(GdipGetAdjustableArrowCapMiddleInset( + GpAdjustableArrowCap(nativeCap), result)); + end; + + function TGPAdjustableArrowCap.SetFillState(isFilled: Bool): TStatus; + begin + result := SetStatus(GdipSetAdjustableArrowCapFillState( + GpAdjustableArrowCap(nativeCap), isFilled)); + end; + + function TGPAdjustableArrowCap.IsFilled: BOOL; + begin + SetStatus(GdipGetAdjustableArrowCapFillState( + GpAdjustableArrowCap(nativeCap), result)); + end; + +(**************************************************************************\ +* +* GDI+ Metafile class +* +\**************************************************************************) + + // Playback a metafile from a HMETAFILE + // If deleteWmf is TRUE, then when the metafile is deleted, + // the hWmf will also be deleted. Otherwise, it won't be. + + constructor TGPMetafile.Create(hWmf: HMETAFILE; + var wmfPlaceableFileHeader: TWmfPlaceableFileHeader; deleteWmf: BOOL = FALSE); + var + metafile: GpMetafile; + begin + metafile := nil; + lastResult := GdipCreateMetafileFromWmf(hWmf, deleteWmf, @wmfPlaceableFileHeader, metafile); + SetNativeImage(metafile); + end; + + // Playback a metafile from a HENHMETAFILE + // If deleteEmf is TRUE, then when the metafile is deleted, + // the hEmf will also be deleted. Otherwise, it won't be. + + constructor TGPMetafile.Create(hEmf: HENHMETAFILE; deleteEmf: BOOL = FALSE); + var + metafile: GpMetafile; + begin + metafile := nil; + lastResult := GdipCreateMetafileFromEmf(hEmf, deleteEmf, metafile); + SetNativeImage(metafile); + end; + + constructor TGPMetafile.Create(filename: WideString); + var + metafile: GpMetafile; + begin + metafile := nil; + lastResult := GdipCreateMetafileFromFile(PWideChar(filename), metafile); + SetNativeImage(metafile); + end; + + // Playback a WMF metafile from a file. + + constructor TGPMetafile.Create(filename: Widestring; var wmfPlaceableFileHeader: TWmfPlaceableFileHeader); + var + metafile: GpMetafile; + begin + metafile := nil; + lastResult := GdipCreateMetafileFromWmfFile(PWideChar(filename), @wmfPlaceableFileHeader, metafile); + SetNativeImage(metafile); + end; + + constructor TGPMetafile.Create(stream: IStream); + var + metafile: GpMetafile; + begin + metafile := nil; + lastResult := GdipCreateMetafileFromStream(stream, metafile); + SetNativeImage(metafile); + end; + + // Record a metafile to memory. + + constructor TGPMetafile.Create(referenceHdc: HDC; type_: TEmfType = EmfTypeEmfPlusDual; + description: PWCHAR = nil); + var + metafile: GpMetafile; + begin + metafile := nil; + lastResult := GdipRecordMetafile(referenceHdc, type_, nil, MetafileFrameUnitGdi, + description, metafile); + SetNativeImage(metafile); + end; + + // Record a metafile to memory. + + constructor TGPMetafile.Create(referenceHdc: HDC; frameRect: TGPRectF; + frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi; + type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); + var metafile: GpMetafile; + begin + metafile := nil; + lastResult := GdipRecordMetafile(referenceHdc, type_, @frameRect, frameUnit, + description, metafile); + SetNativeImage(metafile); + end; + + // Record a metafile to memory. + + constructor TGPMetafile.Create(referenceHdc: HDC; frameRect: TGPRect; + frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi; + type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); + var + metafile: GpMetafile; + begin + metafile := nil; + lastResult := GdipRecordMetafileI(referenceHdc, type_, @frameRect, frameUnit, + description, metafile); + SetNativeImage(metafile); + end; + + constructor TGPMetafile.Create(fileName: WideString; referenceHdc: HDC; + type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); + var + metafile: GpMetafile; + begin + metafile := nil; + lastResult := GdipRecordMetafileFileName(PWideChar(fileName), + referenceHdc, type_, nil, MetafileFrameUnitGdi, description, metafile); + SetNativeImage(metafile); + end; + + constructor TGPMetafile.Create(fileName: WideString; referenceHdc: HDC; frameRect: TGPRectF; + frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi; type_: TEmfType = EmfTypeEmfPlusDual; + description: PWCHAR = nil); + var + metafile: GpMetafile; + begin + metafile := nil; + lastResult := GdipRecordMetafileFileName(PWideChar(fileName), referenceHdc, + type_, @frameRect, frameUnit, description, metafile); + SetNativeImage(metafile); + end; + + constructor TGPMetafile.Create(fileName: WideString; referenceHdc: HDC; frameRect: TGPRect; + frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi; type_: TEmfType = EmfTypeEmfPlusDual; + description: PWCHAR = nil); + var + metafile: GpMetafile; + begin + metafile := nil; + lastResult := GdipRecordMetafileFileNameI(PWideChar(fileName), + referenceHdc, type_, @frameRect, frameUnit, description, metafile); + SetNativeImage(metafile); + end; + + constructor TGPMetafile.Create(stream: IStream; referenceHdc: HDC; + type_: TEmfType = EmfTypeEmfPlusDual; description: PWCHAR = nil); + var + metafile: GpMetafile; + begin + metafile := nil; + lastResult := GdipRecordMetafileStream(stream, referenceHdc, type_, nil, + MetafileFrameUnitGdi, description, metafile); + SetNativeImage(metafile); + end; + + constructor TGPMetafile.Create(stream: IStream; referenceHdc: HDC; frameRect: TGPRectF; + frameUnit: TMetafileFrameUnit = MetafileFrameUnitGdi; type_: TEmfType = EmfTypeEmfPlusDual; + description: PWCHAR = nil); + var + metafile: GpMetafile; + begin + metafile := nil; + lastResult := GdipRecordMetafileStream(stream, referenceHdc, type_, + @frameRect, frameUnit, description, metafile); + SetNativeImage(metafile); + end; + + constructor TGPMetafile.Create(stream : IStream; referenceHdc : HDC; frameRect : TGPRect; + frameUnit : TMetafileFrameUnit = MetafileFrameUnitGdi; type_ : TEmfType = EmfTypeEmfPlusDual; + description : PWCHAR = nil); + var + metafile: GpMetafile; + begin + metafile := nil; + lastResult := GdipRecordMetafileStreamI(stream, referenceHdc, type_, + @frameRect, frameUnit, description, metafile); + SetNativeImage(metafile); + end; + + function TGPMetafile.GetMetafileHeader(hWmf: HMETAFILE; + var wmfPlaceableFileHeader: TWmfPlaceableFileHeader; header: TMetafileHeader): TStatus; + begin + result := GdipGetMetafileHeaderFromWmf(hWmf, @wmfPlaceableFileHeader, @header.Type_); + end; + + function TGPMetafile.GetMetafileHeader(hEmf: HENHMETAFILE; header: TMetafileHeader): TStatus; + begin + result := GdipGetMetafileHeaderFromEmf(hEmf, @header.Type_); + end; + + function TGPMetafile.GetMetafileHeader(filename: WideString; header: TMetafileHeader): TStatus; + begin + result := GdipGetMetafileHeaderFromFile(PWideChar(filename), @header.Type_); + end; + + function TGPMetafile.GetMetafileHeader(stream: IStream; header: TMetafileHeader): TStatus; + begin + result := GdipGetMetafileHeaderFromStream(stream, @header.Type_); + end; + + function TGPMetafile.GetMetafileHeader(header: TMetafileHeader): TStatus; + begin + result := SetStatus(GdipGetMetafileHeaderFromMetafile(GpMetafile(nativeImage), + @header.Type_)); + end; + + // Once this method is called, the Metafile object is in an invalid state + // and can no longer be used. It is the responsiblity of the caller to + // invoke DeleteEnhMetaFile to delete this hEmf. + + function TGPMetafile.GetHENHMETAFILE: HENHMETAFILE; + begin + SetStatus(GdipGetHemfFromMetafile(GpMetafile(nativeImage), result)); + end; + + // Used in conjuction with Graphics::EnumerateMetafile to play an EMF+ + // The data must be DWORD aligned if it's an EMF or EMF+. It must be + // WORD aligned if it's a WMF. + + function TGPMetafile.PlayRecord(recordType: TEmfPlusRecordType; flags, dataSize: UINT; + data: PBYTE): TStatus; + begin + result := SetStatus(GdipPlayMetafileRecord(GpMetafile(nativeImage), + recordType, flags, dataSize, data)); + end; + + // If you're using a printer HDC for the metafile, but you want the + // metafile rasterized at screen resolution, then use this API to set + // the rasterization dpi of the metafile to the screen resolution, + // e.g. 96 dpi or 120 dpi. + + function TGPMetafile.SetDownLevelRasterizationLimit(metafileRasterizationLimitDpi: UINT): TStatus; + begin + result := SetStatus(GdipSetMetafileDownLevelRasterizationLimit( + GpMetafile(nativeImage), metafileRasterizationLimitDpi)); + end; + + function TGPMetafile.GetDownLevelRasterizationLimit: UINT; + var metafileRasterizationLimitDpi: UINT; + begin + metafileRasterizationLimitDpi := 0; + SetStatus(GdipGetMetafileDownLevelRasterizationLimit( + GpMetafile(nativeImage), metafileRasterizationLimitDpi)); + result := metafileRasterizationLimitDpi; + end; + + function TGPMetafile.EmfToWmfBits(hemf: HENHMETAFILE; cbData16: UINT; pData16: PBYTE; + iMapMode: Integer = MM_ANISOTROPIC; eFlags: TEmfToWmfBitsFlags = EmfToWmfBitsFlagsDefault): UINT; + begin + result := GdipEmfToWmfBits(hemf, cbData16, pData16, iMapMode, Integer(eFlags)); + end; + + constructor TGPMetafile.Create; + begin + SetNativeImage(nil); + lastResult := Ok; + end; + +(**************************************************************************\ +* +* GDI+ Codec Image APIs +* +\**************************************************************************) + +//-------------------------------------------------------------------------- +// Codec Management APIs +//-------------------------------------------------------------------------- + + function GetImageDecodersSize(out numDecoders, size: UINT): TStatus; + begin + result := GdipGetImageDecodersSize(numDecoders, size); + end; + + function GetImageDecoders(numDecoders, size: UINT; + decoders: PImageCodecInfo): TStatus; + begin + result := GdipGetImageDecoders(numDecoders, size, decoders); + end; + + + function GetImageEncodersSize(out numEncoders, size: UINT): TStatus; + begin + result := GdipGetImageEncodersSize(numEncoders, size); + end; + + function GetImageEncoders(numEncoders, size: UINT; + encoders: PImageCodecInfo): TStatus; + begin + result := GdipGetImageEncoders(numEncoders, size, encoders); + end; + +(**************************************************************************\ +* +* GDI+ Region class implementation +* +\**************************************************************************) + + constructor TGPRegion.Create; + var + region: GpRegion; + begin + region := nil; + lastResult := GdipCreateRegion(region); + SetNativeRegion(region); + end; + + constructor TGPRegion.Create(rect: TGPRectF); + var + region: GpRegion; + begin + region := nil; + lastResult := GdipCreateRegionRect(@rect, region); + SetNativeRegion(region); + end; + + constructor TGPRegion.Create(rect: TGPRect); + var + region: GpRegion; + begin + region := nil; + lastResult := GdipCreateRegionRectI(@rect, region); + SetNativeRegion(region); + end; + + constructor TGPRegion.Create(path: TGPGraphicsPath); + var + region: GpRegion; + begin + region := nil; + lastResult := GdipCreateRegionPath(path.nativePath, region); + SetNativeRegion(region); + end; + + constructor TGPRegion.Create(regionData: PBYTE; size: Integer); + var + region: GpRegion; + begin + region := nil; + lastResult := GdipCreateRegionRgnData(regionData, size, region); + SetNativeRegion(region); + end; + + constructor TGPRegion.Create(hRgn: HRGN); + var + region: GpRegion; + begin + region := nil; + lastResult := GdipCreateRegionHrgn(hRgn, region); + SetNativeRegion(region); + end; + + function TGPRegion.FromHRGN(hRgn: HRGN): TGPRegion; + var + region: GpRegion; + begin + region := nil; + if (GdipCreateRegionHrgn(hRgn, region) = Ok) then + begin + result := TGPRegion.Create(region); + if (result = nil) then + GdipDeleteRegion(region); + exit; + end + else + result := nil; + end; + + destructor TGPRegion.Destroy; + begin + GdipDeleteRegion(nativeRegion); + end; + + function TGPRegion.Clone: TGPRegion; + var region: GpRegion; + begin + region := nil; + SetStatus(GdipCloneRegion(nativeRegion, region)); + result := TGPRegion.Create(region); + end; + + function TGPRegion.MakeInfinite: TStatus; + begin + result := SetStatus(GdipSetInfinite(nativeRegion)); + end; + + function TGPRegion.MakeEmpty: TStatus; + begin + result := SetStatus(GdipSetEmpty(nativeRegion)); + end; + + // Get the size of the buffer needed for the GetData method + function TGPRegion.GetDataSize: UINT; + var bufferSize: UINT; + begin + bufferSize := 0; + SetStatus(GdipGetRegionDataSize(nativeRegion, bufferSize)); + result := bufferSize; + end; + + + // buffer - where to put the data + // bufferSize - how big the buffer is (should be at least as big as GetDataSize()) + // sizeFilled - if not nil, this is an OUT param that says how many bytes + // of data were written to the buffer. + + function TGPRegion.GetData(buffer: PBYTE; bufferSize: UINT; sizeFilled: PUINT = nil): TStatus; + begin + result := SetStatus(GdipGetRegionData(nativeRegion, buffer, bufferSize, sizeFilled)); + end; + + function TGPRegion.Intersect(const rect: TGPRect): TStatus; + begin + result := SetStatus(GdipCombineRegionRectI(nativeRegion, @rect, CombineModeIntersect)); + end; + + function TGPRegion.Intersect(const rect: TGPRectF): TStatus; + begin + result := SetStatus(GdipCombineRegionRect(nativeRegion, @rect, CombineModeIntersect)); + end; + + function TGPRegion.Intersect(path: TGPGraphicsPath): TStatus; + begin + result := SetStatus(GdipCombineRegionPath(nativeRegion, path.nativePath, + CombineModeIntersect)); + end; + + function TGPRegion.Intersect(region: TGPRegion): TStatus; + begin + result := SetStatus(GdipCombineRegionRegion(nativeRegion, region.nativeRegion, + CombineModeIntersect)); + end; + + function TGPRegion.Union(const rect: TGPRect): TStatus; + begin + result := SetStatus(GdipCombineRegionRectI(nativeRegion, @rect, CombineModeUnion)); + end; + + function TGPRegion.Union(const rect: TGPRectF): TStatus; + begin + result := SetStatus(GdipCombineRegionRect(nativeRegion, @rect, CombineModeUnion)); + end; + + function TGPRegion.Union(path: TGPGraphicsPath): TStatus; + begin + result := SetStatus(GdipCombineRegionPath(nativeRegion, path.nativePath, CombineModeUnion)); + end; + + function TGPRegion.Union(region: TGPRegion): TStatus; + begin + result := SetStatus(GdipCombineRegionRegion(nativeRegion, region.nativeRegion, + CombineModeUnion)); + end; + + function TGPRegion.Xor_(const rect: TGPRect): TStatus; + begin + result := SetStatus(GdipCombineRegionRectI(nativeRegion, @rect, CombineModeXor)); + end; + + function TGPRegion.Xor_(const rect: TGPRectF): TStatus; + begin + result := SetStatus(GdipCombineRegionRect(nativeRegion, @rect, CombineModeXor)); + end; + + function TGPRegion.Xor_(path: TGPGraphicsPath): TStatus; + begin + result := SetStatus(GdipCombineRegionPath(nativeRegion, path.nativePath, CombineModeXor)); + end; + + function TGPRegion.Xor_(region: TGPRegion): TStatus; + begin + result := SetStatus(GdipCombineRegionRegion(nativeRegion, region.nativeRegion, + CombineModeXor)); + end; + + function TGPRegion.Exclude(const rect: TGPRect): TStatus; + begin + result := SetStatus(GdipCombineRegionRectI(nativeRegion, @rect, CombineModeExclude)); + end; + + function TGPRegion.Exclude(const rect: TGPRectF): TStatus; + begin + result := SetStatus(GdipCombineRegionRect(nativeRegion, @rect, CombineModeExclude)); + end; + + function TGPRegion.Exclude(path: TGPGraphicsPath): TStatus; + begin + result := SetStatus(GdipCombineRegionPath(nativeRegion, path.nativePath, CombineModeExclude)); + end; + + function TGPRegion.Exclude(region: TGPRegion): TStatus; + begin + result := SetStatus(GdipCombineRegionRegion(nativeRegion, + region.nativeRegion, + CombineModeExclude)); + end; + + function TGPRegion.Complement(const rect: TGPRect): TStatus; + begin + result := SetStatus(GdipCombineRegionRectI(nativeRegion, @rect, + CombineModeComplement)); + end; + + function TGPRegion.Complement(const rect: TGPRectF): TStatus; + begin + result := SetStatus(GdipCombineRegionRect(nativeRegion, @rect, + CombineModeComplement)); + end; + + function TGPRegion.Complement(path: TGPGraphicsPath): TStatus; + begin + result := SetStatus(GdipCombineRegionPath(nativeRegion, + path.nativePath, + CombineModeComplement)); + end; + + function TGPRegion.Complement(region: TGPRegion): TStatus; + begin + result := SetStatus(GdipCombineRegionRegion(nativeRegion, + region.nativeRegion, + CombineModeComplement)); + end; + + function TGPRegion.Translate(dx, dy: Single): TStatus; + begin + result := SetStatus(GdipTranslateRegion(nativeRegion, dx, dy)); + end; + + function TGPRegion.Translate(dx, dy: Integer): TStatus; + begin + result := SetStatus(GdipTranslateRegionI(nativeRegion, dx, dy)); + end; + + function TGPRegion.Transform(matrix: TGPMatrix): TStatus; + begin + result := SetStatus(GdipTransformRegion(nativeRegion, + matrix.nativeMatrix)); + end; + + function TGPRegion.GetBounds(out rect: TGPRect; g: TGPGraphics): TStatus; + begin + result := SetStatus(GdipGetRegionBoundsI(nativeRegion, + g.nativeGraphics, + @rect)); + end; + + function TGPRegion.GetBounds(out rect: TGPRectF; g: TGPGraphics): TStatus; + begin + result := SetStatus(GdipGetRegionBounds(nativeRegion, + g.nativeGraphics, + @rect)); + end; + + function TGPRegion.GetHRGN(g: TGPGraphics): HRGN; + begin + SetStatus(GdipGetRegionHRgn(nativeRegion, g.nativeGraphics, result)); + end; + + function TGPRegion.IsEmpty(g: TGPGraphics): BOOL; + var booln: BOOL; + begin + booln := FALSE; + SetStatus(GdipIsEmptyRegion(nativeRegion, g.nativeGraphics, booln)); + result := booln; + end; + + function TGPRegion.IsInfinite(g: TGPGraphics): BOOL ; + var booln: BOOL; + begin + booln := FALSE; + SetStatus(GdipIsInfiniteRegion(nativeRegion, g.nativeGraphics, booln)); + result := booln; + end; + + function TGPRegion.IsVisible(x, y: Integer; g: TGPGraphics = nil): BOOL; + var + booln: BOOL; + GPX: GpGraphics; + begin + booln := FALSE; + if assigned(g) then gpx := g.nativeGraphics else gpx := nil; + SetStatus(GdipIsVisibleRegionPointI(nativeRegion, X, Y, gpx, booln)); + result := booln; + end; + + function TGPRegion.IsVisible(const point: TGPPoint; g: TGPGraphics = nil): BOOL; + var + booln: BOOL; + GPX: GpGraphics; + begin + booln := FALSE; + if assigned(g) then gpx := g.nativeGraphics else gpx := nil; + SetStatus(GdipIsVisibleRegionPointI(nativeRegion, point.X, point.Y, gpx, booln)); + result := booln; + end; + + function TGPRegion.IsVisible(x, y: Single; g: TGPGraphics = nil): BOOL; + var + booln: BOOL; + GPX: GpGraphics; + begin + booln := FALSE; + if assigned(g) then gpx := g.nativeGraphics else gpx := nil; + SetStatus(GdipIsVisibleRegionPoint(nativeRegion, X, Y, gpx, booln)); + result := booln; + end; + + function TGPRegion.IsVisible(const point: TGPPointF; g: TGPGraphics = nil): BOOL; + var + booln: BOOL; + GPX: GpGraphics; + begin + booln := FALSE; + if assigned(g) then gpx := g.nativeGraphics else gpx := nil; + SetStatus(GdipIsVisibleRegionPoint(nativeRegion, point.X, point.Y, gpx, booln)); + result := booln; + end; + + function TGPRegion.IsVisible(x, y, width, height: Integer; g: TGPGraphics): BOOL; + var + booln: BOOL; + GPX: GpGraphics; + begin + booln := FALSE; + if assigned(g) then gpx := g.nativeGraphics else gpx := nil; + SetStatus(GdipIsVisibleRegionRectI(nativeRegion, + X, + Y, + Width, + Height, + gpx, + booln)); + result := booln; + end; + + function TGPRegion.IsVisible(const rect: TGPRect; g: TGPGraphics = nil): BOOL; + var + booln: BOOL; + GPX: GpGraphics; + begin + booln := FALSE; + if assigned(g) then gpx := g.nativeGraphics else gpx := nil; + SetStatus(GdipIsVisibleRegionRectI(nativeRegion, + rect.X, + rect.Y, + rect.Width, + rect.Height, + gpx, + booln)); + result := booln; + end; + + function TGPRegion.IsVisible(x, y, width, height: Single; g: TGPGraphics = nil): BOOL; + var + booln: BOOL; + GPX: GpGraphics; + begin + booln := FALSE; + if assigned(g) then gpx := g.nativeGraphics else gpx := nil; + SetStatus(GdipIsVisibleRegionRect(nativeRegion, X, + Y, Width, + Height, + gpx, + booln)); + result := booln; + end; + + function TGPRegion.IsVisible(const rect: TGPRectF; g: TGPGraphics = nil): BOOL; + var + booln: BOOL; + GPX: GpGraphics; + begin + booln := FALSE; + if assigned(g) then gpx := g.nativeGraphics else gpx := nil; + SetStatus(GdipIsVisibleRegionRect(nativeRegion, rect.X, + rect.Y, rect.Width, + rect.Height, + gpx, + booln)); + result := booln; + end; + + function TGPRegion.Equals(region: TGPRegion; g: TGPGraphics): BOOL; + var + booln: BOOL; + begin + booln := FALSE; + SetStatus(GdipIsEqualRegion(nativeRegion, + region.nativeRegion, + g.nativeGraphics, + booln)); + result := booln; + end; + + function TGPRegion.GetRegionScansCount(matrix: TGPMatrix): UINT; + var Count: UINT; + begin + count := 0; + SetStatus(GdipGetRegionScansCount(nativeRegion, count, matrix.nativeMatrix)); + result := count; + end; + + // If rects is nil, result := the count of rects in the region. + // Otherwise, assume rects is big enough to hold all the region rects + // and fill them in and result := the number of rects filled in. + // The rects are result :=ed in the units specified by the matrix + // (which is typically a world-to-device transform). + // Note that the number of rects result :=ed can vary, depending on the + // matrix that is used. + + function TGPRegion.GetRegionScans(matrix: TGPMatrix; rects: PGPRectF; out count: Integer): TStatus; + begin + result := SetStatus(GdipGetRegionScans(nativeRegion, + rects, + count, + matrix.nativeMatrix)); + end; + + function TGPRegion.GetRegionScans(matrix: TGPMatrix; rects: PGPRect; out count: Integer): TStatus; + begin + result := SetStatus(GdipGetRegionScansI(nativeRegion, + rects, + count, + matrix.nativeMatrix)); + end; + + function TGPRegion.GetLastStatus: TStatus; + begin + result := lastResult; + lastResult := Ok; + end; + + function TGPRegion.SetStatus(status: TStatus): TStatus; + begin + if (status <> Ok) then lastResult := status; + result := status; + end; + + constructor TGPRegion.Create(nativeRegion: GpRegion); + begin + SetNativeRegion(nativeRegion); + end; + + procedure TGPRegion.SetNativeRegion(nativeRegion: GpRegion); + begin + self.nativeRegion := nativeRegion; + end; + +(**************************************************************************\ +* +* GDI+ CustomLineCap APIs +* +\**************************************************************************) + + constructor TGPCustomLineCap.Create(fillPath, strokePath: TGPGraphicsPath; + baseCap: TLineCap = LineCapFlat; baseInset: Single = 0); + var nativeFillPath, nativeStrokePath: GpPath; + begin + nativeCap := nil; + nativeFillPath := nil; + nativeStrokePath := nil; + + if assigned(fillPath) then nativeFillPath := fillPath.nativePath; + if assigned(strokePath) then nativeStrokePath := strokePath.nativePath; + + lastResult := GdipCreateCustomLineCap(nativeFillPath, nativeStrokePath, + baseCap, baseInset, nativeCap); + end; + + destructor TGPCustomLineCap.Destroy; + begin + GdipDeleteCustomLineCap(nativeCap); + end; + + function TGPCustomLineCap.Clone: TGPCustomLineCap; + var newNativeLineCap: GpCustomLineCap; + begin + newNativeLineCap := nil; + SetStatus(GdipCloneCustomLineCap(nativeCap, newNativeLineCap)); + if (lastResult = Ok) then + begin + result := TGPCustomLineCap.Create(newNativeLineCap, lastResult); + if (result = nil) then + SetStatus(GdipDeleteCustomLineCap(newNativeLineCap)); + end + else + result := nil; + end; + + // This changes both the start and end cap. + function TGPCustomLineCap.SetStrokeCap(strokeCap: TLineCap): TStatus; + begin + result := SetStrokeCaps(strokeCap, strokeCap); + end; + + function TGPCustomLineCap.SetStrokeCaps(startCap, endCap: TLineCap): TStatus; + begin + result := SetStatus(GdipSetCustomLineCapStrokeCaps(nativeCap, startCap, endCap)); + end; + + function TGPCustomLineCap.GetStrokeCaps(out startCap, endCap: TLineCap): TStatus; + begin + result := SetStatus(GdipGetCustomLineCapStrokeCaps(nativeCap, startCap, endCap)); + end; + + function TGPCustomLineCap.SetStrokeJoin(lineJoin: TLineJoin): TStatus; + begin + result := SetStatus(GdipSetCustomLineCapStrokeJoin(nativeCap, lineJoin)); + end; + + function TGPCustomLineCap.GetStrokeJoin: TLineJoin; + begin + SetStatus(GdipGetCustomLineCapStrokeJoin(nativeCap, result)); + end; + + function TGPCustomLineCap.SetBaseCap(baseCap: TLineCap): TStatus; + begin + result := SetStatus(GdipSetCustomLineCapBaseCap(nativeCap, baseCap)); + end; + + function TGPCustomLineCap.GetBaseCap: TLineCap; + begin + SetStatus(GdipGetCustomLineCapBaseCap(nativeCap, result)); + end; + + function TGPCustomLineCap.SetBaseInset(inset: Single): TStatus; + begin + result := SetStatus(GdipSetCustomLineCapBaseInset(nativeCap, inset)); + end; + + function TGPCustomLineCap.GetBaseInset: Single; + begin + SetStatus(GdipGetCustomLineCapBaseInset(nativeCap, result)); + end; + + function TGPCustomLineCap.SetWidthScale(widthScale: Single): TStatus; + begin + result := SetStatus(GdipSetCustomLineCapWidthScale(nativeCap, widthScale)); + end; + + function TGPCustomLineCap.GetWidthScale: Single; + begin + SetStatus(GdipGetCustomLineCapWidthScale(nativeCap, result)); + end; + + function TGPCustomLineCap.GetLastStatus: TStatus; + begin + result := lastResult; + lastResult := Ok; + end; + + constructor TGPCustomLineCap.Create; + begin + nativeCap := nil; + lastResult := Ok; + end; + + constructor TGPCustomLineCap.Create(nativeCap: GpCustomLineCap; status: TStatus); + begin + lastResult := status; + SetNativeCap(nativeCap); + end; + + procedure TGPCustomLineCap.SetNativeCap(nativeCap: GpCustomLineCap); + begin + self.nativeCap := nativeCap; + end; + + function TGPCustomLineCap.SetStatus(status: TStatus): TStatus; + begin + if (status <> Ok) then lastResult := status; + result := status; + end; + +(************************************************************************** +* +* CachedBitmap class definition +* +* GDI+ CachedBitmap is a representation of an accelerated drawing +* that has restrictions on what operations are allowed in order +* to accelerate the drawing to the destination. +* +**************************************************************************) + + constructor TGPCachedBitmap.Create(bitmap: TGPBitmap; graphics: TGPGraphics); + begin + nativeCachedBitmap := nil; + lastResult := GdipCreateCachedBitmap( + GpBitmap(bitmap.nativeImage), + graphics.nativeGraphics, + nativeCachedBitmap); + end; + + destructor TGPCachedBitmap.Destroy; + begin + GdipDeleteCachedBitmap(nativeCachedBitmap); + end; + + function TGPCachedBitmap.GetLastStatus: TStatus; + begin + result := lastResult; + lastResult := Ok; + end; + +(**************************************************************************\ +* +* GDI+ Pen class +* +\**************************************************************************) + + //-------------------------------------------------------------------------- + // Pen class + //-------------------------------------------------------------------------- + + constructor TGPPen.Create(color: TGPColor; width: Single = 1.0); + var unit_: TUnit; + begin + unit_ := UnitWorld; + nativePen := nil; + lastResult := GdipCreatePen1(color, width, unit_, nativePen); + end; + + constructor TGPPen.Create(brush: TGPBrush; width: Single = 1.0); + var unit_: TUnit; + begin + unit_ := UnitWorld; + nativePen := nil; + lastResult := GdipCreatePen2(brush.nativeBrush, width, unit_, nativePen); + end; + + destructor TGPPen.Destroy; + begin + GdipDeletePen(nativePen); + end; + + function TGPPen.Clone: TGPPen; + var clonePen: GpPen; + begin + clonePen := nil; + lastResult := GdipClonePen(nativePen, clonePen); + result := TGPPen.Create(clonePen, lastResult); + end; + + function TGPPen.SetWidth(width: Single): TStatus; + begin + result := SetStatus(GdipSetPenWidth(nativePen, width)); + end; + + function TGPPen.GetWidth: Single; + begin + SetStatus(GdipGetPenWidth(nativePen, result)); + end; + + // Set/get line caps: start, end, and dash + // Line cap and join APIs by using LineCap and LineJoin enums. + + function TGPPen.SetLineCap(startCap, endCap: TLineCap; dashCap: TDashCap): TStatus; + begin + result := SetStatus(GdipSetPenLineCap197819(nativePen, startCap, endCap, dashCap)); + end; + + function TGPPen.SetStartCap(startCap: TLineCap): TStatus; + begin + result := SetStatus(GdipSetPenStartCap(nativePen, startCap)); + end; + + function TGPPen.SetEndCap(endCap: TLineCap): TStatus; + begin + result := SetStatus(GdipSetPenEndCap(nativePen, endCap)); + end; + + function TGPPen.SetDashCap(dashCap: TDashCap): TStatus; + begin + result := SetStatus(GdipSetPenDashCap197819(nativePen, dashCap)); + end; + + function TGPPen.GetStartCap: TLineCap; + begin + SetStatus(GdipGetPenStartCap(nativePen, result)); + end; + + function TGPPen.GetEndCap: TLineCap; + begin + SetStatus(GdipGetPenEndCap(nativePen, result)); + end; + + function TGPPen.GetDashCap: TDashCap; + begin + SetStatus(GdipGetPenDashCap197819(nativePen, result)); + end; + + function TGPPen.SetLineJoin(lineJoin: TLineJoin): TStatus; + begin + result := SetStatus(GdipSetPenLineJoin(nativePen, lineJoin)); + end; + + function TGPPen.GetLineJoin: TLineJoin; + begin + SetStatus(GdipGetPenLineJoin(nativePen, result)); + end; + + function TGPPen.SetCustomStartCap(customCap: TGPCustomLineCap): TStatus; + var nativeCap: GpCustomLineCap; + begin + nativeCap := nil; + if assigned(customCap) then nativeCap := customCap.nativeCap; + result := SetStatus(GdipSetPenCustomStartCap(nativePen, nativeCap)); + end; + + function TGPPen.GetCustomStartCap(customCap: TGPCustomLineCap): TStatus; + begin + if(customCap = nil) then + result := SetStatus(InvalidParameter) + else + result := SetStatus(GdipGetPenCustomStartCap(nativePen, customCap.nativeCap)); + end; + + function TGPPen.SetCustomEndCap(customCap: TGPCustomLineCap): TStatus; + var nativeCap: GpCustomLineCap; + begin + nativeCap := nil; + if assigned(customCap) then nativeCap := customCap.nativeCap; + result := SetStatus(GdipSetPenCustomEndCap(nativePen, nativeCap)); + end; + + function TGPPen.GetCustomEndCap(customCap: TGPCustomLineCap): TStatus; + begin + if(customCap = nil) then + result := SetStatus(InvalidParameter) + else + result := SetStatus(GdipGetPenCustomEndCap(nativePen, customCap.nativeCap)); + end; + + function TGPPen.SetMiterLimit(miterLimit: Single): TStatus; + begin + result := SetStatus(GdipSetPenMiterLimit(nativePen, miterLimit)); + end; + + function TGPPen.GetMiterLimit: Single; + begin + SetStatus(GdipGetPenMiterLimit(nativePen, result)); + end; + + function TGPPen.SetAlignment(penAlignment: TPenAlignment): TStatus; + begin + result := SetStatus(GdipSetPenMode(nativePen, penAlignment)); + end; + + function TGPPen.GetAlignment: TPenAlignment; + begin + SetStatus(GdipGetPenMode(nativePen, result)); + end; + + function TGPPen.SetTransform(matrix: TGPMatrix): TStatus; + begin + result := SetStatus(GdipSetPenTransform(nativePen, matrix.nativeMatrix)); + end; + + function TGPPen.GetTransform(matrix: TGPMatrix): TStatus; + begin + result := SetStatus(GdipGetPenTransform(nativePen, matrix.nativeMatrix)); + end; + + function TGPPen.ResetTransform: TStatus; + begin + result := SetStatus(GdipResetPenTransform(nativePen)); + end; + + function TGPPen.MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipMultiplyPenTransform(nativePen, matrix.nativeMatrix, order)); + end; + + function TGPPen.TranslateTransform(dx, dy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipTranslatePenTransform(nativePen, dx, dy, order)); + end; + + function TGPPen.ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipScalePenTransform(nativePen, sx, sy, order)); + end; + + function TGPPen.RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipRotatePenTransform(nativePen, angle, order)); + end; + + function TGPPen.GetPenType: TPenType; + begin + SetStatus(GdipGetPenFillType(nativePen, result)); + end; + + function TGPPen.SetColor(color: TGPColor): TStatus; + begin + result := SetStatus(GdipSetPenColor(nativePen, color)); + end; + + function TGPPen.SetBrush(brush: TGPBrush): TStatus; + begin + result := SetStatus(GdipSetPenBrushFill(nativePen, brush.nativeBrush)); + end; + + function TGPPen.GetColor(out Color: TGPColor): TStatus; + var + type_: TPenType; + argb: DWORD; + begin + type_ := GetPenType; + + if (type_ <> PenTypeSolidColor) then + begin + result := WrongState; + exit; + end; + + SetStatus(GdipGetPenColor(nativePen, argb)); + if (lastResult = Ok) then color := argb; + result := lastResult; + end; + + function TGPPen.GetBrush: TGPBrush; + var + type_: TPenType; + Brush: TGPBrush; + nativeBrush: GpBrush; + begin + type_ := GetPenType; + brush := nil; + + case type_ of + PenTypeSolidColor : brush := TGPSolidBrush.Create; + PenTypeHatchFill : brush := TGPHatchBrush.Create; + PenTypeTextureFill : brush := TGPTextureBrush.Create; + PenTypePathGradient : brush := TGPBrush.Create; + PenTypeLinearGradient : brush := TGPLinearGradientBrush.Create; + end; + + if (brush <> nil) then + begin + SetStatus(GdipGetPenBrushFill(nativePen, nativeBrush)); + brush.SetNativeBrush(nativeBrush); + end; + + result := brush; + end; + + function TGPPen.GetDashStyle: TDashStyle; + begin + SetStatus(GdipGetPenDashStyle(nativePen, result)); + end; + + function TGPPen.SetDashStyle(dashStyle: TDashStyle): TStatus; + begin + result := SetStatus(GdipSetPenDashStyle(nativePen, dashStyle)); + end; + + function TGPPen.GetDashOffset: Single; + begin + SetStatus(GdipGetPenDashOffset(nativePen, result)); + end; + + function TGPPen.SetDashOffset(dashOffset: Single): TStatus; + begin + result := SetStatus(GdipSetPenDashOffset(nativePen, dashOffset)); + end; + + function TGPPen.SetDashPattern(dashArray: PSingle; count: Integer): TStatus; + begin + result := SetStatus(GdipSetPenDashArray(nativePen, dashArray, count)); + end; + + function TGPPen.GetDashPatternCount: Integer; + begin + SetStatus(GdipGetPenDashCount(nativePen, result)); + end; + + function TGPPen.GetDashPattern(dashArray: PSingle; count: Integer): TStatus; + begin + result := SetStatus(GdipGetPenDashArray(nativePen, dashArray, count)); + end; + + function TGPPen.SetCompoundArray(compoundArray: PSingle; count: Integer): TStatus; + begin + result := SetStatus(GdipSetPenCompoundArray(nativePen, compoundArray, count)); + end; + + function TGPPen.GetCompoundArrayCount: Integer; + begin + SetStatus(GdipGetPenCompoundCount(nativePen, result)); + end; + + function TGPPen.GetCompoundArray(compoundArray: PSingle; count: Integer): TStatus; + begin + if (count <= 0) then + result := SetStatus(InvalidParameter) + else + result := SetStatus(GdipGetPenCompoundArray(nativePen, compoundArray, count)); + end; + + function TGPPen.GetLastStatus: TStatus; + begin + result := lastResult; + lastResult := Ok; + end; + + constructor TGPPen.Create(nativePen: GpPen; status: TStatus); + begin + lastResult := status; + SetNativePen(nativePen); + end; + + procedure TGPPen.SetNativePen(nativePen: GpPen); + begin + self.nativePen := nativePen; + end; + + function TGPPen.SetStatus(status: TStatus): TStatus; + begin + if (status <> Ok) then lastResult := status; + result := status; + end; + +(**************************************************************************\ +* +* GDI+ Brush class +* +\**************************************************************************) + +//-------------------------------------------------------------------------- +// Abstract base class for various brush types +//-------------------------------------------------------------------------- + + destructor TGPBrush.Destroy; + begin + GdipDeleteBrush(nativeBrush); + end; + + function TGPBrush.Clone: TGPBrush; + var + brush: GpBrush; + newBrush: TGPBrush; + begin + brush := nil; + SetStatus(GdipCloneBrush(nativeBrush, brush)); + newBrush := TGPBrush.Create(brush, lastResult); + if (newBrush = nil) then + GdipDeleteBrush(brush); + result := newBrush; + end; + + function TGPBrush.GetType: TBrushType; + var type_: TBrushType; + begin + type_ := TBrushType(-1); + SetStatus(GdipGetBrushType(nativeBrush, type_)); + result := type_; + end; + + function TGPBrush.GetLastStatus: TStatus; + begin + result := lastResult; + lastResult := Ok; + end; + + constructor TGPBrush.Create; + begin + SetStatus(NotImplemented); + end; + + constructor TGPBrush.Create(nativeBrush: GpBrush; status: TStatus); + begin + lastResult := status; + SetNativeBrush(nativeBrush); + end; + + procedure TGPBrush.SetNativeBrush(nativeBrush: GpBrush); + begin + self.nativeBrush := nativeBrush; + end; + + function TGPBrush.SetStatus(status: TStatus): TStatus; + begin + if (status <> Ok) then lastResult := status; + result := status; + end; + +//-------------------------------------------------------------------------- +// Solid Fill Brush Object +//-------------------------------------------------------------------------- + + constructor TGPSolidBrush.Create(color: TGPColor); + var + brush: GpSolidFill; + begin + brush := nil; + lastResult := GdipCreateSolidFill(color, brush); + SetNativeBrush(brush); + end; + + function TGPSolidBrush.GetColor(out color: TGPColor): TStatus; + begin + SetStatus(GdipGetSolidFillColor(GPSOLIDFILL(nativeBrush), color)); + result := lastResult; + end; + + function TGPSolidBrush.SetColor(color: TGPColor): TStatus; + begin + result := SetStatus(GdipSetSolidFillColor(GpSolidFill(nativeBrush), + color)); + end; + + constructor TGPSolidBrush.Create; + begin + // hide parent function + end; + +//-------------------------------------------------------------------------- +// Texture Brush Fill Object +//-------------------------------------------------------------------------- + + constructor TGPTextureBrush.Create(image: TGPImage; wrapMode: TWrapMode = WrapModeTile); + var texture: GpTexture; + begin + //texture := nil; + lastResult := GdipCreateTexture(image.nativeImage, wrapMode, texture); + SetNativeBrush(texture); + end; + + // When creating a texture brush from a metafile image, the dstRect + // is used to specify the size that the metafile image should be + // rendered at in the device units of the destination graphics. + // It is NOT used to crop the metafile image, so only the width + // and height values matter for metafiles. + + constructor TGPTextureBrush.Create(image: TGPImage; wrapMode: TWrapMode; dstRect: TGPRectF); + var texture: GpTexture; + begin + texture := nil; + lastResult := GdipCreateTexture2(image.nativeImage, wrapMode, dstRect.X, + dstRect.Y, dstRect.Width, dstRect.Height, texture); + SetNativeBrush(texture); + end; + + constructor TGPTextureBrush.Create(image: TGPImage; dstRect: TGPRectF; imageAttributes: TGPImageAttributes = nil); + var texture: GpTexture; + ImgAtt: GpImageAttributes; + begin + texture := nil; + if assigned(imageAttributes) then ImgAtt := imageAttributes.nativeImageAttr + else ImgAtt := nil; + + lastResult := GdipCreateTextureIA(image.nativeImage, ImgAtt, dstRect.X, + dstRect.Y, dstRect.Width, dstRect.Height, texture); + SetNativeBrush(texture); + end; + + constructor TGPTextureBrush.Create(image: TGPImage; dstRect: TGPRect; imageAttributes: TGPImageAttributes = nil); + var texture: GpTexture; + ImgAtt: GpImageAttributes; + begin + texture := nil; + if assigned(imageAttributes) then ImgAtt := imageAttributes.nativeImageAttr + else ImgAtt := nil; + lastResult := GdipCreateTextureIAI(image.nativeImage, ImgAtt, dstRect.X, + dstRect.Y, dstRect.Width, dstRect.Height, texture); + SetNativeBrush(texture); + end; + + constructor TGPTextureBrush.Create(image: TGPImage; wrapMode: TWrapMode; dstRect: TGPRect); + var texture: GpTexture; + begin + texture := nil; + lastResult := GdipCreateTexture2I(image.nativeImage, wrapMode, dstRect.X, + dstRect.Y, dstRect.Width, dstRect.Height, texture); + SetNativeBrush(texture); + end; + + constructor TGPTextureBrush.Create(image: TGPImage; wrapMode: TWrapMode; dstX, dstY, dstWidth, dstHeight: Single); + var texture: GpTexture; + begin + texture := nil; + lastResult := GdipCreateTexture2(image.nativeImage, wrapMode, dstX, dstY, + dstWidth, dstHeight, texture); + SetNativeBrush(texture); + end; + + constructor TGPTextureBrush.Create(image: TGPImage; wrapMode: TWrapMode; dstX, dstY, dstWidth, dstHeight: Integer); + var texture: GpTexture; + begin + texture := nil; + lastResult := GdipCreateTexture2I(image.nativeImage, wrapMode, dstX, dstY, + dstWidth, dstHeight, texture); + SetNativeBrush(texture); + end; + + function TGPTextureBrush.SetTransform(matrix: TGPMatrix): TStatus; + begin + result := SetStatus(GdipSetTextureTransform(GpTexture(nativeBrush), + matrix.nativeMatrix)); + end; + + function TGPTextureBrush.GetTransform(matrix: TGPMatrix): TStatus; + begin + result := SetStatus(GdipGetTextureTransform(GpTexture(nativeBrush), + matrix.nativeMatrix)); + end; + + function TGPTextureBrush.ResetTransform: TStatus; + begin + result := SetStatus(GdipResetTextureTransform(GpTexture(nativeBrush))); + end; + + function TGPTextureBrush.MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipMultiplyTextureTransform(GpTexture(nativeBrush), + matrix.nativeMatrix, order)); + end; + + function TGPTextureBrush.TranslateTransform(dx, dy: Single; order: MatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipTranslateTextureTransform(GpTexture(nativeBrush), + dx, dy, order)); + end; + + function TGPTextureBrush.ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipScaleTextureTransform(GpTexture(nativeBrush), + sx, sy, order)); + end; + + function TGPTextureBrush.RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipRotateTextureTransform(GpTexture(nativeBrush), + angle, order)); + end; + + function TGPTextureBrush.SetWrapMode(wrapMode: TWrapMode): TStatus; + begin + result := SetStatus(GdipSetTextureWrapMode(GpTexture(nativeBrush), wrapMode)); + end; + + function TGPTextureBrush.GetWrapMode: TWrapMode; + begin + SetStatus(GdipGetTextureWrapMode(GpTexture(nativeBrush), result)); + end; + + function TGPTextureBrush.GetImage: TGPImage; + var image: GpImage; + begin + SetStatus(GdipGetTextureImage(GpTexture(nativeBrush), image)); + result := TGPImage.Create(image, lastResult); + if (result = nil) then + GdipDisposeImage(image); + end; + + constructor TGPTextureBrush.Create; + begin + // hide parent function + end; + +//-------------------------------------------------------------------------- +// Linear Gradient Brush Object +//-------------------------------------------------------------------------- + + constructor TGPLinearGradientBrush.Create(const point1, point2: TGPPointF; color1, color2: TGPColor); + var brush: GpLineGradient; + begin + brush := nil; + lastResult := GdipCreateLineBrush(@point1, @point2, color1, color2, WrapModeTile, brush); + SetNativeBrush(brush); + end; + + constructor TGPLinearGradientBrush.Create(const point1, point2: TGPPoint; color1, color2: TGPColor); + var brush: GpLineGradient; + begin + brush := nil; + lastResult := GdipCreateLineBrushI(@point1, @point2, color1, + color2, WrapModeTile, brush); + SetNativeBrush(brush); + end; + + constructor TGPLinearGradientBrush.Create(rect: TGPRectF; color1, color2: TGPColor; mode: TLinearGradientMode); + var brush: GpLineGradient; + begin + brush := nil; + lastResult := GdipCreateLineBrushFromRect(@rect, color1, + color2, mode, WrapModeTile, brush); + SetNativeBrush(brush); + end; + + constructor TGPLinearGradientBrush.Create(rect: TGPRect; color1, color2: TGPColor; mode: TLinearGradientMode); + var brush: GpLineGradient; + begin + brush := nil; + lastResult := GdipCreateLineBrushFromRectI(@rect, color1, + color2, mode, WrapModeTile, brush); + SetNativeBrush(brush); + end; + + constructor TGPLinearGradientBrush.Create(rect: TGPRectF; color1, color2: TGPColor; angle: Single; isAngleScalable: BOOL = FALSE); + var brush: GpLineGradient; + begin + brush := nil; + lastResult := GdipCreateLineBrushFromRectWithAngle(@rect, color1, + color2, angle, isAngleScalable, WrapModeTile, brush); + SetNativeBrush(brush); + end; + + constructor TGPLinearGradientBrush.Create(rect: TGPRect; color1, color2: TGPColor; angle: Single; isAngleScalable: BOOL = FALSE); + var brush: GpLineGradient; + begin + brush := nil; + lastResult := GdipCreateLineBrushFromRectWithAngleI(@rect, color1, + color2, angle, isAngleScalable, WrapModeTile, brush); + SetNativeBrush(brush); + end; + + function TGPLinearGradientBrush.SetLinearColors(color1, color2: TGPColor): TStatus; + begin + result := SetStatus(GdipSetLineColors(GpLineGradient(nativeBrush), + color1, color2)); + end; + + function TGPLinearGradientBrush.GetLinearColors(out color1, color2: TGPColor): TStatus; + var colors: array[0..1] of TGPColor; + begin + SetStatus(GdipGetLineColors(GpLineGradient(nativeBrush), @colors)); + if (lastResult = Ok) then + begin + color1 := colors[0]; + color2 := colors[1]; + end; + result := lastResult; + end; + + function TGPLinearGradientBrush.GetRectangle(out rect: TGPRectF): TStatus; + begin + result := SetStatus(GdipGetLineRect(GpLineGradient(nativeBrush), @rect)); + end; + + function TGPLinearGradientBrush.GetRectangle(out rect: TGPRect): TStatus; + begin + result := SetStatus(GdipGetLineRectI(GpLineGradient(nativeBrush), @rect)); + end; + + function TGPLinearGradientBrush.SetGammaCorrection(useGammaCorrection: BOOL): TStatus; + begin + result := SetStatus(GdipSetLineGammaCorrection(GpLineGradient(nativeBrush), + useGammaCorrection)); + end; + + function TGPLinearGradientBrush.GetGammaCorrection: BOOL; + var useGammaCorrection: BOOL; + begin + SetStatus(GdipGetLineGammaCorrection(GpLineGradient(nativeBrush), + useGammaCorrection)); + result := useGammaCorrection; + end; + + function TGPLinearGradientBrush.GetBlendCount: Integer; + var count: Integer; + begin + count := 0; + SetStatus(GdipGetLineBlendCount(GpLineGradient(nativeBrush), count)); + result := count; + end; + + function TGPLinearGradientBrush.SetBlend(blendFactors, blendPositions: PSingle; count: Integer): TStatus; + begin + result := SetStatus(GdipSetLineBlend(GpLineGradient(nativeBrush), + blendFactors, blendPositions, count)); + end; + + function TGPLinearGradientBrush.GetBlend(blendFactors, blendPositions: PSingle; count: Integer): TStatus; + begin + if ((count <= 0) or (blendFactors = nil) or (blendPositions = nil)) then + result := SetStatus(InvalidParameter) + else + result := SetStatus(GdipGetLineBlend(GpLineGradient(nativeBrush), blendFactors, + blendPositions, count)); + end; + + function TGPLinearGradientBrush.GetInterpolationColorCount: Integer; + var count: Integer; + begin + count := 0; + SetStatus(GdipGetLinePresetBlendCount(GpLineGradient(nativeBrush), count)); + result := count; + end; + + function TGPLinearGradientBrush.SetInterpolationColors(presetColors: PGPColor; + blendPositions: PSingle; count: Integer): TStatus; + begin + if (count <= 0) then + result := SetStatus(InvalidParameter) + else + result := SetStatus(GdipSetLinePresetBlend(GpLineGradient(nativeBrush), + PARGB(presetColors), blendPositions, count)); + end; + + function TGPLinearGradientBrush.GetInterpolationColors(presetColors: PGPColor; blendPositions: PSingle; count: Integer): TStatus; + begin + if (count <= 0) then + result := SetStatus(InvalidParameter) + else + result := SetStatus(GdipGetLinePresetBlend(GpLineGradient(nativeBrush), + PARGB(presetColors), blendPositions, count)); + end; + + function TGPLinearGradientBrush.SetBlendBellShape(focus: Single; scale: Single = 1.0): TStatus; + begin + result := SetStatus(GdipSetLineSigmaBlend(GpLineGradient(nativeBrush), focus, scale)); + end; + + function TGPLinearGradientBrush.SetBlendTriangularShape(focus: Single; scale: Single = 1.0): TStatus; + begin + result := SetStatus(GdipSetLineLinearBlend(GpLineGradient(nativeBrush), focus, scale)); + end; + + function TGPLinearGradientBrush.SetTransform(matrix: TGPMatrix): TStatus; + begin + result := SetStatus(GdipSetLineTransform(GpLineGradient(nativeBrush), + matrix.nativeMatrix)); + end; + + function TGPLinearGradientBrush.GetTransform(matrix: TGPMatrix): TStatus; + begin + result := SetStatus(GdipGetLineTransform(GpLineGradient(nativeBrush), + matrix.nativeMatrix)); + end; + + function TGPLinearGradientBrush.ResetTransform: TStatus; + begin + result := SetStatus(GdipResetLineTransform(GpLineGradient(nativeBrush))); + end; + + function TGPLinearGradientBrush.MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipMultiplyLineTransform(GpLineGradient(nativeBrush), + matrix.nativeMatrix, + order)); + end; + + function TGPLinearGradientBrush.TranslateTransform(dx, dy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipTranslateLineTransform(GpLineGradient(nativeBrush), + dx, dy, order)); + end; + + function TGPLinearGradientBrush.ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipScaleLineTransform(GpLineGradient(nativeBrush), + sx, sy, order)); + end; + + function TGPLinearGradientBrush.RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipRotateLineTransform(GpLineGradient(nativeBrush), + angle, order)); + end; + + function TGPLinearGradientBrush.SetWrapMode(wrapMode: TWrapMode): TStatus; + begin + result := SetStatus(GdipSetLineWrapMode(GpLineGradient(nativeBrush), wrapMode)); + end; + + function TGPLinearGradientBrush.GetWrapMode: TWrapMode; + begin + SetStatus(GdipGetLineWrapMode(GpLineGradient(nativeBrush), result)); + end; + + constructor TGPLinearGradientBrush.Create; + begin + // hide parent function + end; + +//-------------------------------------------------------------------------- +// Hatch Brush Object +//-------------------------------------------------------------------------- + + constructor TGPHatchBrush.Create(hatchStyle: THatchStyle; foreColor: TGPColor; backColor: TGPColor = aclBlack); + var + brush: GpHatch; + begin + brush := nil; + lastResult := GdipCreateHatchBrush(Integer(hatchStyle), foreColor, backColor, brush); + SetNativeBrush(brush); + end; + + function TGPHatchBrush.GetHatchStyle: THatchStyle; + begin + SetStatus(GdipGetHatchStyle(GpHatch(nativeBrush), result)); + end; + + function TGPHatchBrush.GetForegroundColor(out color: TGPColor): TStatus; + begin + result := SetStatus(GdipGetHatchForegroundColor(GpHatch(nativeBrush), color)); + end; + + function TGPHatchBrush.GetBackgroundColor(out color: TGPColor): TStatus; + begin + result := SetStatus(GdipGetHatchBackgroundColor(GpHatch(nativeBrush), color)); + end; + + constructor TGPHatchBrush.Create; + begin + end; + + constructor TGPImage.Create(filename: WideString; + useEmbeddedColorManagement: BOOL = FALSE); + begin + nativeImage := nil; + if(useEmbeddedColorManagement) then + begin + lastResult := GdipLoadImageFromFileICM( + PWideChar(filename), + nativeImage + ); + end + else + begin + lastResult := GdipLoadImageFromFile( + PWideChar(filename), + nativeImage + ); + end; + end; + + constructor TGPImage.Create(stream: IStream; + useEmbeddedColorManagement: BOOL = FALSE); + begin + nativeImage := nil; + if(useEmbeddedColorManagement) then + lastResult := GdipLoadImageFromStreamICM(stream, nativeImage) + else lastResult := GdipLoadImageFromStream(stream, nativeImage); + end; + + function TGPImage.FromFile(filename: WideString; + useEmbeddedColorManagement: BOOL = FALSE): TGPImage; + begin + result := TGPImage.Create( + PWideChar(filename), + useEmbeddedColorManagement + ); + end; + + function TGPImage.FromStream(stream: IStream; + useEmbeddedColorManagement: BOOL = FALSE): TGPImage; + begin + result := TGPImage.Create( + stream, + useEmbeddedColorManagement + ); + end; + + destructor TGPImage.destroy; + begin + GdipDisposeImage(nativeImage); + end; + + function TGPImage.Clone: TGPImage; + var cloneimage: GpImage; + begin + cloneimage := nil; + SetStatus(GdipCloneImage(nativeImage, cloneimage)); + result := TGPImage.Create(cloneimage, lastResult); + end; + + function TGPImage.Save(filename: WideString; const clsidEncoder: TGUID; + encoderParams: PEncoderParameters = nil): TStatus; + begin + result := SetStatus(GdipSaveImageToFile(nativeImage, + PWideChar(filename), + @clsidEncoder, + encoderParams)); + end; + + function TGPImage.Save(stream: IStream; const clsidEncoder: TGUID; + encoderParams: PEncoderParameters = nil): TStatus; + begin + result := SetStatus(GdipSaveImageToStream(nativeImage, + stream, + @clsidEncoder, + encoderParams)); + end; + + function TGPImage.SaveAdd(encoderParams: PEncoderParameters): TStatus; + begin + result := SetStatus(GdipSaveAdd(nativeImage, + encoderParams)); + end; + + function TGPImage.SaveAdd(newImage: TGPImage; + encoderParams: PEncoderParameters): TStatus; + begin + if (newImage = nil) then + begin + result := SetStatus(InvalidParameter); + exit; + end; + result := SetStatus(GdipSaveAddImage(nativeImage, + newImage.nativeImage, + encoderParams)); + end; + + function TGPImage.GetType: TImageType; + begin + SetStatus(GdipGetImageType(nativeImage, result)); + end; + + function TGPImage.GetPhysicalDimension(out size: TGPSizeF): TStatus; + var + width, height: Single; + status: TStatus; + begin + status := SetStatus(GdipGetImageDimension(nativeImage, width, height)); + size.Width := width; + size.Height := height; + result := status; + end; + + function TGPImage.GetBounds(out srcRect: TGPRectF; out srcUnit: TUnit): TStatus; + begin + result := SetStatus(GdipGetImageBounds(nativeImage, @srcRect, srcUnit)); + end; + + function TGPImage.GetWidth: UINT; + var width: UINT; + begin + width := 0; + SetStatus(GdipGetImageWidth(nativeImage, width)); + result := width; + end; + + function TGPImage.GetHeight: UINT; + var height: UINT; + begin + height := 0; + SetStatus(GdipGetImageHeight(nativeImage, height)); + result := height; + end; + + function TGPImage.GetHorizontalResolution: Single; + var resolution: Single; + begin + resolution := 0.0; + SetStatus(GdipGetImageHorizontalResolution(nativeImage, resolution)); + result := resolution; + end; + + function TGPImage.GetVerticalResolution: Single; + var resolution: Single; + begin + resolution := 0.0; + SetStatus(GdipGetImageVerticalResolution(nativeImage, resolution)); + result := resolution; + end; + + function TGPImage.GetFlags: UINT; + var flags: UINT; + begin + flags := 0; + SetStatus(GdipGetImageFlags(nativeImage, flags)); + result := flags; + end; + + function TGPImage.GetRawFormat(out format: TGUID): TStatus; + begin + result := SetStatus(GdipGetImageRawFormat(nativeImage, @format)); + end; + + function TGPImage.GetPixelFormat: TPixelFormat; + begin + SetStatus(GdipGetImagePixelFormat(nativeImage, result)); + end; + + function TGPImage.GetPaletteSize: Integer; + var size: Integer; + begin + size := 0; + SetStatus(GdipGetImagePaletteSize(nativeImage, size)); + result := size; + end; + + function TGPImage.GetPalette(palette: PColorPalette; size: Integer): TStatus; + begin + result := SetStatus(GdipGetImagePalette(nativeImage, palette, size)); + end; + + function TGPImage.SetPalette(palette: PColorPalette): TStatus; + begin + result := SetStatus(GdipSetImagePalette(nativeImage, palette)); + end; + + function TGPImage.GetThumbnailImage(thumbWidth, thumbHeight: UINT; + callback: GetThumbnailImageAbort = nil; + callbackData: pointer = nil): TGPImage; + var + thumbimage: GpImage; + newImage: TGPImage; + begin + thumbimage := nil; + SetStatus(GdipGetImageThumbnail(nativeImage, + thumbWidth, thumbHeight, + thumbimage, + callback, callbackData)); + + newImage := TGPImage.Create(thumbimage, lastResult); + if (newImage = nil) then + GdipDisposeImage(thumbimage); + + result := newImage; + end; + + function TGPImage.GetFrameDimensionsCount: UINT; + var count: UINT; + begin + count := 0; + SetStatus(GdipImageGetFrameDimensionsCount(nativeImage, count)); + result := count; + end; + + function TGPImage.GetFrameDimensionsList(dimensionIDs: PGUID; count: UINT): TStatus; + begin + result := SetStatus(GdipImageGetFrameDimensionsList(nativeImage, dimensionIDs, count)); + end; + + function TGPImage.GetFrameCount(const dimensionID: TGUID): UINT; + var count: UINT; + begin + count := 0; + SetStatus(GdipImageGetFrameCount(nativeImage, @dimensionID, count)); + result := count; + end; + + function TGPImage.SelectActiveFrame(const dimensionID: TGUID; frameIndex: UINT): TStatus; + begin + result := SetStatus(GdipImageSelectActiveFrame(nativeImage, + @dimensionID, + frameIndex)); + end; + + function TGPImage.RotateFlip(rotateFlipType: TRotateFlipType): TStatus; + begin + result := SetStatus(GdipImageRotateFlip(nativeImage, + rotateFlipType)); + end; + + function TGPImage.GetPropertyCount: UINT; + var numProperty: UINT; + begin + numProperty := 0; + SetStatus(GdipGetPropertyCount(nativeImage, numProperty)); + result := numProperty; + end; + + function TGPImage.GetPropertyIdList(numOfProperty: UINT; list: PPropID): TStatus; + begin + result := SetStatus(GdipGetPropertyIdList(nativeImage, numOfProperty, list)); + end; + + function TGPImage.GetPropertyItemSize(propId: PROPID): UINT; + var size: UINT; + begin + size := 0; + SetStatus(GdipGetPropertyItemSize(nativeImage, propId, size)); + result := size; + end; + + function TGPImage.GetPropertyItem(propId: PROPID; propSize: UINT; + buffer: PPropertyItem): TStatus; + begin + result := SetStatus(GdipGetPropertyItem(nativeImage, + propId, propSize, buffer)); + end; + + function TGPImage.GetPropertySize(out totalBufferSize, numProperties : UINT): TStatus; + begin + result := SetStatus(GdipGetPropertySize(nativeImage, + totalBufferSize, + numProperties)); + end; + + function TGPImage.GetAllPropertyItems(totalBufferSize, numProperties: UINT; + allItems: PPROPERTYITEM): TStatus; + begin + result := SetStatus(GdipGetAllPropertyItems(nativeImage, + totalBufferSize, + numProperties, + allItems)); + end; + + function TGPImage.RemovePropertyItem(propId: TPROPID): TStatus; + begin + result := SetStatus(GdipRemovePropertyItem(nativeImage, propId)); + end; + + function TGPImage.SetPropertyItem(const item: TPropertyItem): TStatus; + begin + result := SetStatus(GdipSetPropertyItem(nativeImage, @item)); + end; + + function TGPImage.GetEncoderParameterListSize(const clsidEncoder: TGUID): UINT; + var size: UINT; + begin + size := 0; + SetStatus(GdipGetEncoderParameterListSize(nativeImage, @clsidEncoder, size)); + result := size; + end; + + function TGPImage.GetEncoderParameterList(const clsidEncoder: TGUID; size: UINT; + buffer: PEncoderParameters): TStatus; + begin + result := SetStatus(GdipGetEncoderParameterList(nativeImage, + @clsidEncoder, + size, + buffer)); + end; + + function TGPImage.GetLastStatus: TStatus; + begin + result := lastResult; + lastResult := Ok; + end; + + constructor TGPImage.Create(nativeImage: GpImage; status: TStatus); + begin + SetNativeImage(nativeImage); + lastResult := status; + end; + + procedure TGPImage.SetNativeImage(nativeImage: GpImage); + begin + self.nativeImage := nativeImage; + end; + + function TGPImage.SetStatus(status: TStatus): TStatus; + begin + if (status <> Ok) then lastResult := status; + result := status; + end; + + // TGPBitmap + + constructor TGPBitmap.Create(filename: WideString; useEmbeddedColorManagement: BOOL = FALSE); + var bitmap: GpBitmap; + begin + bitmap := nil; + if(useEmbeddedColorManagement) then + lastResult := GdipCreateBitmapFromFileICM(PWideChar(filename), bitmap) + else + lastResult := GdipCreateBitmapFromFile(PWideChar(filename), bitmap); + SetNativeImage(bitmap); + end; + + constructor TGPBitmap.Create(stream: IStream; useEmbeddedColorManagement: BOOL = FALSE); + var bitmap: GpBitmap; + begin + bitmap := nil; + if(useEmbeddedColorManagement) then + lastResult := GdipCreateBitmapFromStreamICM(stream, bitmap) + else + lastResult := GdipCreateBitmapFromStream(stream, bitmap); + SetNativeImage(bitmap); + end; + + function TGPBitmap.FromFile(filename: WideString; useEmbeddedColorManagement: BOOL = FALSE): TGPBitmap; + begin + result := TGPBitmap.Create( + PWideChar(filename), + useEmbeddedColorManagement + ); + end; + + function TGPBitmap.FromStream(stream: IStream; useEmbeddedColorManagement: BOOL = FALSE): TGPBitmap; + begin + result := TGPBitmap.Create( + stream, + useEmbeddedColorManagement + ); + end; + + constructor TGPBitmap.Create(width, height, stride: Integer; format: TPixelFormat; scan0: PBYTE); + var bitmap: GpBitmap; + begin + bitmap := nil; + lastResult := GdipCreateBitmapFromScan0(width, + height, + stride, + format, + scan0, + bitmap); + + SetNativeImage(bitmap); + end; + + constructor TGPBitmap.Create(width, height: Integer; format: TPixelFormat = PixelFormat32bppARGB); + var bitmap: GpBitmap; + begin + bitmap := nil; + lastResult := GdipCreateBitmapFromScan0(width, + height, + 0, + format, + nil, + bitmap); + + SetNativeImage(bitmap); + end; + + constructor TGPBitmap.Create(width, height: Integer; target: TGPGraphics); + var bitmap: GpBitmap; + begin + bitmap := nil; + lastResult := GdipCreateBitmapFromGraphics(width, + height, + target.nativeGraphics, + bitmap); + + SetNativeImage(bitmap); + end; + + function TGPBitmap.Clone(rect: TGPRect; format: TPixelFormat): TGPBitmap; + begin + result := Clone(rect.X, rect.Y, rect.Width, rect.Height, format); + end; + + function TGPBitmap.Clone(x, y, width, height: Integer; format: TPixelFormat): TGPBitmap; + var + bitmap: TGPBitmap; + gpdstBitmap: GpBitmap; + begin + gpdstBitmap := nil; + lastResult := GdipCloneBitmapAreaI( + x, + y, + width, + height, + format, + GpBitmap(nativeImage), + gpdstBitmap); + + if (lastResult = Ok) then + begin + bitmap := TGPBitmap.Create(gpdstBitmap); + if (bitmap = nil) then + GdipDisposeImage(gpdstBitmap); + result := bitmap; + exit; + end + else + result := nil; + end; + + function TGPBitmap.Clone(rect: TGPRectF; format: TPixelFormat): TGPBitmap; + begin + result := Clone(rect.X, rect.Y, rect.Width, rect.Height, format); + end; + + function TGPBitmap.Clone(x, y, width, height: Single; format: TPixelFormat): TGPBitmap; + var + bitmap: TGPBitmap; + gpdstBitmap: GpBitmap; + begin + gpdstBitmap := nil; + SetStatus(GdipCloneBitmapArea( + x, + y, + width, + height, + format, + GpBitmap(nativeImage), + gpdstBitmap)); + + if (lastResult = Ok) then + begin + bitmap := TGPBitmap.Create(gpdstBitmap); + if (bitmap = nil) then + GdipDisposeImage(gpdstBitmap); + result := bitmap; + end + else + result := nil; + end; + + function TGPBitmap.LockBits(rect: TGPRect; flags: UINT; format: TPixelFormat; + out lockedBitmapData: TBitmapData): TStatus; + begin + result := SetStatus(GdipBitmapLockBits( + GpBitmap(nativeImage), + @rect, + flags, + format, + @lockedBitmapData)); + end; + + function TGPBitmap.UnlockBits(var lockedBitmapData: TBitmapData): TStatus; + begin + result := SetStatus(GdipBitmapUnlockBits( + GpBitmap(nativeImage), + @lockedBitmapData)); + end; + + function TGPBitmap.GetPixel(x, y: Integer; out color: TGPColor): TStatus; + begin + result := SetStatus(GdipBitmapGetPixel(GpBitmap(nativeImage), x, y, color)); + end; + + function TGPBitmap.SetPixel(x, y: Integer; color: TGPColor): TStatus; + begin + result := SetStatus(GdipBitmapSetPixel( + GpBitmap(nativeImage), + x, y, + color)); + end; + + function TGPBitmap.SetResolution(xdpi, ydpi: Single): TStatus; + begin + result := SetStatus(GdipBitmapSetResolution( + GpBitmap(nativeImage), + xdpi, ydpi)); + end; + + constructor TGPBitmap.Create(surface: IDirectDrawSurface7); + var bitmap: GpBitmap; + begin + bitmap := nil; + lastResult := GdipCreateBitmapFromDirectDrawSurface(surface, bitmap); + SetNativeImage(bitmap); + end; + + constructor TGPBitmap.Create(var gdiBitmapInfo: TBITMAPINFO; gdiBitmapData: Pointer); + var bitmap: GpBitmap; + begin + bitmap := nil; + lastResult := GdipCreateBitmapFromGdiDib(@gdiBitmapInfo, gdiBitmapData, bitmap); + SetNativeImage(bitmap); + end; + + constructor TGPBitmap.Create(hbm: HBITMAP; hpal: HPALETTE); + var bitmap: GpBitmap; + begin + bitmap := nil; + lastResult := GdipCreateBitmapFromHBITMAP(hbm, hpal, bitmap); + SetNativeImage(bitmap); + end; + + constructor TGPBitmap.Create(hicon: HICON); + var bitmap: GpBitmap; + begin + bitmap := nil; + lastResult := GdipCreateBitmapFromHICON(hicon, bitmap); + SetNativeImage(bitmap); + end; + + constructor TGPBitmap.Create(hInstance: HMODULE; bitmapName: WideString); + var bitmap: GpBitmap; + begin + bitmap := nil; + lastResult := GdipCreateBitmapFromResource(hInstance, PWideChar(bitmapName), bitmap); + SetNativeImage(bitmap); + end; + + function TGPBitmap.FromDirectDrawSurface7(surface: IDirectDrawSurface7): TGPBitmap; + begin + result := TGPBitmap.Create(surface); + end; + + function TGPBitmap.FromBITMAPINFO(var gdiBitmapInfo: TBITMAPINFO; gdiBitmapData: Pointer): TGPBitmap; + begin + result := TGPBitmap.Create(gdiBitmapInfo, gdiBitmapData); + end; + + function TGPBitmap.FromHBITMAP(hbm: HBITMAP; hpal: HPALETTE): TGPBitmap; + begin + result := TGPBitmap.Create(hbm, hpal); + end; + + function TGPBitmap.FromHICON(hicon: HICON): TGPBitmap; + begin + result := TGPBitmap.Create(hicon); + end; + + function TGPBitmap.FromResource(hInstance: HMODULE; bitmapName: WideString): TGPBitmap; + begin + result := TGPBitmap.Create(hInstance, PWideChar(bitmapName)); + end; + + function TGPBitmap.GetHBITMAP(colorBackground: TGPColor; out hbmreturn: HBITMAP): TStatus; + begin + result := SetStatus(GdipCreateHBITMAPFromBitmap( + GpBitmap(nativeImage), + hbmreturn, + colorBackground)); + end; + + function TGPBitmap.GetHICON(out hicon: HICON): TStatus; + begin + result := SetStatus(GdipCreateHICONFromBitmap( + GpBitmap(nativeImage), + hicon)); + end; + + constructor TGPBitmap.Create(nativeBitmap: GpBitmap); + begin + lastResult := Ok; + SetNativeImage(nativeBitmap); + end; + +(**************************************************************************\ +* +* GDI+ Graphics Object +* +\**************************************************************************) + + function TGPGraphics.FromHDC(hdc: HDC): TGPGraphics; + begin + result := TGPGraphics.Create(hdc); + end; + + function TGPGraphics.FromHDC(hdc: HDC; hdevice: THANDLE): TGPGraphics; + begin + result := TGPGraphics.Create(hdc, hdevice); + end; + + function TGPGraphics.FromHWND(hwnd: HWND; icm: BOOL = FALSE): TGPGraphics; + begin + result := TGPGraphics.Create(hwnd, icm); + end; + + function TGPGraphics.FromImage(image: TGPImage): TGPGraphics; + begin + result := TGPGraphics.Create(image); + end; + + constructor TGPGraphics.Create(hdc: HDC); + var graphics: GpGraphics; + begin + graphics:= nil; + lastResult := GdipCreateFromHDC(hdc, graphics); + SetNativeGraphics(graphics); + end; + + constructor TGPGraphics.Create(hdc: HDC; hdevice: THANDLE); + var graphics: GpGraphics; + begin + graphics:= nil; + lastResult := GdipCreateFromHDC2(hdc, hdevice, graphics); + SetNativeGraphics(graphics); + end; + + constructor TGPGraphics.Create(hwnd: HWND; icm: BOOL{ = FALSE}); + var graphics: GpGraphics; + begin + graphics:= nil; + if icm then lastResult := GdipCreateFromHWNDICM(hwnd, graphics) + else lastResult := GdipCreateFromHWND(hwnd, graphics); + SetNativeGraphics(graphics); + end; + + constructor TGPGraphics.Create(image: TGPImage); + var graphics: GpGraphics; + begin + graphics:= nil; + if (image <> nil) then + lastResult := GdipGetImageGraphicsContext(image.nativeImage, graphics); + SetNativeGraphics(graphics); + end; + + destructor TGPGraphics.destroy; + begin + GdipDeleteGraphics(nativeGraphics); + end; + + procedure TGPGraphics.Flush(intention: TFlushIntention = FlushIntentionFlush); + begin + GdipFlush(nativeGraphics, intention); + end; + + //------------------------------------------------------------------------ + // GDI Interop methods + //------------------------------------------------------------------------ + + // Locks the graphics until ReleaseDC is called + + function TGPGraphics.GetHDC: HDC; + begin + SetStatus(GdipGetDC(nativeGraphics, result)); + end; + + procedure TGPGraphics.ReleaseHDC(hdc: HDC); + begin + SetStatus(GdipReleaseDC(nativeGraphics, hdc)); + end; + + //------------------------------------------------------------------------ + // Rendering modes + //------------------------------------------------------------------------ + + function TGPGraphics.SetRenderingOrigin(x, y: Integer): TStatus; + begin + result := SetStatus(GdipSetRenderingOrigin(nativeGraphics, x, y)); + end; + + function TGPGraphics.GetRenderingOrigin(out x, y: Integer): TStatus; + begin + result := SetStatus(GdipGetRenderingOrigin(nativeGraphics, x, y)); + end; + + function TGPGraphics.SetCompositingMode(compositingMode: TCompositingMode): TStatus; + begin + result := SetStatus(GdipSetCompositingMode(nativeGraphics, + compositingMode)); + end; + + function TGPGraphics.GetCompositingMode: TCompositingMode; + begin + SetStatus(GdipGetCompositingMode(nativeGraphics, result)); + end; + + function TGPGraphics.SetCompositingQuality(compositingQuality: TCompositingQuality): TStatus; + begin + result := SetStatus(GdipSetCompositingQuality( nativeGraphics, compositingQuality)); + end; + + function TGPGraphics.GetCompositingQuality: TCompositingQuality; + begin + SetStatus(GdipGetCompositingQuality(nativeGraphics, result)); + end; + + function TGPGraphics.SetTextRenderingHint(newMode: TTextRenderingHint): TStatus; + begin + result := SetStatus(GdipSetTextRenderingHint(nativeGraphics, newMode)); + end; + + function TGPGraphics.GetTextRenderingHint: TTextRenderingHint; + begin + SetStatus(GdipGetTextRenderingHint(nativeGraphics, result)); + end; + + function TGPGraphics.SetTextContrast(contrast: UINT): TStatus; + begin + result := SetStatus(GdipSetTextContrast(nativeGraphics, contrast)); + end; + + function TGPGraphics.GetTextContrast: UINT; + begin + SetStatus(GdipGetTextContrast(nativeGraphics, result)); + end; + + function TGPGraphics.GetInterpolationMode: TInterpolationMode; + var mode: TInterpolationMode; + begin + mode := InterpolationModeInvalid; + SetStatus(GdipGetInterpolationMode(nativeGraphics, mode)); + result := mode; + end; + + function TGPGraphics.SetInterpolationMode(interpolationMode: TInterpolationMode): TStatus; + begin + result := SetStatus(GdipSetInterpolationMode(nativeGraphics, + interpolationMode)); + end; + + function TGPGraphics.GetSmoothingMode: TSmoothingMode; + var smoothingMode: TSmoothingMode; + begin + smoothingMode := SmoothingModeInvalid; + SetStatus(GdipGetSmoothingMode(nativeGraphics, smoothingMode)); + result := smoothingMode; + end; + + function TGPGraphics.SetSmoothingMode(smoothingMode: TSmoothingMode): TStatus; + begin + result := SetStatus(GdipSetSmoothingMode(nativeGraphics, smoothingMode)); + end; + + function TGPGraphics.GetPixelOffsetMode: TPixelOffsetMode; + var pixelOffsetMode: TPixelOffsetMode; + begin + pixelOffsetMode := PixelOffsetModeInvalid; + SetStatus(GdipGetPixelOffsetMode(nativeGraphics, pixelOffsetMode)); + result := pixelOffsetMode; + end; + + function TGPGraphics.SetPixelOffsetMode(pixelOffsetMode: TPixelOffsetMode): TStatus; + begin + result := SetStatus(GdipSetPixelOffsetMode(nativeGraphics, pixelOffsetMode)); + end; + + //------------------------------------------------------------------------ + // Manipulate current world transform + //------------------------------------------------------------------------ + + function TGPGraphics.SetTransform(matrix: TGPMatrix): TStatus; + begin + result := SetStatus(GdipSetWorldTransform(nativeGraphics, matrix.nativeMatrix)); + end; + + function TGPGraphics.ResetTransform: TStatus; + begin + result := SetStatus(GdipResetWorldTransform(nativeGraphics)); + end; + + function TGPGraphics.MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipMultiplyWorldTransform(nativeGraphics, + matrix.nativeMatrix, + order)); + end; + + function TGPGraphics.TranslateTransform(dx, dy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipTranslateWorldTransform(nativeGraphics, + dx, dy, order)); + end; + + function TGPGraphics.ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipScaleWorldTransform(nativeGraphics, + sx, sy, order)); + end; + + function TGPGraphics.RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipRotateWorldTransform(nativeGraphics, + angle, order)); + end; + + function TGPGraphics.GetTransform(matrix: TGPMatrix): TStatus; + begin + result := SetStatus(GdipGetWorldTransform(nativeGraphics, + matrix.nativeMatrix)); + end; + + function TGPGraphics.SetPageUnit(unit_: TUnit): TStatus; + begin + result := SetStatus(GdipSetPageUnit(nativeGraphics, + unit_)); + end; + + function TGPGraphics.SetPageScale(scale: Single): TStatus; + begin + result := SetStatus(GdipSetPageScale(nativeGraphics, + scale)); + end; + + function TGPGraphics.GetPageUnit: TUnit; + begin + SetStatus(GdipGetPageUnit(nativeGraphics, result)); + end; + + function TGPGraphics.GetPageScale: Single; + begin + SetStatus(GdipGetPageScale(nativeGraphics, result)); + end; + + function TGPGraphics.GetDpiX: Single; + begin + SetStatus(GdipGetDpiX(nativeGraphics, result)); + end; + + function TGPGraphics.GetDpiY: Single; + begin + SetStatus(GdipGetDpiY(nativeGraphics, result)); + end; + + function TGPGraphics.TransformPoints(destSpace: TCoordinateSpace; + srcSpace: TCoordinateSpace; + pts: PGPPointF; + count: Integer): TStatus; + begin + result := SetStatus(GdipTransformPoints(nativeGraphics, + destSpace, + srcSpace, + pts, + count)); + end; + + function TGPGraphics.TransformPoints(destSpace: TCoordinateSpace; + srcSpace: TCoordinateSpace; + pts: PGPPoint; + count: Integer): TStatus; + begin + + result := SetStatus(GdipTransformPointsI(nativeGraphics, + destSpace, + srcSpace, + pts, + count)); + end; + + //------------------------------------------------------------------------ + // GetNearestColor (for <= 8bpp surfaces). Note: Alpha is ignored. + //------------------------------------------------------------------------ + + function TGPGraphics.GetNearestColor(var color: TGPColor): TStatus; + begin + result := SetStatus(GdipGetNearestColor(nativeGraphics, @color)); + end; + + function TGPGraphics.DrawLine(pen: TGPPen; x1, y1, x2, y2: Single): TStatus; + begin + result := SetStatus(GdipDrawLine(nativeGraphics, + pen.nativePen, x1, y1, x2, + y2)); + end; + + function TGPGraphics.DrawLine(pen: TGPPen; const pt1, pt2: TGPPointF): TStatus; + begin + result := DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y); + end; + + function TGPGraphics.DrawLines(pen: TGPPen; points: PGPPointF; count: Integer): TStatus; + begin + result := SetStatus(GdipDrawLines(nativeGraphics, + pen.nativePen, + points, count)); + end; + + function TGPGraphics.DrawLine(pen: TGPPen; x1, y1, x2, y2: Integer): TStatus; + begin + result := SetStatus(GdipDrawLineI(nativeGraphics, + pen.nativePen, + x1, + y1, + x2, + y2)); + end; + + function TGPGraphics.DrawLine(pen: TGPPen; const pt1, pt2: TGPPoint): TStatus; + begin + result := DrawLine(pen, + pt1.X, + pt1.Y, + pt2.X, + pt2.Y); + end; + + function TGPGraphics.DrawLines(pen: TGPPen; points: PGPPoint; count: Integer): TStatus; + begin + result := SetStatus(GdipDrawLinesI(nativeGraphics, + pen.nativePen, + points, + count)); + end; + + function TGPGraphics.DrawArc(pen: TGPPen; x, y, width, height, startAngle, sweepAngle: Single): TStatus; + begin + result := SetStatus(GdipDrawArc(nativeGraphics, + pen.nativePen, + x, + y, + width, + height, + startAngle, + sweepAngle)); + end; + + function TGPGraphics.DrawArc(pen: TGPPen; const rect: TGPRectF; startAngle, sweepAngle: Single): TStatus; + begin + result := DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height, + startAngle, sweepAngle); + end; + + function TGPGraphics.DrawArc(pen: TGPPen; x, y, width, height: Integer; startAngle, + sweepAngle: Single): TStatus; + begin + result := SetStatus(GdipDrawArcI(nativeGraphics, + pen.nativePen, + x, + y, + width, + height, + startAngle, + sweepAngle)); + end; + + + function TGPGraphics.DrawArc(pen: TGPPen; const rect: TGPRect; startAngle, sweepAngle: Single): TStatus; + begin + result := DrawArc(pen, + rect.X, + rect.Y, + rect.Width, + rect.Height, + startAngle, + sweepAngle); + end; + + function TGPGraphics.DrawBezier(pen: TGPPen; x1, y1, x2, y2, x3, y3, x4, y4: Single): TStatus; + begin + result := SetStatus(GdipDrawBezier(nativeGraphics, + pen.nativePen, x1, y1, + x2, y2, x3, y3, x4, y4)); + end; + + function TGPGraphics.DrawBezier(pen: TGPPen; const pt1, pt2, pt3, pt4: TGPPointF): TStatus; + begin + result := DrawBezier(pen, + pt1.X, + pt1.Y, + pt2.X, + pt2.Y, + pt3.X, + pt3.Y, + pt4.X, + pt4.Y); + end; + + function TGPGraphics.DrawBeziers(pen: TGPPen; points: PGPPointF; count: Integer): TStatus; + begin + result := SetStatus(GdipDrawBeziers(nativeGraphics, + pen.nativePen, + points, + count)); + end; + + function TGPGraphics.DrawBezier(pen: TGPPen; x1, y1, x2, y2, x3, y3, x4, y4: Integer): TStatus; + begin + result := SetStatus(GdipDrawBezierI(nativeGraphics, + pen.nativePen, + x1, + y1, + x2, + y2, + x3, + y3, + x4, + y4)); + end; + + function TGPGraphics.DrawBezier(pen: TGPPen; const pt1, pt2, pt3, pt4: TGPPoint): TStatus; + begin + result := DrawBezier(pen, + pt1.X, + pt1.Y, + pt2.X, + pt2.Y, + pt3.X, + pt3.Y, + pt4.X, + pt4.Y); + end; + + function TGPGraphics.DrawBeziers(pen: TGPPen; points: PGPPoint; count: Integer): TStatus; + begin + result := SetStatus(GdipDrawBeziersI(nativeGraphics, + pen.nativePen, + points, + count)); + end; + + function TGPGraphics.DrawRectangle(pen: TGPPen; const rect: TGPRectF): TStatus; + begin + result := DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height); + end; + + function TGPGraphics.DrawRectangle(pen: TGPPen; x, y, width, height: Single): TStatus; + begin + result := SetStatus(GdipDrawRectangle(nativeGraphics, + pen.nativePen, x, y, + width, height)); + end; + + function TGPGraphics.DrawRectangles(pen: TGPPen; rects: PGPRectF; count: Integer): TStatus; + begin + result := SetStatus(GdipDrawRectangles(nativeGraphics, + pen.nativePen, + rects, count)); + end; + + function TGPGraphics.DrawRectangle(pen: TGPPen; const rect: TGPRect): TStatus; + begin + result := DrawRectangle(pen, + rect.X, + rect.Y, + rect.Width, + rect.Height); + end; + + function TGPGraphics.DrawRectangle(pen: TGPPen; x, y, width, height: Integer): TStatus; + begin + result := SetStatus(GdipDrawRectangleI(nativeGraphics, + pen.nativePen, + x, + y, + width, + height)); + end; + + function TGPGraphics.DrawRectangles(pen: TGPPen; rects: PGPRect; count: Integer): TStatus; + begin + result := SetStatus(GdipDrawRectanglesI(nativeGraphics, + pen.nativePen, + rects, + count)); + end; + + function TGPGraphics.DrawEllipse(pen: TGPPen; const rect: TGPRectF): TStatus; + begin + result := DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height); + end; + + function TGPGraphics.DrawEllipse(pen: TGPPen; x, y, width, height: Single): TStatus; + begin + result := SetStatus(GdipDrawEllipse(nativeGraphics, + pen.nativePen, + x, + y, + width, + height)); + end; + + function TGPGraphics.DrawEllipse(pen: TGPPen; const rect: TGPRect): TStatus; + begin + result := DrawEllipse(pen, + rect.X, + rect.Y, + rect.Width, + rect.Height); + end; + + function TGPGraphics.DrawEllipse(pen: TGPPen; x, y, width, height: Integer): TStatus; + begin + result := SetStatus(GdipDrawEllipseI(nativeGraphics, + pen.nativePen, + x, + y, + width, + height)); + end; + + function TGPGraphics.DrawPie(pen: TGPPen; const rect: TGPRectF; startAngle, sweepAngle: Single): TStatus; + begin + result := DrawPie(pen, + rect.X, + rect.Y, + rect.Width, + rect.Height, + startAngle, + sweepAngle); + end; + + function TGPGraphics.DrawPie(pen: TGPPen; x, y, width, height, startAngle, sweepAngle: Single): TStatus; + begin + result := SetStatus(GdipDrawPie(nativeGraphics, + pen.nativePen, + x, + y, + width, + height, + startAngle, + sweepAngle)); + end; + + function TGPGraphics.DrawPie(pen: TGPPen; const rect: TGPRect; startAngle, sweepAngle: Single): TStatus; + begin + result := DrawPie(pen, + rect.X, + rect.Y, + rect.Width, + rect.Height, + startAngle, + sweepAngle); + end; + + function TGPGraphics.DrawPie(pen: TGPPen; x, y, width, height: Integer; + startAngle, sweepAngle: Single): TStatus; + begin + result := SetStatus(GdipDrawPieI(nativeGraphics, + pen.nativePen, + x, + y, + width, + height, + startAngle, + sweepAngle)); + end; + + function TGPGraphics.DrawPolygon(pen: TGPPen; points: PGPPointF; count: Integer): TStatus; + begin + result := SetStatus(GdipDrawPolygon(nativeGraphics, + pen.nativePen, + points, + count)); + end; + + function TGPGraphics.DrawPolygon(pen: TGPPen; points: PGPPoint; count: Integer): TStatus; + begin + result := SetStatus(GdipDrawPolygonI(nativeGraphics, + pen.nativePen, + points, + count)); + end; + + function TGPGraphics.DrawPath(pen: TGPPen; path: TGPGraphicsPath): TStatus; + var + nPen: GpPen; + nPath: GpPath; + begin + if assigned(pen) then nPen := pen.nativePen else nPen := nil; + if assigned(path) then nPath := path.nativePath else nPath := nil; + result := SetStatus(GdipDrawPath(nativeGraphics, nPen, nPath)); + end; + + function TGPGraphics.DrawCurve(pen: TGPPen; points: PGPPointF; count: Integer): TStatus; + begin + result := SetStatus(GdipDrawCurve(nativeGraphics, + pen.nativePen, points, + count)); + end; + + function TGPGraphics.DrawCurve(pen: TGPPen; points: PGPPointF; count: Integer; tension: Single): TStatus; + begin + result := SetStatus(GdipDrawCurve2(nativeGraphics, + pen.nativePen, points, + count, tension)); + end; + + function TGPGraphics.DrawCurve(pen: TGPPen; points: PGPPointF; count, offset, + numberOfSegments: Integer; tension: Single = 0.5): TStatus; + begin + result := SetStatus(GdipDrawCurve3(nativeGraphics, + pen.nativePen, points, + count, offset, + numberOfSegments, tension)); + end; + + function TGPGraphics.DrawCurve(pen: TGPPen; points: PGPPoint; count: Integer): TStatus; + begin + result := SetStatus(GdipDrawCurveI(nativeGraphics, + pen.nativePen, + points, + count)); + end; + + function TGPGraphics.DrawCurve(pen: TGPPen; points: PGPPoint; count: Integer; tension: Single): TStatus; + begin + result := SetStatus(GdipDrawCurve2I(nativeGraphics, + pen.nativePen, + points, + count, + tension)); + end; + + function TGPGraphics.DrawCurve(pen: TGPPen; points: PGPPoint; count, offset, + numberOfSegments: Integer; tension: Single = 0.5): TStatus; + begin + result := SetStatus(GdipDrawCurve3I(nativeGraphics, + pen.nativePen, + points, + count, + offset, + numberOfSegments, + tension)); + end; + + function TGPGraphics.DrawClosedCurve(pen: TGPPen; points: PGPPointF; count: Integer): TStatus; + begin + result := SetStatus(GdipDrawClosedCurve(nativeGraphics, + pen.nativePen, + points, count)); + end; + + function TGPGraphics.DrawClosedCurve(pen: TGPPen; points: PGPPointF; count: Integer; + tension: Single): TStatus; + begin + result := SetStatus(GdipDrawClosedCurve2(nativeGraphics, + pen.nativePen, + points, count, + tension)); + end; + + function TGPGraphics.DrawClosedCurve(pen: TGPPen; points: PGPPoint; count: Integer): TStatus; + begin + result := SetStatus(GdipDrawClosedCurveI(nativeGraphics, + pen.nativePen, + points, + count)); + end; + + function TGPGraphics.DrawClosedCurve(pen: TGPPen; points: PGPPoint; + count: Integer; tension: Single): TStatus; + begin + result := SetStatus(GdipDrawClosedCurve2I(nativeGraphics, + pen.nativePen, + points, + count, + tension)); + end; + + function TGPGraphics.Clear(color: TGPColor): TStatus; + begin + result := SetStatus(GdipGraphicsClear( + nativeGraphics, + color)); + end; + + function TGPGraphics.FillRectangle(brush: TGPBrush; const rect: TGPRectF): TStatus; + begin + result := FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height); + end; + + function TGPGraphics.FillRectangle(brush: TGPBrush; x, y, width, height: Single): TStatus; + begin + result := SetStatus(GdipFillRectangle(nativeGraphics, + brush.nativeBrush, x, y, + width, height)); + end; + + function TGPGraphics.FillRectangles(brush: TGPBrush; rects: PGPRectF; count: Integer): TStatus; + begin + result := SetStatus(GdipFillRectangles(nativeGraphics, + brush.nativeBrush, + rects, count)); + end; + + function TGPGraphics.FillRectangle(brush: TGPBrush; const rect: TGPRect): TStatus; + begin + result := FillRectangle(brush, + rect.X, + rect.Y, + rect.Width, + rect.Height); + end; + + function TGPGraphics.FillRectangle(brush: TGPBrush; x, y, width, height: Integer): TStatus; + begin + result := SetStatus(GdipFillRectangleI(nativeGraphics, + brush.nativeBrush, + x, + y, + width, + height)); + end; + + function TGPGraphics.FillRectangles(brush: TGPBrush; rects: PGPRect; count: Integer): TStatus; + begin + result := SetStatus(GdipFillRectanglesI(nativeGraphics, + brush.nativeBrush, + rects, + count)); + end; + + function TGPGraphics.FillPolygon(brush: TGPBrush; points: PGPPointF; count: Integer): TStatus; + begin + result := FillPolygon(brush, points, count, FillModeAlternate); + end; + + function TGPGraphics.FillPolygon(brush: TGPBrush; points: PGPPointF; count: Integer; + fillMode: TFillMode): TStatus; + begin + result := SetStatus(GdipFillPolygon(nativeGraphics, + brush.nativeBrush, + points, count, fillMode)); + end; + + function TGPGraphics.FillPolygon(brush: TGPBrush; points: PGPPoint; count: Integer): TStatus; + begin + result := FillPolygon(brush, points, count, FillModeAlternate); + end; + + function TGPGraphics.FillPolygon(brush: TGPBrush; points: PGPPoint; count: Integer; + fillMode: TFillMode): TStatus; + begin + result := SetStatus(GdipFillPolygonI(nativeGraphics, + brush.nativeBrush, + points, count, + fillMode)); + end; + + function TGPGraphics.FillEllipse(brush: TGPBrush; const rect: TGPRectF): TStatus; + begin + result := FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height); + end; + + function TGPGraphics.FillEllipse(brush: TGPBrush; x, y, width, height: Single): TStatus; + begin + result := SetStatus(GdipFillEllipse(nativeGraphics, + brush.nativeBrush, x, y, + width, height)); + end; + + function TGPGraphics.FillEllipse(brush: TGPBrush; const rect: TGPRect): TStatus; + begin + result := FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height); + end; + + function TGPGraphics.FillEllipse(brush: TGPBrush; x, y, width, height: Integer): TStatus; + begin + result := SetStatus(GdipFillEllipseI(nativeGraphics, + brush.nativeBrush, + x, + y, + width, + height)); + end; + + function TGPGraphics.FillPie(brush: TGPBrush; const rect: TGPRectF; startAngle, sweepAngle: Single): TStatus; + begin + result := FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height, + startAngle, sweepAngle); + end; + + function TGPGraphics.FillPie(brush: TGPBrush; x, y, width, height, startAngle, sweepAngle: Single): TStatus; + begin + result := SetStatus(GdipFillPie(nativeGraphics, + brush.nativeBrush, x, y, + width, height, startAngle, + sweepAngle)); + end; + + function TGPGraphics.FillPie(brush: TGPBrush; const rect: TGPRect; startAngle, sweepAngle: Single): TStatus; + begin + result := FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height, + startAngle, sweepAngle); + end; + + function TGPGraphics.FillPie(brush: TGPBrush; x, y, width, height: Integer; startAngle, + sweepAngle: Single): TStatus; + begin + result := SetStatus(GdipFillPieI(nativeGraphics, + brush.nativeBrush, + x, + y, + width, + height, + startAngle, + sweepAngle)); + end; + + function TGPGraphics.FillPath(brush: TGPBrush; path: TGPGraphicsPath): TStatus; + begin + result := SetStatus(GdipFillPath(nativeGraphics, + brush.nativeBrush, + path.nativePath)); + end; + + function TGPGraphics.FillClosedCurve(brush: TGPBrush; points: PGPPointF; count: Integer): TStatus; + begin + result := SetStatus(GdipFillClosedCurve(nativeGraphics, + brush.nativeBrush, + points, count)); + + end; + + function TGPGraphics.FillClosedCurve(brush: TGPBrush; points: PGPPointF; count: Integer; + fillMode: TFillMode; tension: Single = 0.5): TStatus; + begin + result := SetStatus(GdipFillClosedCurve2(nativeGraphics, + brush.nativeBrush, + points, count, + tension, fillMode)); + end; + + function TGPGraphics.FillClosedCurve(brush: TGPBrush; points: PGPPoint; count: Integer): TStatus; + begin + result := SetStatus(GdipFillClosedCurveI(nativeGraphics, + brush.nativeBrush, + points, + count)); + end; + + function TGPGraphics.FillClosedCurve(brush: TGPBrush; points: PGPPoint; + count: Integer; fillMode: TFillMode; tension: Single = 0.5): TStatus; + begin + result := SetStatus(GdipFillClosedCurve2I(nativeGraphics, + brush.nativeBrush, + points, count, + tension, fillMode)); + end; + + function TGPGraphics.FillRegion(brush: TGPBrush; region: TGPRegion): TStatus; + begin + result := SetStatus(GdipFillRegion(nativeGraphics, + brush.nativeBrush, + region.nativeRegion)); + end; + + + function TGPGraphics.DrawString( string_: WideString; length: Integer; font: TGPFont; + const layoutRect: TGPRectF; stringFormat: TGPStringFormat; brush: TGPBrush): TStatus; + var + nFont: GpFont; + nStringFormat: GpStringFormat; + nBrush: GpBrush; + begin + if assigned(font) then nfont := font.nativeFont else nfont := nil; + if assigned(stringFormat) then nstringFormat := stringFormat.nativeFormat else nstringFormat := nil; + if assigned(brush) then nbrush := brush.nativeBrush else nbrush := nil; + result := SetStatus(GdipDrawString( + nativeGraphics, + PWideChar(string_), + length, + nfont, + @layoutRect, + nstringFormat, + nbrush)); + end; + + function TGPGraphics.DrawString(string_: WideString; length: Integer; font: TGPFont; + const origin: TGPPointF; brush: TGPBrush): TStatus; + var + rect: TGPRectF; + nfont: Gpfont; + nBrush: GpBrush; + begin + rect.X := origin.X; + rect.Y := origin.Y; + rect.Width := 0.0; + rect.Height := 0.0; + if assigned(font) then nfont := font.nativeFont else nfont := nil; + if assigned(Brush) then nBrush := Brush.nativeBrush else nBrush := nil; + result := SetStatus(GdipDrawString( + nativeGraphics, + PWideChar(string_), + length, + nfont, + @rect, + nil, + nbrush)); + end; + + function TGPGraphics.DrawString(string_: WideString; length: Integer; font: TGPFont; + const origin: TGPPointF; stringFormat: TGPStringFormat; brush: TGPBrush): TStatus; + var + rect: TGPRectF; + nFont: GpFont; + nStringFormat: GpStringFormat; + nBrush: GpBrush; + begin + rect.X := origin.X; + rect.Y := origin.Y; + rect.Width := 0.0; + rect.Height := 0.0; + if assigned(font) then nfont := font.nativeFont else nfont := nil; + if assigned(stringFormat) then nstringFormat := stringFormat.nativeFormat else nstringFormat := nil; + if assigned(brush) then nbrush := brush.nativeBrush else nbrush := nil; + result := SetStatus(GdipDrawString( + nativeGraphics, + PWideChar(string_), + length, + nfont, + @rect, + nstringFormat, + nbrush)); + end; + + + function TGPGraphics.MeasureString(string_: WideString; length: Integer; font: TGPFont; + const layoutRect: TGPRectF; stringFormat: TGPStringFormat; out boundingBox: TGPRectF; + codepointsFitted: PInteger = nil; linesFilled: PInteger = nil): TStatus; + var + nFont: GpFont; + nStringFormat: GpStringFormat; + begin + if assigned(font) then nfont := font.nativeFont else nfont := nil; + if assigned(stringFormat) then nstringFormat := stringFormat.nativeFormat else nstringFormat := nil; + result := SetStatus(GdipMeasureString( + nativeGraphics, + PWideChar(string_), + length, + nfont, + @layoutRect, + nstringFormat, + @boundingBox, + codepointsFitted, + linesFilled + )); + end; + + + function TGPGraphics.MeasureString(string_: WideString; length: Integer; font: TGPFont; + const layoutRectSize: TGPSizeF; stringFormat: TGPStringFormat; out size: TGPSizeF; + codepointsFitted: PInteger = nil; linesFilled: PInteger = nil): TStatus; + var + layoutRect, boundingBox: TGPRectF; + status: TStatus; + nFont: GpFont; + nStringFormat: GpStringFormat; + begin + layoutRect.X := 0; + layoutRect.Y := 0; + layoutRect.Width := layoutRectSize.Width; + layoutRect.Height := layoutRectSize.Height; + + if assigned(font) then nfont := font.nativeFont else nfont := nil; + if assigned(stringFormat) then nstringFormat := stringFormat.nativeFormat else nstringFormat := nil; + + status := SetStatus(GdipMeasureString( + nativeGraphics, + PWideChar(string_), + length, + nfont, + @layoutRect, + nstringFormat, + @boundingBox, + codepointsFitted, + linesFilled + )); + + if (status = Ok) then + begin + size.Width := boundingBox.Width; + size.Height := boundingBox.Height; + end; + result := status; + end; + + + function TGPGraphics.MeasureString(string_: WideString ; length: Integer; font: TGPFont; + const origin: TGPPointF; stringFormat: TGPStringFormat; out boundingBox: TGPRectF): TStatus; + var + rect: TGPRectF; + nFont: GpFont; + nstringFormat: GpstringFormat; + begin + rect.X := origin.X; + rect.Y := origin.Y; + rect.Width := 0.0; + rect.Height := 0.0; + + if assigned(font) then nfont := font.nativeFont else nfont := nil; + if assigned(stringFormat) then nstringFormat := stringFormat.nativeFormat else nstringFormat := nil; + + result := SetStatus(GdipMeasureString( + nativeGraphics, + PWideChar(string_), + length, + nfont, + @rect, + nstringFormat, + @boundingBox, + nil, + nil + )); + end; + + + function TGPGraphics.MeasureString(string_: WideString; length: Integer; font: TGPFont; + const layoutRect: TGPRectF; out boundingBox: TGPRectF): TStatus; + var + nFont: GpFont; + begin + if assigned(font) then nfont := font.nativeFont else nfont := nil; + result := SetStatus(GdipMeasureString( + nativeGraphics, + PWideChar(string_), + length, + nfont, + @layoutRect, + nil, + @boundingBox, + nil, + nil + )); + end; + + + function TGPGraphics.MeasureString(string_: WideString; length: Integer; font: TGPFont; + const origin: TGPPointF; out boundingBox: TGPRectF): TStatus; + var + nFont: GpFont; + rect: TGPRectF; + begin + if assigned(font) then nfont := font.nativeFont else nfont := nil; + rect.X := origin.X; + rect.Y := origin.Y; + rect.Width := 0.0; + rect.Height := 0.0; + + result := SetStatus(GdipMeasureString( + nativeGraphics, + PWideChar(string_), + length, + nfont, + @rect, + nil, + @boundingBox, + nil, + nil + )); + end; + + + + function TGPGraphics.MeasureCharacterRanges(string_: WideString; length: Integer; font: TGPFont; + const layoutRect: TGPRectF; stringFormat: TGPStringFormat; regionCount: Integer; + const regions: array of TGPRegion): TStatus; + var + nativeRegions: Pointer; + i: Integer; + Status: TStatus; + nFont: GpFont; + nstringFormat: GpstringFormat; + type + TArrayGpRegion = array of GpRegion; + begin + if assigned(font) then nfont := font.nativeFont else nfont := nil; + if assigned(stringFormat) then nstringFormat := stringFormat.nativeFormat else nstringFormat := nil; + + if (regionCount <= 0) then + begin + result := InvalidParameter; + exit; + end; + + getmem(nativeRegions, Sizeof(GpRegion)* regionCount); + + for i := 0 to regionCount - 1 do + TArrayGpRegion(nativeRegions)[i] := regions[i].nativeRegion; + + status := SetStatus(GdipMeasureCharacterRanges( + nativeGraphics, + PWideChar(string_), + length, + nfont, + @layoutRect, + nstringFormat, + regionCount, + nativeRegions + )); + + freemem(nativeRegions, Sizeof(GpRegion)* regionCount); + result := status; + end; + + function TGPGraphics.DrawDriverString(text: PUINT16; length: Integer; font: TGPFont + ; brush: TGPBrush; positions: PGPPointF; flags: Integer + ; matrix: TGPMatrix): TStatus; + var + nfont: Gpfont; + nbrush: Gpbrush; + nmatrix: Gpmatrix; + begin + if assigned(font) then nfont := font.nativeFont else nfont := nil; + if assigned(brush) then nbrush := brush.nativeBrush else nbrush := nil; + if assigned(matrix) then nmatrix := matrix.nativeMatrix else nmatrix := nil; + + result := SetStatus(GdipDrawDriverString( + nativeGraphics, + text, + length, + nfont, + nbrush, + positions, + flags, + nmatrix)); + end; + + function TGPGraphics.MeasureDriverString(text: PUINT16; length: Integer; font: TGPFont; + positions: PGPPointF; flags: Integer; matrix: TGPMatrix; + out boundingBox: TGPRectF): TStatus; + var + nfont: Gpfont; + nmatrix: Gpmatrix; + begin + if assigned(font) then nfont := font.nativeFont else nfont := nil; + if assigned(matrix) then nmatrix := matrix.nativeMatrix else nmatrix := nil; + + result := SetStatus(GdipMeasureDriverString( + nativeGraphics, + text, + length, + nfont, + positions, + flags, + nmatrix, + @boundingBox + )); + end; + + // Draw a cached bitmap on this graphics destination offset by + // x, y. Note this will fail with WrongState if the CachedBitmap + // native format differs from this Graphics. + + function TGPGraphics.DrawCachedBitmap(cb: TGPCachedBitmap; x, y: Integer): TStatus; + begin + result := SetStatus(GdipDrawCachedBitmap( + nativeGraphics, + cb.nativeCachedBitmap, + x, y + )); + end; + + function TGPGraphics.DrawImage(image: TGPImage; const point: TGPPointF): TStatus; + begin + result := DrawImage(image, point.X, point.Y); + end; + + function TGPGraphics.DrawImage(image: TGPImage; x, y: Single): TStatus; + var + nImage: GpImage; + begin + if assigned(Image) then nImage := Image.nativeImage else nImage := nil; + result := SetStatus(GdipDrawImage(nativeGraphics, nImage, x, y)); + end; + + function TGPGraphics.DrawImage(image: TGPImage; const rect: TGPRectF): TStatus; + begin + result := DrawImage(image, rect.X, rect.Y, rect.Width, rect.Height); + end; + + function TGPGraphics.DrawImage(image: TGPImage; x, y, width, height: Single): TStatus; + var + nImage: GpImage; + begin + if assigned(Image) then nImage := Image.nativeImage else nImage := nil; + result := SetStatus(GdipDrawImageRect(nativeGraphics, + nimage, + x, + y, + width, + height)); + end; + + function TGPGraphics.DrawImage(image: TGPImage; const point: TGPPoint): TStatus; + begin + result := DrawImage(image, point.X, point.Y); + end; + + function TGPGraphics.DrawImage(image: TGPImage; x, y: Integer): TStatus; + var + nImage: GpImage; + begin + if assigned(Image) then + nImage := Image.nativeImage + else + nImage := nil; + + if Assigned(nImage) then + begin + if Image.lastResult<>win32Error then + result := SetStatus(GdipDrawImageI(nativeGraphics, + nimage, + x, + y)) + else + result := GdiplusNotInitialized; + end + else + result := GdiplusNotInitialized; + end; + + function TGPGraphics.DrawImage(image: TGPImage; const rect: TGPRect): TStatus; + begin + result := DrawImage(image, + rect.X, + rect.Y, + rect.Width, + rect.Height); + end; + + function TGPGraphics.DrawImage(image: TGPImage; x, y, width, height: Integer): TStatus; + var + nImage: GpImage; + begin + if assigned(Image) then nImage := Image.nativeImage else nImage := nil; + result := SetStatus(GdipDrawImageRectI(nativeGraphics, + nimage, + x, + y, + width, + height)); + end; + + + // Affine Draw Image + // destPoints.length = 3: rect => parallelogram + // destPoints[0] <=> top-left corner of the source rectangle + // destPoints[1] <=> top-right corner + // destPoints[2] <=> bottom-left corner + // destPoints.length = 4: rect => quad + // destPoints[3] <=> bottom-right corner + + function TGPGraphics.DrawImage(image: TGPImage; destPoints: PGPPointF; count: Integer): TStatus; + var + nImage: GpImage; + begin + if (((count <> 3) and (count <> 4)) or (destPoints = nil)) then + begin + result := SetStatus(InvalidParameter); + exit; + end; + if assigned(Image) then nImage := Image.nativeImage else nImage := nil; + result := SetStatus(GdipDrawImagePoints(nativeGraphics, + nimage, + destPoints, count)); + end; + + function TGPGraphics.DrawImage(image: TGPImage; destPoints: PGPPoint; count: Integer): TStatus; + var + nImage: GpImage; + begin + if (((count <> 3) and (count <> 4))or (destPoints = nil)) then + begin + result := SetStatus(InvalidParameter); + exit; + end; + + if assigned(Image) then nImage := Image.nativeImage else nImage := nil; + result := SetStatus(GdipDrawImagePointsI(nativeGraphics, + nimage, + destPoints, + count)); + end; + + function TGPGraphics.DrawImage(image: TGPImage; x, y, srcx, srcy, srcwidth, srcheight: Single; + srcUnit: TUnit): TStatus; + var + nImage: GpImage; + begin + if assigned(Image) then nImage := Image.nativeImage else nImage := nil; + result := SetStatus(GdipDrawImagePointRect(nativeGraphics, + nimage, + x, y, + srcx, srcy, + srcwidth, srcheight, srcUnit)); + end; + + function TGPGraphics.DrawImage(image: TGPImage; const destRect: TGPRectF; srcx, srcy, srcwidth, srcheight: Single; + srcUnit: TUnit; imageAttributes: TGPImageAttributes = nil; callback: DrawImageAbort = nil; + callbackData: Pointer = nil): TStatus; + var + nImage: GpImage; + nimageAttributes: GpimageAttributes; + begin + if assigned(Image) then nImage := Image.nativeImage else nImage := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + result := SetStatus(GdipDrawImageRectRect(nativeGraphics, + nimage, + destRect.X, + destRect.Y, + destRect.Width, + destRect.Height, + srcx, srcy, + srcwidth, srcheight, + srcUnit, + nimageAttributes, + callback, + callbackData)); + end; + + function TGPGraphics.DrawImage(image: TGPImage; destPoints: PGPPointF; count: Integer; + srcx, srcy, srcwidth, srcheight: Single; srcUnit: TUnit; + imageAttributes: TGPImageAttributes = nil; callback: DrawImageAbort = nil; + callbackData: Pointer = nil): TStatus; + var + nImage: GpImage; + nimageAttributes: GpimageAttributes; + begin + if assigned(Image) then nImage := Image.nativeImage else nImage := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + result := SetStatus(GdipDrawImagePointsRect(nativeGraphics, + nimage, + destPoints, count, + srcx, srcy, + srcwidth, + srcheight, + srcUnit, + nimageAttributes, + callback, + callbackData)); + end; + + function TGPGraphics.DrawImage(image: TGPImage; x, y, srcx, srcy, srcwidth, srcheight: Integer; + srcUnit: TUnit): TStatus; + var + nImage: GpImage; + begin + if assigned(Image) then nImage := Image.nativeImage else nImage := nil; + result := SetStatus(GdipDrawImagePointRectI(nativeGraphics, + nimage, + x, + y, + srcx, + srcy, + srcwidth, + srcheight, + srcUnit)); + end; + + function TGPGraphics.DrawImage(image: TGPImage; const destRect: TGPRect; srcx, srcy, srcwidth, + srcheight: Integer; srcUnit: TUnit; imageAttributes: TGPImageAttributes = nil; + callback: DrawImageAbort = nil; callbackData: Pointer = nil): TStatus; + var + nImage: GpImage; + nimageAttributes: GpimageAttributes; + begin + if assigned(Image) then nImage := Image.nativeImage else nImage := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + result := SetStatus(GdipDrawImageRectRectI(nativeGraphics, + nimage, + destRect.X, + destRect.Y, + destRect.Width, + destRect.Height, + srcx, + srcy, + srcwidth, + srcheight, + srcUnit, + nimageAttributes, + callback, + callbackData)); + end; + + function TGPGraphics.DrawImage(image: TGPImage; destPoints: PGPPoint; + count, srcx, srcy, srcwidth, srcheight: Integer; srcUnit: TUnit; + imageAttributes: TGPImageAttributes = nil; callback: DrawImageAbort = nil; + callbackData: Pointer = nil): TStatus; + var + nImage: GpImage; + nimageAttributes: GpimageAttributes; + begin + if assigned(Image) then nImage := Image.nativeImage else nImage := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + + result := SetStatus(GdipDrawImagePointsRectI(nativeGraphics, + nimage, + destPoints, + count, + srcx, + srcy, + srcwidth, + srcheight, + srcUnit, + nimageAttributes, + callback, + callbackData)); + end; + + // The following methods are for playing an EMF+ to a graphics + // via the enumeration interface. Each record of the EMF+ is + // sent to the callback (along with the callbackData). Then + // the callback can invoke the Metafile::PlayRecord method + // to play the particular record. + + + function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; const destPoint: TGPPointF; + callback: EnumerateMetafileProc; callbackData: Pointer = nil; + imageAttributes: TGPImageAttributes = nil): TStatus; + var + nMetafile: GpMetafile; + nimageAttributes: GpimageAttributes; + begin + if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + result := SetStatus(GdipEnumerateMetafileDestPoint( + nativeGraphics, + nmetafile, + @destPoint, + callback, + callbackData, + nimageAttributes)); + end; + + + function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; const destPoint: TGPPoint; + callback: EnumerateMetafileProc; callbackData: pointer = nil; + imageAttributes: TGPImageAttributes = nil): TStatus; + var + nMetafile: GpMetafile; + nimageAttributes: GpimageAttributes; + begin + if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + result := SetStatus(GdipEnumerateMetafileDestPointI( + nativeGraphics, + nmetafile, + @destPoint, + callback, + callbackData, + nimageAttributes)); + end; + + + function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; const destRect: TGPRectF; + callback: EnumerateMetafileProc; callbackData: Pointer = nil; + imageAttributes: TGPImageAttributes = nil): TStatus; + var + nMetafile: GpMetafile; + nimageAttributes: GpimageAttributes; + begin + if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + result := SetStatus(GdipEnumerateMetafileDestRect( + nativeGraphics, + nmetafile, + @destRect, + callback, + callbackData, + nimageAttributes)); + end; + + + function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; const destRect: TGPRect; + callback: EnumerateMetafileProc; callbackData: Pointer = nil; + imageAttributes: TGPImageAttributes = nil): TStatus; + var + nMetafile: GpMetafile; + nimageAttributes: GpimageAttributes; + begin + if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + result := SetStatus(GdipEnumerateMetafileDestRectI( + nativeGraphics, + nmetafile, + @destRect, + callback, + callbackData, + nimageAttributes)); + end; + + + function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; destPoints: PGPPointF; + count: Integer; callback: EnumerateMetafileProc; callbackData: Pointer = nil; + imageAttributes: TGPImageAttributes = nil): TStatus; + var + nMetafile: GpMetafile; + nimageAttributes: GpimageAttributes; + begin + if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + result := SetStatus(GdipEnumerateMetafileDestPoints( + nativeGraphics, + nmetafile, + destPoints, + count, + callback, + callbackData, + nimageAttributes)); + end; + + + function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; destPoints: PGPPoint; + count: Integer; callback: EnumerateMetafileProc; callbackData: Pointer = nil; + imageAttributes: TGPImageAttributes = nil): TStatus; + var + nMetafile: GpMetafile; + nimageAttributes: GpimageAttributes; + begin + if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + result := SetStatus(GdipEnumerateMetafileDestPointsI( + nativeGraphics, + nmetafile, + destPoints, + count, + callback, + callbackData, + nimageAttributes)); + end; + + + function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; const destPoint: TGPPointF; + const srcRect: TGPRectF; srcUnit: TUnit; callback: EnumerateMetafileProc; + callbackData: pointer = nil; imageAttributes: TGPImageAttributes = nil): TStatus; + var + nMetafile: GpMetafile; + nimageAttributes: GpimageAttributes; + begin + if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + result := SetStatus(GdipEnumerateMetafileSrcRectDestPoint( + nativeGraphics, + nmetafile, + @destPoint, + @srcRect, + srcUnit, + callback, + callbackData, + nimageAttributes)); + end; + + + function TGPGraphics.EnumerateMetafile(metafile : TGPMetafile; const destPoint : TGPPoint; + const srcRect : TGPRect; srcUnit : TUnit; callback : EnumerateMetafileProc; + callbackData : Pointer = nil; imageAttributes : TGPImageAttributes = nil): TStatus; + var + nMetafile: GpMetafile; + nimageAttributes: GpimageAttributes; + begin + if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + result := SetStatus(GdipEnumerateMetafileSrcRectDestPointI( + nativeGraphics, + nmetafile, + @destPoint, + @srcRect, + srcUnit, + callback, + callbackData, + nimageAttributes)); + end; + + + function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; const destRect: TGPRectF; + const srcRect: TGPRectF; srcUnit: TUnit; callback: EnumerateMetafileProc; + callbackData: Pointer = nil; imageAttributes: TGPImageAttributes = nil): TStatus; + var + nMetafile: GpMetafile; + nimageAttributes: GpimageAttributes; + begin + if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + result := SetStatus(GdipEnumerateMetafileSrcRectDestRect( + nativeGraphics, + nmetafile, + @destRect, + @srcRect, + srcUnit, + callback, + callbackData, + nimageAttributes)); + end; + + + function TGPGraphics.EnumerateMetafile(metafile : TGPMetafile; const destRect, srcRect: TGPRect; + srcUnit : TUnit; callback : EnumerateMetafileProc; callbackData : Pointer = nil; + imageAttributes : TGPImageAttributes = nil): TStatus; + var + nMetafile: GpMetafile; + nimageAttributes: GpimageAttributes; + begin + if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + result := SetStatus(GdipEnumerateMetafileSrcRectDestRectI( + nativeGraphics, + nmetafile, + @destRect, + @srcRect, + srcUnit, + callback, + callbackData, + nimageAttributes)); + end; + + + function TGPGraphics.EnumerateMetafile( metafile: TGPMetafile; destPoints: PGPPointF; + count: Integer; const srcRect: TGPRectF; srcUnit: TUnit; callback: EnumerateMetafileProc; + callbackData: Pointer = nil; imageAttributes: TGPImageAttributes = nil): TStatus; + var + nMetafile: GpMetafile; + nimageAttributes: GpimageAttributes; + begin + if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + result := SetStatus(GdipEnumerateMetafileSrcRectDestPoints( + nativeGraphics, + nmetafile, + destPoints, + count, + @srcRect, + srcUnit, + callback, + callbackData, + nimageAttributes)); + end; + + + function TGPGraphics.EnumerateMetafile(metafile: TGPMetafile; destPoints: PGPPoint; + count: Integer; const srcRect: TGPRect; srcUnit: TUnit; callback: EnumerateMetafileProc; + callbackData: Pointer = nil; imageAttributes: TGPImageAttributes = nil): TStatus; + var + nMetafile: GpMetafile; + nimageAttributes: GpimageAttributes; + begin + if assigned(Metafile) then nMetafile := GpMetafile(Metafile.nativeImage) else nMetafile := nil; + if assigned(imageAttributes) then nimageAttributes := imageAttributes.nativeImageAttr else nimageAttributes := nil; + result := SetStatus(GdipEnumerateMetafileSrcRectDestPointsI( + nativeGraphics, + nmetafile, + destPoints, + count, + @srcRect, + srcUnit, + callback, + callbackData, + nimageAttributes)); + end; + + function TGPGraphics.SetClip(g: TGPGraphics; combineMode: TCombineMode = CombineModeReplace): TStatus; + begin + result := SetStatus(GdipSetClipGraphics(nativeGraphics, + g.nativeGraphics, + combineMode)); + end; + + function TGPGraphics.SetClip(rect: TGPRectF; combineMode: TCombineMode = CombineModeReplace): TStatus; + begin + result := SetStatus(GdipSetClipRect(nativeGraphics, + rect.X, rect.Y, + rect.Width, rect.Height, + combineMode)); + end; + + function TGPGraphics.SetClip(rect: TGPRect; combineMode: TCombineMode = CombineModeReplace): TStatus; + begin + result := SetStatus(GdipSetClipRectI(nativeGraphics, + rect.X, rect.Y, + rect.Width, rect.Height, + combineMode)); + end; + + function TGPGraphics.SetClip(path: TGPGraphicsPath; combineMode: TCombineMode = CombineModeReplace): TStatus; + begin + result := SetStatus(GdipSetClipPath(nativeGraphics, + path.nativePath, + combineMode)); + end; + + function TGPGraphics.SetClip(region: TGPRegion; combineMode: TCombineMode = CombineModeReplace): TStatus; + begin + result := SetStatus(GdipSetClipRegion(nativeGraphics, + region.nativeRegion, + combineMode)); + end; + + // This is different than the other SetClip methods because it assumes + // that the HRGN is already in device units, so it doesn't transform + // the coordinates in the HRGN. + + function TGPGraphics.SetClip(hRgn: HRGN; combineMode: TCombineMode = CombineModeReplace): TStatus; + begin + result := SetStatus(GdipSetClipHrgn(nativeGraphics, hRgn, + combineMode)); + end; + + function TGPGraphics.IntersectClip(const rect: TGPRectF): TStatus; + begin + result := SetStatus(GdipSetClipRect(nativeGraphics, + rect.X, rect.Y, + rect.Width, rect.Height, + CombineModeIntersect)); + end; + + function TGPGraphics.IntersectClip(const rect: TGPRect): TStatus; + begin + result := SetStatus(GdipSetClipRectI(nativeGraphics, + rect.X, rect.Y, + rect.Width, rect.Height, + CombineModeIntersect)); + end; + + function TGPGraphics.IntersectClip(region: TGPRegion): TStatus; + begin + result := SetStatus(GdipSetClipRegion(nativeGraphics, + region.nativeRegion, + CombineModeIntersect)); + end; + + function TGPGraphics.ExcludeClip(const rect: TGPRectF): TStatus; + begin + result := SetStatus(GdipSetClipRect(nativeGraphics, + rect.X, rect.Y, + rect.Width, rect.Height, + CombineModeExclude)); + end; + + function TGPGraphics.ExcludeClip(const rect: TGPRect): TStatus; + begin + result := SetStatus(GdipSetClipRectI(nativeGraphics, + rect.X, rect.Y, + rect.Width, rect.Height, + CombineModeExclude)); + end; + + function TGPGraphics.ExcludeClip(region: TGPRegion): TStatus; + begin + result := SetStatus(GdipSetClipRegion(nativeGraphics, + region.nativeRegion, + CombineModeExclude)); + end; + + function TGPGraphics.ResetClip: TStatus; + begin + result := SetStatus(GdipResetClip(nativeGraphics)); + end; + + function TGPGraphics.TranslateClip(dx, dy: Single): TStatus; + begin + result := SetStatus(GdipTranslateClip(nativeGraphics, dx, dy)); + end; + + function TGPGraphics.TranslateClip(dx, dy: Integer): TStatus; + begin + result := SetStatus(GdipTranslateClipI(nativeGraphics, + dx, dy)); + end; + + function TGPGraphics.GetClip(region: TGPRegion): TStatus; + begin + result := SetStatus(GdipGetClip(nativeGraphics, + region.nativeRegion)); + end; + + function TGPGraphics.GetClipBounds(out rect: TGPRectF): TStatus; + begin + result := SetStatus(GdipGetClipBounds(nativeGraphics, @rect)); + end; + + function TGPGraphics.GetClipBounds(out rect: TGPRect): TStatus; + begin + result := SetStatus(GdipGetClipBoundsI(nativeGraphics, @rect)); + end; + + function TGPGraphics.IsClipEmpty: Bool; + var booln: BOOL; + begin + booln := FALSE; + SetStatus(GdipIsClipEmpty(nativeGraphics, @booln)); + result := booln; + end; + + function TGPGraphics.GetVisibleClipBounds(out rect: TGPRectF): TStatus; + begin + result := SetStatus(GdipGetVisibleClipBounds(nativeGraphics, @rect)); + end; + + function TGPGraphics.GetVisibleClipBounds(out rect: TGPRect): TStatus; + begin + result := SetStatus(GdipGetVisibleClipBoundsI(nativeGraphics, @rect)); + end; + + function TGPGraphics.IsVisibleClipEmpty: BOOL; + var booln: BOOL; + begin + booln := FALSE; + SetStatus(GdipIsVisibleClipEmpty(nativeGraphics, booln)); + result := booln; + end; + + function TGPGraphics.IsVisible(x, y: Integer): BOOL; + var pt: TGPPoint; + begin + pt.X := x; pt.Y := y; + result := IsVisible(pt); + end; + + function TGPGraphics.IsVisible(const point: TGPPoint): BOOL; + var booln: BOOL; + begin + booln := FALSE; + SetStatus(GdipIsVisiblePointI(nativeGraphics, + point.X, + point.Y, + booln)); + result := booln; + end; + + function TGPGraphics.IsVisible(x, y, width, height: Integer): BOOL; + var booln: BOOL; + begin + booln := TRUE; + SetStatus(GdipIsVisibleRectI(nativeGraphics, + X, + Y, + Width, + Height, + booln)); + result := booln; + end; + + function TGPGraphics.IsVisible(const rect: TGPRect): BOOL; + var booln: BOOL; + begin + booln := TRUE; + SetStatus(GdipIsVisibleRectI(nativeGraphics, + rect.X, + rect.Y, + rect.Width, + rect.Height, + booln)); + result := booln; + end; + + function TGPGraphics.IsVisible(x, y: Single): BOOL; + var booln: BOOL; + begin + booln := FALSE; + SetStatus(GdipIsVisiblePoint(nativeGraphics, + X, + Y, + booln)); + + result := booln; + end; + + function TGPGraphics.IsVisible(const point: TGPPointF): BOOL; + var booln: BOOL; + begin + booln := FALSE; + SetStatus(GdipIsVisiblePoint(nativeGraphics, + point.X, + point.Y, + booln)); + + result := booln; + end; + + function TGPGraphics.IsVisible(x, y, width, height: Single): BOOL; + var booln: BOOL; + begin + booln := TRUE; + SetStatus(GdipIsVisibleRect(nativeGraphics, + X, + Y, + Width, + Height, + booln)); + result := booln; + end; + + function TGPGraphics.IsVisible(const rect: TGPRectF): BOOL; + var booln: BOOL; + begin + booln := TRUE; + SetStatus(GdipIsVisibleRect(nativeGraphics, + rect.X, + rect.Y, + rect.Width, + rect.Height, + booln)); + result := booln; + end; + + function TGPGraphics.Save: GraphicsState; + begin + SetStatus(GdipSaveGraphics(nativeGraphics, result)); + end; + + function TGPGraphics.Restore(gstate: GraphicsState): TStatus; + begin + result := SetStatus(GdipRestoreGraphics(nativeGraphics, + gstate)); + end; + + function TGPGraphics.BeginContainer(const dstrect,srcrect: TGPRectF; unit_: TUnit): GraphicsContainer; + begin + SetStatus(GdipBeginContainer(nativeGraphics, @dstrect, + @srcrect, unit_, result)); + end; + + function TGPGraphics.BeginContainer(const dstrect, srcrect: TGPRect; unit_: TUnit): GraphicsContainer; + begin + SetStatus(GdipBeginContainerI(nativeGraphics, @dstrect, + @srcrect, unit_, result)); + end; + + function TGPGraphics.BeginContainer: GraphicsContainer; + begin + SetStatus(GdipBeginContainer2(nativeGraphics, result)); + end; + + function TGPGraphics.EndContainer(state: GraphicsContainer): TStatus; + begin + result := SetStatus(GdipEndContainer(nativeGraphics, state)); + end; + + // Only valid when recording metafiles. + + function TGPGraphics.AddMetafileComment(data: PBYTE; sizeData: UINT): TStatus; + begin + result := SetStatus(GdipComment(nativeGraphics, sizeData, data)); + end; + + function TGPGraphics.GetHalftonePalette: HPALETTE; + begin + result := GdipCreateHalftonePalette; + end; + + function TGPGraphics.GetLastStatus: TStatus; + begin + result := lastResult; + lastResult := Ok; + end; + + constructor TGPGraphics.Create(graphics: GpGraphics); + begin + lastResult := Ok; + SetNativeGraphics(graphics); + end; + + procedure TGPGraphics.SetNativeGraphics(graphics: GpGraphics); + begin + self.nativeGraphics := graphics; + end; + + function TGPGraphics.SetStatus(status: TStatus): TStatus; + begin + if (status <> Ok) then lastResult := status; + result := status; + end; + + function TGPGraphics.GetNativeGraphics: GpGraphics; + begin + result := self.nativeGraphics; + end; + + function TGPGraphics.GetNativePen(pen: TGPPen): GpPen; + begin + result := pen.nativePen; + end; + +(**************************************************************************\ +* +* GDI+ Font Family class +* +\**************************************************************************) + + constructor TGPFontFamily.Create; + begin + nativeFamily := nil; + lastResult := Ok; + end; + + constructor TGPFontFamily.Create(name: WideString; fontCollection: TGPFontCollection = nil); + var nfontCollection: GpfontCollection; + begin + nativeFamily := nil; + if assigned(fontCollection) then nfontCollection := fontCollection.nativeFontCollection else nfontCollection := nil; + lastResult := GdipCreateFontFamilyFromName(PWideChar(name), nfontCollection, nativeFamily); + end; + + destructor TGPFontFamily.Destroy; + begin + GdipDeleteFontFamily (nativeFamily); + end; + + class function TGPFontFamily.GenericSansSerif: TGPFontFamily; + var + nFontFamily: GpFontFamily; + begin + if (GenericSansSerifFontFamily <> nil) then + begin + result := GenericSansSerifFontFamily; + exit; + end; + GenericSansSerifFontFamily := TGPFontFamily.Create; + GenericSansSerifFontFamily.lastResult := GdipGetGenericFontFamilySansSerif(nFontFamily); + GenericSansSerifFontFamily.nativeFamily := nFontFamily; + result := GenericSansSerifFontFamily; + end; + + class function TGPFontFamily.GenericSerif: TGPFontFamily; + var nFontFamily: GpFontFamily; + begin + if (GenericSerifFontFamily <> nil) then + begin + result := GenericSerifFontFamily; + exit; + end; + + GenericSerifFontFamily := TGPFontFamily.Create;// (GenericSerifFontFamilyBuffer); + GenericSerifFontFamily.lastResult := GdipGetGenericFontFamilySerif(nFontFamily); + GenericSerifFontFamily.nativeFamily := nFontFamily; + result := GenericSerifFontFamily; + end; + + class function TGPFontFamily.GenericMonospace: TGPFontFamily; + var nFontFamily: GpFontFamily; + begin + if (GenericMonospaceFontFamily <> nil) then + begin + result := GenericMonospaceFontFamily; + exit; + end; + GenericMonospaceFontFamily := TGPFontFamily.Create;// (GenericMonospaceFontFamilyBuffer); + GenericMonospaceFontFamily.lastResult := GdipGetGenericFontFamilyMonospace(nFontFamily); + GenericMonospaceFontFamily.nativeFamily := nFontFamily; + result := GenericMonospaceFontFamily; + end; + + function TGPFontFamily.GetFamilyName(out name: string; language: LANGID = 0): TStatus; + var str: array[0..LF_FACESIZE - 1] of WideChar; + begin + result := SetStatus(GdipGetFamilyName(nativeFamily, @str, language)); + name := str; + end; + + function TGPFontFamily.Clone: TGPFontFamily; + var + clonedFamily: GpFontFamily; + begin + clonedFamily := nil; + SetStatus(GdipCloneFontFamily (nativeFamily, clonedFamily)); + result := TGPFontFamily.Create(clonedFamily, lastResult); + end; + + function TGPFontFamily.IsAvailable: BOOL; + begin + result := (nativeFamily <> nil); + end; + + function TGPFontFamily.IsStyleAvailable(style: Integer): BOOL; + var + StyleAvailable: BOOL; + status: TStatus; + begin + status := SetStatus(GdipIsStyleAvailable(nativeFamily, style, StyleAvailable)); + if (status <> Ok) then StyleAvailable := FALSE; + result := StyleAvailable; + end; + + function TGPFontFamily.GetEmHeight(style: Integer): UINT16; + begin + SetStatus(GdipGetEmHeight(nativeFamily, style, result)); + end; + + function TGPFontFamily.GetCellAscent(style: Integer): UINT16; + begin + SetStatus(GdipGetCellAscent(nativeFamily, style, result)); + end; + + function TGPFontFamily.GetCellDescent(style: Integer): UINT16; + begin + SetStatus(GdipGetCellDescent(nativeFamily, style, result)); + end; + + function TGPFontFamily.GetLineSpacing(style: Integer): UINT16; + begin + SetStatus(GdipGetLineSpacing(nativeFamily, style, result)); + end; + + function TGPFontFamily.GetLastStatus: TStatus; + begin + result := lastResult; + lastResult := Ok; + end; + + function TGPFontFamily.SetStatus(status: TStatus): TStatus; + begin + if (status <> Ok) then lastResult := status; + result := status; + end; + + constructor TGPFontFamily.Create(nativeOrig: GpFontFamily; status: TStatus); + begin + lastResult := status; + nativeFamily := nativeOrig; + end; + +(**************************************************************************\ +* +* GDI+ Font class +* +\**************************************************************************) + + constructor TGPFont.Create(hdc: HDC); + var font: GpFont; + begin + font := nil; + lastResult := GdipCreateFontFromDC(hdc, font); + SetNativeFont(font); + end; + + constructor TGPFont.Create(hdc: HDC; logfont: PLogFontA); + var font: GpFont; + begin + font := nil; + if assigned(logfont) then + lastResult := GdipCreateFontFromLogfontA(hdc, logfont, font) + else + lastResult := GdipCreateFontFromDC(hdc, font); + SetNativeFont(font); + end; + + constructor TGPFont.Create(hdc: HDC; logfont: PLogFontW); + var font: GpFont; + begin + font := nil; + if assigned(logfont) then + lastResult := GdipCreateFontFromLogfontW(hdc, logfont, font) + else + lastResult := GdipCreateFontFromDC(hdc, font); + SetNativeFont(font); + end; + + constructor TGPFont.Create(hdc: HDC; hfont: HFONT); + var + font: GpFont; + lf: LOGFONTA; + begin + font := nil; + if BOOL(hfont) then + begin + if( BOOL(GetObjectA(hfont, sizeof(LOGFONTA), @lf))) then + lastResult := GdipCreateFontFromLogfontA(hdc, @lf, font) + else + lastResult := GdipCreateFontFromDC(hdc, font); + end + else + lastResult := GdipCreateFontFromDC(hdc, font); + SetNativeFont(font); + end; + + constructor TGPFont.Create(family: TGPFontFamily; emSize: Single; + style: TFontStyle = FontStyleRegular; unit_: TUnit = UnitPoint); + var + font: GpFont; + nFontFamily: GpFontFamily; + begin + font := nil; + if assigned(Family) then nFontFamily := Family.nativeFamily else nFontFamily := nil; + lastResult := GdipCreateFont(nFontFamily, emSize, Integer(style), Integer(unit_), font); + SetNativeFont(font); + end; + + constructor TGPFont.Create(familyName: WideString; emSize: Single; + style: TFontStyle = FontStyleRegular; unit_: TUnit = UnitPoint; + fontCollection: TGPFontCollection = nil); + var + family: TGPFontFamily; + nativeFamily: GpFontFamily; + begin + nativeFont := nil; + family := TGPFontFamily.Create(familyName, fontCollection); + nativeFamily := family.nativeFamily; + lastResult := family.GetLastStatus; + if (lastResult <> Ok) then + begin + nativeFamily := TGPFontFamily.GenericSansSerif.nativeFamily; + lastResult := TGPFontFamily.GenericSansSerif.lastResult; + if (lastResult <> Ok) then + begin + family.Free; + exit; + end; + end; + + lastResult := GdipCreateFont(nativeFamily, + emSize, + integer(style), + integer(unit_), + nativeFont); + + if (lastResult <> Ok) then + begin + nativeFamily := TGPFontFamily.GenericSansSerif.nativeFamily; + lastResult := TGPFontFamily.GenericSansSerif.lastResult; + if (lastResult <> Ok) then + begin + family.Free; + exit; + end; + + lastResult := GdipCreateFont( + nativeFamily, + emSize, + Integer(style), + Integer(unit_), + nativeFont); + end; + family.Free; + end; + + function TGPFont.GetLogFontA(g: TGPGraphics; out logfontA: TLogFontA): TStatus; + var nGraphics: GpGraphics; + begin + if assigned(g) then nGraphics := g.nativeGraphics else nGraphics := nil; + result := SetStatus(GdipGetLogFontA(nativeFont, nGraphics, logfontA)); + end; + + function TGPFont.GetLogFontW(g: TGPGraphics; out logfontW: TLogFontW): TStatus; + var nGraphics: GpGraphics; + begin + if assigned(g) then nGraphics := g.nativeGraphics else nGraphics := nil; + result := SetStatus(GdipGetLogFontW(nativeFont, nGraphics, logfontW)); + end; + + function TGPFont.Clone: TGPFont; + var cloneFont: GpFont; + begin + cloneFont := nil; + SetStatus(GdipCloneFont(nativeFont, cloneFont)); + result := TGPFont.Create(cloneFont, lastResult); + end; + + destructor TGPFont.Destroy; + begin + GdipDeleteFont(nativeFont); + end; + + function TGPFont.IsAvailable: BOOL; + begin + result := (nativeFont <> nil); + end; + + function TGPFont.GetStyle: Integer; + begin + SetStatus(GdipGetFontStyle(nativeFont, result)); + end; + + function TGPFont.GetSize: Single; + begin + SetStatus(GdipGetFontSize(nativeFont, result)); + end; + + function TGPFont.GetUnit: TUnit; + begin + SetStatus(GdipGetFontUnit(nativeFont, result)); + end; + + function TGPFont.GetLastStatus: TStatus; + begin + result := lastResult; + end; + + function TGPFont.GetHeight(graphics: TGPGraphics): Single; + var ngraphics: Gpgraphics; + begin + if assigned(graphics) then ngraphics := graphics.nativeGraphics else ngraphics := nil; + SetStatus(GdipGetFontHeight(nativeFont, ngraphics, result)); + end; + + function TGPFont.GetHeight(dpi: Single): Single; + begin + SetStatus(GdipGetFontHeightGivenDPI(nativeFont, dpi, result)); + end; + + function TGPFont.GetFamily(family: TGPFontFamily): TStatus; + var + status: TStatus; + nFamily: GpFontFamily; + begin + if (family = nil) then + begin + result := SetStatus(InvalidParameter); + exit; + end; + + status := GdipGetFamily(nativeFont, nFamily); + family.nativeFamily := nFamily; + family.SetStatus(status); + result := SetStatus(status); + end; + + constructor TGPFont.Create(font: GpFont; status: TStatus); + begin + lastResult := status; + SetNativeFont(font); + end; + + procedure TGPFont.SetNativeFont(Font: GpFont); + begin + nativeFont := Font; + end; + + function TGPFont.SetStatus(status: TStatus): TStatus; + begin + if (status <> Ok) then lastResult := status; + result := status; + end; + +(**************************************************************************\ +* +* Font collections (Installed and Private) +* +\**************************************************************************) + + constructor TGPFontCollection.Create; + begin + nativeFontCollection := nil; + end; + + destructor TGPFontCollection.Destroy; + begin + inherited Destroy; + end; + + function TGPFontCollection.GetFamilyCount: Integer; + var + numFound: Integer; + begin + numFound := 0; + lastResult := GdipGetFontCollectionFamilyCount(nativeFontCollection, numFound); + result := numFound; + end; + + function TGPFontCollection.GetFamilies(numSought: Integer; out gpfamilies: array of TGPFontFamily; + out numFound: Integer): TStatus; + var + nativeFamilyList: Pointer; + Status: TStatus; + i: Integer; + type + ArrGpFontFamily = array of GpFontFamily; + begin + if ((numSought <= 0) or (length(gpfamilies) = 0)) then + begin + result := SetStatus(InvalidParameter); + exit; + end; + numFound := 0; + + getMem(nativeFamilyList, numSought * SizeOf(GpFontFamily)); + if nativeFamilyList = nil then + begin + result := SetStatus(OutOfMemory); + exit; + end; + + status := SetStatus(GdipGetFontCollectionFamilyList( + nativeFontCollection, + numSought, + nativeFamilyList, + numFound + )); + + if (status = Ok) then + for i := 0 to numFound - 1 do + GdipCloneFontFamily(ArrGpFontFamily(nativeFamilyList)[i], gpfamilies[i].nativeFamily); + Freemem(nativeFamilyList, numSought * SizeOf(GpFontFamily)); + result := status; + end; + + function TGPFontCollection.GetLastStatus: TStatus; + begin + result := lastResult; + end; + + function TGPFontCollection.SetStatus(status: TStatus): TStatus; + begin + lastResult := status; + result := lastResult; + end; + + + constructor TGPInstalledFontCollection.Create; + begin + nativeFontCollection := nil; + lastResult := GdipNewInstalledFontCollection(nativeFontCollection); + end; + + destructor TGPInstalledFontCollection.Destroy; + begin + inherited Destroy; + end; + + constructor TGPPrivateFontCollection.Create; + begin + nativeFontCollection := nil; + lastResult := GdipNewPrivateFontCollection(nativeFontCollection); + end; + + destructor TGPPrivateFontCollection.destroy; + begin + GdipDeletePrivateFontCollection(nativeFontCollection); + inherited Destroy; + end; + + function TGPPrivateFontCollection.AddFontFile(filename: WideString): TStatus; + begin + result := SetStatus(GdipPrivateAddFontFile(nativeFontCollection, PWideChar(filename))); + end; + + function TGPPrivateFontCollection.AddMemoryFont(memory: Pointer; length: Integer): TStatus; + begin + result := SetStatus(GdipPrivateAddMemoryFont( + nativeFontCollection, + memory, + length)); + end; + +(**************************************************************************\ +* +* GDI+ Graphics Path class +* +\**************************************************************************) + + constructor TGPGraphicsPath.Create(fillMode: TFillMode = FillModeAlternate); + begin + nativePath := nil; + lastResult := GdipCreatePath(fillMode, nativePath); + end; + + constructor TGPGraphicsPath.Create(points: PGPPointF; types: PBYTE; count: Integer; + fillMode: TFillMode = FillModeAlternate); + begin + nativePath := nil; + lastResult := GdipCreatePath2(points, types, count, fillMode, nativePath); + end; + + constructor TGPGraphicsPath.Create(points: PGPPoint; types: PBYTE; count: Integer; + fillMode: TFillMode = FillModeAlternate); + begin + nativePath := nil; + lastResult := GdipCreatePath2I(points, types, count, fillMode, nativePath); + end; + + destructor TGPGraphicsPath.destroy; + begin + GdipDeletePath(nativePath); + end; + + function TGPGraphicsPath.Clone: TGPGraphicsPath; + var + clonepath: GpPath; + begin + clonepath := nil; + SetStatus(GdipClonePath(nativePath, clonepath)); + result := TGPGraphicsPath.Create(clonepath); + end; + + // Reset the path object to empty (and fill mode to FillModeAlternate) + + function TGPGraphicsPath.Reset: TStatus; + begin + result := SetStatus(GdipResetPath(nativePath)); + end; + + function TGPGraphicsPath.GetFillMode: TFillMode; + var FMode: TFillMode; + begin + FMode := FillModeAlternate; + SetStatus(GdipGetPathFillMode(nativePath, result)); + result := FMode; + end; + + function TGPGraphicsPath.SetFillMode(fillmode: TFillMode): TStatus; + begin + result := SetStatus(GdipSetPathFillMode(nativePath, fillmode)); + end; + + function TGPGraphicsPath.GetPathData(pathData: TPathData): TStatus; + var + count: Integer; + begin + count := GetPointCount; + if ((count <= 0) or ((pathData.Count > 0) and (pathData.Count < Count))) then + begin + pathData.Count := 0; + if assigned(pathData.Points) then + begin + FreeMem(pathData.Points); + pathData.Points := nil; + end; + if assigned(pathData.Types) then + begin + freemem(pathData.Types); + pathData.Types := nil; + end; + if (count <= 0) then + begin + result := lastResult; + exit; + end; + end; + + if (pathData.Count = 0) then + begin + getmem(pathData.Points, SizeOf(TGPPointF) * count); + if (pathData.Points = nil) then + begin + result := SetStatus(OutOfMemory); + exit; + end; + Getmem(pathData.Types, count); + if (pathData.Types = nil) then + begin + freemem(pathData.Points); + pathData.Points := nil; + result := SetStatus(OutOfMemory); + exit; + end; + pathData.Count := count; + end; + + result := SetStatus(GdipGetPathData(nativePath, @pathData.Count)); + end; + + function TGPGraphicsPath.StartFigure: TStatus; + begin + result := SetStatus(GdipStartPathFigure(nativePath)); + end; + + function TGPGraphicsPath.CloseFigure: TStatus; + begin + result := SetStatus(GdipClosePathFigure(nativePath)); + end; + + function TGPGraphicsPath.CloseAllFigures: TStatus; + begin + result := SetStatus(GdipClosePathFigures(nativePath)); + end; + + function TGPGraphicsPath.SetMarker: TStatus; + begin + result := SetStatus(GdipSetPathMarker(nativePath)); + end; + + function TGPGraphicsPath.ClearMarkers: TStatus; + begin + result := SetStatus(GdipClearPathMarkers(nativePath)); + end; + + function TGPGraphicsPath.Reverse: TStatus; + begin + result := SetStatus(GdipReversePath(nativePath)); + end; + + function TGPGraphicsPath.GetLastPoint(out lastPoint: TGPPointF): TStatus; + begin + result := SetStatus(GdipGetPathLastPoint(nativePath, + @lastPoint)); + end; + + function TGPGraphicsPath.AddLine(const pt1, pt2: TGPPointF): TStatus; + begin + result := AddLine(pt1.X, pt1.Y, pt2.X, pt2.Y); + end; + + function TGPGraphicsPath.AddLine(x1, y1, x2, y2: Single): TStatus; + begin + result := SetStatus(GdipAddPathLine(nativePath, x1, y1, + x2, y2)); + end; + + function TGPGraphicsPath.AddLines(points: PGPPointF; count: Integer): TStatus; + begin + result := SetStatus(GdipAddPathLine2(nativePath, points, count)); + end; + + function TGPGraphicsPath.AddLine(const pt1, pt2: TGPPoint): TStatus; + begin + result := AddLine(pt1.X, pt1.Y, pt2.X, pt2.Y); + end; + + function TGPGraphicsPath.AddLine(x1, y1, x2, y2: Integer): TStatus; + begin + result := SetStatus(GdipAddPathLineI(nativePath, x1, y1, x2, y2)); + end; + + function TGPGraphicsPath.AddLines(points: PGPPoint; count: Integer): TStatus; + begin + result := SetStatus(GdipAddPathLine2I(nativePath, points, count)); + end; + + function TGPGraphicsPath.AddArc(rect: TGPRectF; startAngle, sweepAngle: Single): TStatus; + begin + result := AddArc(rect.X, rect.Y, rect.Width, rect.Height, + startAngle, sweepAngle); + end; + + function TGPGraphicsPath.AddArc(x, y, width, height, startAngle, sweepAngle: Single): TStatus; + begin + result := SetStatus(GdipAddPathArc(nativePath, x, y, width, height, startAngle, sweepAngle)); + end; + + function TGPGraphicsPath.AddArc(rect: TGPRect; startAngle, sweepAngle: Single): TStatus; + begin + result := AddArc(rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle); + end; + + function TGPGraphicsPath.AddArc(x, y, width, height: Integer; startAngle, sweepAngle: Single): TStatus; + begin + result := SetStatus(GdipAddPathArcI(nativePath, x, y, width, height, startAngle, sweepAngle)); + end; + + function TGPGraphicsPath.AddBezier(pt1, pt2, pt3, pt4: TGPPointF): TStatus; + begin + result := AddBezier(pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y); + end; + + function TGPGraphicsPath.AddBezier(x1, y1, x2, y2, x3, y3, x4, y4: Single): TStatus; + begin + result := SetStatus(GdipAddPathBezier(nativePath, x1, y1, x2, y2, x3, y3, x4, y4)); + end; + + function TGPGraphicsPath.AddBeziers(points: PGPPointF; count: Integer): TStatus; + begin + result := SetStatus(GdipAddPathBeziers(nativePath, points, count)); + end; + + function TGPGraphicsPath.AddBezier(pt1, pt2, pt3, pt4: TGPPoint): TStatus; + begin + result := AddBezier(pt1.X, pt1.Y, pt2.X, pt2.Y, pt3.X, pt3.Y, pt4.X, pt4.Y); + end; + + function TGPGraphicsPath.AddBezier(x1, y1, x2, y2, x3, y3, x4, y4: Integer): TStatus; + begin + result := SetStatus(GdipAddPathBezierI(nativePath, x1, y1, x2, y2, x3, y3, x4, y4)); + end; + + function TGPGraphicsPath.AddBeziers(points: PGPPoint; count: Integer): TStatus; + begin + result := SetStatus(GdipAddPathBeziersI(nativePath, points, count)); + end; + + function TGPGraphicsPath.AddCurve(points: PGPPointF; count: Integer): TStatus; + begin + result := SetStatus(GdipAddPathCurve(nativePath, points, count)); + end; + + function TGPGraphicsPath.AddCurve(points: PGPPointF; count: Integer; + tension: Single): TStatus; + begin + result := SetStatus(GdipAddPathCurve2(nativePath, points, count, tension)); + end; + + function TGPGraphicsPath.AddCurve(points: PGPPointF; count, offset, + numberOfSegments: Integer; tension: Single): TStatus; + begin + result := SetStatus(GdipAddPathCurve3(nativePath, points, count, offset, + numberOfSegments, tension)); + end; + + function TGPGraphicsPath.AddCurve(points: PGPPoint; count: Integer): TStatus; + begin + result := SetStatus(GdipAddPathCurveI(nativePath, points, count)); + end; + + function TGPGraphicsPath.AddCurve(points: PGPPoint; count: Integer; tension: Single): TStatus; + begin + result := SetStatus(GdipAddPathCurve2I(nativePath, points, count, tension)); + end; + + function TGPGraphicsPath.AddCurve(points: PGPPoint; count, offset, + numberOfSegments: Integer; tension: Single): TStatus; + begin + result := SetStatus(GdipAddPathCurve3I(nativePath, points, count, offset, + numberOfSegments, tension)); + end; + + function TGPGraphicsPath.AddClosedCurve(points: PGPPointF; count: Integer): TStatus; + begin + result := SetStatus(GdipAddPathClosedCurve(nativePath, points, count)); + end; + + function TGPGraphicsPath.AddClosedCurve(points: PGPPointF; count: Integer; tension: Single): TStatus; + begin + result := SetStatus(GdipAddPathClosedCurve2(nativePath, points, count, tension)); + end; + + function TGPGraphicsPath.AddClosedCurve(points: PGPPoint; count: Integer): TStatus; + begin + result := SetStatus(GdipAddPathClosedCurveI(nativePath, points, count)); + end; + + + function TGPGraphicsPath.AddClosedCurve(points: PGPPoint; count: Integer; tension: Single): TStatus; + begin + result := SetStatus(GdipAddPathClosedCurve2I(nativePath, points, count, tension)); + end; + + function TGPGraphicsPath.AddRectangle(rect: TGPRectF): TStatus; + begin + result := SetStatus(GdipAddPathRectangle(nativePath, + rect.X, + rect.Y, + rect.Width, + rect.Height)); + end; + + function TGPGraphicsPath.AddRectangles(rects: PGPRectF; count: Integer): TStatus; + begin + result := SetStatus(GdipAddPathRectangles(nativePath, + rects, + count)); + end; + + function TGPGraphicsPath.AddRectangle(rect: TGPRect): TStatus; + begin + result := SetStatus(GdipAddPathRectangleI(nativePath, + rect.X, + rect.Y, + rect.Width, + rect.Height)); + end; + + function TGPGraphicsPath.AddRectangles(rects: PGPRect; count: Integer): TStatus; + begin + result := SetStatus(GdipAddPathRectanglesI(nativePath, + rects, + count)); + end; + + function TGPGraphicsPath.AddEllipse(rect: TGPRectF): TStatus; + begin + result := AddEllipse(rect.X, rect.Y, rect.Width, rect.Height); + end; + + function TGPGraphicsPath.AddEllipse(x, y, width, height: Single): TStatus; + begin + result := SetStatus(GdipAddPathEllipse(nativePath, + x, + y, + width, + height)); + end; + + function TGPGraphicsPath.AddEllipse(rect: TGPRect): TStatus; + begin + result := AddEllipse(rect.X, rect.Y, rect.Width, rect.Height); + end; + + function TGPGraphicsPath.AddEllipse(x, y, width, height: Integer): TStatus; + begin + result := SetStatus(GdipAddPathEllipseI(nativePath, + x, + y, + width, + height)); + end; + + function TGPGraphicsPath.AddPie(rect: TGPRectF; startAngle, sweepAngle: Single): TStatus; + begin + result := AddPie(rect.X, rect.Y, rect.Width, rect.Height, startAngle, + sweepAngle); + end; + + function TGPGraphicsPath.AddPie(x, y, width, height, startAngle, sweepAngle: Single): TStatus; + begin + result := SetStatus(GdipAddPathPie(nativePath, x, y, width, + height, startAngle, + sweepAngle)); + end; + + function TGPGraphicsPath.AddPie(rect: TGPRect; startAngle, sweepAngle: Single): TStatus; + begin + result := AddPie(rect.X, + rect.Y, + rect.Width, + rect.Height, + startAngle, + sweepAngle); + end; + + function TGPGraphicsPath.AddPie(x, y, width, height: Integer; startAngle, sweepAngle: Single): TStatus; + begin + result := SetStatus(GdipAddPathPieI(nativePath, + x, + y, + width, + height, + startAngle, + sweepAngle)); + end; + + function TGPGraphicsPath.AddPolygon(points: PGPPointF; count: Integer): TStatus; + begin + result := SetStatus(GdipAddPathPolygon(nativePath, points, count)); + end; + + function TGPGraphicsPath.AddPolygon(points: PGPPoint; count: Integer): TStatus; + begin + result := SetStatus(GdipAddPathPolygonI(nativePath, points, + count)); + end; + + function TGPGraphicsPath.AddPath(addingPath: TGPGraphicsPath; connect: Bool): TStatus; + var + nativePath2: GpPath; + begin + nativePath2 := nil; + if assigned(addingPath) then nativePath2 := addingPath.nativePath; + result := SetStatus(GdipAddPathPath(nativePath, nativePath2, connect)); + end; + + function TGPGraphicsPath.AddString( + string_: WideString; length: Integer; + family : TGPFontFamily; + style : Integer; + emSize : Single; // World units + origin : TGPPointF; + format : TGPStringFormat): TStatus; + var + rect : TGPRectF; + gpff : GPFONTFAMILY; + gpsf : GPSTRINGFORMAT; + begin + rect.X := origin.X; + rect.Y := origin.Y; + rect.Width := 0.0; + rect.Height := 0.0; + + gpff := nil; + gpsf := nil; + if assigned(family) then gpff := family.nativeFamily; + if assigned(format) then gpsf := format.nativeFormat; + result := SetStatus(GdipAddPathString(nativePath, PWideChar(string_), length, gpff, + style, emSize, @rect, gpsf)); + end; + + function TGPGraphicsPath.AddString( + string_: WideString; + length : Integer; + family : TGPFontFamily; + style : Integer; + emSize : Single; // World units + layoutRect: TGPRectF; + format : TGPStringFormat): TStatus; + var + gpff : GPFONTFAMILY; + gpsf : GPSTRINGFORMAT; + begin + gpff := nil; + gpsf := nil; + if assigned(family) then gpff := family.nativeFamily; + if assigned(format) then gpsf := format.nativeFormat; + result := SetStatus(GdipAddPathString( nativePath, PWideChar(string_), length, gpff, + style, emSize, @layoutRect, gpsf)); + end; + + function TGPGraphicsPath.AddString( + string_: WideString; + length : Integer; + family : TGPFontFamily; + style : Integer; + emSize : Single; // World units + origin : TGPPoint; + format : TGPStringFormat): TStatus; + var + rect : TGPRect; + gpff : GPFONTFAMILY; + gpsf : GPSTRINGFORMAT; + begin + rect.X := origin.X; + rect.Y := origin.Y; + rect.Width := 0; + rect.Height := 0; + gpff := nil; + gpsf := nil; + if assigned(family) then gpff := family.nativeFamily; + if assigned(format) then gpsf := format.nativeFormat; + result := SetStatus(GdipAddPathStringI(nativePath, PWideChar(string_), length, gpff, + style, emSize, @rect, gpsf)); + end; + + function TGPGraphicsPath.AddString( + string_: WideString; + length : Integer; + family : TGPFontFamily; + style : Integer; + emSize : Single; // World units + layoutRect: TGPRect; + format : TGPStringFormat): TStatus; + var + gpff : GPFONTFAMILY; + gpsf : GPSTRINGFORMAT; + begin + gpff := nil; + gpsf := nil; + if assigned(family) then gpff := family.nativeFamily; + if assigned(format) then gpsf := format.nativeFormat; + result := SetStatus(GdipAddPathStringI( nativePath, PWideChar(string_), length, gpff, + style, emSize, @layoutRect, gpsf)); + end; + + function TGPGraphicsPath.Transform(matrix: TGPMatrix): TStatus; + begin + if assigned(matrix) then + result := SetStatus(GdipTransformPath(nativePath, matrix.nativeMatrix)) + else + result := Ok; + end; + + // This is not always the tightest bounds. + + function TGPGraphicsPath.GetBounds(out bounds: TGPRectF; matrix: TGPMatrix = nil; pen: TGPPen = nil): TStatus; + var + nativeMatrix: GpMatrix; + nativePen: GpPen; + begin + nativeMatrix := nil; + nativePen := nil; + if assigned(matrix) then nativeMatrix := matrix.nativeMatrix; + if assigned(pen) then nativePen := pen.nativePen; + + result := SetStatus(GdipGetPathWorldBounds(nativePath, @bounds, nativeMatrix, nativePen)); + end; + + function TGPGraphicsPath.GetBounds(out bounds: TGPRect; matrix: TGPMatrix = nil; pen: TGPPen = nil): TStatus; + var + nativeMatrix: GpMatrix; + nativePen: GpPen; + begin + nativeMatrix := nil; + nativePen := nil; + if assigned(matrix) then nativeMatrix := matrix.nativeMatrix; + if assigned(pen) then nativePen := pen.nativePen; + + result := SetStatus(GdipGetPathWorldBoundsI(nativePath, @bounds, nativeMatrix, nativePen)); + end; + + // Once flattened, the resultant path is made of line segments and + // the original path information is lost. When matrix is nil the + // identity matrix is assumed. + + function TGPGraphicsPath.Flatten(matrix: TGPMatrix = nil; flatness: Single = FlatnessDefault): TStatus; + var nativeMatrix: GpMatrix; + begin + nativeMatrix := nil; + if assigned(matrix) then nativeMatrix := matrix.nativeMatrix; + result := SetStatus(GdipFlattenPath(nativePath, nativeMatrix, flatness)); + end; + + function TGPGraphicsPath.Widen(pen: TGPPen; matrix: TGPMatrix = nil; flatness: Single = FlatnessDefault): TStatus; + var nativeMatrix: GpMatrix; + begin + nativeMatrix := nil; + if assigned(matrix) then nativeMatrix := matrix.nativeMatrix; + result := SetStatus(GdipWidenPath(nativePath, pen.nativePen, nativeMatrix, flatness)); + end; + + function TGPGraphicsPath.Outline(matrix: TGPMatrix = nil; flatness: Single = FlatnessDefault): TStatus; + var nativeMatrix: GpMatrix; + begin + nativeMatrix := nil; + if assigned(matrix) then nativeMatrix := matrix.nativeMatrix; + result := SetStatus(GdipWindingModeOutline(nativePath, nativeMatrix, flatness)); + end; + + // Once this is called, the resultant path is made of line segments and + // the original path information is lost. When matrix is nil, the + // identity matrix is assumed. + + function TGPGraphicsPath.Warp(destPoints: PGPPointF; count: Integer; srcRect: TGPRectF; + matrix: TGPMatrix = nil; warpMode: TWarpMode = WarpModePerspective; + flatness: Single = FlatnessDefault): TStatus; + var nativeMatrix: GpMatrix; + begin + nativeMatrix := nil; + if assigned(matrix) then nativeMatrix := matrix.nativeMatrix; + result := SetStatus(GdipWarpPath(nativePath, nativeMatrix, destPoints, + count, srcRect.X, srcRect.Y, srcRect.Width, srcRect.Height, + warpMode, flatness)); + end; + + function TGPGraphicsPath.GetPointCount: Integer; + var count: Integer; + begin + count := 0; + SetStatus(GdipGetPointCount(nativePath, count)); + result := count; + end; + + function TGPGraphicsPath.GetPathTypes(types: PBYTE; count: Integer): TStatus; + begin + result := SetStatus(GdipGetPathTypes(nativePath, types, count)); + end; + + function TGPGraphicsPath.GetPathPoints(points: PGPPointF; count: Integer): TStatus; + begin + result := SetStatus(GdipGetPathPoints(nativePath, points, count)); + end; + + function TGPGraphicsPath.GetPathPoints(points: PGPPoint; count: Integer): TStatus; + begin + result := SetStatus(GdipGetPathPointsI(nativePath, points, count)); + end; + + function TGPGraphicsPath.GetLastStatus: TStatus; + begin + result := lastResult; + lastResult := Ok; + end; + + function TGPGraphicsPath.IsVisible(point: TGPPointF; g: TGPGraphics = nil): BOOL; + begin + result := IsVisible(point.X, point.Y, g); + end; + + function TGPGraphicsPath.IsVisible(x, y: Single; g: TGPGraphics = nil): BOOL; + var + booln: BOOL; + nativeGraphics: GpGraphics; + begin + booln := FALSE; + nativeGraphics := nil; + if assigned(g) then nativeGraphics := g.nativeGraphics; + SetStatus(GdipIsVisiblePathPoint(nativePath, x, y, nativeGraphics, booln)); + result := booln; + end; + + function TGPGraphicsPath.IsVisible(point: TGPPoint; g : TGPGraphics = nil): BOOL; + begin + result := IsVisible(point.X, point.Y, g); + end; + + function TGPGraphicsPath.IsVisible(x, y: Integer; g: TGPGraphics = nil): BOOL; + var + booln: BOOL; + nativeGraphics: GpGraphics; + begin + booln := FALSE; + nativeGraphics := nil; + if assigned(g) then nativeGraphics := g.nativeGraphics; + SetStatus(GdipIsVisiblePathPointI(nativePath, x, y, nativeGraphics, booln)); + result := booln; + end; + + function TGPGraphicsPath.IsOutlineVisible(point: TGPPointF; pen: TGPPen; g: TGPGraphics = nil): BOOL; + begin + result := IsOutlineVisible(point.X, point.Y, pen, g); + end; + + function TGPGraphicsPath.IsOutlineVisible(x, y: Single; pen: TGPPen; g: TGPGraphics = nil): BOOL; + var + booln: BOOL; + nativeGraphics: GpGraphics; + nativePen: GpPen; + begin + booln := FALSE; + nativeGraphics := nil; + nativePen := nil; + if assigned(g) then nativeGraphics := g.nativeGraphics; + if assigned(pen) then nativePen := pen.nativePen; + SetStatus(GdipIsOutlineVisiblePathPoint(nativePath, x, y, nativePen, + nativeGraphics, booln)); + result := booln; + end; + + function TGPGraphicsPath.IsOutlineVisible(point: TGPPoint; pen: TGPPen; g: TGPGraphics = nil): BOOL; + begin + result := IsOutlineVisible(point.X, point.Y, pen, g); + end; + + function TGPGraphicsPath.IsOutlineVisible(x, y: Integer; pen: TGPPen; g: TGPGraphics = nil): BOOL; + var + booln: BOOL; + nativeGraphics: GpGraphics; + nativePen: GpPen; + begin + booln := FALSE; + nativeGraphics := nil; + nativePen := nil; + if assigned(g) then nativeGraphics := g.nativeGraphics; + if assigned(pen) then nativePen := pen.nativePen; + SetStatus(GdipIsOutlineVisiblePathPointI(nativePath, x, y, nativePen, + nativeGraphics, booln)); + result := booln; + end; + + constructor TGPGraphicsPath.Create(path: TGPGraphicsPath); + var clonepath: GpPath; + begin + clonepath := nil; + SetStatus(GdipClonePath(path.nativePath, clonepath)); + SetNativePath(clonepath); + end; + + constructor TGPGraphicsPath.Create(nativePath: GpPath); + begin + lastResult := Ok; + SetNativePath(nativePath); + end; + + procedure TGPGraphicsPath.SetNativePath(nativePath: GpPath); + begin + self.nativePath := nativePath; + end; + + function TGPGraphicsPath.SetStatus(status: TStatus): TStatus; + begin + if (status <> Ok) then LastResult := status; + result := status; + end; + +//-------------------------------------------------------------------------- +// GraphisPathIterator class +//-------------------------------------------------------------------------- + + constructor TGPGraphicsPathIterator.Create(path: TGPGraphicsPath); + var + nativePath: GpPath; + iter: GpPathIterator; + begin + nativePath := nil; + if assigned(path) then nativePath := path.nativePath; + iter := nil; + lastResult := GdipCreatePathIter(iter, nativePath); + SetNativeIterator(iter); + end; + + destructor TGPGraphicsPathIterator.Destroy; + begin + GdipDeletePathIter(nativeIterator); + end; + + + function TGPGraphicsPathIterator.NextSubpath(out startIndex, endIndex: Integer; out isClosed: bool): Integer; + begin + SetStatus(GdipPathIterNextSubpath(nativeIterator, result, startIndex, endIndex, isClosed)); + end; + + function TGPGraphicsPathIterator.NextSubpath(path: TGPGraphicsPath; out isClosed: BOOL): Integer; + var + nativePath: GpPath; + resultCount: Integer; + begin + nativePath := nil; + if assigned(path) then nativePath := path.nativePath; + SetStatus(GdipPathIterNextSubpathPath(nativeIterator, resultCount, + nativePath, isClosed)); + result := resultCount; + end; + + function TGPGraphicsPathIterator.NextPathType(out pathType: TPathPointType; out startIndex, endIndex: Integer): Integer; + var + resultCount: Integer; + begin + SetStatus(GdipPathIterNextPathType(nativeIterator, resultCount, @pathType, + startIndex, endIndex)); + result := resultCount; + end; + + function TGPGraphicsPathIterator.NextMarker(out startIndex, endIndex: Integer): Integer; + begin + SetStatus(GdipPathIterNextMarker(nativeIterator, result, startIndex, endIndex)); + end; + + function TGPGraphicsPathIterator.NextMarker(path: TGPGraphicsPath): Integer; + var nativePath: GpPath; + begin + nativePath := nil; + if assigned(path) then nativePath := path.nativePath; + SetStatus(GdipPathIterNextMarkerPath(nativeIterator, result, nativePath)); + end; + + function TGPGraphicsPathIterator.GetCount: Integer; + begin + SetStatus(GdipPathIterGetCount(nativeIterator, result)); + end; + + function TGPGraphicsPathIterator.GetSubpathCount: Integer; + begin + SetStatus(GdipPathIterGetSubpathCount(nativeIterator, result)); + end; + + function TGPGraphicsPathIterator.HasCurve: BOOL; + begin + SetStatus(GdipPathIterHasCurve(nativeIterator, result)); + end; + + procedure TGPGraphicsPathIterator.Rewind; + begin + SetStatus(GdipPathIterRewind(nativeIterator)); + end; + + function TGPGraphicsPathIterator.Enumerate(points: PGPPointF; types: PBYTE; + count: Integer): Integer; + begin + SetStatus(GdipPathIterEnumerate(nativeIterator, result, points, types, count)); + end; + + function TGPGraphicsPathIterator.CopyData(points: PGPPointF; types: PBYTE; + startIndex, endIndex: Integer): Integer; + begin + SetStatus(GdipPathIterCopyData(nativeIterator, result, points, types, + startIndex, endIndex)); + end; + + function TGPGraphicsPathIterator.GetLastStatus: TStatus; + begin + result := lastResult; + lastResult := Ok; + end; + + procedure TGPGraphicsPathIterator.SetNativeIterator(nativeIterator: GpPathIterator); + begin + self.nativeIterator := nativeIterator; + end; + + function TGPGraphicsPathIterator.SetStatus(status: TStatus): TStatus; + begin + if (status <> Ok) then lastResult := status; + result := status; + end; + +//-------------------------------------------------------------------------- +// Path Gradient Brush +//-------------------------------------------------------------------------- + + constructor TGPPathGradientBrush.Create(points: PGPPointF; count: Integer; wrapMode: TWrapMode = WrapModeClamp); + var brush: GpPathGradient; + begin + brush := nil; + lastResult := GdipCreatePathGradient(points, count, wrapMode, brush); + SetNativeBrush(brush); + end; + + constructor TGPPathGradientBrush.Create(points: PGPPoint; count: Integer; wrapMode: TWrapMode = WrapModeClamp); + var brush: GpPathGradient; + begin + brush := nil; + lastResult := GdipCreatePathGradientI(points, count, wrapMode, brush); + SetNativeBrush(brush); + end; + + constructor TGPPathGradientBrush.Create(path: TGPGraphicsPath); + var brush: GpPathGradient; + begin + brush := nil; + lastResult := GdipCreatePathGradientFromPath(path.nativePath, brush); + SetNativeBrush(brush); + end; + + function TGPPathGradientBrush.GetCenterColor(out Color: TGPColor): TStatus; + begin + SetStatus(GdipGetPathGradientCenterColor(GpPathGradient(nativeBrush), Color)); + result := lastResult; + end; + + function TGPPathGradientBrush.SetCenterColor(color: TGPColor): TStatus; + begin + SetStatus(GdipSetPathGradientCenterColor(GpPathGradient(nativeBrush),color)); + result := lastResult; + end; + + function TGPPathGradientBrush.GetPointCount: Integer; + begin + SetStatus(GdipGetPathGradientPointCount(GpPathGradient(nativeBrush), result)); + end; + + function TGPPathGradientBrush.GetSurroundColorCount: Integer; + begin + SetStatus(GdipGetPathGradientSurroundColorCount(GpPathGradient(nativeBrush), result)); + end; + + function TGPPathGradientBrush.GetSurroundColors(colors: PARGB; var count: Integer): TStatus; + var + count1: Integer; + begin + if not assigned(colors) then + begin + result := SetStatus(InvalidParameter); + exit; + end; + + SetStatus(GdipGetPathGradientSurroundColorCount(GpPathGradient(nativeBrush), count1)); + + if(lastResult <> Ok) then + begin + result := lastResult; + exit; + end; + + if((count < count1) or (count1 <= 0)) then + begin + result := SetStatus(InsufficientBuffer); + exit; + end; + + SetStatus(GdipGetPathGradientSurroundColorsWithCount(GpPathGradient(nativeBrush), colors, count1)); + if(lastResult = Ok) then + count := count1; + + result := lastResult; + end; + + function TGPPathGradientBrush.SetSurroundColors(colors: PARGB; var count: Integer): TStatus; + var + count1: Integer; + type + TDynArrDWORD = array of DWORD; + begin + if (colors = nil) then + begin + result := SetStatus(InvalidParameter); + exit; + end; + + count1 := GetPointCount; + + if((count > count1) or (count1 <= 0)) then + begin + result := SetStatus(InvalidParameter); + exit; + end; + + count1 := count; + + SetStatus(GdipSetPathGradientSurroundColorsWithCount( + GpPathGradient(nativeBrush), colors, count1)); + + if(lastResult = Ok) then count := count1; + result := lastResult; + end; + + function TGPPathGradientBrush.GetGraphicsPath(path: TGPGraphicsPath): TStatus; + begin + if(path = nil) then + begin + result := SetStatus(InvalidParameter); + exit; + end; + result := SetStatus(GdipGetPathGradientPath(GpPathGradient(nativeBrush), path.nativePath)); + end; + + function TGPPathGradientBrush.SetGraphicsPath(path: TGPGraphicsPath): TStatus; + begin + if(path = nil) then + begin + result := SetStatus(InvalidParameter); + exit; + end; + result := SetStatus(GdipSetPathGradientPath(GpPathGradient(nativeBrush), path.nativePath)); + end; + + function TGPPathGradientBrush.GetCenterPoint(out point: TGPPointF): TStatus; + begin + result := SetStatus(GdipGetPathGradientCenterPoint(GpPathGradient(nativeBrush), @point)); + end; + + function TGPPathGradientBrush.GetCenterPoint(out point: TGPPoint): TStatus; + begin + result := SetStatus(GdipGetPathGradientCenterPointI(GpPathGradient(nativeBrush), @point)); + end; + + function TGPPathGradientBrush.SetCenterPoint(point: TGPPointF): TStatus; + begin + result := SetStatus(GdipSetPathGradientCenterPoint(GpPathGradient(nativeBrush), @point)); + end; + + function TGPPathGradientBrush.SetCenterPoint(point: TGPPoint): TStatus; + begin + result := SetStatus(GdipSetPathGradientCenterPointI(GpPathGradient(nativeBrush), @point)); + end; + + function TGPPathGradientBrush.GetRectangle(out rect: TGPRectF): TStatus; + begin + result := SetStatus(GdipGetPathGradientRect(GpPathGradient(nativeBrush), @rect)); + end; + + function TGPPathGradientBrush.GetRectangle(out rect: TGPRect): TStatus; + begin + result := SetStatus(GdipGetPathGradientRectI(GpPathGradient(nativeBrush), @rect)); + end; + + function TGPPathGradientBrush.SetGammaCorrection(useGammaCorrection: BOOL): TStatus; + begin + result := SetStatus(GdipSetPathGradientGammaCorrection(GpPathGradient(nativeBrush), + useGammaCorrection)); + end; + + function TGPPathGradientBrush.GetGammaCorrection: BOOL; + begin + SetStatus(GdipGetPathGradientGammaCorrection(GpPathGradient(nativeBrush), result)); + end; + + function TGPPathGradientBrush.GetBlendCount: Integer; + var count: Integer; + begin + count := 0; + SetStatus(GdipGetPathGradientBlendCount(GpPathGradient(nativeBrush), count)); + result := count; + end; + + function TGPPathGradientBrush.GetBlend(blendFactors, blendPositions:PSingle; count: Integer): TStatus; + begin + result := SetStatus(GdipGetPathGradientBlend( + GpPathGradient(nativeBrush), + blendFactors, blendPositions, count)); + end; + + function TGPPathGradientBrush.SetBlend(blendFactors, blendPositions: PSingle; count: Integer): TStatus; + begin + result := SetStatus(GdipSetPathGradientBlend( + GpPathGradient(nativeBrush), + blendFactors, blendPositions, count)); + end; + + function TGPPathGradientBrush.GetInterpolationColorCount: Integer; + var count: Integer; + begin + count := 0; + SetStatus(GdipGetPathGradientPresetBlendCount(GpPathGradient(nativeBrush), count)); + result := count; + end; + + function TGPPathGradientBrush.SetInterpolationColors(presetColors: PARGB; + blendPositions: PSingle; count: Integer): TStatus; + var + status: TStatus; + begin + if ((count <= 0) or (presetColors = nil)) then + begin + result := SetStatus(InvalidParameter); + exit; + end; + + status := SetStatus(GdipSetPathGradientPresetBlend(GpPathGradient(nativeBrush), + presetColors, blendPositions, count)); + result := status; + end; + + function TGPPathGradientBrush.GetInterpolationColors(presetColors: PARGB; + blendPositions: PSingle; count: Integer): TStatus; + var + status: GpStatus; + i: Integer; + argbs: PARGB; + begin + if ((count <= 0) or (presetColors = nil)) then + begin + result := SetStatus(InvalidParameter); + exit; + end; + getmem(argbs, count*SizeOf(ARGB)); + if (argbs = nil) then + begin + result := SetStatus(OutOfMemory); + exit; + end; + + status := SetStatus(GdipGetPathGradientPresetBlend(nativeBrush, argbs, + blendPositions, count)); + + for i := 0 to count - 1 do + TColorDynArray(presetColors)[i] := TColorDynArray(argbs)[i]; + + freemem(argbs); + + result := status; + end; + + function TGPPathGradientBrush.SetBlendBellShape(focus: Single; scale: Single = 1.0): TStatus; + begin + result := SetStatus(GdipSetPathGradientSigmaBlend(GpPathGradient(nativeBrush), focus, scale)); + end; + + function TGPPathGradientBrush.SetBlendTriangularShape(focus: Single; scale: Single = 1.0): TStatus; + begin + result := SetStatus(GdipSetPathGradientLinearBlend(GpPathGradient(nativeBrush), focus, scale)); + end; + + function TGPPathGradientBrush.GetTransform(matrix: TGPMatrix): TStatus; + begin + result := SetStatus(GdipGetPathGradientTransform(GpPathGradient(nativeBrush), + matrix.nativeMatrix)); + end; + + function TGPPathGradientBrush.SetTransform(matrix: TGPMatrix): TStatus; + begin + result := SetStatus(GdipSetPathGradientTransform( + GpPathGradient(nativeBrush), + matrix.nativeMatrix)); + end; + + function TGPPathGradientBrush.ResetTransform: TStatus; + begin + result := SetStatus(GdipResetPathGradientTransform( + GpPathGradient(nativeBrush))); + end; + + function TGPPathGradientBrush.MultiplyTransform(matrix: TGPMatrix; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipMultiplyPathGradientTransform( + GpPathGradient(nativeBrush), + matrix.nativeMatrix, + order)); + end; + + function TGPPathGradientBrush.TranslateTransform(dx, dy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipTranslatePathGradientTransform( + GpPathGradient(nativeBrush), + dx, dy, order)); + end; + + function TGPPathGradientBrush.ScaleTransform(sx, sy: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipScalePathGradientTransform( + GpPathGradient(nativeBrush), + sx, sy, order)); + end; + + function TGPPathGradientBrush.RotateTransform(angle: Single; order: TMatrixOrder = MatrixOrderPrepend): TStatus; + begin + result := SetStatus(GdipRotatePathGradientTransform( + GpPathGradient(nativeBrush), + angle, order)); + end; + + function TGPPathGradientBrush.GetFocusScales(out xScale, yScale: Single): TStatus; + begin + result := SetStatus(GdipGetPathGradientFocusScales( + GpPathGradient(nativeBrush), xScale, yScale)); + end; + + function TGPPathGradientBrush.SetFocusScales(xScale, yScale: Single): TStatus; + begin + result := SetStatus(GdipSetPathGradientFocusScales( + GpPathGradient(nativeBrush), xScale, yScale)); + end; + + function TGPPathGradientBrush.GetWrapMode: TWrapMode; + begin + SetStatus(GdipGetPathGradientWrapMode(GpPathGradient(nativeBrush), result)); + end; + + function TGPPathGradientBrush.SetWrapMode(wrapMode: TWrapMode): TStatus; + begin + result := SetStatus(GdipSetPathGradientWrapMode( + GpPathGradient(nativeBrush), wrapMode)); + end; + + constructor TGPPathGradientBrush.Create; + begin + // �crase la fonction parent + end; + +initialization +begin + // Initialize StartupInput structure + StartupInput.DebugEventCallback := nil; + StartupInput.SuppressBackgroundThread := False; + StartupInput.SuppressExternalCodecs := False; + StartupInput.GdiplusVersion := 1; + // Initialize GDI+ + GdiplusStartup(gdiplusToken, @StartupInput, nil); + +end; + +finalization +begin + + if assigned(GenericSansSerifFontFamily) then GenericSansSerifFontFamily.Free; + if assigned(GenericSerifFontFamily) then GenericSerifFontFamily.Free; + if assigned(GenericMonospaceFontFamily) then GenericMonospaceFontFamily.Free; + + if assigned(GenericTypographicStringFormatBuffer) then GenericTypographicStringFormatBuffer.free; + if assigned(GenericDefaultStringFormatBuffer) then GenericDefaultStringFormatBuffer.Free; + + // Close GDI + + GdiplusShutdown(gdiplusToken); +end; + +end. diff --git a/thirparty/GDIPUTIL.pas b/thirparty/GDIPUTIL.pas new file mode 100644 index 0000000..664aa61 --- /dev/null +++ b/thirparty/GDIPUTIL.pas @@ -0,0 +1,378 @@ + {******************************************************************} + { GDI+ Util } + { } + { 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 rkGDIPUTIL; + +interface +uses + Windows, + rkGDIPAPI, + rkGDIPOBJ; + +function ValueTypeFromULONG(Type_: ULONG): String; +function GetMetaDataIDString(id: ULONG): string; +function GetEncoderClsid(format: String; out pClsid: TGUID): integer; +function GetStatus(Stat: TStatus): string; +function PixelFormatString(PixelFormat: TPixelFormat): string; + +{from WinNT.h} +// creates a language identifier from a primary language identifier and a +// sublanguage identifier for the TStringFormat & TFontFamily class. +function MakeLangID(PrimaryLanguage, SubLanguage: LANGID): WORD; + +implementation + +function ValueTypeFromULONG(Type_: ULONG): String; +begin + case Type_ of + 0 : result := 'Nothing'; + 1 : result := 'PropertyTagTypeByte'; + 2 : result := 'PropertyTagTypeASCII'; + 3 : result := 'PropertyTagTypeShort'; + 4 : result := 'PropertyTagTypeLong'; + 5 : result := 'PropertyTagTypeRational'; + 6 : result := 'Nothing'; + 7 : result := 'PropertyTagTypeUndefined'; + 8 : result := 'Nothing'; + 9 : result := 'PropertyTagTypeSLONG'; + 10: result := 'PropertyTagTypeSRational'; + else + result := ''; + end; +end; + +function GetMetaDataIDString(id: ULONG): string; +begin + case id of + PropertyTagExifIFD : result := 'PropertyTagExifIFD'; + PropertyTagGpsIFD : result := 'PropertyTagGpsIFD'; + PropertyTagNewSubfileType : result := 'PropertyTagNewSubfileType'; + PropertyTagSubfileType : result := 'PropertyTagSubfileType'; + PropertyTagImageWidth : result := 'PropertyTagImageWidth'; + PropertyTagImageHeight : result := 'PropertyTagImageHeight'; + PropertyTagBitsPerSample : result := 'PropertyTagBitsPerSample'; + PropertyTagCompression : result := 'PropertyTagCompression'; + PropertyTagPhotometricInterp : result := 'PropertyTagPhotometricInterp'; + PropertyTagThreshHolding : result := 'PropertyTagThreshHolding'; + PropertyTagCellWidth : result := 'PropertyTagCellWidth'; + PropertyTagCellHeight : result := 'PropertyTagCellHeight'; + PropertyTagFillOrder : result := 'PropertyTagFillOrder'; + PropertyTagDocumentName : result := 'PropertyTagDocumentName'; + PropertyTagImageDescription : result := 'PropertyTagImageDescription'; + PropertyTagEquipMake : result := 'PropertyTagEquipMake'; + PropertyTagEquipModel : result := 'PropertyTagEquipModel'; + PropertyTagStripOffsets : result := 'PropertyTagStripOffsets'; + PropertyTagOrientation : result := 'PropertyTagOrientation'; + PropertyTagSamplesPerPixel : result := 'PropertyTagSamplesPerPixel'; + PropertyTagRowsPerStrip : result := 'PropertyTagRowsPerStrip'; + PropertyTagStripBytesCount : result := 'PropertyTagStripBytesCount'; + PropertyTagMinSampleValue : result := 'PropertyTagMinSampleValue'; + PropertyTagMaxSampleValue : result := 'PropertyTagMaxSampleValue'; + PropertyTagXResolution : result := 'PropertyTagXResolution'; + PropertyTagYResolution : result := 'PropertyTagYResolution'; + PropertyTagPlanarConfig : result := 'PropertyTagPlanarConfig'; + PropertyTagPageName : result := 'PropertyTagPageName'; + PropertyTagXPosition : result := 'PropertyTagXPosition'; + PropertyTagYPosition : result := 'PropertyTagYPosition'; + PropertyTagFreeOffset : result := 'PropertyTagFreeOffset'; + PropertyTagFreeByteCounts : result := 'PropertyTagFreeByteCounts'; + PropertyTagGrayResponseUnit : result := 'PropertyTagGrayResponseUnit'; + PropertyTagGrayResponseCurve : result := 'PropertyTagGrayResponseCurve'; + PropertyTagT4Option : result := 'PropertyTagT4Option'; + PropertyTagT6Option : result := 'PropertyTagT6Option'; + PropertyTagResolutionUnit : result := 'PropertyTagResolutionUnit'; + PropertyTagPageNumber : result := 'PropertyTagPageNumber'; + PropertyTagTransferFuncition : result := 'PropertyTagTransferFuncition'; + PropertyTagSoftwareUsed : result := 'PropertyTagSoftwareUsed'; + PropertyTagDateTime : result := 'PropertyTagDateTime'; + PropertyTagArtist : result := 'PropertyTagArtist'; + PropertyTagHostComputer : result := 'PropertyTagHostComputer'; + PropertyTagPredictor : result := 'PropertyTagPredictor'; + PropertyTagWhitePoint : result := 'PropertyTagWhitePoint'; + PropertyTagPrimaryChromaticities : result := 'PropertyTagPrimaryChromaticities'; + PropertyTagColorMap : result := 'PropertyTagColorMap'; + PropertyTagHalftoneHints : result := 'PropertyTagHalftoneHints'; + PropertyTagTileWidth : result := 'PropertyTagTileWidth'; + PropertyTagTileLength : result := 'PropertyTagTileLength'; + PropertyTagTileOffset : result := 'PropertyTagTileOffset'; + PropertyTagTileByteCounts : result := 'PropertyTagTileByteCounts'; + PropertyTagInkSet : result := 'PropertyTagInkSet'; + PropertyTagInkNames : result := 'PropertyTagInkNames'; + PropertyTagNumberOfInks : result := 'PropertyTagNumberOfInks'; + PropertyTagDotRange : result := 'PropertyTagDotRange'; + PropertyTagTargetPrinter : result := 'PropertyTagTargetPrinter'; + PropertyTagExtraSamples : result := 'PropertyTagExtraSamples'; + PropertyTagSampleFormat : result := 'PropertyTagSampleFormat'; + PropertyTagSMinSampleValue : result := 'PropertyTagSMinSampleValue'; + PropertyTagSMaxSampleValue : result := 'PropertyTagSMaxSampleValue'; + PropertyTagTransferRange : result := 'PropertyTagTransferRange'; + PropertyTagJPEGProc : result := 'PropertyTagJPEGProc'; + PropertyTagJPEGInterFormat : result := 'PropertyTagJPEGInterFormat'; + PropertyTagJPEGInterLength : result := 'PropertyTagJPEGInterLength'; + PropertyTagJPEGRestartInterval : result := 'PropertyTagJPEGRestartInterval'; + PropertyTagJPEGLosslessPredictors : result := 'PropertyTagJPEGLosslessPredictors'; + PropertyTagJPEGPointTransforms : result := 'PropertyTagJPEGPointTransforms'; + PropertyTagJPEGQTables : result := 'PropertyTagJPEGQTables'; + PropertyTagJPEGDCTables : result := 'PropertyTagJPEGDCTables'; + PropertyTagJPEGACTables : result := 'PropertyTagJPEGACTables'; + PropertyTagYCbCrCoefficients : result := 'PropertyTagYCbCrCoefficients'; + PropertyTagYCbCrSubsampling : result := 'PropertyTagYCbCrSubsampling'; + PropertyTagYCbCrPositioning : result := 'PropertyTagYCbCrPositioning'; + PropertyTagREFBlackWhite : result := 'PropertyTagREFBlackWhite'; + PropertyTagICCProfile : result := 'PropertyTagICCProfile'; + PropertyTagGamma : result := 'PropertyTagGamma'; + PropertyTagICCProfileDescriptor : result := 'PropertyTagICCProfileDescriptor'; + PropertyTagSRGBRenderingIntent : result := 'PropertyTagSRGBRenderingIntent'; + PropertyTagImageTitle : result := 'PropertyTagImageTitle'; + PropertyTagCopyright : result := 'PropertyTagCopyright'; + PropertyTagResolutionXUnit : result := 'PropertyTagResolutionXUnit'; + PropertyTagResolutionYUnit : result := 'PropertyTagResolutionYUnit'; + PropertyTagResolutionXLengthUnit : result := 'PropertyTagResolutionXLengthUnit'; + PropertyTagResolutionYLengthUnit : result := 'PropertyTagResolutionYLengthUnit'; + PropertyTagPrintFlags : result := 'PropertyTagPrintFlags'; + PropertyTagPrintFlagsVersion : result := 'PropertyTagPrintFlagsVersion'; + PropertyTagPrintFlagsCrop : result := 'PropertyTagPrintFlagsCrop'; + PropertyTagPrintFlagsBleedWidth : result := 'PropertyTagPrintFlagsBleedWidth'; + PropertyTagPrintFlagsBleedWidthScale : result := 'PropertyTagPrintFlagsBleedWidthScale'; + PropertyTagHalftoneLPI : result := 'PropertyTagHalftoneLPI'; + PropertyTagHalftoneLPIUnit : result := 'PropertyTagHalftoneLPIUnit'; + PropertyTagHalftoneDegree : result := 'PropertyTagHalftoneDegree'; + PropertyTagHalftoneShape : result := 'PropertyTagHalftoneShape'; + PropertyTagHalftoneMisc : result := 'PropertyTagHalftoneMisc'; + PropertyTagHalftoneScreen : result := 'PropertyTagHalftoneScreen'; + PropertyTagJPEGQuality : result := 'PropertyTagJPEGQuality'; + PropertyTagGridSize : result := 'PropertyTagGridSize'; + PropertyTagThumbnailFormat : result := 'PropertyTagThumbnailFormat'; + PropertyTagThumbnailWidth : result := 'PropertyTagThumbnailWidth'; + PropertyTagThumbnailHeight : result := 'PropertyTagThumbnailHeight'; + PropertyTagThumbnailColorDepth : result := 'PropertyTagThumbnailColorDepth'; + PropertyTagThumbnailPlanes : result := 'PropertyTagThumbnailPlanes'; + PropertyTagThumbnailRawBytes : result := 'PropertyTagThumbnailRawBytes'; + PropertyTagThumbnailSize : result := 'PropertyTagThumbnailSize'; + PropertyTagThumbnailCompressedSize : result := 'PropertyTagThumbnailCompressedSize'; + PropertyTagColorTransferFunction : result := 'PropertyTagColorTransferFunction'; + PropertyTagThumbnailData : result := 'PropertyTagThumbnailData'; + PropertyTagThumbnailImageWidth : result := 'PropertyTagThumbnailImageWidth'; + PropertyTagThumbnailImageHeight : result := 'PropertyTagThumbnailImageHeight'; + PropertyTagThumbnailBitsPerSample : result := 'PropertyTagThumbnailBitsPerSample'; + PropertyTagThumbnailCompression : result := 'PropertyTagThumbnailCompression'; + PropertyTagThumbnailPhotometricInterp : result := 'PropertyTagThumbnailPhotometricInterp'; + PropertyTagThumbnailImageDescription : result := 'PropertyTagThumbnailImageDescription'; + PropertyTagThumbnailEquipMake : result := 'PropertyTagThumbnailEquipMake'; + PropertyTagThumbnailEquipModel : result := 'PropertyTagThumbnailEquipModel'; + PropertyTagThumbnailStripOffsets : result := 'PropertyTagThumbnailStripOffsets'; + PropertyTagThumbnailOrientation : result := 'PropertyTagThumbnailOrientation'; + PropertyTagThumbnailSamplesPerPixel : result := 'PropertyTagThumbnailSamplesPerPixel'; + PropertyTagThumbnailRowsPerStrip : result := 'PropertyTagThumbnailRowsPerStrip'; + PropertyTagThumbnailStripBytesCount : result := 'PropertyTagThumbnailStripBytesCount'; + PropertyTagThumbnailResolutionX : result := 'PropertyTagThumbnailResolutionX'; + PropertyTagThumbnailResolutionY : result := 'PropertyTagThumbnailResolutionY'; + PropertyTagThumbnailPlanarConfig : result := 'PropertyTagThumbnailPlanarConfig'; + PropertyTagThumbnailResolutionUnit : result := 'PropertyTagThumbnailResolutionUnit'; + PropertyTagThumbnailTransferFunction : result := 'PropertyTagThumbnailTransferFunction'; + PropertyTagThumbnailSoftwareUsed : result := 'PropertyTagThumbnailSoftwareUsed'; + PropertyTagThumbnailDateTime : result := 'PropertyTagThumbnailDateTime'; + PropertyTagThumbnailArtist : result := 'PropertyTagThumbnailArtist'; + PropertyTagThumbnailWhitePoint : result := 'PropertyTagThumbnailWhitePoint'; + PropertyTagThumbnailPrimaryChromaticities : result := 'PropertyTagThumbnailPrimaryChromaticities'; + PropertyTagThumbnailYCbCrCoefficients : result := 'PropertyTagThumbnailYCbCrCoefficients'; + PropertyTagThumbnailYCbCrSubsampling : result := 'PropertyTagThumbnailYCbCrSubsampling'; + PropertyTagThumbnailYCbCrPositioning : result := 'PropertyTagThumbnailYCbCrPositioning'; + PropertyTagThumbnailRefBlackWhite : result := 'PropertyTagThumbnailRefBlackWhite'; + PropertyTagThumbnailCopyRight : result := 'PropertyTagThumbnailCopyRight'; + PropertyTagLuminanceTable : result := 'PropertyTagLuminanceTable'; + PropertyTagChrominanceTable : result := 'PropertyTagChrominanceTable'; + PropertyTagFrameDelay : result := 'PropertyTagFrameDelay'; + PropertyTagLoopCount : result := 'PropertyTagLoopCount'; + PropertyTagPixelUnit : result := 'PropertyTagPixelUnit'; + PropertyTagPixelPerUnitX : result := 'PropertyTagPixelPerUnitX'; + PropertyTagPixelPerUnitY : result := 'PropertyTagPixelPerUnitY'; + PropertyTagPaletteHistogram : result := 'PropertyTagPaletteHistogram'; + PropertyTagExifExposureTime : result := 'PropertyTagExifExposureTime'; + PropertyTagExifFNumber : result := 'PropertyTagExifFNumber'; + PropertyTagExifExposureProg : result := 'PropertyTagExifExposureProg'; + PropertyTagExifSpectralSense : result := 'PropertyTagExifSpectralSense'; + PropertyTagExifISOSpeed : result := 'PropertyTagExifISOSpeed'; + PropertyTagExifOECF : result := 'PropertyTagExifOECF'; + PropertyTagExifVer : result := 'PropertyTagExifVer'; + PropertyTagExifDTOrig : result := 'PropertyTagExifDTOrig'; + PropertyTagExifDTDigitized : result := 'PropertyTagExifDTDigitized'; + PropertyTagExifCompConfig : result := 'PropertyTagExifCompConfig'; + PropertyTagExifCompBPP : result := 'PropertyTagExifCompBPP'; + PropertyTagExifShutterSpeed : result := 'PropertyTagExifShutterSpeed'; + PropertyTagExifAperture : result := 'PropertyTagExifAperture'; + PropertyTagExifBrightness : result := 'PropertyTagExifBrightness'; + PropertyTagExifExposureBias : result := 'PropertyTagExifExposureBias'; + PropertyTagExifMaxAperture : result := 'PropertyTagExifMaxAperture'; + PropertyTagExifSubjectDist : result := 'PropertyTagExifSubjectDist'; + PropertyTagExifMeteringMode : result := 'PropertyTagExifMeteringMode'; + PropertyTagExifLightSource : result := 'PropertyTagExifLightSource'; + PropertyTagExifFlash : result := 'PropertyTagExifFlash'; + PropertyTagExifFocalLength : result := 'PropertyTagExifFocalLength'; + PropertyTagExifMakerNote : result := 'PropertyTagExifMakerNote'; + PropertyTagExifUserComment : result := 'PropertyTagExifUserComment'; + PropertyTagExifDTSubsec : result := 'PropertyTagExifDTSubsec'; + PropertyTagExifDTOrigSS : result := 'PropertyTagExifDTOrigSS'; + PropertyTagExifDTDigSS : result := 'PropertyTagExifDTDigSS'; + PropertyTagExifFPXVer : result := 'PropertyTagExifFPXVer'; + PropertyTagExifColorSpace : result := 'PropertyTagExifColorSpace'; + PropertyTagExifPixXDim : result := 'PropertyTagExifPixXDim'; + PropertyTagExifPixYDim : result := 'PropertyTagExifPixYDim'; + PropertyTagExifRelatedWav : result := 'PropertyTagExifRelatedWav'; + PropertyTagExifInterop : result := 'PropertyTagExifInterop'; + PropertyTagExifFlashEnergy : result := 'PropertyTagExifFlashEnergy'; + PropertyTagExifSpatialFR : result := 'PropertyTagExifSpatialFR'; + PropertyTagExifFocalXRes : result := 'PropertyTagExifFocalXRes'; + PropertyTagExifFocalYRes : result := 'PropertyTagExifFocalYRes'; + PropertyTagExifFocalResUnit : result := 'PropertyTagExifFocalResUnit'; + PropertyTagExifSubjectLoc : result := 'PropertyTagExifSubjectLoc'; + PropertyTagExifExposureIndex : result := 'PropertyTagExifExposureIndex'; + PropertyTagExifSensingMethod : result := 'PropertyTagExifSensingMethod'; + PropertyTagExifFileSource : result := 'PropertyTagExifFileSource'; + PropertyTagExifSceneType : result := 'PropertyTagExifSceneType'; + PropertyTagExifCfaPattern : result := 'PropertyTagExifCfaPattern'; + PropertyTagGpsVer : result := 'PropertyTagGpsVer'; + PropertyTagGpsLatitudeRef : result := 'PropertyTagGpsLatitudeRef'; + PropertyTagGpsLatitude : result := 'PropertyTagGpsLatitude'; + PropertyTagGpsLongitudeRef : result := 'PropertyTagGpsLongitudeRef'; + PropertyTagGpsLongitude : result := 'PropertyTagGpsLongitude'; + PropertyTagGpsAltitudeRef : result := 'PropertyTagGpsAltitudeRef'; + PropertyTagGpsAltitude : result := 'PropertyTagGpsAltitude'; + PropertyTagGpsGpsTime : result := 'PropertyTagGpsGpsTime'; + PropertyTagGpsGpsSatellites : result := 'PropertyTagGpsGpsSatellites'; + PropertyTagGpsGpsStatus : result := 'PropertyTagGpsGpsStatus'; + PropertyTagGpsGpsMeasureMode : result := 'PropertyTagGpsGpsMeasureMode'; + PropertyTagGpsGpsDop : result := 'PropertyTagGpsGpsDop'; + PropertyTagGpsSpeedRef : result := 'PropertyTagGpsSpeedRef'; + PropertyTagGpsSpeed : result := 'PropertyTagGpsSpeed'; + PropertyTagGpsTrackRef : result := 'PropertyTagGpsTrackRef'; + PropertyTagGpsTrack : result := 'PropertyTagGpsTrack'; + PropertyTagGpsImgDirRef : result := 'PropertyTagGpsImgDirRef'; + PropertyTagGpsImgDir : result := 'PropertyTagGpsImgDir'; + PropertyTagGpsMapDatum : result := 'PropertyTagGpsMapDatum'; + PropertyTagGpsDestLatRef : result := 'PropertyTagGpsDestLatRef'; + PropertyTagGpsDestLat : result := 'PropertyTagGpsDestLat'; + PropertyTagGpsDestLongRef : result := 'PropertyTagGpsDestLongRef'; + PropertyTagGpsDestLong : result := 'PropertyTagGpsDestLong'; + PropertyTagGpsDestBearRef : result := 'PropertyTagGpsDestBearRef'; + PropertyTagGpsDestBear : result := 'PropertyTagGpsDestBear'; + PropertyTagGpsDestDistRef : result := 'PropertyTagGpsDestDistRef'; + PropertyTagGpsDestDist : result := 'PropertyTagGpsDestDist'; + else + result := ''; + end; +end; + +function GetEncoderClsid(format: String; out pClsid: TGUID): integer; +var + num, size, j: UINT; + ImageCodecInfo: PImageCodecInfo; +Type + ArrIMgInf = array of TImageCodecInfo; +begin + num := 0; // number of image encoders + size := 0; // size of the image encoder array in bytes + result := -1; + + GetImageEncodersSize(num, size); + if (size = 0) then exit; + + GetMem(ImageCodecInfo, size); + if(ImageCodecInfo = nil) then exit; + + GetImageEncoders(num, size, ImageCodecInfo); + + for j := 0 to num - 1 do + begin + if( ArrIMgInf(ImageCodecInfo)[j].MimeType = format) then + begin + pClsid := ArrIMgInf(ImageCodecInfo)[j].Clsid; + result := j; // Success + end; + end; + FreeMem(ImageCodecInfo, size); +end; + +function GetStatus(Stat: TStatus): string; +begin + case Stat of + Ok : result := 'Ok'; + GenericError : result := 'GenericError'; + InvalidParameter : result := 'InvalidParameter'; + OutOfMemory : result := 'OutOfMemory'; + ObjectBusy : result := 'ObjectBusy'; + InsufficientBuffer : result := 'InsufficientBuffer'; + NotImplemented : result := 'NotImplemented'; + Win32Error : result := 'Win32Error'; + WrongState : result := 'WrongState'; + Aborted : result := 'Aborted'; + FileNotFound : result := 'FileNotFound'; + ValueOverflow : result := 'ValueOverflow'; + AccessDenied : result := 'AccessDenied'; + UnknownImageFormat : result := 'UnknownImageFormat'; + FontFamilyNotFound : result := 'FontFamilyNotFound'; + FontStyleNotFound : result := 'FontStyleNotFound'; + NotTrueTypeFont : result := 'NotTrueTypeFont'; + UnsupportedGdiplusVersion : result := 'UnsupportedGdiplusVersion'; + GdiplusNotInitialized : result := 'GdiplusNotInitialized'; + PropertyNotFound : result := 'PropertyNotFound'; + PropertyNotSupported : result := 'PropertyNotSupported'; + else + result := ''; + end; +end; + +function PixelFormatString(PixelFormat: TPixelFormat): string; +begin + case PixelFormat of + PixelFormatIndexed : result := 'PixelFormatIndexed'; + PixelFormatGDI : result := 'PixelFormatGDI'; + PixelFormatAlpha : result := 'PixelFormatAlpha'; + PixelFormatPAlpha : result := 'PixelFormatPAlpha'; + PixelFormatExtended : result := 'PixelFormatExtended'; + PixelFormatCanonical : result := 'PixelFormatCanonical'; + PixelFormatUndefined : result := 'PixelFormatUndefined'; + PixelFormat1bppIndexed : result := 'PixelFormat1bppIndexed'; + PixelFormat4bppIndexed : result := 'PixelFormat4bppIndexed'; + PixelFormat8bppIndexed : result := 'PixelFormat8bppIndexed'; + PixelFormat16bppGrayScale : result := 'PixelFormat16bppGrayScale'; + PixelFormat16bppRGB555 : result := 'PixelFormat16bppRGB555'; + PixelFormat16bppRGB565 : result := 'PixelFormat16bppRGB565'; + PixelFormat16bppARGB1555 : result := 'PixelFormat16bppARGB1555'; + PixelFormat24bppRGB : result := 'PixelFormat24bppRGB'; + PixelFormat32bppRGB : result := 'PixelFormat32bppRGB'; + PixelFormat32bppARGB : result := 'PixelFormat32bppARGB'; + PixelFormat32bppPARGB : result := 'PixelFormat32bppPARGB'; + PixelFormat48bppRGB : result := 'PixelFormat48bppRGB'; + PixelFormat64bppARGB : result := 'PixelFormat64bppARGB'; + PixelFormat64bppPARGB : result := 'PixelFormat64bppPARGB'; + PixelFormatMax : result := 'PixelFormatMax'; + else + result := ''; + end; +end; + +function MakeLangID(PrimaryLanguage, SubLanguage: LANGID): Word; +begin + result := (SubLanguage shl 10) or PrimaryLanguage; +end; + +end. diff --git a/thirparty/VirtualDesktopAPI.pas b/thirparty/VirtualDesktopAPI.pas new file mode 100644 index 0000000..9f9d85c --- /dev/null +++ b/thirparty/VirtualDesktopAPI.pas @@ -0,0 +1,374 @@ +// Translated by Alexey Andriukhin (dr. F.I.N.) http://www.delphisources.ru/forum/member.php?u=9721 +// Tested on Win10 x32 (build 14393), Delphi7 +// +// Great thanks: +// Caintic - https://github.com/Ciantic/VirtualDesktopAccessor +// NikoTin - http://www.cyberforum.ru/blogs/105416/blog3671.html +// Grabacr07 - https://github.com/Grabacr07/VirtualDesktop +// jlubea - https://github.com/jlubea/VirtualDesktop +{ + CHANGELOG: + 2023-04-07 + - Fixed error that caused Windows explorer to restart by adding to W11 GetAllCurrentDesktops + 2022-05-26: + - Updated IVirtualDesktop to include hstring functions + TODO : handle those hstring + - CLSID_VirtualDesktopAPI_Unknown corrected name to CLSID_VirtualDesktopManagerInternal +} + +unit VirtualDesktopAPI; + +interface + +uses + Windows;//, UITypes, Winapi.Winrt {HSTRING}; + +const + EMPTY_GUID: TGUID = '{00000000-0000-0000-0000-000000000000}'; + +const + CLSID_ImmersiveShell: TGUID = '{C2F03A33-21F5-47FA-B4BB-156362A2F239}'; + IID_ServiceProvider: TGUID = '{6D5140C1-7436-11CE-8034-00AA006009FA}'; +// + CLSID_ApplicationViewCollection: TGUID = '{1841C6D7-4F9D-42C0-AF41-8747538F10E5}'; // <--- CLSID same as IID? not shure, but it's works + IID_ApplicationViewCollection: TGUID = '{1841C6D7-4F9D-42C0-AF41-8747538F10E5}'; + IID_ApplicationViewCollectionW11: TGUID = '{1841C6D7-4F9D-42C0-AF41-8747538F10E5}'; +// + IID_ApplicationView: TGUID = '{9AC0B5C8-1484-4C5B-9533-4134A0F97CEA}'; + IID_ApplicationViewW11: TGUID = '{372e1d3b-38d3-42e4-a15b-8ab2b178f513}'; +// + CLSID_VirtualDesktopManager: TGUID = '{AA509086-5CA9-4C25-8F95-589D3C07B48A}'; + IID_VirtualDesktopManager: TGUID = '{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}'; +// +// CLSID_VirtualDesktopAPI_Unknown: TGUID = '{C5E0CDCA-7B6E-41B2-9FC4-D93975CC467B}'; + CLSID_VirtualDesktopManagerInternal: TGUID = '{C5E0CDCA-7B6E-41B2-9FC4-D93975CC467B}'; + IID_VirtualDesktopManagerInternal_14393: TGUID = '{F31574D6-B682-4CDC-BD56-1827860ABEC6}'; // build 14393 or later + IID_VirtualDesktopManagerInternal_10240: TGUID = '{AF8DA486-95BB-4460-B3B7-6E7A6B2962B5}'; // build 10240 or later + IID_VirtualDesktopManagerInternal_10130: TGUID = '{EF9F1A6C-D3CC-4358-B712-F84B635BEBE7}'; // build 10130 or later + IID_VirtualDesktopManagerInternal_22000: TGUID = '{B2F925B9-5A0F-4D2E-9F4D-2B1507593C10}'; // build 22000 or later + IID_VirtualDesktopManagerInternal_22621: TGUID = '{A3175F2D-239C-4BD2-8AA0-EEBA8B0B138E}'; // build 22621 or later + IID_VirtualDesktopManagerInternal_22631: TGUID = '{4970BA3D-FD4E-4647-BEA3-D89076EF4B9C}'; // build 22631 or later +// + IID_VirtualDesktop: TGUID = '{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4}'; + IID_VirtualDesktopW11: TGUID = '{536d3495-b208-4cc9-ae26-de8111275bf8}'; +// + CLSID_VirtualNotificationService: TGUID = '{A501FDEC-4A09-464C-AE4E-1B9C21B84918}'; + IID_VirtualNotificationService: TGUID = '{0CD45E71-D927-4F15-8B0A-8FEF525337BF}'; +// + IID_VirtualDesktopNotification: TGUID = '{C179334C-4295-40D3-BEA1-C654D965605A}'; + IID_VirtualDesktopNotificationW11: TGUID = '{cd403e52-deed-4c13-b437-b98380f2b1e8}'; + +// + CLSID_VirtualDesktopPinnedApps: TGUID = '{B5A399E7-1C87-46B8-88E9-FC5747B171BD}'; + IID_VirtualDesktopPinnedApps: TGUID = '{4CE81583-1E4C-4632-A621-07A53543148F}'; + +{ ApplicationViewCompatibilityPolicy } + AVCP_NONE = 0; + AVCP_SMALL_SCREEN = 1; + AVCP_TABLET_SMALL_SCREEN = 2; + AVCP_VERY_SMALL_SCREEN = 3; + AVCP_HIGH_SCALE_FACTOR = 4; + +type + HSTRING = type THandle; + { IVirtualDesktopManager } + + IVirtualDesktopManager = interface(IUnknown) + ['{A5CD92FF-29BE-454C-8D04-D82879FB3F1B}'] + function IsWindowOnCurrentVirtualDesktop(Wnd: HWND; pIsTrue: PBOOL): HResult; stdcall; // ok {INFORMATION: this only works with the current process windows} + function GetWindowDesktopId(Wnd: HWND; pDesktopID: PGUID): HResult; stdcall; // ok + function MoveWindowToDesktop(Wnd: HWND; const DesktopID: TGUID): HResult; stdcall; // ok + end; + + { IObjectArray } + + PIUnknown = ^IUnknown; + + PIObjectArray = ^IObjectArray; + + IObjectArray = interface + function GetCount(pCount: PUINT): HRESULT; stdcall; // ok + function GetAt(uiIndex: UINT; riid: PGUID; ppv: PIUnknown): HRESULT; stdcall; // ok + end; + + { IApplicationView } + + PLONGLONG = ^LONGLONG; + + PHWND = ^HWND; + + PIApplicationView = ^IApplicationView; + PIApplicationViewW11 = ^IApplicationViewW11; + + IApplicationView = interface(IUnknown) + ['{9AC0B5C8-1484-4C5B-9533-4134A0F97CEA}'] + function SetFocus: HRESULT; stdcall; // ok + function SwitchTo: HRESULT; stdcall; // ok + function notimpl1(): HRESULT; stdcall; //int TryInvokeBack(IntPtr /* IAsyncCallback* */ callback); + function GetThumbnailWindow(pWnd: PHWND): HRESULT; stdcall; // ok + function notimpl2(): HRESULT; stdcall; //int GetMonitor(out IntPtr /* IImmersiveMonitor */ immersiveMonitor); + function notimpl3(): HRESULT; stdcall; //int GetVisibility(out int visibility); + function notimpl4(): HRESULT; stdcall; //int SetCloak(ApplicationViewCloakType cloakType, int unknown); + function notimpl5(): HRESULT; stdcall; //int GetPosition(ref Guid guid /* GUID for IApplicationViewPosition */, out IntPtr /* IApplicationViewPosition** */ position); + function notimpl6(): HRESULT; stdcall; //int SetPosition(ref IntPtr /* IApplicationViewPosition* */ position); + function InsertAfterWindow(Wnd: HWND): HRESULT; stdcall; // not tested + function GetExtendedFramePosition(Rect: PRect): HRESULT; stdcall; // ok + function GetAppUserModelId(Id: PLPWSTR): HRESULT; stdcall; // ok + function SetAppUserModelId(Id: LPWSTR): HRESULT; stdcall; // not tested + function IsEqualByAppUserModelId(Id: LPWSTR; isequal: BOOL): HRESULT; stdcall; // not tested + function notimpl7(): HRESULT; stdcall; //int GetViewState(out uint state); + function notimpl8(): HRESULT; stdcall; //int SetViewState(uint state); + function notimpl9(): HRESULT; stdcall; //int GetNeediness(out int neediness); + function GetLastActivationTimestamp(ptimestamp: PLONGLONG): HRESULT; stdcall; // <--- don't understand how convert to datetime (or it's works incorrectly) + function SetLastActivationTimestamp(timestamp: LONGLONG): HRESULT; stdcall; // <--- don't understand how convert from datetime (or it's works incorrectly) + function GetVirtualDesktopId(pguid: PGUID): HRESULT; stdcall; // ok + function SetVirtualDesktopId(pguid: PGUID): HRESULT; stdcall; // ok + function GetShowInSwitchers(pflag: PBOOL): HRESULT; stdcall; // ok + function SetShowInSwitchers(flag: BOOL): HRESULT; stdcall; // not supported at build 14393 and lower + function notimpl10(): HRESULT; stdcall; //int GetScaleFactor(out int factor); + function CanReceiveInput(pcanReceiveInput: PBOOL): HRESULT; stdcall; // not tested + function GetCompatibilityPolicyType(pflag: PUINT): HRESULT; stdcall; // It seems that works ok + function SetCompatibilityPolicyType(flag: UINT): HRESULT; stdcall; // not tested + function notimpl11(): HRESULT; stdcall; //int GetPositionPriority(out IntPtr /* IShellPositionerPriority** */ priority); + function notimpl12(): HRESULT; stdcall; //int SetPositionPriority(IntPtr /* IShellPositionerPriority* */ priority); + function notimpl13(): HRESULT; stdcall; //int GetSizeConstraints(IntPtr /* IImmersiveMonitor* */ monitor, out Size size1, out Size size2); + function notimpl14(): HRESULT; stdcall; //int GetSizeConstraintsForDpi(uint uint1, out Size size1, out Size size2); + function notimpl15(): HRESULT; stdcall; //int SetSizeConstraintsForDpi(ref uint uint1, ref Size size1, ref Size size2); + function notimpl16(): HRESULT; stdcall; //int QuerySizeConstraintsFromApp(); // It leads to a crash + function OnMinSizePreferencesUpdated(Wnd: HWND): HRESULT; stdcall; // not tested + function notimpl17(): HRESULT; stdcall; //int ApplyOperation(IntPtr /* IApplicationViewOperation* */ operation); + function IsTray(pisTray: PBOOL): HRESULT; stdcall; // allways return TRUE + function IsInHighZOrderBand(pisInHighZOrderBand: PBOOL): HRESULT; stdcall; // It seems that works ok + function IsSplashScreenPresented(pisSplashScreenPresented: PBOOL): HRESULT; stdcall; // allways return FALSE + function Flash: HRESULT; stdcall; // ok + function GetRootSwitchableOwner(rootSwitchableOwner: PIApplicationView): HRESULT; stdcall; // not tested + function EnumerateOwnershipTree(ownershipTree: PIObjectArray): HRESULT; stdcall; // not tested + function GetEnterpriseId(Id: PLPWSTR): HRESULT; stdcall; // build 10584 or later // allwaus return empty value + function IsMirrored(pisMirrored: PBOOL): HRESULT; stdcall; // build 10584 or later // allways return FALSE + end; + + IApplicationViewW11 = interface(IUnknown) + ['{372e1d3b-38d3-42e4-a15b-8ab2b178f513}'] + function SetFocus: HRESULT; stdcall; // ok + function SwitchTo: HRESULT; stdcall; // ok + function notimpl1(): HRESULT; stdcall; //int TryInvokeBack(IntPtr /* IAsyncCallback* */ callback); + function GetThumbnailWindow(pWnd: PHWND): HRESULT; stdcall; // ok + function notimpl2(): HRESULT; stdcall; //int GetMonitor(out IntPtr /* IImmersiveMonitor */ immersiveMonitor); + function notimpl3(): HRESULT; stdcall; //int GetVisibility(out int visibility); + function notimpl4(): HRESULT; stdcall; //int SetCloak(ApplicationViewCloakType cloakType, int unknown); + function notimpl5(): HRESULT; stdcall; //int GetPosition(ref Guid guid /* GUID for IApplicationViewPosition */, out IntPtr /* IApplicationViewPosition** */ position); + function notimpl6(): HRESULT; stdcall; //int SetPosition(ref IntPtr /* IApplicationViewPosition* */ position); + function InsertAfterWindow(Wnd: HWND): HRESULT; stdcall; // not tested + function GetExtendedFramePosition(Rect: PRect): HRESULT; stdcall; // ok + function GetAppUserModelId(Id: PLPWSTR): HRESULT; stdcall; // ok + function SetAppUserModelId(Id: LPWSTR): HRESULT; stdcall; // not tested + function IsEqualByAppUserModelId(Id: LPWSTR; isequal: BOOL): HRESULT; stdcall; // not tested + function notimpl7(): HRESULT; stdcall; //int GetViewState(out uint state); + function notimpl8(): HRESULT; stdcall; //int SetViewState(uint state); + function notimpl9(): HRESULT; stdcall; //int GetNeediness(out int neediness); + function GetLastActivationTimestamp(ptimestamp: PLONGLONG): HRESULT; stdcall; // <--- don't understand how convert to datetime (or it's works incorrectly) + function SetLastActivationTimestamp(timestamp: LONGLONG): HRESULT; stdcall; // <--- don't understand how convert from datetime (or it's works incorrectly) + function GetVirtualDesktopId(pguid: PGUID): HRESULT; stdcall; // ok + function SetVirtualDesktopId(pguid: PGUID): HRESULT; stdcall; // ok + function GetShowInSwitchers(pflag: PBOOL): HRESULT; stdcall; // ok + function SetShowInSwitchers(flag: BOOL): HRESULT; stdcall; // not supported at build 14393 and lower + function notimpl10(): HRESULT; stdcall; //int GetScaleFactor(out int factor); + function CanReceiveInput(pcanReceiveInput: PBOOL): HRESULT; stdcall; // not tested + function GetCompatibilityPolicyType(pflag: PUINT): HRESULT; stdcall; // It seems that works ok + function SetCompatibilityPolicyType(flag: UINT): HRESULT; stdcall; // not tested + function notimpl11(): HRESULT; stdcall; //int GetPositionPriority(out IntPtr /* IShellPositionerPriority** */ priority); + function notimpl12(): HRESULT; stdcall; //int SetPositionPriority(IntPtr /* IShellPositionerPriority* */ priority); + function notimpl13(): HRESULT; stdcall; //int GetSizeConstraints(IntPtr /* IImmersiveMonitor* */ monitor, out Size size1, out Size size2); + function notimpl14(): HRESULT; stdcall; //int GetSizeConstraintsForDpi(uint uint1, out Size size1, out Size size2); + function notimpl15(): HRESULT; stdcall; //int SetSizeConstraintsForDpi(ref uint uint1, ref Size size1, ref Size size2); + function notimpl16(): HRESULT; stdcall; //int QuerySizeConstraintsFromApp(); // It leads to a crash + function OnMinSizePreferencesUpdated(Wnd: HWND): HRESULT; stdcall; // not tested + function notimpl17(): HRESULT; stdcall; //int ApplyOperation(IntPtr /* IApplicationViewOperation* */ operation); + function IsTray(pisTray: PBOOL): HRESULT; stdcall; // allways return TRUE + function IsInHighZOrderBand(pisInHighZOrderBand: PBOOL): HRESULT; stdcall; // It seems that works ok + function IsSplashScreenPresented(pisSplashScreenPresented: PBOOL): HRESULT; stdcall; // allways return FALSE + function Flash: HRESULT; stdcall; // ok + function GetRootSwitchableOwner(rootSwitchableOwner: PIApplicationViewW11): HRESULT; stdcall; // not tested + function EnumerateOwnershipTree(ownershipTree: PIObjectArray): HRESULT; stdcall; // not tested + function GetEnterpriseId(Id: PLPWSTR): HRESULT; stdcall; // build 10584 or later // allwaus return empty value + function IsMirrored(pisMirrored: PBOOL): HRESULT; stdcall; // build 10584 or later // allways return FALSE + end; + + { IApplicationViewCollection } + + IApplicationViewCollection = interface(IUnknown) + ['{1841C6D7-4F9D-42C0-AF41-8747538F10E5}'] + function GetViews(pViews: PIObjectArray): HRESULT; stdcall; // ok + function GetViewsByZOrder(pViews: PIObjectArray): HRESULT; stdcall; // ok + function GetViewsByAppUserModelId(Id: LPWSTR; pViews: PIObjectArray): HRESULT; stdcall; // not tested, but i think it works normaly + function GetViewForHwnd(Wnd: HWND; pView: PIApplicationView): HRESULT; stdcall; // ok + function notimpl1(): HRESULT; stdcall; //int GetViewForApplication(object application, out IApplicationView view); + function GetViewForAppUserModelId(Id: LPWSTR; View: IApplicationView): HRESULT; stdcall; // not tested, but i think it works normaly + function GetViewInFocus(pView: PIApplicationView): HRESULT; stdcall; // ok + function RefreshCollection(): HRESULT; stdcall; // It seems that works ok + function notimpl2(): HRESULT; stdcall; //int RegisterForApplicationViewChanges(object listener, out int cookie); + function notimpl3(): HRESULT; stdcall; //int RegisterForApplicationViewPositionChanges(object listener, out int cookie); + function notimpl4(): HRESULT; stdcall; //int UnregisterForApplicationViewChanges(int cookie); + end; + + IApplicationViewCollectionW11 = interface(IUnknown) + ['{1841C6D7-4F9D-42C0-AF41-8747538F10E5}'] + function GetViews(pViews: PIObjectArray): HRESULT; stdcall; // ok + function GetViewsByZOrder(pViews: PIObjectArray): HRESULT; stdcall; // ok + function GetViewsByAppUserModelId(Id: LPWSTR; pViews: PIObjectArray): HRESULT; stdcall; // not tested, but i think it works normaly + function GetViewForHwnd(Wnd: HWND; pView: PIApplicationViewW11): HRESULT; stdcall; // ok + function notimpl1(): HRESULT; stdcall; //int GetViewForApplication(object application, out IApplicationView view); + function GetViewForAppUserModelId(Id: LPWSTR; View: IApplicationViewW11): HRESULT; stdcall; // not tested, but i think it works normaly + function GetViewInFocus(pView: PIApplicationViewW11): HRESULT; stdcall; // ok + function RefreshCollection(): HRESULT; stdcall; // It seems that works ok + function notimpl2(): HRESULT; stdcall; //int RegisterForApplicationViewChanges(object listener, out int cookie); + function notimpl3(): HRESULT; stdcall; //int RegisterForApplicationViewPositionChanges(object listener, out int cookie); + function notimpl4(): HRESULT; stdcall; //int UnregisterForApplicationViewChanges(int cookie); + end; + + { IVirtualDesktop } + + PIVirtualDesktop = ^IVirtualDesktop; + + IVirtualDesktop = interface(IUnknown) + ['{FF72FFDD-BE7E-43FC-9C03-AD81681E88E4}'] + function IsViewVisible(View: IApplicationView; pfVisible: PBOOL): HRESULT; stdcall; // ok + function GetId(Id: PGUID): HRESULT; stdcall; // ok + end; + + { IVirtualDesktop Windows 11 } + + PIVirtualDesktopW11 = ^IVirtualDesktopW11; + + IVirtualDesktopW11 = interface(IUnknown) + ['{536d3495-b208-4cc9-ae26-de8111275bf8}'] + function IsViewVisible(View: IApplicationViewW11; pfVisible: PBOOL): HRESULT; stdcall; // ok + function GetId(Id: PGUID): HRESULT; stdcall; // ok + function Proc5(PProc5: PUINT): HRESULT; stdcall; + function GetName(Hs: HSTRING): HRESULT; stdcall; + function GetWallpaperPath(Hs: HSTRING): HRESULT; stdcall; + end; + + { IVirtualDesktopManagerInternal } + + IVirtualDesktopManagerInternal = interface(IUnknown) +// ['{F31574D6-B682-4CDC-BD56-1827860ABEC6}'] // build 14393 or later +// ['{AF8DA486-95BB-4460-B3B7-6E7A6B2962B5}'] // build 10240 or later +// ['{EF9F1A6C-D3CC-4358-B712-F84B635BEBE7}'] // build 10130 or later + function GetCount(pCount: PUINT): HRESULT; stdcall; // ok + function MoveViewToDesktop(View: IApplicationView; Desktop: IVirtualDesktop): HRESULT; stdcall; // ok + function CanViewMoveDesktops(View: IApplicationView; pfCanViewMoveDesktops: PBOOL): HRESULT; stdcall; // build 10240 or later // not tested + function GetCurrentDesktop(pVD: PIVirtualDesktop): HRESULT; stdcall; // ok + function GetDesktops(pDesktops: PIObjectArray): HRESULT; stdcall; // ok + function GetAdjacentDesktop(Desktop: IVirtualDesktop; AdjacentDesktop: UINT; pAdjacentDesktop: PIVirtualDesktop): HRESULT; stdcall; // ok + function SwitchDesktop(Desktop: IVirtualDesktop): HRESULT; stdcall; // ok + function CreateDesktopW(pNewDesctop: PIVirtualDesktop): HRESULT; stdcall; // ok + function RemoveDesktop(Desktop: IVirtualDesktop; FallbackDesktop: IVirtualDesktop): HRESULT; stdcall; // ok + function FindDesktop(pId: PGUID; Desktop: PIVirtualDesktop): HRESULT; stdcall; // build 10240 or later // ok + end; + + IVirtualDesktopManagerInternalW11 = interface(IUnknown) +// ['{B2F925B9-5A0F-4D2E-9F4D-2B1507593C10}'] // 22000 or later + function GetCount(pCount: PUINT): HRESULT; stdcall; // ok + function MoveViewToDesktop(View: IApplicationViewW11; Desktop: IVirtualDesktopW11): HRESULT; stdcall; // ok + function CanViewMoveDesktops(View: IApplicationViewW11; pfCanViewMoveDesktops: PBOOL): HRESULT; stdcall; // build 10240 or later // not tested + function GetCurrentDesktop(hWndOrMon: PUINT; pVD: PIVirtualDesktopW11): HRESULT; stdcall; // ok + //do not know if this is for all 22000 or later, trying on 22H2 build 22621.1413, just added the next function, and it works now on it + function GetAllCurrentDesktops(pDesktops: PIObjectArray): HRESULT; stdcall; + function GetDesktops(hWndOrMon: PUINT; pDesktops: PIObjectArray): HRESULT; stdcall; // ok + function GetAdjacentDesktop(Desktop: IVirtualDesktopW11; AdjacentDesktop: UINT; pAdjacentDesktop: PIVirtualDesktopW11): HRESULT; stdcall; // ok + function SwitchDesktop(hWndOrMon: PUINT; Desktop: IVirtualDesktopW11): HRESULT; stdcall; // ok + function CreateDesktopW(hWndOrMon: PUINT; pNewDesctop: PIVirtualDesktopW11): HRESULT; stdcall; // ok + function MoveDesktop(Desktop: IVirtualDesktopW11; hWndOrMon: PUINT; nIndex: Integer): HRESULT; stdcall; + // + function RemoveDesktop(Desktop: IVirtualDesktopW11; FallbackDesktop: IVirtualDesktopW11): HRESULT; stdcall; // ok + function FindDesktop(pId: PGUID; Desktop: PIVirtualDesktopW11): HRESULT; stdcall; // build 10240 or later // ok + // + function GetDesktopSwitchIncludeExcludeViews(Desktop: IVirtualDesktopW11; var o1: IObjectArray; var o2: IObjectArray): HRESULT; stdcall; + function SetDesktopName(Desktop: IVirtualDesktopW11; name: HSTRING): HRESULT; stdcall; + function SetDesktopWallpaper(Desktop: IVirtualDesktopW11; path: HSTRING): HRESULT; stdcall; + function UpdateWallpaperPathForAllDesktops(path: HSTRING): HRESULT; stdcall; + function CopyDesktopState(pView0: IApplicationViewW11; pView1: IApplicationViewW11): HRESULT; stdcall; + function GetDesktopIsPerMonitor(pGetDesktopIsPerMonitor: PBOOL): HRESULT; stdcall; + function SetDesktopIsPerMonitor(state: BOOL): HRESULT; stdcall; + end; + + { IVirtualDesktopNotification } + + IVirtualDesktopNotification = interface(IUnknown) //10240 + ['{C179334C-4295-40D3-BEA1-C654D965605A}'] + function VirtualDesktopCreated(Desktop: IVirtualDesktop): HRESULT; stdcall; // ok + function VirtualDesktopDestroyBegin(Desktop: IVirtualDesktop; DesktopFallback: IVirtualDesktop): HRESULT; stdcall; // ok + function VirtualDesktopDestroyFailed(Desktop: IVirtualDesktop; DesktopFallback: IVirtualDesktop): HRESULT; stdcall; // ok + function VirtualDesktopDestroyed(Desktop: IVirtualDesktop; DesktopFallback: IVirtualDesktop): HRESULT; stdcall; // ok + function ViewVirtualDesktopChanged(View: IApplicationView): HRESULT; stdcall; // ok + function CurrentVirtualDesktopChanged(DesktopOld: IVirtualDesktop; DesktopNew: IVirtualDesktop): HRESULT; stdcall; // ok + end; + + IVirtualDesktopNotification20231 = interface(IUnknown) //build 20231 + ['{C179334C-4295-40D3-BEA1-C654D965605A}'] + function VirtualDesktopCreated(Desktop: IVirtualDesktop): HRESULT; stdcall; // ok + function VirtualDesktopDestroyBegin(Desktop: IVirtualDesktop; DesktopFallback: IVirtualDesktop): HRESULT; stdcall; // ok + function VirtualDesktopDestroyFailed(Desktop: IVirtualDesktop; DesktopFallback: IVirtualDesktop): HRESULT; stdcall; // ok + function VirtualDesktopDestroyed(Desktop: IVirtualDesktop; DesktopFallback: IVirtualDesktop): HRESULT; stdcall; // ok + function ViewVirtualDesktopChanged(View: IApplicationView): HRESULT; stdcall; // ok + function CurrentVirtualDesktopChanged(DesktopOld: IVirtualDesktop; DesktopNew: IVirtualDesktop): HRESULT; stdcall; // ok + end; + + IVirtualDesktopNotification21313 = interface(IUnknown) //build 21313 + ['{cd403e52-deed-4c13-b437-b98380f2b1e8}'] + function VirtualDesktopCreated(p0: IObjectArray; Desktop: IVirtualDesktopW11): HRESULT; stdcall; // ok + function VirtualDesktopDestroyBegin(p0: IObjectArray; Desktop: IVirtualDesktopW11; DesktopFallback: IVirtualDesktopW11): HRESULT; stdcall; // ok + function VirtualDesktopDestroyFailed(p0: IObjectArray; Desktop: IVirtualDesktopW11; DesktopFallback: IVirtualDesktopW11): HRESULT; stdcall; // ok + function VirtualDesktopDestroyed(p0: IObjectArray; Desktop: IVirtualDesktopW11; DesktopFallback: IVirtualDesktopW11): HRESULT; stdcall; // ok + function Unknown1(Number: Integer): HRESULT; stdcall; + function VirtualDesktopMoved(p0: IObjectArray; Desktop: IVirtualDesktopW11; nFromIndex: Integer; nToIndex: Integer): HRESULT; stdcall; + function VirtualDesktopRenamed(Desktop: IVirtualDesktopW11; chName: HSTRING): HRESULT; stdcall; + function ViewVirtualDesktopChanged(View: IApplicationViewW11): HRESULT; stdcall; // ok + function CurrentVirtualDesktopChanged(p0: IObjectArray; DesktopOld: IVirtualDesktopW11; DesktopNew: IVirtualDesktopW11): HRESULT; stdcall; // ok + function VirtualDesktopWallpaperChanged(Desktop: IVirtualDesktopW11; chPath: HSTRING): HRESULT; stdcall; + end; + + + { IVirtualNotificationService } + + IVirtualNotificationService = interface(IUnknown) + ['{0CD45E71-D927-4F15-8B0A-8FEF525337BF}'] + function Register(Notification: IVirtualDesktopNotification; pdwCookie: Pointer): HRESULT; stdcall; // ok + function Unregister(dwCookie: DWORD): HRESULT; stdcall; // ok + end; + + IVirtualNotificationServiceW11 = interface(IUnknown) + ['{0CD45E71-D927-4F15-8B0A-8FEF525337BF}'] + function Register(Notification: IVirtualDesktopNotification21313; pdwCookie: Pointer): HRESULT; stdcall; // ok + function Unregister(dwCookie: DWORD): HRESULT; stdcall; // ok + end; + + { IVirtualDesktopPinnedApps } + + IVirtualDesktopPinnedApps = interface(IUnknown) + ['{4CE81583-1E4C-4632-A621-07A53543148F}'] + function IsAppIdPinned(appId: LPWSTR; pfPinned: PBOOL): HRESULT; stdcall; // ok + function PinAppID(appId: LPWSTR): HRESULT; stdcall; // ok + function UnpinAppID(appId: LPWSTR): HRESULT; stdcall; // ok + function IsViewPinned(View: IApplicationView; pfPinned: PBOOL): HRESULT; stdcall; // ok + function PinView(View: IApplicationView): HRESULT; stdcall; // ok + function UnpinView(View: IApplicationView): HRESULT; stdcall; // ok + end; + + IVirtualDesktopPinnedAppsW11 = interface(IUnknown) + ['{4CE81583-1E4C-4632-A621-07A53543148F}'] + function IsAppIdPinned(appId: LPWSTR; pfPinned: PBOOL): HRESULT; stdcall; // ok + function PinAppID(appId: LPWSTR): HRESULT; stdcall; // ok + function UnpinAppID(appId: LPWSTR): HRESULT; stdcall; // ok + function IsViewPinned(View: IApplicationViewW11; pfPinned: PBOOL): HRESULT; stdcall; // ok + function PinView(View: IApplicationViewW11): HRESULT; stdcall; // ok + function UnpinView(View: IApplicationViewW11): HRESULT; stdcall; // ok + end; + + + +implementation + +end. + diff --git a/thirparty/VirtualDesktopManager.pas b/thirparty/VirtualDesktopManager.pas new file mode 100644 index 0000000..7081916 --- /dev/null +++ b/thirparty/VirtualDesktopManager.pas @@ -0,0 +1,1752 @@ +// Created by Alexey Andriukhin (dr. F.I.N.) http://www.delphisources.ru/forum/member.php?u=9721 +// Tested on Win10 x32 (build 14393), Delphi7 + +{ + CHANGELOG: + 2022-05-26: + - Updated IVirtualDesktop to include hstring functions + TODO : handle those hstring +} + +unit VirtualDesktopManager; + +interface + +uses + { CodeGear } + Windows, // used for many functions + Classes, // used for: TList + SysUtils, // used for: FreeAndNil() + ActiveX, // used for: CoInitialize(), CoUninitialize, Succeeded(), Failed(), IsEqualGUID() + ComObj, // used for: GUIDToString() + { VirtualDesktopAPI } + VirtualDesktopAPI; +// Winapi.Winrt {HSTRING}; + +type + TNonRefInterfacedObject = class(TObject, IInterface) + private + fRefCount: Integer; + fDestroyed: Boolean; + protected + { IInterface } + function _AddRef: Integer; stdcall; + function _Release: Integer; stdcall; + function QueryInterface(const IID: TGUID; out Obj): HRESULT; stdcall; + { Self } + procedure DoFreeInstance; virtual; + public + procedure FreeInstance; override; + end; + + TVirtualDesktopManager = class; + TVirtualDesktopManagerW11 = class; + + TVirtualDesktop = class(TNonRefInterfacedObject, IVirtualDesktop) + private + fManager: TVirtualDesktopManager; + fIDesktop: IVirtualDesktop; + function _GetId: TGUID; + function _GetIdAsString: AnsiString; + function _GetIndex: Integer; + function _GetIsCurrent: Boolean; + protected + { IVirtualDesktop } + function IsViewVisible(View: IApplicationView; pfVisible: PBOOL): HRESULT; stdcall; + function GetId(Id: PGUID): HRESULT; stdcall; + function GetName(Hs: HSTRING): HRESULT; stdcall; + function GetWallpaperPath(Hs: HSTRING): HRESULT; stdcall; + { IInterface } + function QueryInterface(const IID: TGUID; out Obj): HRESULT; stdcall; + { Self } + constructor Create(Manager: TVirtualDesktopManager; iDesktop: IVirtualDesktop); + procedure DoFreeInstance; override; + public + { Methods } + // Switch + function SwitchHere: Boolean; + // Remove + function Remove: Boolean; overload; + function Remove(FallbackDesktop: TVirtualDesktop): Boolean; overload; + function Remove(FallbackDesktopIndex: Integer): Boolean; overload; + function Remove(FallbackDesktopId: TGUID): Boolean; overload; + // Additional + function IsWindowVisible(Wnd: HWND): Boolean; + { Properties } + property Id: TGUID read _GetId; + property IdAsString: AnsiString read _GetIdAsString; + property Index: Integer read _GetIndex; + property IsCurrent: Boolean read _GetIsCurrent; + end; + + TVirtualDesktopW11 = class(TNonRefInterfacedObject, IVirtualDesktopW11) + private + fManager: TVirtualDesktopManagerW11; + fIDesktop: IVirtualDesktopW11; + function _GetId: TGUID; + function _GetIdAsString: AnsiString; + function _GetIndex: Integer; + function _GetIsCurrent: Boolean; + protected + { IVirtualDesktop } + function IsViewVisible(View: IApplicationViewW11; pfVisible: PBOOL): HRESULT; stdcall; + function GetId(Id: PGUID): HRESULT; stdcall; + function Proc5(PProc5: PUINT): HRESULT; stdcall; + function GetName(Hs: HSTRING): HRESULT; stdcall; + function GetWallpaperPath(Hs: HSTRING): HRESULT; stdcall; + { IInterface } + function QueryInterface(const IID: TGUID; out Obj): HRESULT; stdcall; + { Self } + constructor Create(Manager: TVirtualDesktopManagerW11; iDesktop: IVirtualDesktopW11); + procedure DoFreeInstance; override; + public + { Methods } + // Switch + function SwitchHere: Boolean; + // Remove + function Remove: Boolean; overload; + function Remove(FallbackDesktop: TVirtualDesktopW11): Boolean; overload; + function Remove(FallbackDesktopIndex: Integer): Boolean; overload; + function Remove(FallbackDesktopId: TGUID): Boolean; overload; + // Additional + function IsWindowVisible(Wnd: HWND): Boolean; + { Properties } + property Id: TGUID read _GetId; + property IdAsString: AnsiString read _GetIdAsString; + property Index: Integer read _GetIndex; + property IsCurrent: Boolean read _GetIsCurrent; + end; + + TErrorNotify = procedure(Sender: TObject; ErroCode: HRESULT) of object; + + TVirtualDesktopCreatedNotify = procedure(Sender: TObject; Desktop: TVirtualDesktop) of object; + + TVirtualDesktopDestroyNotify = procedure(Sender: TObject; Desktop, DesktopFallback: TVirtualDesktop) of object; + + TCurrentVirtualDesktopChangedNotify = procedure(Sender: TObject; OldDesktop, NewDesktop: TVirtualDesktop) of object; + + TVirtualDesktopCreatedNotifyW11 = procedure(Sender: TObject; Desktop: TVirtualDesktopW11) of object; + + TVirtualDesktopDestroyNotifyW11 = procedure(Sender: TObject; Desktop, DesktopFallback: TVirtualDesktopW11) of object; + + TCurrentVirtualDesktopChangedNotifyW11 = procedure(Sender: TObject; OldDesktop, NewDesktop: TVirtualDesktopW11) of object; + + TVirtualDesktopManager = class(TNonRefInterfacedObject, IVirtualDesktopNotification) + private + fISP: IServiceProvider; + fIVDM: IVirtualDesktopManager; + fIVDMI: IVirtualDesktopManagerInternal; + fIVDMI11: IVirtualDesktopManagerInternalW11; + fIVNS: IVirtualNotificationService; + fIAVC: IApplicationViewCollection; + fIVDPA: IVirtualDesktopPinnedApps; + fCookie: DWORD; + protected + { IVirtualDesktopNotification } + function VirtualDesktopCreated(Desktop: IVirtualDesktop): HRESULT; stdcall; + function VirtualDesktopDestroyBegin(Desktop: IVirtualDesktop; DesktopFallback: IVirtualDesktop): HRESULT; stdcall; + function VirtualDesktopDestroyFailed(Desktop: IVirtualDesktop; DesktopFallback: IVirtualDesktop): HRESULT; stdcall; + function VirtualDesktopDestroyed(Desktop: IVirtualDesktop; DesktopFallback: IVirtualDesktop): HRESULT; stdcall; + function ViewVirtualDesktopChanged(View: IApplicationView): HRESULT; stdcall; + function CurrentVirtualDesktopChanged(DesktopOld: IVirtualDesktop; DesktopNew: IVirtualDesktop): HRESULT; stdcall; + { Self } + procedure DoFreeInstance; override; + private + fEnabled: Boolean; + fLastError: HRESULT; + fDesktops: TList; + fOnCurrentChanged: TCurrentVirtualDesktopChangedNotify; + fOnCreated: TVirtualDesktopCreatedNotify; + fOnDestroyBegin: TVirtualDesktopDestroyNotify; + fOnDestroyFailed: TVirtualDesktopDestroyNotify; + fOnDestroyed: TVirtualDesktopDestroyNotify; + fOnError: TErrorNotify; + procedure FreeDesktops; + function CheckError(res: HRESULT): Boolean; + procedure Initialize; + procedure Finalize; + function _GetCount: Integer; + function _GetDesktop(Index: Integer): TVirtualDesktop; + function _GetCurrentDesktop: TVirtualDesktop; + function _GetCurrentDesktopIndex: Integer; + procedure _SetCurrentDesktopIndex(const Value: Integer); + function _GetCurrentDesktopId: TGUID; + protected + procedure SetLastError(error: HRESULT); + public + procedure AfterConstruction; override; + { Methods } + // DESKTOPS + // Additional + procedure Refresh; + function GetDesktopIndexById(Id: TGUID): Integer; + // Create + function CreateDesktop: Boolean; + function CreateDesktopAndSwitch: Boolean; + // Switch + function SwitchToDesktop(Desktop: TVirtualDesktop): Boolean; overload; + function SwitchToDesktop(DesktopId: TGUID): Boolean; overload; + function SwitchToDesktop(DesktopIndex: Integer): Boolean; overload; + // Remove + function RemoveDesktop(Desktop: TVirtualDesktop): Boolean; overload; + function RemoveDesktop(Desktop, DesktopFallback: TVirtualDesktop): Boolean; overload; + function RemoveDesktop(DesktopId: TGUID): Boolean; overload; + function RemoveDesktop(DesktopId, DesktopFallbackId: TGUID): Boolean; overload; + function RemoveDesktop(DesktopIndex: Integer): Boolean; overload; + function RemoveDesktop(DesktopIndex, DesktopFallbackIndex: Integer): Boolean; overload; + // WINDOWS AND APPS + function IsWindowOnCurrentDesktop(Wnd: HWND): Boolean; + function GetWindowDesktop(Wnd: HWND): TVirtualDesktop; + // Visibility + function IsWindowVisibleAtDesktop(Wnd: HWND; Desktop: TVirtualDesktop): Boolean; overload; + function IsWindowVisibleAtDesktop(Wnd: HWND; DesktopId: TGUID): Boolean; overload; + function IsWindowVisibleAtDesktop(Wnd: HWND; DesktopIndex: Integer): Boolean; overload; + // Move + function MoveWindowToDesktop(Wnd: HWND; Desktop: TVirtualDesktop): Boolean; overload; + function MoveWindowToDesktop(Wnd: HWND; DesktopId: TGUID): Boolean; overload; + function MoveWindowToDesktop(Wnd: HWND; DesktopIndex: Integer): Boolean; overload; + // Additional + function IsWindowHaveView(Wnd: HWND): Boolean; + function FlashWindow(Wnd: HWND): Boolean; + function SwithToWindow(Wnd: HWND): Boolean; + // Pin + function IsPinnedWindow(Wnd: HWND): Boolean; + function IsPinnedApplication(Wnd: HWND): Boolean; + function PinWindow(Wnd: HWND): Boolean; + function PinApplication(Wnd: HWND): Boolean; + function UnpinWindow(Wnd: HWND): Boolean; + function UnpinApplication(Wnd: HWND): Boolean; + { Properties } + property Enabled: Boolean read fEnabled; + property LastError: HRESULT read fLastError; + property Count: Integer read _GetCount; + property Desktops[Index: Integer]: TVirtualDesktop read _GetDesktop; + property CurrentDesktop: TVirtualDesktop read _GetCurrentDesktop; + property CurrentDesktopId: TGUID read _GetCurrentDesktopId; + property CurrentDesktopIndex: Integer read _GetCurrentDesktopIndex write _SetCurrentDesktopIndex; + { Events } + property OnDesktopCreated: TVirtualDesktopCreatedNotify read fOnCreated write fOnCreated; + property OnDesktopDestroyBegin: TVirtualDesktopDestroyNotify read fOnDestroyBegin write fOnDestroyBegin; + property OnDesktopDestroyFailed: TVirtualDesktopDestroyNotify read fOnDestroyFailed write fOnDestroyFailed; + property OnDesktopDestroyed: TVirtualDesktopDestroyNotify read fOnDestroyed write fOnDestroyed; + property OnCurrentDesktopChanged: TCurrentVirtualDesktopChangedNotify read fOnCurrentChanged write fOnCurrentChanged; + property OnError: TErrorNotify read fOnError write fOnError; + end; + + TVirtualDesktopManagerW11 = class(TNonRefInterfacedObject, IVirtualDesktopNotification21313) + private + fISP: IServiceProvider; + fIVDM: IVirtualDesktopManager; + fIVDMI11: IVirtualDesktopManagerInternalW11; + fIVNS: IVirtualNotificationServiceW11; + fIAVC: IApplicationViewCollectionW11; + fIVDPA: IVirtualDesktopPinnedAppsW11; + fCookie: DWORD; + protected + { IVirtualDesktopNotification } + function VirtualDesktopCreated(p0: IObjectArray; Desktop: IVirtualDesktopW11): HRESULT; stdcall; // ok + function VirtualDesktopDestroyBegin(p0: IObjectArray; Desktop: IVirtualDesktopW11; DesktopFallback: IVirtualDesktopW11): HRESULT; stdcall; // ok + function VirtualDesktopDestroyFailed(p0: IObjectArray; Desktop: IVirtualDesktopW11; DesktopFallback: IVirtualDesktopW11): HRESULT; stdcall; // ok + function VirtualDesktopDestroyed(p0: IObjectArray; Desktop: IVirtualDesktopW11; DesktopFallback: IVirtualDesktopW11): HRESULT; stdcall; // ok + function Unknown1(Number: Integer): HRESULT; stdcall; + function VirtualDesktopMoved(p0: IObjectArray; Desktop: IVirtualDesktopW11; nFromIndex: Integer; nToIndex: Integer): HRESULT; stdcall; + function VirtualDesktopRenamed(Desktop: IVirtualDesktopW11; chName: HSTRING): HRESULT; stdcall; + function ViewVirtualDesktopChanged(View: IApplicationViewW11): HRESULT; stdcall; // ok + function CurrentVirtualDesktopChanged(p0: IObjectArray; DesktopOld: IVirtualDesktopW11; DesktopNew: IVirtualDesktopW11): HRESULT; stdcall; // ok + function VirtualDesktopWallpaperChanged(Desktop: IVirtualDesktopW11; chPath: HSTRING): HRESULT; stdcall; + { Self } + procedure DoFreeInstance; override; + private + fEnabled: Boolean; + fLastError: HRESULT; + fDesktops: TList; + fOnCurrentChanged: TCurrentVirtualDesktopChangedNotifyW11; + fOnCreated: TVirtualDesktopCreatedNotifyW11; + fOnDestroyBegin: TVirtualDesktopDestroyNotifyW11; + fOnDestroyFailed: TVirtualDesktopDestroyNotifyW11; + fOnDestroyed: TVirtualDesktopDestroyNotifyW11; + fOnError: TErrorNotify; + procedure FreeDesktops; + function CheckError(res: HRESULT): Boolean; + procedure Initialize; + procedure Finalize; + function _GetCount: Integer; + function _GetDesktop(Index: Integer): TVirtualDesktopW11; + function _GetCurrentDesktop: TVirtualDesktopW11; + function _GetCurrentDesktopIndex: Integer; + procedure _SetCurrentDesktopIndex(const Value: Integer); + function _GetCurrentDesktopId: TGUID; + protected + procedure SetLastError(error: HRESULT); + public + procedure AfterConstruction; override; + { Methods } + // DESKTOPS + // Additional + procedure Refresh; + function GetDesktopIndexById(Id: TGUID): Integer; + // Create + function CreateDesktop: Boolean; + function CreateDesktopAndSwitch: Boolean; + // Switch + function SwitchToDesktop(Desktop: TVirtualDesktopW11): Boolean; overload; + function SwitchToDesktop(DesktopId: TGUID): Boolean; overload; + function SwitchToDesktop(DesktopIndex: Integer): Boolean; overload; + // Remove + function RemoveDesktop(Desktop: TVirtualDesktopW11): Boolean; overload; + function RemoveDesktop(Desktop, DesktopFallback: TVirtualDesktopW11): Boolean; overload; + function RemoveDesktop(DesktopId: TGUID): Boolean; overload; + function RemoveDesktop(DesktopId, DesktopFallbackId: TGUID): Boolean; overload; + function RemoveDesktop(DesktopIndex: Integer): Boolean; overload; + function RemoveDesktop(DesktopIndex, DesktopFallbackIndex: Integer): Boolean; overload; + // WINDOWS AND APPS + function IsWindowOnCurrentDesktop(Wnd: HWND): Boolean; + function GetWindowDesktop(Wnd: HWND): TVirtualDesktopW11; + // Visibility + function IsWindowVisibleAtDesktop(Wnd: HWND; Desktop: TVirtualDesktopW11): Boolean; overload; + function IsWindowVisibleAtDesktop(Wnd: HWND; DesktopId: TGUID): Boolean; overload; + function IsWindowVisibleAtDesktop(Wnd: HWND; DesktopIndex: Integer): Boolean; overload; + // Move + function MoveWindowToDesktop(Wnd: HWND; Desktop: TVirtualDesktopW11): Boolean; overload; + function MoveWindowToDesktop(Wnd: HWND; DesktopId: TGUID): Boolean; overload; + function MoveWindowToDesktop(Wnd: HWND; DesktopIndex: Integer): Boolean; overload; + // Additional + function IsWindowHaveView(Wnd: HWND): Boolean; + function FlashWindow(Wnd: HWND): Boolean; + function SwithToWindow(Wnd: HWND): Boolean; + // Pin + function IsPinnedWindow(Wnd: HWND): Boolean; + function IsPinnedApplication(Wnd: HWND): Boolean; + function PinWindow(Wnd: HWND): Boolean; + function PinApplication(Wnd: HWND): Boolean; + function UnpinWindow(Wnd: HWND): Boolean; + function UnpinApplication(Wnd: HWND): Boolean; + { Properties } + property Enabled: Boolean read fEnabled; + property LastError: HRESULT read fLastError; + property Count: Integer read _GetCount; + property Desktops[Index: Integer]: TVirtualDesktopW11 read _GetDesktop; + property CurrentDesktop: TVirtualDesktopW11 read _GetCurrentDesktop; + property CurrentDesktopId: TGUID read _GetCurrentDesktopId; + property CurrentDesktopIndex: Integer read _GetCurrentDesktopIndex write _SetCurrentDesktopIndex; + { Events } + property OnDesktopCreated: TVirtualDesktopCreatedNotifyW11 read fOnCreated write fOnCreated; + property OnDesktopDestroyBegin: TVirtualDesktopDestroyNotifyW11 read fOnDestroyBegin write fOnDestroyBegin; + property OnDesktopDestroyFailed: TVirtualDesktopDestroyNotifyW11 read fOnDestroyFailed write fOnDestroyFailed; + property OnDesktopDestroyed: TVirtualDesktopDestroyNotifyW11 read fOnDestroyed write fOnDestroyed; + property OnCurrentDesktopChanged: TCurrentVirtualDesktopChangedNotifyW11 read fOnCurrentChanged write fOnCurrentChanged; + property OnError: TErrorNotify read fOnError write fOnError; + end; + +var + DesktopManager: TVirtualDesktopManager; + DesktopManagerW11: TVirtualDesktopManagerW11; + +implementation + +function IsW11:Boolean; +begin + Result := Win32BuildNumber >= 22000; +end; + +{ TNonRefInterfacedObject } + +function TNonRefInterfacedObject._AddRef: Integer; +begin + Result := InterlockedIncrement(fRefCount); +end; + +function TNonRefInterfacedObject._Release: Integer; +begin + Assert(fRefCount > 0, 'Reference count must be greater than zero.'); + Result := InterlockedDecrement(fRefCount); + if (fRefCount = 0) and fDestroyed then + FreeInstance; +end; + +procedure TNonRefInterfacedObject.FreeInstance; +begin + fDestroyed := True; + if fRefCount = 0 then + begin + DoFreeInstance; + inherited FreeInstance; + end; +end; + +function TNonRefInterfacedObject.QueryInterface(const IID: TGUID; out Obj): HRESULT; +begin + if GetInterface(IID, Obj) then + Result := 0 + else + Result := E_NOINTERFACE; +end; + +procedure TNonRefInterfacedObject.DoFreeInstance; +begin +end; + +{ TVirtualDesktop } + +constructor TVirtualDesktop.Create(Manager: TVirtualDesktopManager; iDesktop: IVirtualDesktop); +begin + Assert((Manager <> nil), 'Manager must be assigned!'); + Assert((iDesktop <> nil), 'Desktop interface must be assigned!'); + fManager := Manager; + fIDesktop := iDesktop; + fIDesktop._AddRef; +end; + +procedure TVirtualDesktop.DoFreeInstance; +begin + fIDesktop._Release; +end; + +function TVirtualDesktop.GetId(Id: PGUID): HRESULT; +begin + Result := fIDesktop.GetId(Id); +end; + +function TVirtualDesktop.GetName(Hs: HSTRING): HRESULT; +begin + Result := S_OK; +end; + +function TVirtualDesktop.GetWallpaperPath(Hs: HSTRING): HRESULT; +begin + +end; + +function TVirtualDesktop.IsViewVisible(View: IApplicationView; pfVisible: PBOOL): HRESULT; +begin + Result := fIDesktop.IsViewVisible(View, pfVisible); +end; + +function TVirtualDesktop.IsWindowVisible(Wnd: HWND): Boolean; +begin + Result := fManager.IsWindowVisibleAtDesktop(Wnd, Self); +end; + +function TVirtualDesktop.QueryInterface(const IID: TGUID; out Obj): HRESULT; +begin + if GetInterface(IID, Obj) then + Result := 0 + else + Result := fIDesktop.QueryInterface(IID, Obj); +end; + +function TVirtualDesktop.Remove: Boolean; +begin + Result := fManager.RemoveDesktop(Self); +end; + +function TVirtualDesktop.Remove(FallbackDesktop: TVirtualDesktop): Boolean; +begin + Result := fManager.RemoveDesktop(Self, FallbackDesktop); +end; + +function TVirtualDesktop.Remove(FallbackDesktopId: TGUID): Boolean; +begin + Result := fManager.RemoveDesktop(_GetId, FallbackDesktopId); +end; + +function TVirtualDesktop.Remove(FallbackDesktopIndex: Integer): Boolean; +begin + Result := fManager.RemoveDesktop(_GetIndex, FallbackDesktopIndex); +end; + +function TVirtualDesktop.SwitchHere: Boolean; +begin + Result := fManager.SwitchToDesktop(Self); +end; + +function TVirtualDesktop._GetId: TGUID; +var + error_code: HRESULT; +begin + error_code := fIDesktop.GetId(@Result); + if Failed(error_code) then + Result := EMPTY_GUID; + fManager.SetLastError(error_code); +end; + +function TVirtualDesktop._GetIdAsString: AnsiString; +begin + Result := GUIDToString(_GetId); +end; + +function TVirtualDesktop._GetIndex: Integer; +begin + Result := fManager.GetDesktopIndexById(_GetId); +end; + +function TVirtualDesktop._GetIsCurrent: Boolean; +begin + Result := IsEqualGUID(fManager.CurrentDesktop.Id, _GetId); +end; + +{ TVirtualDesktopManager } + +procedure ReleaseAndNil(var Intf); +var + Temp: IUnknown; +begin + Temp := IUnknown(Intf); + if Temp = nil then + Exit; + Temp._Release; + Pointer(Intf) := nil; +end; + +procedure TVirtualDesktopManager.AfterConstruction; +begin + inherited AfterConstruction; + Initialize; + if fEnabled then + Refresh; +end; + +function TVirtualDesktopManager.CheckError(res: HRESULT): Boolean; +begin + fLastError := Res; + Result := Succeeded(Res); + if (not Result) and Assigned(fOnError) then + fOnError(Self, res); +end; + +function TVirtualDesktopManager.CreateDesktop: Boolean; +var + intf_desktop: IVirtualDesktop; +begin + Result := CheckError(fIVDMI.CreateDesktopW(@intf_desktop)); +end; + +function TVirtualDesktopManager.CreateDesktopAndSwitch: Boolean; +var + intf_desktop: IVirtualDesktop; +begin + Result := CheckError(fIVDMI.CreateDesktopW(@intf_desktop)); + if Result then + Result := CheckError(fIVDMI.SwitchDesktop(intf_desktop)); +end; + +function TVirtualDesktopManager.CurrentVirtualDesktopChanged(DesktopOld, DesktopNew: IVirtualDesktop): HRESULT; +var + old_desktop_id, new_desktop_id: TGUID; +begin + if Assigned(fOnCurrentChanged) then + begin + CheckError(DesktopOld.GetId(@old_desktop_id)); + CheckError(DesktopNew.GetId(@new_desktop_id)); + fOnCurrentChanged(Self, _GetDesktop(GetDesktopIndexById(old_desktop_id)), _GetDesktop(GetDesktopIndexById(new_desktop_id))); + end; + Result := S_OK; +end; + +procedure TVirtualDesktopManager.DoFreeInstance; +begin + if fEnabled then + Finalize; + FreeDesktops; +end; + +procedure TVirtualDesktopManager.Finalize; +begin + if fIVNS <> nil then + fIVNS.Unregister(fCookie); + ReleaseAndNil(fIVDM); + ReleaseAndNil(fIVDMI); + ReleaseAndNil(fIVNS); + ReleaseAndNil(fIAVC); + ReleaseAndNil(fIVDPA); + ReleaseAndNil(fISP); +end; + +procedure TVirtualDesktopManager.FreeDesktops; +var + desktop_index: Integer; +begin + if fDesktops <> nil then + begin + for desktop_index := fDesktops.Count - 1 downto 0 do + TVirtualDesktop(fDesktops[desktop_index]).Free; + FreeAndNil(fDesktops); + end; +end; + +function TVirtualDesktopManager.GetDesktopIndexById(Id: TGUID): Integer; +begin + Result := 0; + while (Result < Count) and (not IsEqualGUID(TVirtualDesktop(fDesktops[Result]).Id, Id)) do + Inc(Result); + if Result = Count then + Result := -1; +end; + +function TVirtualDesktopManager.GetWindowDesktop(Wnd: HWND): TVirtualDesktop; +var + desktop_id: TGUID; +begin + Result := nil; + if fEnabled then + if CheckError(fIVDM.GetWindowDesktopId(Wnd, @desktop_id)) then + Result := _GetDesktop(GetDesktopIndexById(desktop_id)); +end; + +function TVirtualDesktopManager.FlashWindow(Wnd: HWND): Boolean; +var + intf_view: IApplicationView; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + Result := CheckError(intf_view.Flash); + end; +end; + +procedure TVirtualDesktopManager.Initialize; +begin + fISP := nil; + fIVDM := nil; + fIVDMI := nil; + fIVDMI11 := nil; + fIVNS := nil; + fIAVC := nil; + fIVDPA := nil; + if IsW11 then + begin + fEnabled := CheckError(CoCreateInstance(CLSID_VirtualDesktopManager, nil, CLSCTX_INPROC_SERVER, IID_VirtualDesktopManager, fIVDMI11)) and // + CheckError(CoCreateInstance(CLSID_ImmersiveShell, nil, CLSCTX_LOCAL_SERVER, IID_ServiceProvider, fISP)); + if fEnabled then + begin + //22000 and later using IVirtualDesktopManagerInternalW11 instead + fEnabled := CheckError(fISP.QueryService(CLSID_VirtualDesktopManagerInternal, IID_VirtualDesktopManagerInternal_22000, fIVDMI11)); + if not fEnabled then + fEnabled := CheckError(fISP.QueryService(CLSID_VirtualDesktopManagerInternal, IID_VirtualDesktopManagerInternal_22621, fIVDMI11)); + if not fEnabled then + fEnabled := CheckError(fISP.QueryService(CLSID_VirtualDesktopManagerInternal, IID_VirtualDesktopManagerInternal_22631, fIVDMI11)); + fEnabled := fEnabled and // + CheckError(fISP.QueryService(CLSID_VirtualNotificationService, IID_VirtualNotificationService, fIVNS)) and // + CheckError(fISP.QueryService(CLSID_ApplicationViewCollection, IID_ApplicationViewCollection, fIAVC)) and // + CheckError(fISP.QueryService(CLSID_VirtualDesktopPinnedApps, IID_VirtualDesktopPinnedApps, fIVDPA)); + if fEnabled then + begin + // fEnabled := CheckError(fIVNS.Register(Self, @fCookie)); + OleCheck(fIVNS.Register(Self, @fCookie)); + end; + end; + end + else + begin + fEnabled := CheckError(CoCreateInstance(CLSID_VirtualDesktopManager, nil, CLSCTX_INPROC_SERVER, IID_VirtualDesktopManager, fIVDM)) and // + CheckError(CoCreateInstance(CLSID_ImmersiveShell, nil, CLSCTX_LOCAL_SERVER, IID_ServiceProvider, fISP)); + if fEnabled then + begin + fEnabled := CheckError(fISP.QueryService(CLSID_VirtualDesktopManagerInternal, IID_VirtualDesktopManagerInternal_14393, fIVDMI)); + if not fEnabled then + fEnabled := CheckError(fISP.QueryService(CLSID_VirtualDesktopManagerInternal, IID_VirtualDesktopManagerInternal_10240, fIVDMI)); + if not fEnabled then + fEnabled := CheckError(fISP.QueryService(CLSID_VirtualDesktopManagerInternal, IID_VirtualDesktopManagerInternal_10130, fIVDMI)); + if not fEnabled then + begin + //22000 and later using IVirtualDesktopManagerInternalW11 instead + fEnabled := CheckError(fISP.QueryService(CLSID_VirtualDesktopManagerInternal, IID_VirtualDesktopManagerInternal_22000, fIVDMI11)); + end; + fEnabled := fEnabled and // + CheckError(fISP.QueryService(CLSID_VirtualNotificationService, IID_VirtualNotificationService, fIVNS)) and // + CheckError(fISP.QueryService(CLSID_ApplicationViewCollection, IID_ApplicationViewCollection, fIAVC)) and // + CheckError(fISP.QueryService(CLSID_VirtualDesktopPinnedApps, IID_VirtualDesktopPinnedApps, fIVDPA)); + if fEnabled then + begin + fEnabled := CheckError(fIVNS.Register(Self, @fCookie)); +// OleCheck(fIVNS.Register(Self, @fCookie)); + end; + end; + end; + + if not fEnabled then + Finalize; +end; + +function TVirtualDesktopManager.IsWindowOnCurrentDesktop(Wnd: HWND): Boolean; +var + bool_result: BOOL; +begin + Result := False; + if fEnabled then + if CheckError(fIVDM.IsWindowOnCurrentVirtualDesktop(Wnd, @bool_result)) then + Result := bool_result; +end; + +function TVirtualDesktopManager.MoveWindowToDesktop(Wnd: HWND; Desktop: TVirtualDesktop): Boolean; +var + intf_view: IApplicationView; +begin + Result := False; + if fEnabled then + if GetWindowThreadProcessId(Wnd) = GetCurrentProcessId then + Result := CheckError(fIVDM.MoveWindowToDesktop(Wnd, Desktop.Id)) + else + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + Result := CheckError(fIVDMI.MoveViewToDesktop(intf_view, (Desktop as IVirtualDesktop))); + end; +end; + +function TVirtualDesktopManager.MoveWindowToDesktop(Wnd: HWND; DesktopId: TGUID): Boolean; +begin + Result := MoveWindowToDesktop(Wnd, _GetDesktop(GetDesktopIndexById(DesktopId))); +end; + +function TVirtualDesktopManager.MoveWindowToDesktop(Wnd: HWND; DesktopIndex: Integer): Boolean; +begin + Result := MoveWindowToDesktop(Wnd, _GetDesktop(DesktopIndex)); +end; + +function TVirtualDesktopManager.IsWindowHaveView(Wnd: HWND): Boolean; +var + intf_view: IApplicationView; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + Result := Succeeded(fIAVC.GetViewForHwnd(Wnd, @intf_view)); + end; +end; + +function TVirtualDesktopManager.IsPinnedApplication(Wnd: HWND): Boolean; +var + intf_view: IApplicationView; + app_id: PLPWSTR; + bool_result: BOOL; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + begin + GetMem(app_id, 1024); + if CheckError(intf_view.GetAppUserModelId(app_id)) then + if CheckError(fIVDPA.IsAppIdPinned(app_id^, @bool_result)) then + Result := bool_result; + FreeMem(app_id); + end; + end; +end; + +function TVirtualDesktopManager.IsPinnedWindow(Wnd: HWND): Boolean; +var + intf_view: IApplicationView; + bool_result: BOOL; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + if CheckError(fIVDPA.IsViewPinned(intf_view, @bool_result)) then + Result := bool_result; + end; +end; + +function TVirtualDesktopManager.IsWindowVisibleAtDesktop(Wnd: HWND; Desktop: TVirtualDesktop): Boolean; +var + intf_view: IApplicationView; + bool_result: Boolean; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + if CheckError((Desktop as IVirtualDesktop).IsViewVisible(intf_view, @bool_result)) then + Result := bool_result; + end; +end; + +function TVirtualDesktopManager.IsWindowVisibleAtDesktop(Wnd: HWND; DesktopId: TGUID): Boolean; +begin + Result := IsWindowVisibleAtDesktop(Wnd, _GetDesktop(GetDesktopIndexById(DesktopId))); +end; + +function TVirtualDesktopManager.IsWindowVisibleAtDesktop(Wnd: HWND; DesktopIndex: Integer): Boolean; +begin + Result := IsWindowVisibleAtDesktop(Wnd, _GetDesktop(DesktopIndex)); +end; + +procedure TVirtualDesktopManager.Refresh; +var + desktop_count: UINT; + desktop_index: Integer; + desktop_new: TVirtualDesktop; + intf_desktop: IVirtualDesktop; + intf_desktops: IObjectArray; +begin + FreeDesktops; + if fEnabled then + if CheckError(fIVDMI.GetDesktops(@intf_desktops)) then + if CheckError(intf_desktops.GetCount(@desktop_count)) and (desktop_count > 0) then + begin + fDesktops := TList.Create; + for desktop_index := 0 to desktop_count - 1 do + if CheckError(intf_desktops.GetAt(desktop_index, @IID_VirtualDesktop, @intf_desktop)) then + begin + desktop_new := TVirtualDesktop.Create(Self, intf_desktop); + fDesktops.Add(desktop_new); + end; + end; +end; + +function TVirtualDesktopManager.RemoveDesktop(Desktop: TVirtualDesktop): Boolean; +var + intf_desktop: IVirtualDesktop; + candidate: Integer; +begin + Result := False; + if fEnabled then + if Count = 1 then + begin + Result := CheckError(fIVDMI.CreateDesktopW(@intf_desktop)); + if Result then + Result := CheckError(fIVDMI.RemoveDesktop((Desktop as IVirtualDesktop), intf_desktop)); + end + else if Desktop.IsCurrent then + begin + candidate := 0; + while IsEqualGUID(_GetDesktop(candidate).Id, Desktop.Id) do + Inc(candidate); + Result := CheckError(fIVDMI.RemoveDesktop((Desktop as IVirtualDesktop), (_GetDesktop(candidate) as IVirtualDesktop))); + end + else + Result := CheckError(fIVDMI.RemoveDesktop((Desktop as IVirtualDesktop), (_GetCurrentDesktop as IVirtualDesktop))); +end; + +function TVirtualDesktopManager.RemoveDesktop(DesktopId: TGUID): Boolean; +begin + Result := RemoveDesktop(_GetDesktop(GetDesktopIndexById(DesktopId))); +end; + +function TVirtualDesktopManager.RemoveDesktop(DesktopIndex: Integer): Boolean; +begin + Result := RemoveDesktop(_GetDesktop(DesktopIndex)); +end; + +function TVirtualDesktopManager.RemoveDesktop(Desktop, DesktopFallback: TVirtualDesktop): Boolean; +begin + Result := CheckError(fIVDMI.RemoveDesktop((Desktop as IVirtualDesktop), (DesktopFallback as IVirtualDesktop))); +end; + +function TVirtualDesktopManager.RemoveDesktop(DesktopId, DesktopFallbackId: TGUID): Boolean; +begin + Result := RemoveDesktop(_GetDesktop(GetDesktopIndexById(DesktopId)), _GetDesktop(GetDesktopIndexById(DesktopFallbackId))); +end; + +function TVirtualDesktopManager.RemoveDesktop(DesktopIndex, DesktopFallbackIndex: Integer): Boolean; +begin + Result := RemoveDesktop(_GetDesktop(DesktopIndex), _GetDesktop(DesktopFallbackIndex)); +end; + +function TVirtualDesktopManager.PinApplication(Wnd: HWND): Boolean; +var + intf_view: IApplicationView; + app_id: PLPWSTR; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + begin + GetMem(app_id, 1024); + if CheckError(intf_view.GetAppUserModelId(app_id)) then + Result := CheckError(fIVDPA.PinAppID(app_id^)); + FreeMem(app_id); + end; + end; +end; + +function TVirtualDesktopManager.PinWindow(Wnd: HWND): Boolean; +var + intf_view: IApplicationView; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + Result := CheckError(fIVDPA.PinView(intf_view)); + end; +end; + +procedure TVirtualDesktopManager.SetLastError(error: HRESULT); +begin + fLastError := error; +end; + +function TVirtualDesktopManager.SwitchToDesktop(Desktop: TVirtualDesktop): Boolean; +begin + if fEnabled then + Result := CheckError(fIVDMI.SwitchDesktop((Desktop as IVirtualDesktop))) + else + Result := False; +end; + +function TVirtualDesktopManager.SwitchToDesktop(DesktopId: TGUID): Boolean; +begin + Result := SwitchToDesktop(_GetDesktop(GetDesktopIndexById(DesktopId))); +end; + +function TVirtualDesktopManager.SwitchToDesktop(DesktopIndex: Integer): Boolean; +begin + Result := SwitchToDesktop(_GetDesktop(DesktopIndex)); +end; + +function TVirtualDesktopManager.SwithToWindow(Wnd: HWND): Boolean; +var + intf_view: IApplicationView; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + Result := CheckError(intf_view.SwitchTo); + end; +end; + +function TVirtualDesktopManager.UnpinApplication(Wnd: HWND): Boolean; +var + intf_view: IApplicationView; + app_id: PLPWSTR; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + begin + GetMem(app_id, 1024); + if CheckError(intf_view.GetAppUserModelId(app_id)) then + Result := CheckError(fIVDPA.UnpinAppID(app_id^)); + FreeMem(app_id); + end; + end; +end; + +function TVirtualDesktopManager.UnpinWindow(Wnd: HWND): Boolean; +var + intf_view: IApplicationView; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + Result := CheckError(fIVDPA.UnpinView(intf_view)); + end; +end; + +function TVirtualDesktopManager.ViewVirtualDesktopChanged(View: IApplicationView): HRESULT; +begin + // to do + Result := S_OK; +end; + +function TVirtualDesktopManager.VirtualDesktopCreated(Desktop: IVirtualDesktop): HRESULT; +var + new_desktop: TVirtualDesktop; +begin + new_desktop := TVirtualDesktop.Create(Self, Desktop); + fDesktops.Add(new_desktop); + if Assigned(fOnCreated) then + fOnCreated(Self, new_desktop); + Result := S_OK; +end; + +function TVirtualDesktopManager.VirtualDesktopDestroyBegin(Desktop, DesktopFallback: IVirtualDesktop): HRESULT; +var + desktop_id, desktop_fallback_id: TGUID; +begin + if Assigned(fOnDestroyBegin) then + begin + CheckError(Desktop.GetId(@desktop_id)); + CheckError(DesktopFallback.GetId(@desktop_fallback_id)); + fOnDestroyBegin(Self, _GetDesktop(GetDesktopIndexById(desktop_id)), _GetDesktop(GetDesktopIndexById(desktop_fallback_id))); + end; + Result := S_OK; +end; + +function TVirtualDesktopManager.VirtualDesktopDestroyed(Desktop, DesktopFallback: IVirtualDesktop): HRESULT; +var + desktop_id, desktop_fallback_id: TGUID; + destroyed_desktop: TVirtualDesktop; +begin + CheckError(Desktop.GetId(@desktop_id)); + destroyed_desktop := TVirtualDesktop(fDesktops.Extract(_GetDesktop(GetDesktopIndexById(desktop_id)))); + if Assigned(fOnDestroyed) then + begin + CheckError(DesktopFallback.GetId(@desktop_fallback_id)); + fOnDestroyed(Self, destroyed_desktop, _GetDesktop(GetDesktopIndexById(desktop_fallback_id))); + end; + destroyed_desktop.Free; + Result := S_OK; +end; + +function TVirtualDesktopManager.VirtualDesktopDestroyFailed(Desktop, DesktopFallback: IVirtualDesktop): HRESULT; +var + desktop_id, desktop_fallback_id: TGUID; +begin + if Assigned(fOnDestroyFailed) then + begin + CheckError(Desktop.GetId(@desktop_id)); + CheckError(DesktopFallback.GetId(@desktop_fallback_id)); + fOnDestroyFailed(Self, _GetDesktop(GetDesktopIndexById(desktop_id)), _GetDesktop(GetDesktopIndexById(desktop_fallback_id))); + end; + Result := S_OK; +end; + +function TVirtualDesktopManager._GetCount: Integer; +begin + if fDesktops = nil then + Result := 0 + else + Result := fDesktops.Count; +end; + +function TVirtualDesktopManager._GetCurrentDesktop: TVirtualDesktop; +begin + Result := _GetDesktop(_GetCurrentDesktopIndex); +end; + +function TVirtualDesktopManager._GetCurrentDesktopIndex: Integer; +var + intf_desktop: IVirtualDesktop; + desktop_id: TGUID; +begin + Result := -1; + if fEnabled then + if CheckError(fIVDMI.GetCurrentDesktop(@intf_desktop)) then + if CheckError(intf_desktop.GetId(@desktop_id)) then + Result := GetDesktopIndexById(desktop_id); +end; + +function TVirtualDesktopManager._GetDesktop(Index: Integer): TVirtualDesktop; +begin + if (fDesktops = nil) or (Index < 0) or (Index >= fDesktops.Count) then + Result := nil + else + Result := TVirtualDesktop(fDesktops.Items[Index]); +end; + +function TVirtualDesktopManager._GetCurrentDesktopId: TGUID; +begin + Result := CurrentDesktop.Id; +end; + +procedure TVirtualDesktopManager._SetCurrentDesktopIndex(const Value: Integer); +begin + SwitchToDesktop(Value); +end; + +{ TVirtualDesktopManagerW11 } + +procedure TVirtualDesktopManagerW11.AfterConstruction; +begin + inherited AfterConstruction; + Initialize; + if fEnabled then + Refresh; +end; + +function TVirtualDesktopManagerW11.CheckError(res: HRESULT): Boolean; +begin + fLastError := Res; + Result := Succeeded(Res); + if (not Result) and Assigned(fOnError) then + fOnError(Self, res); +end; + +function TVirtualDesktopManagerW11.CreateDesktop: Boolean; +var + intf_desktop: IVirtualDesktopW11; +begin +{ TODO : watch if nil (pointer.zero) works } + Result := CheckError(fIVDMI11.CreateDesktopW(nil, @intf_desktop)); +end; + +function TVirtualDesktopManagerW11.CreateDesktopAndSwitch: Boolean; +var + intf_desktop: IVirtualDesktopW11; +begin +{ TODO : watch if nil (pointer.zero) works } + Result := CheckError(fIVDMI11.CreateDesktopW(nil, @intf_desktop)); + if Result then + Result := CheckError(fIVDMI11.SwitchDesktop(nil, intf_desktop)); +end; + +function TVirtualDesktopManagerW11.CurrentVirtualDesktopChanged(p0: IObjectArray; DesktopOld, + DesktopNew: IVirtualDesktopW11): HRESULT; +var + old_desktop_id, new_desktop_id: TGUID; +begin + if Assigned(fOnCurrentChanged) then + begin + CheckError(DesktopOld.GetId(@old_desktop_id)); + CheckError(DesktopNew.GetId(@new_desktop_id)); + fOnCurrentChanged(Self, _GetDesktop(GetDesktopIndexById(old_desktop_id)), _GetDesktop(GetDesktopIndexById(new_desktop_id))); + end; + Result := S_OK; +end; + +procedure TVirtualDesktopManagerW11.DoFreeInstance; +begin + if fEnabled then + Finalize; + FreeDesktops; +end; + +procedure TVirtualDesktopManagerW11.Finalize; +begin + if fIVNS <> nil then + fIVNS.Unregister(fCookie); + ReleaseAndNil(fIVDM); + ReleaseAndNil(fIVDMI11); + ReleaseAndNil(fIVNS); + ReleaseAndNil(fIAVC); + ReleaseAndNil(fIVDPA); + ReleaseAndNil(fISP); +end; + +function TVirtualDesktopManagerW11.FlashWindow(Wnd: HWND): Boolean; +var + intf_view: IApplicationViewW11; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + Result := CheckError(intf_view.Flash); + end; +end; + +procedure TVirtualDesktopManagerW11.FreeDesktops; +var + desktop_index: Integer; +begin + if fDesktops <> nil then + begin + for desktop_index := fDesktops.Count - 1 downto 0 do + TVirtualDesktopW11(fDesktops[desktop_index]).Free; + FreeAndNil(fDesktops); + end; +end; + +function TVirtualDesktopManagerW11.GetDesktopIndexById(Id: TGUID): Integer; +begin + Result := 0; + while (Result < Count) and (not IsEqualGUID(TVirtualDesktopW11(fDesktops[Result]).Id, Id)) do + Inc(Result); + if Result = Count then + Result := -1; +end; + +function TVirtualDesktopManagerW11.GetWindowDesktop( + Wnd: HWND): TVirtualDesktopW11; +var + desktop_id: TGUID; +begin + Result := nil; + if fEnabled then + if CheckError(fIVDM.GetWindowDesktopId(Wnd, @desktop_id)) then + Result := _GetDesktop(GetDesktopIndexById(desktop_id)); +end; + +procedure TVirtualDesktopManagerW11.Initialize; +begin + fISP := nil; + fIVDM := nil; + fIVDMI11 := nil; + fIVNS := nil; + fIAVC := nil; + fIVDPA := nil; + fEnabled := CheckError(CoCreateInstance(CLSID_VirtualDesktopManager, nil, CLSCTX_INPROC_SERVER, IID_VirtualDesktopManager, fIVDMI11)) and // + CheckError(CoCreateInstance(CLSID_ImmersiveShell, nil, CLSCTX_LOCAL_SERVER, IID_ServiceProvider, fISP)); + if fEnabled then + begin + //22000 and later using IVirtualDesktopManagerInternalW11 instead + fEnabled := CheckError(fISP.QueryService(CLSID_VirtualDesktopManagerInternal, IID_VirtualDesktopManagerInternal_22000, fIVDMI11)); + fEnabled := fEnabled and // + CheckError(fISP.QueryService(CLSID_VirtualNotificationService, IID_VirtualNotificationService, fIVNS)) and // + CheckError(fISP.QueryService(CLSID_ApplicationViewCollection, IID_ApplicationViewCollectionW11, fIAVC)) and // + CheckError(fISP.QueryService(CLSID_VirtualDesktopPinnedApps, IID_VirtualDesktopPinnedApps, fIVDPA)); + if fEnabled then + begin + // fEnabled := CheckError(fIVNS.Register(Self, @fCookie)); + OleCheck(fIVNS.Register(Self, @fCookie)); + end; + end; + if not fEnabled then + Finalize; +end; + +function TVirtualDesktopManagerW11.IsPinnedApplication(Wnd: HWND): Boolean; +var + intf_view: IApplicationViewW11; + app_id: PLPWSTR; + bool_result: BOOL; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + begin + GetMem(app_id, 1024); + if CheckError(intf_view.GetAppUserModelId(app_id)) then + if CheckError(fIVDPA.IsAppIdPinned(app_id^, @bool_result)) then + Result := bool_result; + FreeMem(app_id); + end; + end; +end; + +function TVirtualDesktopManagerW11.IsPinnedWindow(Wnd: HWND): Boolean; +var + intf_view: IApplicationViewW11; + bool_result: BOOL; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + if CheckError(fIVDPA.IsViewPinned(intf_view, @bool_result)) then + Result := bool_result; + end; +end; + +function TVirtualDesktopManagerW11.IsWindowHaveView(Wnd: HWND): Boolean; +var + intf_view: IApplicationViewW11; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + Result := Succeeded(fIAVC.GetViewForHwnd(Wnd, @intf_view)); + end; +end; + +function TVirtualDesktopManagerW11.IsWindowOnCurrentDesktop(Wnd: HWND): Boolean; +var + bool_result: BOOL; +begin + Result := False; + if fEnabled then + if CheckError(fIVDM.IsWindowOnCurrentVirtualDesktop(Wnd, @bool_result)) then + Result := bool_result; +end; + +function TVirtualDesktopManagerW11.IsWindowVisibleAtDesktop(Wnd: HWND; + DesktopIndex: Integer): Boolean; +begin + Result := IsWindowVisibleAtDesktop(Wnd, _GetDesktop(DesktopIndex)); +end; + +function TVirtualDesktopManagerW11.IsWindowVisibleAtDesktop(Wnd: HWND; + DesktopId: TGUID): Boolean; +begin + Result := IsWindowVisibleAtDesktop(Wnd, _GetDesktop(GetDesktopIndexById(DesktopId))); +end; + +function TVirtualDesktopManagerW11.IsWindowVisibleAtDesktop(Wnd: HWND; + Desktop: TVirtualDesktopW11): Boolean; +var + intf_view: IApplicationViewW11; + bool_result: Boolean; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + if CheckError((Desktop as IVirtualDesktopW11).IsViewVisible(intf_view, @bool_result)) then + Result := bool_result; + end; +end; + +function TVirtualDesktopManagerW11.MoveWindowToDesktop(Wnd: HWND; + Desktop: TVirtualDesktopW11): Boolean; +var + intf_view: IApplicationViewW11; +begin + Result := False; + if fEnabled then + if GetWindowThreadProcessId(Wnd) = GetCurrentProcessId then + Result := CheckError(fIVDM.MoveWindowToDesktop(Wnd, Desktop.Id)) + else + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + Result := CheckError(fIVDMI11.MoveViewToDesktop(intf_view, (Desktop as IVirtualDesktopW11))); + end; +end; + +function TVirtualDesktopManagerW11.MoveWindowToDesktop(Wnd: HWND; + DesktopId: TGUID): Boolean; +begin + Result := MoveWindowToDesktop(Wnd, _GetDesktop(GetDesktopIndexById(DesktopId))); +end; + +function TVirtualDesktopManagerW11.MoveWindowToDesktop(Wnd: HWND; + DesktopIndex: Integer): Boolean; +begin + Result := MoveWindowToDesktop(Wnd, _GetDesktop(DesktopIndex)); +end; + +function TVirtualDesktopManagerW11.PinApplication(Wnd: HWND): Boolean; +var + intf_view: IApplicationViewW11; + app_id: PLPWSTR; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + begin + GetMem(app_id, 1024); + if CheckError(intf_view.GetAppUserModelId(app_id)) then + Result := CheckError(fIVDPA.PinAppID(app_id^)); + FreeMem(app_id); + end; + end; +end; + +function TVirtualDesktopManagerW11.PinWindow(Wnd: HWND): Boolean; +var + intf_view: IApplicationViewW11; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + Result := CheckError(fIVDPA.PinView(intf_view)); + end; +end; + +procedure TVirtualDesktopManagerW11.Refresh; +var + desktop_count: UINT; + desktop_index: Integer; + desktop_new: TVirtualDesktopW11; + intf_desktop: IVirtualDesktopW11; + intf_desktops: IObjectArray; +begin + FreeDesktops; + if fEnabled then + { TODO : watch if nil (pointer.zero) works } + if CheckError(fIVDMI11.GetDesktops(nil, @intf_desktops)) then + if CheckError(intf_desktops.GetCount(@desktop_count)) and (desktop_count > 0) then + begin + fDesktops := TList.Create; + for desktop_index := 0 to desktop_count - 1 do + if CheckError(intf_desktops.GetAt(desktop_index, @IID_VirtualDesktopW11, @intf_desktop)) then + begin + desktop_new := TVirtualDesktopW11.Create(Self, intf_desktop); + fDesktops.Add(desktop_new); + end; + end; +end; + +function TVirtualDesktopManagerW11.RemoveDesktop( + Desktop: TVirtualDesktopW11): Boolean; +var + intf_desktop: IVirtualDesktopW11; + candidate: Integer; +begin + Result := False; + if fEnabled then + if Count = 1 then + begin + { TODO : watch if nil (pointer.zero) works } + Result := CheckError(fIVDMI11.CreateDesktopW(nil,@intf_desktop)); + if Result then + Result := CheckError(fIVDMI11.RemoveDesktop((Desktop as IVirtualDesktopW11), intf_desktop)); + end + else if Desktop.IsCurrent then + begin + candidate := 0; + while IsEqualGUID(_GetDesktop(candidate).Id, Desktop.Id) do + Inc(candidate); + Result := CheckError(fIVDMI11.RemoveDesktop((Desktop as IVirtualDesktopW11), (_GetDesktop(candidate) as IVirtualDesktopW11))); + end + else + Result := CheckError(fIVDMI11.RemoveDesktop((Desktop as IVirtualDesktopW11), (_GetCurrentDesktop as IVirtualDesktopW11))); +end; + +function TVirtualDesktopManagerW11.RemoveDesktop(Desktop, + DesktopFallback: TVirtualDesktopW11): Boolean; +begin + Result := CheckError(fIVDMI11.RemoveDesktop((Desktop as IVirtualDesktopW11), (DesktopFallback as IVirtualDesktopW11))); +end; + +function TVirtualDesktopManagerW11.RemoveDesktop(DesktopIndex, + DesktopFallbackIndex: Integer): Boolean; +begin + Result := RemoveDesktop(_GetDesktop(DesktopIndex), _GetDesktop(DesktopFallbackIndex)); +end; + +function TVirtualDesktopManagerW11.RemoveDesktop( + DesktopIndex: Integer): Boolean; +begin + Result := RemoveDesktop(_GetDesktop(DesktopIndex)); +end; + +function TVirtualDesktopManagerW11.RemoveDesktop(DesktopId, + DesktopFallbackId: TGUID): Boolean; +begin + Result := RemoveDesktop(_GetDesktop(GetDesktopIndexById(DesktopId)), _GetDesktop(GetDesktopIndexById(DesktopFallbackId))); +end; + +function TVirtualDesktopManagerW11.RemoveDesktop(DesktopId: TGUID): Boolean; +begin + Result := RemoveDesktop(_GetDesktop(GetDesktopIndexById(DesktopId))); +end; + +procedure TVirtualDesktopManagerW11.SetLastError(error: HRESULT); +begin + fLastError := error; +end; + +function TVirtualDesktopManagerW11.SwitchToDesktop(DesktopId: TGUID): Boolean; +begin + Result := SwitchToDesktop(_GetDesktop(GetDesktopIndexById(DesktopId))); +end; + +function TVirtualDesktopManagerW11.SwitchToDesktop( + Desktop: TVirtualDesktopW11): Boolean; +begin + if fEnabled then + { TODO : watch if nil (pointer.zero) works } + Result := CheckError(fIVDMI11.SwitchDesktop(nil, (Desktop as IVirtualDesktopW11))) + else + Result := False; +end; + +function TVirtualDesktopManagerW11.SwitchToDesktop( + DesktopIndex: Integer): Boolean; +begin + Result := SwitchToDesktop(_GetDesktop(DesktopIndex)); +end; + +function TVirtualDesktopManagerW11.SwithToWindow(Wnd: HWND): Boolean; +var + intf_view: IApplicationViewW11; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + Result := CheckError(intf_view.SwitchTo); + end; +end; + +function TVirtualDesktopManagerW11.Unknown1(Number: Integer): HRESULT; +begin + +end; + +function TVirtualDesktopManagerW11.UnpinApplication(Wnd: HWND): Boolean; +var + intf_view: IApplicationViewW11; + app_id: PLPWSTR; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + begin + GetMem(app_id, 1024); + if CheckError(intf_view.GetAppUserModelId(app_id)) then + Result := CheckError(fIVDPA.UnpinAppID(app_id^)); + FreeMem(app_id); + end; + end; +end; + +function TVirtualDesktopManagerW11.UnpinWindow(Wnd: HWND): Boolean; +var + intf_view: IApplicationViewW11; +begin + Result := False; + if fEnabled then + begin + CheckError(fIAVC.RefreshCollection); + if CheckError(fIAVC.GetViewForHwnd(Wnd, @intf_view)) then + Result := CheckError(fIVDPA.UnpinView(intf_view)); + end; +end; + +function TVirtualDesktopManagerW11.ViewVirtualDesktopChanged( + View: IApplicationViewW11): HRESULT; +begin + // to do + Result := S_OK; +end; + +function TVirtualDesktopManagerW11.VirtualDesktopCreated(p0: IObjectArray; + Desktop: IVirtualDesktopW11): HRESULT; +var + new_desktop: TVirtualDesktopW11; +begin + new_desktop := TVirtualDesktopW11.Create(Self, Desktop); + fDesktops.Add(new_desktop); + if Assigned(fOnCreated) then + fOnCreated(Self, new_desktop); + Result := S_OK; +end; + +function TVirtualDesktopManagerW11.VirtualDesktopDestroyBegin(p0: IObjectArray; Desktop, + DesktopFallback: IVirtualDesktopW11): HRESULT; +var + desktop_id, desktop_fallback_id: TGUID; +begin + if Assigned(fOnDestroyBegin) then + begin + CheckError(Desktop.GetId(@desktop_id)); + CheckError(DesktopFallback.GetId(@desktop_fallback_id)); + fOnDestroyBegin(Self, _GetDesktop(GetDesktopIndexById(desktop_id)), _GetDesktop(GetDesktopIndexById(desktop_fallback_id))); + end; + Result := S_OK; +end; + +function TVirtualDesktopManagerW11.VirtualDesktopDestroyed(p0: IObjectArray; Desktop, + DesktopFallback: IVirtualDesktopW11): HRESULT; +var + desktop_id, desktop_fallback_id: TGUID; + destroyed_desktop: TVirtualDesktopW11; +begin + CheckError(Desktop.GetId(@desktop_id)); + destroyed_desktop := TVirtualDesktopW11(fDesktops.Extract(_GetDesktop(GetDesktopIndexById(desktop_id)))); + if Assigned(fOnDestroyed) then + begin + CheckError(DesktopFallback.GetId(@desktop_fallback_id)); + fOnDestroyed(Self, destroyed_desktop, _GetDesktop(GetDesktopIndexById(desktop_fallback_id))); + end; + destroyed_desktop.Free; + Result := S_OK; +end; + +function TVirtualDesktopManagerW11.VirtualDesktopDestroyFailed(p0: IObjectArray; Desktop, + DesktopFallback: IVirtualDesktopW11): HRESULT; +var + desktop_id, desktop_fallback_id: TGUID; +begin + if Assigned(fOnDestroyFailed) then + begin + CheckError(Desktop.GetId(@desktop_id)); + CheckError(DesktopFallback.GetId(@desktop_fallback_id)); + fOnDestroyFailed(Self, _GetDesktop(GetDesktopIndexById(desktop_id)), _GetDesktop(GetDesktopIndexById(desktop_fallback_id))); + end; + Result := S_OK; +end; + +function TVirtualDesktopManagerW11.VirtualDesktopMoved(p0: IObjectArray; + Desktop: IVirtualDesktopW11; nFromIndex, nToIndex: Integer): HRESULT; +begin + +end; + +function TVirtualDesktopManagerW11.VirtualDesktopRenamed( + Desktop: IVirtualDesktopW11; chName: HSTRING): HRESULT; +begin + +end; + +function TVirtualDesktopManagerW11.VirtualDesktopWallpaperChanged( + Desktop: IVirtualDesktopW11; chPath: HSTRING): HRESULT; +begin + +end; + +function TVirtualDesktopManagerW11._GetCount: Integer; +begin + if fDesktops = nil then + Result := 0 + else + Result := fDesktops.Count; +end; + +function TVirtualDesktopManagerW11._GetCurrentDesktop: TVirtualDesktopW11; +begin + Result := _GetDesktop(_GetCurrentDesktopIndex); +end; + +function TVirtualDesktopManagerW11._GetCurrentDesktopId: TGUID; +begin + Result := CurrentDesktop.Id; +end; + +function TVirtualDesktopManagerW11._GetCurrentDesktopIndex: Integer; +var + intf_desktop: IVirtualDesktopW11; + desktop_id: TGUID; +begin + Result := -1; + if fEnabled then + { TODO : watch if nil (pointer.zero) works } + if CheckError(fIVDMI11.GetCurrentDesktop(nil, @intf_desktop)) then + if CheckError(intf_desktop.GetId(@desktop_id)) then + Result := GetDesktopIndexById(desktop_id); +end; + +function TVirtualDesktopManagerW11._GetDesktop( + Index: Integer): TVirtualDesktopW11; +begin + if (fDesktops = nil) or (Index < 0) or (Index >= fDesktops.Count) then + Result := nil + else + Result := TVirtualDesktopW11(fDesktops.Items[Index]); +end; + +procedure TVirtualDesktopManagerW11._SetCurrentDesktopIndex( + const Value: Integer); +begin + SwitchToDesktop(Value); +end; + +{ TVirtualDesktopW11 } + +constructor TVirtualDesktopW11.Create(Manager: TVirtualDesktopManagerW11; + iDesktop: IVirtualDesktopW11); +begin + Assert((Manager <> nil), 'Manager must be assigned!'); + Assert((iDesktop <> nil), 'Desktop interface must be assigned!'); + fManager := Manager; + fIDesktop := iDesktop; + fIDesktop._AddRef; +end; + +procedure TVirtualDesktopW11.DoFreeInstance; +begin + fIDesktop._Release; +end; + +function TVirtualDesktopW11.GetId(Id: PGUID): HRESULT; +begin + Result := fIDesktop.GetId(Id); +end; + +function TVirtualDesktopW11.GetName(Hs: HSTRING): HRESULT; +begin + Result := fIDesktop.GetName(Hs); +end; + +function TVirtualDesktopW11.GetWallpaperPath(Hs: HSTRING): HRESULT; +begin + Result := fIDesktop.GetWallpaperPath(Hs); +end; + +function TVirtualDesktopW11.IsViewVisible(View: IApplicationViewW11; + pfVisible: PBOOL): HRESULT; +begin + Result := fIDesktop.IsViewVisible(View, pfVisible); +end; + +function TVirtualDesktopW11.IsWindowVisible(Wnd: HWND): Boolean; +begin + Result := fManager.IsWindowVisibleAtDesktop(Wnd, Self); +end; + +function TVirtualDesktopW11.Proc5(PProc5: PUINT): HRESULT; +begin + { TODO : unknown function } + Result := S_OK; +end; + +function TVirtualDesktopW11.QueryInterface(const IID: TGUID; out Obj): HRESULT; +begin + if GetInterface(IID, Obj) then + Result := 0 + else + Result := fIDesktop.QueryInterface(IID, Obj); +end; + +function TVirtualDesktopW11.Remove( + FallbackDesktop: TVirtualDesktopW11): Boolean; +begin + Result := fManager.RemoveDesktop(Self, FallbackDesktop); +end; + +function TVirtualDesktopW11.Remove: Boolean; +begin + Result := fManager.RemoveDesktop(Self); +end; + +function TVirtualDesktopW11.Remove(FallbackDesktopIndex: Integer): Boolean; +begin + Result := fManager.RemoveDesktop(_GetIndex, FallbackDesktopIndex); +end; + +function TVirtualDesktopW11.Remove(FallbackDesktopId: TGUID): Boolean; +begin + Result := fManager.RemoveDesktop(_GetId, FallbackDesktopId); +end; + +function TVirtualDesktopW11.SwitchHere: Boolean; +begin + Result := fManager.SwitchToDesktop(Self); +end; + +function TVirtualDesktopW11._GetId: TGUID; +var + error_code: HRESULT; +begin + error_code := fIDesktop.GetId(@Result); + if Failed(error_code) then + Result := EMPTY_GUID; + fManager.SetLastError(error_code); +end; + +function TVirtualDesktopW11._GetIdAsString: AnsiString; +begin + Result := GUIDToString(_GetId); +end; + +function TVirtualDesktopW11._GetIndex: Integer; +begin + Result := fManager.GetDesktopIndexById(_GetId); +end; + +function TVirtualDesktopW11._GetIsCurrent: Boolean; +begin + Result := IsEqualGUID(fManager.CurrentDesktop.Id, _GetId); +end; + +initialization + CoInitialize(nil); + if IsW11 then + DesktopManagerW11 := TVirtualDesktopManagerW11.Create + else + DesktopManager := TVirtualDesktopManager.Create; + +finalization + if IsW11 then + DesktopManagerW11.Free + else + DesktopManager.Free; + + CoUninitialize; + +end. + diff --git a/XGraphics.pas b/thirparty/XGraphics.pas similarity index 100% rename from XGraphics.pas rename to thirparty/XGraphics.pas diff --git a/thirparty/pngimage.pas b/thirparty/pngimage.pas new file mode 100644 index 0000000..d873ca0 --- /dev/null +++ b/thirparty/pngimage.pas @@ -0,0 +1,5824 @@ +{Portable Network Graphics Delphi 1.564 (31 July 2006) } + +{This is a full, open sourced implementation of png in Delphi } +{It has native support for most of png features including the } +{partial transparency, gamma and more. } +{For the latest version, please be sure to check my website } +{http://pngdelphi.sourceforge.net } +{Gustavo Huffenbacher Daud (gustavo.daud@terra.com.br) } + + +{ + Version 1.564 + 2006-07-25 BUG 1 - There was one GDI Palette object leak + when assigning from other PNG (fixed) + BUG 2 - Loosing color information when assigning png + to bmp on lower screen depth system + BUG 3 - There was a bug in TStream.GetSize + (fixed thanks to Vladimir Panteleev) + IMPROVE 1 - When assigning png to bmp now alpha information + is drawn (simulated into a white background) + + Version 1.563 + 2006-07-25 BUG 1 - There was a memory bug in the main component + destructor (fixed thanks to Steven L Brenner) + BUG 2 - The packages name contained spaces which was + causing some strange bugs in Delphi + (fixed thanks to Martijn Saly) + BUG 3 - Lots of fixes when handling palettes + (bugs implemented in the last version) + Fixed thanks to Gabriel Corneanu!!! + BUG 4 - CreateAlpha was raising an error because it did + not resized the palette chunk it created; + Fixed thanks to Miha Sokolov + IMPROVE 1 - Renamed the pngzlib.pas unit to zlibpas.pas + as a tentative to all libraries use the same + shared zlib implementation and to avoid including + two or three times the same P-Code. + (Gabriel Corneanu idea) + + + + Version 1.561 + 2006-05-17 BUG 1 - There was a bug in the method that draws semi + transparent images (a memory leak). fixed. + + Version 1.56 + 2006-05-09 - IMPROVE 1 - Delphi standard TCanvas support is now implemented + IMPROVE 2 - The PNG files may now be resized and created from + scratch using CreateBlank, Resize, Width and Height + BUG 1 - Fixed some bugs on handling tRNS transparencies + BUG 2 - Fixed bugs related to palette handling + + Version 1.535 + 2006-04-21 - IMPROVE 1 - Now the library uses the latest ZLIB release (1.2.3) + (thanks to: Roberto Della Pasqua + http://www.dellapasqua.com/delphizlib/) + + Version 1.53 + 2006-04-14 - + BUG 1 - Remove transparency was not working for + RGB Alpha and Grayscale alpha. fixed + BUG 2 - There was a bug were compressed text chunks no keyword + name could not be read + IMPROVE 1 - Add classes and methods to work with the pHYs chunk + (including TPNGObject.DrawUsingPixelInformation) + IMPROVE 3 - Included a property Version to return the library + version + IMPROVE 4 - New polish translation (thanks to Piotr Domanski) + IMPROVE 5 - Now packages for delphi 5, 6, 7, 2005 and 2006 + + Also Martijn Saly (thany) made some improvements in the library: + IMPROVE 1 - SetPixel now works with grayscale + IMPROVE 2 - Palette property now can be written using a + windows handle + Thanks !! + + Version 1.5 + 2005-06-29 - Fixed a lot of bugs using tips from mails that I´ve + being receiving for some time + BUG 1 - Loosing palette when assigning to TBitmap. fixed + BUG 2 - SetPixels and GetPixels worked only with + parameters in range 0..255. fixed + BUG 3 - Force type address off using directive + BUG 4 - TChunkzTXt contained an error + BUG 5 - MaxIdatSize was not working correctly (fixed thanks + to Gabriel Corneanu + BUG 6 - Corrected german translation (thanks to Mael Horz) + And the following improvements: + IMPROVE 1 - Create ImageHandleValue properties as public in + TChunkIHDR to get access to this handle + IMPROVE 2 - Using SetStretchBltMode to improve stretch quality + IMPROVE 3 - Scale is now working for alpha transparent images + IMPROVE 4 - GammaTable propery is now public to support an + article in the help file + + Version 1.4361 + 2003-03-04 - Fixed important bug for simple transparency when using + RGB, Grayscale color modes + + Version 1.436 + 2003-03-04 - * NEW * Property Pixels for direct access to pixels + * IMPROVED * Palette property (TPngObject) (read only) + Slovenian traslation for the component (Miha Petelin) + Help file update (scanline article/png->jpg example) + + Version 1.435 + 2003-11-03 - * NEW * New chunk implementation zTXt (method AddzTXt) + * NEW * New compiler flags to store the extra 8 bits + from 16 bits samples (when saving it is ignored), the + extra data may be acessed using ExtraScanline property + * Fixed * a bug on tIMe chunk + French translation included (Thanks to IBE Software) + Bugs fixed + + Version 1.432 + 2002-08-24 - * NEW * A new method, CreateAlpha will transform the + current image into partial transparency. + Help file updated with a new article on how to handle + partial transparency. + + Version 1.431 + 2002-08-14 - Fixed and tested to work on: + C++ Builder 3 + C++ Builder 5 + Delphi 3 + There was an error when setting TransparentColor, fixed + New method, RemoveTransparency to remove image + BIT TRANSPARENCY + + Version 1.43 + 2002-08-01 - * NEW * Support for Delphi 3 and C++ Builder 3 + Implements mostly some things that were missing, + a few tweaks and fixes. + + Version 1.428 + 2002-07-24 - More minor fixes (thanks to Ian Boyd) + Bit transparency fixes + * NEW * Finally support to bit transparency + (palette / rgb / grayscale -> all) + + Version 1.427 + 2002-07-19 - Lots of bugs and leaks fixed + * NEW * method to easy adding text comments, AddtEXt + * NEW * property for setting bit transparency, + TransparentColor + + Version 1.426 + 2002-07-18 - Clipboard finally fixed and working + Changed UseDelphi trigger to UseDelphi + * NEW * Support for bit transparency bitmaps + when assigning from/to TBitmap objects + Altough it does not support drawing transparent + parts of bit transparency pngs (only partial) + it is closer than ever + + Version 1.425 + 2002-07-01 - Clipboard methods implemented + Lots of bugs fixed + + Version 1.424 + 2002-05-16 - Scanline and AlphaScanline are now working correctly. + New methods for handling the clipboard + + Version 1.423 + 2002-05-16 - * NEW * Partial transparency for 1, 2, 4 and 8 bits is + also supported using the tRNS chunk (for palette and + grayscaling). + New bug fixes (Peter Haas). + + Version 1.422 + 2002-05-14 - Fixed some critical leaks, thanks to Peter Haas tips. + New translation for German (Peter Haas). + + Version 1.421 + 2002-05-06 - Now uses new ZLIB version, 1.1.4 with some security + fixes. + LoadFromResourceID and LoadFromResourceName added and + help file updated for that. + The resources strings are now located in pnglang.pas. + New translation for Brazilian Portuguese. + Bugs fixed. + + IMPORTANT: As always I´m looking for bugs on the library. If + anyone has found one, please send me an email and + I will fix asap. Thanks for all the help and ideas + I'm receiving so far.} + +{My email is : gustavo.daud@terra.com.br} +{Website link : http://pngdelphi.sourceforge.net} +{Gustavo Huffenbacher Daud} + +unit pngimage; + +interface + +{Triggers avaliable (edit the fields bellow)} +{$TYPEDADDRESS OFF} + +{$DEFINE UseDelphi} //Disable fat vcl units(perfect for small apps) +{$DEFINE ErrorOnUnknownCritical} //Error when finds an unknown critical chunk +{$DEFINE CheckCRC} //Enables CRC checking +{$DEFINE RegisterGraphic} //Registers TPNGObject to use with TPicture +{$DEFINE PartialTransparentDraw} //Draws partial transparent images +{$DEFINE Store16bits} //Stores the extra 8 bits from 16bits/sample +{$RANGECHECKS OFF} {$J+} + + + +uses + Windows {$IFDEF UseDelphi}, Classes, Graphics, SysUtils{$ENDIF}, + zlibpas, pnglang; + +const + LibraryVersion = '1.564'; + +{$IFNDEF UseDelphi} + const + soFromBeginning = 0; + soFromCurrent = 1; + soFromEnd = 2; +{$ENDIF} + +const + {ZLIB constants} + ZLIBErrors: Array[-6..2] of string = ('incompatible version (-6)', + 'buffer error (-5)', 'insufficient memory (-4)', 'data error (-3)', + 'stream error (-2)', 'file error (-1)', '(0)', 'stream end (1)', + 'need dictionary (2)'); + Z_NO_FLUSH = 0; + Z_FINISH = 4; + Z_STREAM_END = 1; + + {Avaliable PNG filters for mode 0} + FILTER_NONE = 0; + FILTER_SUB = 1; + FILTER_UP = 2; + FILTER_AVERAGE = 3; + FILTER_PAETH = 4; + + {Avaliable color modes for PNG} + COLOR_GRAYSCALE = 0; + COLOR_RGB = 2; + COLOR_PALETTE = 3; + COLOR_GRAYSCALEALPHA = 4; + COLOR_RGBALPHA = 6; + + +type + {$IFNDEF UseDelphi} + {Custom exception handler} + Exception = class(TObject) + constructor Create(Msg: String); + end; + ExceptClass = class of Exception; + TColor = ColorRef; + {$ENDIF} + + {Error types} + EPNGOutMemory = class(Exception); + EPngError = class(Exception); + EPngUnexpectedEnd = class(Exception); + EPngInvalidCRC = class(Exception); + EPngInvalidIHDR = class(Exception); + EPNGMissingMultipleIDAT = class(Exception); + EPNGZLIBError = class(Exception); + EPNGInvalidPalette = class(Exception); + EPNGInvalidFileHeader = class(Exception); + EPNGIHDRNotFirst = class(Exception); + EPNGNotExists = class(Exception); + EPNGSizeExceeds = class(Exception); + EPNGMissingPalette = class(Exception); + EPNGUnknownCriticalChunk = class(Exception); + EPNGUnknownCompression = class(Exception); + EPNGUnknownInterlace = class(Exception); + EPNGNoImageData = class(Exception); + EPNGCouldNotLoadResource = class(Exception); + EPNGCannotChangeTransparent = class(Exception); + EPNGHeaderNotPresent = class(Exception); + EPNGInvalidNewSize = class(Exception); + EPNGInvalidSpec = class(Exception); + +type + {Direct access to pixels using R,G,B} + TRGBLine = array[word] of TRGBTriple; + pRGBLine = ^TRGBLine; + + {Same as TBitmapInfo but with allocated space for} + {palette entries} + TMAXBITMAPINFO = packed record + bmiHeader: TBitmapInfoHeader; + bmiColors: packed array[0..255] of TRGBQuad; + end; + + {Transparency mode for pngs} + TPNGTransparencyMode = (ptmNone, ptmBit, ptmPartial); + {Pointer to a cardinal type} + pCardinal = ^Cardinal; + {Access to a rgb pixel} + pRGBPixel = ^TRGBPixel; + TRGBPixel = packed record + B, G, R: Byte; + end; + + {Pointer to an array of bytes type} + TByteArray = Array[Word] of Byte; + pByteArray = ^TByteArray; + + {Forward} + TPNGObject = class; + pPointerArray = ^TPointerArray; + TPointerArray = Array[Word] of Pointer; + + {Contains a list of objects} + TPNGPointerList = class + private + fOwner: TPNGObject; + fCount : Cardinal; + fMemory: pPointerArray; + function GetItem(Index: Cardinal): Pointer; + procedure SetItem(Index: Cardinal; const Value: Pointer); + protected + {Removes an item} + function Remove(Value: Pointer): Pointer; virtual; + {Inserts an item} + procedure Insert(Value: Pointer; Position: Cardinal); + {Add a new item} + procedure Add(Value: Pointer); + {Returns an item} + property Item[Index: Cardinal]: Pointer read GetItem write SetItem; + {Set the size of the list} + procedure SetSize(const Size: Cardinal); + {Returns owner} + property Owner: TPNGObject read fOwner; + public + {Returns number of items} + property Count: Cardinal read fCount write SetSize; + {Object being either created or destroyed} + constructor Create(AOwner: TPNGObject); + destructor Destroy; override; + end; + + {Forward declaration} + TChunk = class; + TChunkClass = class of TChunk; + + {Same as TPNGPointerList but providing typecasted values} + TPNGList = class(TPNGPointerList) + private + {Used with property Item} + function GetItem(Index: Cardinal): TChunk; + public + {Finds the first item with this class} + function FindChunk(ChunkClass: TChunkClass): TChunk; + {Removes an item} + procedure RemoveChunk(Chunk: TChunk); overload; + {Add a new chunk using the class from the parameter} + function Add(ChunkClass: TChunkClass): TChunk; + {Returns pointer to the first chunk of class} + function ItemFromClass(ChunkClass: TChunkClass): TChunk; + {Returns a chunk item from the list} + property Item[Index: Cardinal]: TChunk read GetItem; + end; + + {$IFNDEF UseDelphi} + {The STREAMs bellow are only needed in case delphi provided ones is not} + {avaliable (UseDelphi trigger not set)} + {Object becomes handles} + TCanvas = THandle; + TBitmap = HBitmap; + {Trick to work} + TPersistent = TObject; + + {Base class for all streams} + TStream = class + protected + {Returning/setting size} + function GetSize: Longint; virtual; + procedure SetSize(const Value: Longint); virtual; abstract; + {Returns/set position} + function GetPosition: Longint; virtual; + procedure SetPosition(const Value: Longint); virtual; + public + {Returns/sets current position} + property Position: Longint read GetPosition write SetPosition; + {Property returns/sets size} + property Size: Longint read GetSize write SetSize; + {Allows reading/writing data} + function Read(var Buffer; Count: Longint): Cardinal; virtual; abstract; + function Write(const Buffer; Count: Longint): Cardinal; virtual; abstract; + {Copies from another Stream} + function CopyFrom(Source: TStream; + Count: Cardinal): Cardinal; virtual; + {Seeks a stream position} + function Seek(Offset: Longint; Origin: Word): Longint; virtual; abstract; + end; + + {File stream modes} + TFileStreamMode = (fsmRead, fsmWrite, fsmCreate); + TFileStreamModeSet = set of TFileStreamMode; + + {File stream for reading from files} + TFileStream = class(TStream) + private + {Opened mode} + Filemode: TFileStreamModeSet; + {Handle} + fHandle: THandle; + protected + {Set the size of the file} + procedure SetSize(const Value: Longint); override; + public + {Seeks a file position} + function Seek(Offset: Longint; Origin: Word): Longint; override; + {Reads/writes data from/to the file} + function Read(var Buffer; Count: Longint): Cardinal; override; + function Write(const Buffer; Count: Longint): Cardinal; override; + {Stream being created and destroy} + constructor Create(Filename: String; Mode: TFileStreamModeSet); + destructor Destroy; override; + end; + + {Stream for reading from resources} + TResourceStream = class(TStream) + constructor Create(Instance: HInst; const ResName: String; ResType:PChar); + private + {Variables for reading} + Size: Integer; + Memory: Pointer; + Position: Integer; + protected + {Set the size of the file} + procedure SetSize(const Value: Longint); override; + public + {Stream processing} + function Read(var Buffer; Count: Integer): Cardinal; override; + function Seek(Offset: Integer; Origin: Word): Longint; override; + function Write(const Buffer; Count: Longint): Cardinal; override; + end; + {$ENDIF} + + {Forward} + TChunkIHDR = class; + TChunkpHYs = class; + {Interlace method} + TInterlaceMethod = (imNone, imAdam7); + {Compression level type} + TCompressionLevel = 0..9; + {Filters type} + TFilter = (pfNone, pfSub, pfUp, pfAverage, pfPaeth); + TFilters = set of TFilter; + + {Png implementation object} + TPngObject = class{$IFDEF UseDelphi}(TGraphic){$ENDIF} + protected + {Inverse gamma table values} + InverseGamma: Array[Byte] of Byte; + procedure InitializeGamma; + private + {Canvas} + {$IFDEF UseDelphi}fCanvas: TCanvas;{$ENDIF} + {Filters to test to encode} + fFilters: TFilters; + {Compression level for ZLIB} + fCompressionLevel: TCompressionLevel; + {Maximum size for IDAT chunks} + fMaxIdatSize: Integer; + {Returns if image is interlaced} + fInterlaceMethod: TInterlaceMethod; + {Chunks object} + fChunkList: TPngList; + {Clear all chunks in the list} + procedure ClearChunks; + {Returns if header is present} + function HeaderPresent: Boolean; + procedure GetPixelInfo(var LineSize, Offset: Cardinal); + {Returns linesize and byte offset for pixels} + procedure SetMaxIdatSize(const Value: Integer); + function GetAlphaScanline(const LineIndex: Integer): pByteArray; + function GetScanline(const LineIndex: Integer): Pointer; + {$IFDEF Store16bits} + function GetExtraScanline(const LineIndex: Integer): Pointer; + {$ENDIF} + function GetPixelInformation: TChunkpHYs; + function GetTransparencyMode: TPNGTransparencyMode; + function GetTransparentColor: TColor; + procedure SetTransparentColor(const Value: TColor); + {Returns the version} + function GetLibraryVersion: String; + protected + {Being created} + BeingCreated: Boolean; + {Returns / set the image palette} + function GetPalette: HPALETTE; {$IFDEF UseDelphi}override;{$ENDIF} + procedure SetPalette(Value: HPALETTE); {$IFDEF UseDelphi}override;{$ENDIF} + procedure DoSetPalette(Value: HPALETTE; const UpdateColors: Boolean); + {Returns/sets image width and height} + function GetWidth: Integer; {$IFDEF UseDelphi}override;{$ENDIF} + function GetHeight: Integer; {$IFDEF UseDelphi}override; {$ENDIF} + procedure SetWidth(Value: Integer); {$IFDEF UseDelphi}override; {$ENDIF} + procedure SetHeight(Value: Integer); {$IFDEF UseDelphi}override;{$ENDIF} + {Assigns from another TPNGObject} + procedure AssignPNG(Source: TPNGObject); + {Returns if the image is empty} + function GetEmpty: Boolean; {$IFDEF UseDelphi}override; {$ENDIF} + {Used with property Header} + function GetHeader: TChunkIHDR; + {Draws using partial transparency} + procedure DrawPartialTrans(DC: HDC; Rect: TRect); + {$IFDEF UseDelphi} + {Returns if the image is transparent} + function GetTransparent: Boolean; override; + {$ENDIF} + {Returns a pixel} + function GetPixels(const X, Y: Integer): TColor; virtual; + procedure SetPixels(const X, Y: Integer; const Value: TColor); virtual; + public + {Gamma table array} + GammaTable: Array[Byte] of Byte; + {Resizes the PNG image} + procedure Resize(const CX, CY: Integer); + {Generates alpha information} + procedure CreateAlpha; + {Removes the image transparency} + procedure RemoveTransparency; + {Transparent color} + property TransparentColor: TColor read GetTransparentColor write + SetTransparentColor; + {Add text chunk, TChunkTEXT, TChunkzTXT} + procedure AddtEXt(const Keyword, Text: String); + procedure AddzTXt(const Keyword, Text: String); + {$IFDEF UseDelphi} + {Saves to clipboard format (thanks to Antoine Pottern)} + procedure SaveToClipboardFormat(var AFormat: Word; var AData: THandle; + var APalette: HPalette); override; + procedure LoadFromClipboardFormat(AFormat: Word; AData: THandle; + APalette: HPalette); override; + {$ENDIF} + {Calling errors} + procedure RaiseError(ExceptionClass: ExceptClass; Text: String); + {Returns a scanline from png} + property Scanline[const Index: Integer]: Pointer read GetScanline; + {$IFDEF Store16bits} + property ExtraScanline[const Index: Integer]: Pointer read GetExtraScanline; + {$ENDIF} + {Used to return pixel information} + function HasPixelInformation: Boolean; + property PixelInformation: TChunkpHYs read GetPixelInformation; + property AlphaScanline[const Index: Integer]: pByteArray read + GetAlphaScanline; + procedure DrawUsingPixelInformation(Canvas: TCanvas; Point: TPoint); + + {Canvas} + {$IFDEF UseDelphi}property Canvas: TCanvas read fCanvas;{$ENDIF} + {Returns pointer to the header} + property Header: TChunkIHDR read GetHeader; + {Returns the transparency mode used by this png} + property TransparencyMode: TPNGTransparencyMode read GetTransparencyMode; + {Assigns from another object} + procedure Assign(Source: TPersistent);{$IFDEF UseDelphi}override;{$ENDIF} + {Assigns to another object} + procedure AssignTo(Dest: TPersistent);{$IFDEF UseDelphi}override;{$ENDIF} + {Assigns from a windows bitmap handle} + procedure AssignHandle(Handle: HBitmap; Transparent: Boolean; + TransparentColor: ColorRef); + {Draws the image into a canvas} + procedure Draw(ACanvas: TCanvas; const Rect: TRect); + {$IFDEF UseDelphi}override;{$ENDIF} + {Width and height properties} + property Width: Integer read GetWidth; + property Height: Integer read GetHeight; + {Returns if the image is interlaced} + property InterlaceMethod: TInterlaceMethod read fInterlaceMethod + write fInterlaceMethod; + {Filters to test to encode} + property Filters: TFilters read fFilters write fFilters; + {Maximum size for IDAT chunks, default and minimum is 65536} + property MaxIdatSize: Integer read fMaxIdatSize write SetMaxIdatSize; + {Property to return if the image is empty or not} + property Empty: Boolean read GetEmpty; + {Compression level} + property CompressionLevel: TCompressionLevel read fCompressionLevel + write fCompressionLevel; + {Access to the chunk list} + property Chunks: TPngList read fChunkList; + {Object being created and destroyed} + constructor Create; {$IFDEF UseDelphi}override;{$ENDIF} + constructor CreateBlank(ColorType, Bitdepth: Cardinal; cx, cy: Integer); + destructor Destroy; override; + {$IFNDEF UseDelphi}procedure LoadFromFile(const Filename: String);{$ENDIF} + {$IFNDEF UseDelphi}procedure SaveToFile(const Filename: String);{$ENDIF} + procedure LoadFromStream(Stream: TStream); + {$IFDEF UseDelphi}override;{$ENDIF} + procedure SaveToStream(Stream: TStream); {$IFDEF UseDelphi}override;{$ENDIF} + {Loading the image from resources} + procedure LoadFromResourceName(Instance: HInst; const Name: String); + procedure LoadFromResourceID(Instance: HInst; ResID: Integer); + {Access to the png pixels} + property Pixels[const X, Y: Integer]: TColor read GetPixels write SetPixels; + {Palette property} + {$IFNDEF UseDelphi}property Palette: HPalette read GetPalette write + SetPalette;{$ENDIF} + {Returns the version} + property Version: String read GetLibraryVersion; + end; + + {Chunk name object} + TChunkName = Array[0..3] of Char; + + {Global chunk object} + TChunk = class + private + {Contains data} + fData: Pointer; + fDataSize: Cardinal; + {Stores owner} + fOwner: TPngObject; + {Stores the chunk name} + fName: TChunkName; + {Returns pointer to the TChunkIHDR} + function GetHeader: TChunkIHDR; + {Used with property index} + function GetIndex: Integer; + {Should return chunk class/name} + class function GetName: String; virtual; + {Returns the chunk name} + function GetChunkName: String; + public + {Returns index from list} + property Index: Integer read GetIndex; + {Returns pointer to the TChunkIHDR} + property Header: TChunkIHDR read GetHeader; + {Resize the data} + procedure ResizeData(const NewSize: Cardinal); + {Returns data and size} + property Data: Pointer read fData; + property DataSize: Cardinal read fDataSize; + {Assigns from another TChunk} + procedure Assign(Source: TChunk); virtual; + {Returns owner} + property Owner: TPngObject read fOwner; + {Being destroyed/created} + constructor Create(Owner: TPngObject); virtual; + destructor Destroy; override; + {Returns chunk class/name} + property Name: String read GetChunkName; + {Loads the chunk from a stream} + function LoadFromStream(Stream: TStream; const ChunkName: TChunkName; + Size: Integer): Boolean; virtual; + {Saves the chunk to a stream} + function SaveData(Stream: TStream): Boolean; + function SaveToStream(Stream: TStream): Boolean; virtual; + end; + + {Chunk classes} + TChunkIEND = class(TChunk); {End chunk} + + {IHDR data} + pIHDRData = ^TIHDRData; + TIHDRData = packed record + Width, Height: Cardinal; + BitDepth, + ColorType, + CompressionMethod, + FilterMethod, + InterlaceMethod: Byte; + end; + + {Information header chunk} + TChunkIHDR = class(TChunk) + private + {Current image} + ImageHandle: HBitmap; + ImageDC: HDC; + ImagePalette: HPalette; + {Output windows bitmap} + HasPalette: Boolean; + BitmapInfo: TMaxBitmapInfo; + {Stores the image bytes} + {$IFDEF Store16bits}ExtraImageData: Pointer;{$ENDIF} + ImageData: pointer; + ImageAlpha: Pointer; + + {Contains all the ihdr data} + IHDRData: TIHDRData; + protected + BytesPerRow: Integer; + {Creates a grayscale palette} + function CreateGrayscalePalette(Bitdepth: Integer): HPalette; + {Copies the palette to the Device Independent bitmap header} + procedure PaletteToDIB(Palette: HPalette); + {Resizes the image data to fill the color type, bit depth, } + {width and height parameters} + procedure PrepareImageData; + {Release allocated ImageData memory} + procedure FreeImageData; + public + {Access to ImageHandle} + property ImageHandleValue: HBitmap read ImageHandle; + {Properties} + property Width: Cardinal read IHDRData.Width write IHDRData.Width; + property Height: Cardinal read IHDRData.Height write IHDRData.Height; + property BitDepth: Byte read IHDRData.BitDepth write IHDRData.BitDepth; + property ColorType: Byte read IHDRData.ColorType write IHDRData.ColorType; + property CompressionMethod: Byte read IHDRData.CompressionMethod + write IHDRData.CompressionMethod; + property FilterMethod: Byte read IHDRData.FilterMethod + write IHDRData.FilterMethod; + property InterlaceMethod: Byte read IHDRData.InterlaceMethod + write IHDRData.InterlaceMethod; + {Loads the chunk from a stream} + function LoadFromStream(Stream: TStream; const ChunkName: TChunkName; + Size: Integer): Boolean; override; + {Saves the chunk to a stream} + function SaveToStream(Stream: TStream): Boolean; override; + {Destructor/constructor} + constructor Create(Owner: TPngObject); override; + destructor Destroy; override; + {Assigns from another TChunk} + procedure Assign(Source: TChunk); override; + end; + + {pHYs chunk} + pUnitType = ^TUnitType; + TUnitType = (utUnknown, utMeter); + TChunkpHYs = class(TChunk) + private + fPPUnitX, fPPUnitY: Cardinal; + fUnit: TUnitType; + public + {Returns the properties} + property PPUnitX: Cardinal read fPPUnitX write fPPUnitX; + property PPUnitY: Cardinal read fPPUnitY write fPPUnitY; + property UnitType: TUnitType read fUnit write fUnit; + {Loads the chunk from a stream} + function LoadFromStream(Stream: TStream; const ChunkName: TChunkName; + Size: Integer): Boolean; override; + {Saves the chunk to a stream} + function SaveToStream(Stream: TStream): Boolean; override; + {Assigns from another TChunk} + procedure Assign(Source: TChunk); override; + end; + + {Gamma chunk} + TChunkgAMA = class(TChunk) + private + {Returns/sets the value for the gamma chunk} + function GetValue: Cardinal; + procedure SetValue(const Value: Cardinal); + public + {Returns/sets gamma value} + property Gamma: Cardinal read GetValue write SetValue; + {Loading the chunk from a stream} + function LoadFromStream(Stream: TStream; const ChunkName: TChunkName; + Size: Integer): Boolean; override; + {Being created} + constructor Create(Owner: TPngObject); override; + {Assigns from another TChunk} + procedure Assign(Source: TChunk); override; + end; + + {ZLIB Decompression extra information} + TZStreamRec2 = packed record + {From ZLIB} + ZLIB: TZStreamRec; + {Additional info} + Data: Pointer; + fStream : TStream; + end; + + {Palette chunk} + TChunkPLTE = class(TChunk) + protected + {Number of items in the palette} + fCount: Integer; + private + {Contains the palette handle} + function GetPaletteItem(Index: Byte): TRGBQuad; + public + {Returns the color for each item in the palette} + property Item[Index: Byte]: TRGBQuad read GetPaletteItem; + {Returns the number of items in the palette} + property Count: Integer read fCount; + {Loads the chunk from a stream} + function LoadFromStream(Stream: TStream; const ChunkName: TChunkName; + Size: Integer): Boolean; override; + {Saves the chunk to a stream} + function SaveToStream(Stream: TStream): Boolean; override; + {Assigns from another TChunk} + procedure Assign(Source: TChunk); override; + end; + + {Transparency information} + TChunktRNS = class(TChunk) + private + fBitTransparency: Boolean; + function GetTransparentColor: ColorRef; + {Returns the transparent color} + procedure SetTransparentColor(const Value: ColorRef); + public + {Palette values for transparency} + PaletteValues: Array[Byte] of Byte; + {Returns if it uses bit transparency} + property BitTransparency: Boolean read fBitTransparency; + {Returns the transparent color} + property TransparentColor: ColorRef read GetTransparentColor write + SetTransparentColor; + {Loads/saves the chunk from/to a stream} + function LoadFromStream(Stream: TStream; const ChunkName: TChunkName; + Size: Integer): Boolean; override; + function SaveToStream(Stream: TStream): Boolean; override; + {Assigns from another TChunk} + procedure Assign(Source: TChunk); override; + end; + + {Actual image information} + TChunkIDAT = class(TChunk) + private + {Holds another pointer to the TChunkIHDR} + Header: TChunkIHDR; + {Stores temporary image width and height} + ImageWidth, ImageHeight: Integer; + {Size in bytes of each line and offset} + Row_Bytes, Offset : Cardinal; + {Contains data for the lines} + Encode_Buffer: Array[0..5] of pByteArray; + Row_Buffer: Array[Boolean] of pByteArray; + {Variable to invert the Row_Buffer used} + RowUsed: Boolean; + {Ending position for the current IDAT chunk} + EndPos: Integer; + {Filter the current line} + procedure FilterRow; + {Filter to encode and returns the best filter} + function FilterToEncode: Byte; + {Reads ZLIB compressed data} + function IDATZlibRead(var ZLIBStream: TZStreamRec2; Buffer: Pointer; + Count: Integer; var EndPos: Integer; var crcfile: Cardinal): Integer; + {Compress and writes IDAT data} + procedure IDATZlibWrite(var ZLIBStream: TZStreamRec2; Buffer: Pointer; + const Length: Cardinal); + procedure FinishIDATZlib(var ZLIBStream: TZStreamRec2); + {Prepares the palette} + procedure PreparePalette; + protected + {Decode interlaced image} + procedure DecodeInterlacedAdam7(Stream: TStream; + var ZLIBStream: TZStreamRec2; const Size: Integer; var crcfile: Cardinal); + {Decode non interlaced imaged} + procedure DecodeNonInterlaced(Stream: TStream; + var ZLIBStream: TZStreamRec2; const Size: Integer; + var crcfile: Cardinal); + protected + {Encode non interlaced images} + procedure EncodeNonInterlaced(Stream: TStream; + var ZLIBStream: TZStreamRec2); + {Encode interlaced images} + procedure EncodeInterlacedAdam7(Stream: TStream; + var ZLIBStream: TZStreamRec2); + protected + {Memory copy methods to decode} + procedure CopyNonInterlacedRGB8( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyNonInterlacedRGB16( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyNonInterlacedPalette148( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyNonInterlacedPalette2( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyNonInterlacedGray2( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyNonInterlacedGrayscale16( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyNonInterlacedRGBAlpha8( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyNonInterlacedRGBAlpha16( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyNonInterlacedGrayscaleAlpha8( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyNonInterlacedGrayscaleAlpha16( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyInterlacedRGB8(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyInterlacedRGB16(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyInterlacedPalette148(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyInterlacedPalette2(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyInterlacedGray2(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyInterlacedGrayscale16(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyInterlacedRGBAlpha8(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyInterlacedRGBAlpha16(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyInterlacedGrayscaleAlpha8(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + procedure CopyInterlacedGrayscaleAlpha16(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); + protected + {Memory copy methods to encode} + procedure EncodeNonInterlacedRGB8(Src, Dest, Trans: pChar); + procedure EncodeNonInterlacedRGB16(Src, Dest, Trans: pChar); + procedure EncodeNonInterlacedGrayscale16(Src, Dest, Trans: pChar); + procedure EncodeNonInterlacedPalette148(Src, Dest, Trans: pChar); + procedure EncodeNonInterlacedRGBAlpha8(Src, Dest, Trans: pChar); + procedure EncodeNonInterlacedRGBAlpha16(Src, Dest, Trans: pChar); + procedure EncodeNonInterlacedGrayscaleAlpha8(Src, Dest, Trans: pChar); + procedure EncodeNonInterlacedGrayscaleAlpha16(Src, Dest, Trans: pChar); + procedure EncodeInterlacedRGB8(const Pass: Byte; Src, Dest, Trans: pChar); + procedure EncodeInterlacedRGB16(const Pass: Byte; Src, Dest, Trans: pChar); + procedure EncodeInterlacedPalette148(const Pass: Byte; + Src, Dest, Trans: pChar); + procedure EncodeInterlacedGrayscale16(const Pass: Byte; + Src, Dest, Trans: pChar); + procedure EncodeInterlacedRGBAlpha8(const Pass: Byte; + Src, Dest, Trans: pChar); + procedure EncodeInterlacedRGBAlpha16(const Pass: Byte; + Src, Dest, Trans: pChar); + procedure EncodeInterlacedGrayscaleAlpha8(const Pass: Byte; + Src, Dest, Trans: pChar); + procedure EncodeInterlacedGrayscaleAlpha16(const Pass: Byte; + Src, Dest, Trans: pChar); + public + {Loads the chunk from a stream} + function LoadFromStream(Stream: TStream; const ChunkName: TChunkName; + Size: Integer): Boolean; override; + {Saves the chunk to a stream} + function SaveToStream(Stream: TStream): Boolean; override; + end; + + {Image last modification chunk} + TChunktIME = class(TChunk) + private + {Holds the variables} + fYear: Word; + fMonth, fDay, fHour, fMinute, fSecond: Byte; + public + {Returns/sets variables} + property Year: Word read fYear write fYear; + property Month: Byte read fMonth write fMonth; + property Day: Byte read fDay write fDay; + property Hour: Byte read fHour write fHour; + property Minute: Byte read fMinute write fMinute; + property Second: Byte read fSecond write fSecond; + {Loads the chunk from a stream} + function LoadFromStream(Stream: TStream; const ChunkName: TChunkName; + Size: Integer): Boolean; override; + {Saves the chunk to a stream} + function SaveToStream(Stream: TStream): Boolean; override; + {Assigns from another TChunk} + procedure Assign(Source: TChunk); override; + end; + + {Textual data} + TChunktEXt = class(TChunk) + private + fKeyword, fText: String; + public + {Keyword and text} + property Keyword: String read fKeyword write fKeyword; + property Text: String read fText write fText; + {Loads the chunk from a stream} + function LoadFromStream(Stream: TStream; const ChunkName: TChunkName; + Size: Integer): Boolean; override; + {Saves the chunk to a stream} + function SaveToStream(Stream: TStream): Boolean; override; + {Assigns from another TChunk} + procedure Assign(Source: TChunk); override; + end; + + {zTXT chunk} + TChunkzTXt = class(TChunktEXt) + {Loads the chunk from a stream} + function LoadFromStream(Stream: TStream; const ChunkName: TChunkName; + Size: Integer): Boolean; override; + {Saves the chunk to a stream} + function SaveToStream(Stream: TStream): Boolean; override; + end; + +{Here we test if it's c++ builder or delphi version 3 or less} +{$IFDEF VER110}{$DEFINE DelphiBuilder3Less}{$ENDIF} +{$IFDEF VER100}{$DEFINE DelphiBuilder3Less}{$ENDIF} +{$IFDEF VER93}{$DEFINE DelphiBuilder3Less}{$ENDIF} +{$IFDEF VER90}{$DEFINE DelphiBuilder3Less}{$ENDIF} +{$IFDEF VER80}{$DEFINE DelphiBuilder3Less}{$ENDIF} + + +{Registers a new chunk class} +procedure RegisterChunk(ChunkClass: TChunkClass); +{Calculates crc} +function update_crc(crc: {$IFNDEF DelphiBuilder3Less}Cardinal{$ELSE}Integer + {$ENDIF}; buf: pByteArray; len: Integer): Cardinal; +{Invert bytes using assembly} +function ByteSwap(const a: integer): integer; + +implementation + +var + ChunkClasses: TPngPointerList; + {Table of CRCs of all 8-bit messages} + crc_table: Array[0..255] of Cardinal; + {Flag: has the table been computed? Initially false} + crc_table_computed: Boolean; + +{Draw transparent image using transparent color} +procedure DrawTransparentBitmap(dc: HDC; srcBits: Pointer; + var srcHeader: TBitmapInfoHeader; + srcBitmapInfo: pBitmapInfo; Rect: TRect; cTransparentColor: COLORREF); +var + cColor: COLORREF; + bmAndBack, bmAndObject, bmAndMem: HBITMAP; + bmBackOld, bmObjectOld, bmMemOld: HBITMAP; + hdcMem, hdcBack, hdcObject, hdcTemp: HDC; + ptSize, orgSize: TPOINT; + OldBitmap, DrawBitmap: HBITMAP; +begin + hdcTemp := CreateCompatibleDC(dc); + {Select the bitmap} + DrawBitmap := CreateDIBitmap(dc, srcHeader, CBM_INIT, srcBits, srcBitmapInfo^, + DIB_RGB_COLORS); + OldBitmap := SelectObject(hdcTemp, DrawBitmap); + + {Get sizes} + OrgSize.x := abs(srcHeader.biWidth); + OrgSize.y := abs(srcHeader.biHeight); + ptSize.x := Rect.Right - Rect.Left; // Get width of bitmap + ptSize.y := Rect.Bottom - Rect.Top; // Get height of bitmap + + {Create some DCs to hold temporary data} + hdcBack := CreateCompatibleDC(dc); + hdcObject := CreateCompatibleDC(dc); + hdcMem := CreateCompatibleDC(dc); + + // Create a bitmap for each DC. DCs are required for a number of + // GDI functions. + + // Monochrome DCs + bmAndBack := CreateBitmap(ptSize.x, ptSize.y, 1, 1, nil); + bmAndObject := CreateBitmap(ptSize.x, ptSize.y, 1, 1, nil); + + bmAndMem := CreateCompatibleBitmap(dc, ptSize.x, ptSize.y); + + // Each DC must select a bitmap object to store pixel data. + bmBackOld := SelectObject(hdcBack, bmAndBack); + bmObjectOld := SelectObject(hdcObject, bmAndObject); + bmMemOld := SelectObject(hdcMem, bmAndMem); + + // Set the background color of the source DC to the color. + // contained in the parts of the bitmap that should be transparent + cColor := SetBkColor(hdcTemp, cTransparentColor); + + // Create the object mask for the bitmap by performing a BitBlt + // from the source bitmap to a monochrome bitmap. + StretchBlt(hdcObject, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, + orgSize.x, orgSize.y, SRCCOPY); + + // Set the background color of the source DC back to the original + // color. + SetBkColor(hdcTemp, cColor); + + // Create the inverse of the object mask. + BitBlt(hdcBack, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, + NOTSRCCOPY); + + // Copy the background of the main DC to the destination. + BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, dc, Rect.Left, Rect.Top, + SRCCOPY); + + // Mask out the places where the bitmap will be placed. + BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, SRCAND); + + // Mask out the transparent colored pixels on the bitmap. +// BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcBack, 0, 0, SRCAND); + StretchBlt(hdcTemp, 0, 0, OrgSize.x, OrgSize.y, hdcBack, 0, 0, + PtSize.x, PtSize.y, SRCAND); + + // XOR the bitmap with the background on the destination DC. + StretchBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, + OrgSize.x, OrgSize.y, SRCPAINT); + + // Copy the destination to the screen. + BitBlt(dc, Rect.Left, Rect.Top, ptSize.x, ptSize.y, hdcMem, 0, 0, + SRCCOPY); + + // Delete the memory bitmaps. + DeleteObject(SelectObject(hdcBack, bmBackOld)); + DeleteObject(SelectObject(hdcObject, bmObjectOld)); + DeleteObject(SelectObject(hdcMem, bmMemOld)); + DeleteObject(SelectObject(hdcTemp, OldBitmap)); + + // Delete the memory DCs. + DeleteDC(hdcMem); + DeleteDC(hdcBack); + DeleteDC(hdcObject); + DeleteDC(hdcTemp); +end; + +{Make the table for a fast CRC.} +procedure make_crc_table; +var + c: Cardinal; + n, k: Integer; +begin + + {fill the crc table} + for n := 0 to 255 do + begin + c := Cardinal(n); + for k := 0 to 7 do + begin + if Boolean(c and 1) then + c := $edb88320 xor (c shr 1) + else + c := c shr 1; + end; + crc_table[n] := c; + end; + + {The table has already being computated} + crc_table_computed := true; +end; + +{Update a running CRC with the bytes buf[0..len-1]--the CRC + should be initialized to all 1's, and the transmitted value + is the 1's complement of the final running CRC (see the + crc() routine below)).} +function update_crc(crc: {$IFNDEF DelphiBuilder3Less}Cardinal{$ELSE}Integer + {$ENDIF}; buf: pByteArray; len: Integer): Cardinal; +var + c: Cardinal; + n: Integer; +begin + c := crc; + + {Create the crc table in case it has not being computed yet} + if not crc_table_computed then make_crc_table; + + {Update} + for n := 0 to len - 1 do + c := crc_table[(c XOR buf^[n]) and $FF] XOR (c shr 8); + + {Returns} + Result := c; +end; + +{$IFNDEF UseDelphi} + function FileExists(Filename: String): Boolean; + var + FindFile: THandle; + FindData: TWin32FindData; + begin + FindFile := FindFirstFile(PChar(Filename), FindData); + Result := FindFile <> INVALID_HANDLE_VALUE; + if Result then Windows.FindClose(FindFile); + end; + + +{$ENDIF} + +{$IFNDEF UseDelphi} + {Exception implementation} + constructor Exception.Create(Msg: String); + begin + end; +{$ENDIF} + +{Calculates the paeth predictor} +function PaethPredictor(a, b, c: Byte): Byte; +var + pa, pb, pc: Integer; +begin + { a = left, b = above, c = upper left } + pa := abs(b - c); { distances to a, b, c } + pb := abs(a - c); + pc := abs(a + b - c * 2); + + { return nearest of a, b, c, breaking ties in order a, b, c } + if (pa <= pb) and (pa <= pc) then + Result := a + else + if pb <= pc then + Result := b + else + Result := c; +end; + +{Invert bytes using assembly} +function ByteSwap(const a: integer): integer; +asm + bswap eax +end; +function ByteSwap16(inp:word): word; +asm + bswap eax + shr eax, 16 +end; + +{Calculates number of bytes for the number of pixels using the} +{color mode in the paramenter} +function BytesForPixels(const Pixels: Integer; const ColorType, + BitDepth: Byte): Integer; +begin + case ColorType of + {Palette and grayscale contains a single value, for palette} + {an value of size 2^bitdepth pointing to the palette index} + {and grayscale the value from 0 to 2^bitdepth with color intesity} + COLOR_GRAYSCALE, COLOR_PALETTE: + Result := (Pixels * BitDepth + 7) div 8; + {RGB contains 3 values R, G, B with size 2^bitdepth each} + COLOR_RGB: + Result := (Pixels * BitDepth * 3) div 8; + {Contains one value followed by alpha value booth size 2^bitdepth} + COLOR_GRAYSCALEALPHA: + Result := (Pixels * BitDepth * 2) div 8; + {Contains four values size 2^bitdepth, Red, Green, Blue and alpha} + COLOR_RGBALPHA: + Result := (Pixels * BitDepth * 4) div 8; + else + Result := 0; + end {case ColorType} +end; + +type + pChunkClassInfo = ^TChunkClassInfo; + TChunkClassInfo = record + ClassName: TChunkClass; + end; + +{Register a chunk type} +procedure RegisterChunk(ChunkClass: TChunkClass); +var + NewClass: pChunkClassInfo; +begin + {In case the list object has not being created yet} + if ChunkClasses = nil then ChunkClasses := TPngPointerList.Create(nil); + + {Add this new class} + new(NewClass); + NewClass^.ClassName := ChunkClass; + ChunkClasses.Add(NewClass); +end; + +{Free chunk class list} +procedure FreeChunkClassList; +var + i: Integer; +begin + if (ChunkClasses <> nil) then + begin + FOR i := 0 TO ChunkClasses.Count - 1 do + Dispose(pChunkClassInfo(ChunkClasses.Item[i])); + ChunkClasses.Free; + end; +end; + +{Registering of common chunk classes} +procedure RegisterCommonChunks; +begin + {Important chunks} + RegisterChunk(TChunkIEND); + RegisterChunk(TChunkIHDR); + RegisterChunk(TChunkIDAT); + RegisterChunk(TChunkPLTE); + RegisterChunk(TChunkgAMA); + RegisterChunk(TChunktRNS); + + {Not so important chunks} + RegisterChunk(TChunkpHYs); + RegisterChunk(TChunktIME); + RegisterChunk(TChunktEXt); + RegisterChunk(TChunkzTXt); +end; + +{Creates a new chunk of this class} +function CreateClassChunk(Owner: TPngObject; Name: TChunkName): TChunk; +var + i : Integer; + NewChunk: TChunkClass; +begin + {Looks for this chunk} + NewChunk := TChunk; {In case there is no registered class for this} + + {Looks for this class in all registered chunks} + if Assigned(ChunkClasses) then + FOR i := 0 TO ChunkClasses.Count - 1 DO + begin + if pChunkClassInfo(ChunkClasses.Item[i])^.ClassName.GetName = Name then + begin + NewChunk := pChunkClassInfo(ChunkClasses.Item[i])^.ClassName; + break; + end; + end; + + {Returns chunk class} + Result := NewChunk.Create(Owner); + Result.fName := Name; +end; + +{ZLIB support} + +const + ZLIBAllocate = High(Word); + +{Initializes ZLIB for decompression} +function ZLIBInitInflate(Stream: TStream): TZStreamRec2; +begin + {Fill record} + Fillchar(Result, SIZEOF(TZStreamRec2), #0); + + {Set internal record information} + with Result do + begin + GetMem(Data, ZLIBAllocate); + fStream := Stream; + end; + + {Init decompression} + InflateInit_(Result.zlib, zlib_version, SIZEOF(TZStreamRec)); +end; + +{Initializes ZLIB for compression} +function ZLIBInitDeflate(Stream: TStream; + Level: TCompressionlevel; Size: Cardinal): TZStreamRec2; +begin + {Fill record} + Fillchar(Result, SIZEOF(TZStreamRec2), #0); + + {Set internal record information} + with Result, ZLIB do + begin + GetMem(Data, Size); + fStream := Stream; + next_out := Data; + avail_out := Size; + end; + + {Inits compression} + deflateInit_(Result.zlib, Level, zlib_version, sizeof(TZStreamRec)); +end; + +{Terminates ZLIB for compression} +procedure ZLIBTerminateDeflate(var ZLIBStream: TZStreamRec2); +begin + {Terminates decompression} + DeflateEnd(ZLIBStream.zlib); + {Free internal record} + FreeMem(ZLIBStream.Data, ZLIBAllocate); +end; + +{Terminates ZLIB for decompression} +procedure ZLIBTerminateInflate(var ZLIBStream: TZStreamRec2); +begin + {Terminates decompression} + InflateEnd(ZLIBStream.zlib); + {Free internal record} + FreeMem(ZLIBStream.Data, ZLIBAllocate); +end; + +{Decompresses ZLIB into a memory address} +function DecompressZLIB(const Input: Pointer; InputSize: Integer; + var Output: Pointer; var OutputSize: Integer; + var ErrorOutput: String): Boolean; +var + StreamRec : TZStreamRec; + Buffer : Array[Byte] of Byte; + InflateRet: Integer; +begin + with StreamRec do + begin + {Initializes} + Result := True; + OutputSize := 0; + + {Prepares the data to decompress} + FillChar(StreamRec, SizeOf(TZStreamRec), #0); + InflateInit_(StreamRec, zlib_version, SIZEOF(TZStreamRec)); + next_in := Input; + avail_in := InputSize; + + {Decodes data} + repeat + {In case it needs an output buffer} + if (avail_out = 0) then + begin + next_out := @Buffer; + avail_out := SizeOf(Buffer); + end {if (avail_out = 0)}; + + {Decompress and put in output} + InflateRet := inflate(StreamRec, 0); + if (InflateRet = Z_STREAM_END) or (InflateRet = 0) then + begin + {Reallocates output buffer} + inc(OutputSize, total_out); + if Output = nil then + GetMem(Output, OutputSize) else ReallocMem(Output, OutputSize); + {Copies the new data} + CopyMemory(Ptr(Longint(Output) + OutputSize - total_out), + @Buffer, total_out); + end {if (InflateRet = Z_STREAM_END) or (InflateRet = 0)} + {Now tests for errors} + else if InflateRet < 0 then + begin + Result := False; + ErrorOutput := StreamRec.msg; + InflateEnd(StreamRec); + Exit; + end {if InflateRet < 0} + until InflateRet = Z_STREAM_END; + + {Terminates decompression} + InflateEnd(StreamRec); + end {with StreamRec} + +end; + +{Compresses ZLIB into a memory address} +function CompressZLIB(Input: Pointer; InputSize, CompressionLevel: Integer; + var Output: Pointer; var OutputSize: Integer; + var ErrorOutput: String): Boolean; +var + StreamRec : TZStreamRec; + Buffer : Array[Byte] of Byte; + DeflateRet: Integer; +begin + with StreamRec do + begin + Result := True; {By default returns TRUE as everything might have gone ok} + OutputSize := 0; {Initialize} + {Prepares the data to compress} + FillChar(StreamRec, SizeOf(TZStreamRec), #0); + DeflateInit_(StreamRec, CompressionLevel,zlib_version, SIZEOF(TZStreamRec)); + + next_in := Input; + avail_in := InputSize; + + while avail_in > 0 do + begin + {When it needs new buffer to stores the compressed data} + if avail_out = 0 then + begin + {Restore buffer} + next_out := @Buffer; + avail_out := SizeOf(Buffer); + end {if avail_out = 0}; + + {Compresses} + DeflateRet := deflate(StreamRec, Z_FINISH); + + if (DeflateRet = Z_STREAM_END) or (DeflateRet = 0) then + begin + {Updates the output memory} + inc(OutputSize, total_out); + if Output = nil then + GetMem(Output, OutputSize) else ReallocMem(Output, OutputSize); + + {Copies the new data} + CopyMemory(Ptr(Longint(Output) + OutputSize - total_out), + @Buffer, total_out); + end {if (InflateRet = Z_STREAM_END) or (InflateRet = 0)} + {Now tests for errors} + else if DeflateRet < 0 then + begin + Result := False; + ErrorOutput := StreamRec.msg; + DeflateEnd(StreamRec); + Exit; + end {if InflateRet < 0} + + end {while avail_in > 0}; + + {Finishes compressing} + DeflateEnd(StreamRec); + end {with StreamRec} + +end; + +{TPngPointerList implementation} + +{Object being created} +constructor TPngPointerList.Create(AOwner: TPNGObject); +begin + inherited Create; {Let ancestor work} + {Holds owner} + fOwner := AOwner; + {Memory pointer not being used yet} + fMemory := nil; + {No items yet} + fCount := 0; +end; + +{Removes value from the list} +function TPngPointerList.Remove(Value: Pointer): Pointer; +var + I, Position: Integer; +begin + {Gets item position} + Position := -1; + FOR I := 0 TO Count - 1 DO + if Value = Item[I] then Position := I; + {In case a match was found} + if Position >= 0 then + begin + Result := Item[Position]; {Returns pointer} + {Remove item and move memory} + Dec(fCount); + if Position < Integer(FCount) then + System.Move(fMemory^[Position + 1], fMemory^[Position], + (Integer(fCount) - Position) * SizeOf(Pointer)); + end {if Position >= 0} else Result := nil +end; + +{Add a new value in the list} +procedure TPngPointerList.Add(Value: Pointer); +begin + Count := Count + 1; + Item[Count - 1] := Value; +end; + + +{Object being destroyed} +destructor TPngPointerList.Destroy; +begin + {Release memory if needed} + if fMemory <> nil then + FreeMem(fMemory, fCount * sizeof(Pointer)); + + {Free things} + inherited Destroy; +end; + +{Returns one item from the list} +function TPngPointerList.GetItem(Index: Cardinal): Pointer; +begin + if (Index <= Count - 1) then + Result := fMemory[Index] + else + {In case it's out of bounds} + Result := nil; +end; + +{Inserts a new item in the list} +procedure TPngPointerList.Insert(Value: Pointer; Position: Cardinal); +begin + if (Position < Count) or (Count = 0) then + begin + {Increase item count} + SetSize(Count + 1); + {Move other pointers} + if Position < Count then + System.Move(fMemory^[Position], fMemory^[Position + 1], + (Count - Position - 1) * SizeOf(Pointer)); + {Sets item} + Item[Position] := Value; + end; +end; + +{Sets one item from the list} +procedure TPngPointerList.SetItem(Index: Cardinal; const Value: Pointer); +begin + {If index is in bounds, set value} + if (Index <= Count - 1) then + fMemory[Index] := Value +end; + +{This method resizes the list} +procedure TPngPointerList.SetSize(const Size: Cardinal); +begin + {Sets the size} + if (fMemory = nil) and (Size > 0) then + GetMem(fMemory, Size * SIZEOF(Pointer)) + else + if Size > 0 then {Only realloc if the new size is greater than 0} + ReallocMem(fMemory, Size * SIZEOF(Pointer)) + else + {In case user is resize to 0 items} + begin + FreeMem(fMemory); + fMemory := nil; + end; + {Update count} + fCount := Size; +end; + +{TPNGList implementation} + +{Finds the first chunk of this class} +function TPNGList.FindChunk(ChunkClass: TChunkClass): TChunk; +var + i: Integer; +begin + Result := nil; + for i := 0 to Count - 1 do + if Item[i] is ChunkClass then + begin + Result := Item[i]; + Break + end +end; + + +{Removes an item} +procedure TPNGList.RemoveChunk(Chunk: TChunk); +begin + Remove(Chunk); + Chunk.Free +end; + +{Add a new item} +function TPNGList.Add(ChunkClass: TChunkClass): TChunk; +var + IHDR: TChunkIHDR; + IEND: TChunkIEND; + + IDAT: TChunkIDAT; + PLTE: TChunkPLTE; +begin + Result := nil; {Default result} + {Adding these is not allowed} + if ((ChunkClass = TChunkIHDR) or (ChunkClass = TChunkIDAT) or + (ChunkClass = TChunkPLTE) or (ChunkClass = TChunkIEND)) and not + (Owner.BeingCreated) then + fOwner.RaiseError(EPngError, EPNGCannotAddChunkText) + {Two of these is not allowed} + else if ((ChunkClass = TChunkgAMA) and (ItemFromClass(TChunkgAMA) <> nil)) or + ((ChunkClass = TChunktRNS) and (ItemFromClass(TChunktRNS) <> nil)) or + ((ChunkClass = TChunkpHYs) and (ItemFromClass(TChunkpHYs) <> nil)) then + fOwner.RaiseError(EPngError, EPNGCannotAddChunkText) + {There must have an IEND and IHDR chunk} + else if ((ItemFromClass(TChunkIEND) = nil) or + (ItemFromClass(TChunkIHDR) = nil)) and not Owner.BeingCreated then + fOwner.RaiseError(EPngError, EPNGCannotAddInvalidImageText) + else + begin + {Get common chunks} + IHDR := ItemFromClass(TChunkIHDR) as TChunkIHDR; + IEND := ItemFromClass(TChunkIEND) as TChunkIEND; + {Create new chunk} + Result := ChunkClass.Create(Owner); + {Add to the list} + if (ChunkClass = TChunkgAMA) or (ChunkClass = TChunkpHYs) or + (ChunkClass = TChunkPLTE) then + Insert(Result, IHDR.Index + 1) + {Header and end} + else if (ChunkClass = TChunkIEND) then + Insert(Result, Count) + else if (ChunkClass = TChunkIHDR) then + Insert(Result, 0) + {Transparency chunk (fix by Ian Boyd)} + else if (ChunkClass = TChunktRNS) then + begin + {Transparecy chunk must be after PLTE; before IDAT} + IDAT := ItemFromClass(TChunkIDAT) as TChunkIDAT; + PLTE := ItemFromClass(TChunkPLTE) as TChunkPLTE; + + if Assigned(PLTE) then + Insert(Result, PLTE.Index + 1) + else if Assigned(IDAT) then + Insert(Result, IDAT.Index) + else + Insert(Result, IHDR.Index + 1) + end + else {All other chunks} + Insert(Result, IEND.Index); + end {if} +end; + +{Returns item from the list} +function TPNGList.GetItem(Index: Cardinal): TChunk; +begin + Result := inherited GetItem(Index); +end; + +{Returns first item from the list using the class from parameter} +function TPNGList.ItemFromClass(ChunkClass: TChunkClass): TChunk; +var + i: Integer; +begin + Result := nil; {Initial result} + FOR i := 0 TO Count - 1 DO + {Test if this item has the same class} + if Item[i] is ChunkClass then + begin + {Returns this item and exit} + Result := Item[i]; + break; + end {if} +end; + +{$IFNDEF UseDelphi} + + {TStream implementation} + + {Copies all from another stream} + function TStream.CopyFrom(Source: TStream; Count: Cardinal): Cardinal; + const + MaxBytes = $f000; + var + Buffer: PChar; + BufSize, N: Cardinal; + begin + {If count is zero, copy everything from Source} + if Count = 0 then + begin + Source.Seek(0, soFromBeginning); + Count := Source.Size; + end; + + Result := Count; {Returns the number of bytes readed} + {Allocates memory} + if Count > MaxBytes then BufSize := MaxBytes else BufSize := Count; + GetMem(Buffer, BufSize); + + {Copy memory} + while Count > 0 do + begin + if Count > BufSize then N := BufSize else N := Count; + Source.Read(Buffer^, N); + Write(Buffer^, N); + dec(Count, N); + end; + + {Deallocates memory} + FreeMem(Buffer, BufSize); + end; + +{Set current stream position} +procedure TStream.SetPosition(const Value: Longint); +begin + Seek(Value, soFromBeginning); +end; + +{Returns position} +function TStream.GetPosition: Longint; +begin + Result := Seek(0, soFromCurrent); +end; + + {Returns stream size} +function TStream.GetSize: Longint; + var + Pos: Cardinal; + begin + Pos := Seek(0, soFromCurrent); + Result := Seek(0, soFromEnd); + Seek(Pos, soFromBeginning); + end; + + {TFileStream implementation} + + {Filestream object being created} + constructor TFileStream.Create(Filename: String; Mode: TFileStreamModeSet); + {Makes file mode} + function OpenMode: DWORD; + begin + Result := 0; + if fsmRead in Mode then Result := GENERIC_READ; + if (fsmWrite in Mode) or (fsmCreate in Mode) then + Result := Result OR GENERIC_WRITE; + end; + const + IsCreate: Array[Boolean] of Integer = (OPEN_ALWAYS, CREATE_ALWAYS); + begin + {Call ancestor} + inherited Create; + + {Create handle} + fHandle := CreateFile(PChar(Filename), OpenMode, FILE_SHARE_READ or + FILE_SHARE_WRITE, nil, IsCreate[fsmCreate in Mode], 0, 0); + {Store mode} + FileMode := Mode; + end; + + {Filestream object being destroyed} + destructor TFileStream.Destroy; + begin + {Terminates file and close} + if FileMode = [fsmWrite] then + SetEndOfFile(fHandle); + CloseHandle(fHandle); + + {Call ancestor} + inherited Destroy; + end; + + {Writes data to the file} + function TFileStream.Write(const Buffer; Count: Longint): Cardinal; + begin + if not WriteFile(fHandle, Buffer, Count, Result, nil) then + Result := 0; + end; + + {Reads data from the file} + function TFileStream.Read(var Buffer; Count: Longint): Cardinal; + begin + if not ReadFile(fHandle, Buffer, Count, Result, nil) then + Result := 0; + end; + + {Seeks the file position} + function TFileStream.Seek(Offset: Integer; Origin: Word): Longint; + begin + Result := SetFilePointer(fHandle, Offset, nil, Origin); + end; + + {Sets the size of the file} + procedure TFileStream.SetSize(const Value: Longint); + begin + Seek(Value, soFromBeginning); + SetEndOfFile(fHandle); + end; + + {TResourceStream implementation} + + {Creates the resource stream} + constructor TResourceStream.Create(Instance: HInst; const ResName: String; + ResType: PChar); + var + ResID: HRSRC; + ResGlobal: HGlobal; + begin + {Obtains the resource ID} + ResID := FindResource(hInstance, PChar(ResName), RT_RCDATA); + if ResID = 0 then raise EPNGError.Create(''); + {Obtains memory and size} + ResGlobal := LoadResource(hInstance, ResID); + Size := SizeOfResource(hInstance, ResID); + Memory := LockResource(ResGlobal); + if (ResGlobal = 0) or (Memory = nil) then EPNGError.Create(''); + end; + + + {Setting resource stream size is not supported} + procedure TResourceStream.SetSize(const Value: Integer); + begin + end; + + {Writing into a resource stream is not supported} + function TResourceStream.Write(const Buffer; Count: Integer): Cardinal; + begin + Result := 0; + end; + + {Reads data from the stream} + function TResourceStream.Read(var Buffer; Count: Integer): Cardinal; + begin + //Returns data + CopyMemory(@Buffer, Ptr(Longint(Memory) + Position), Count); + //Update position + inc(Position, Count); + //Returns + Result := Count; + end; + + {Seeks data} + function TResourceStream.Seek(Offset: Integer; Origin: Word): Longint; + begin + {Move depending on the origin} + case Origin of + soFromBeginning: Position := Offset; + soFromCurrent: inc(Position, Offset); + soFromEnd: Position := Size + Offset; + end; + + {Returns the current position} + Result := Position; + end; + +{$ENDIF} + +{TChunk implementation} + +{Resizes the data} +procedure TChunk.ResizeData(const NewSize: Cardinal); +begin + fDataSize := NewSize; + ReallocMem(fData, NewSize + 1); +end; + +{Returns index from list} +function TChunk.GetIndex: Integer; +var + i: Integer; +begin + Result := -1; {Avoiding warnings} + {Searches in the list} + FOR i := 0 TO Owner.Chunks.Count - 1 DO + if Owner.Chunks.Item[i] = Self then + begin + {Found match} + Result := i; + exit; + end {for i} +end; + +{Returns pointer to the TChunkIHDR} +function TChunk.GetHeader: TChunkIHDR; +begin + Result := Owner.Chunks.Item[0] as TChunkIHDR; +end; + +{Assigns from another TChunk} +procedure TChunk.Assign(Source: TChunk); +begin + {Copy properties} + fName := Source.fName; + {Set data size and realloc} + ResizeData(Source.fDataSize); + + {Copy data (if there's any)} + if fDataSize > 0 then CopyMemory(fData, Source.fData, fDataSize); +end; + +{Chunk being created} +constructor TChunk.Create(Owner: TPngObject); +var + ChunkName: String; +begin + {Ancestor create} + inherited Create; + + {If it's a registered class, set the chunk name based on the class} + {name. For instance, if the class name is TChunkgAMA, the GAMA part} + {will become the chunk name} + ChunkName := Copy(ClassName, Length('TChunk') + 1, Length(ClassName)); + if Length(ChunkName) = 4 then CopyMemory(@fName[0], @ChunkName[1], 4); + + {Initialize data holder} + GetMem(fData, 1); + fDataSize := 0; + {Record owner} + fOwner := Owner; +end; + +{Chunk being destroyed} +destructor TChunk.Destroy; +begin + {Free data holder} + FreeMem(fData, fDataSize + 1); + {Let ancestor destroy} + inherited Destroy; +end; + +{Returns the chunk name 1} +function TChunk.GetChunkName: String; +begin + Result := fName +end; + +{Returns the chunk name 2} +class function TChunk.GetName: String; +begin + {For avoid writing GetName for each TChunk descendent, by default for} + {classes which don't declare GetName, it will look for the class name} + {to extract the chunk kind. Example, if the class name is TChunkIEND } + {this method extracts and returns IEND} + Result := Copy(ClassName, Length('TChunk') + 1, Length(ClassName)); +end; + +{Saves the data to the stream} +function TChunk.SaveData(Stream: TStream): Boolean; +var + ChunkSize, ChunkCRC: Cardinal; +begin + {First, write the size for the following data in the chunk} + ChunkSize := ByteSwap(DataSize); + Stream.Write(ChunkSize, 4); + {The chunk name} + Stream.Write(fName, 4); + {If there is data for the chunk, write it} + if DataSize > 0 then Stream.Write(Data^, DataSize); + {Calculates and write CRC} + ChunkCRC := update_crc($ffffffff, @fName[0], 4); + ChunkCRC := Byteswap(update_crc(ChunkCRC, Data, DataSize) xor $ffffffff); + Stream.Write(ChunkCRC, 4); + + {Returns that everything went ok} + Result := TRUE; +end; + +{Saves the chunk to the stream} +function TChunk.SaveToStream(Stream: TStream): Boolean; +begin + Result := SaveData(Stream) +end; + + +{Loads the chunk from a stream} +function TChunk.LoadFromStream(Stream: TStream; const ChunkName: TChunkName; + Size: Integer): Boolean; +var + CheckCRC: Cardinal; + {$IFDEF CheckCRC}RightCRC: Cardinal;{$ENDIF} +begin + {Copies data from source} + ResizeData(Size); + if Size > 0 then Stream.Read(fData^, Size); + {Reads CRC} + Stream.Read(CheckCRC, 4); + CheckCrc := ByteSwap(CheckCRC); + + {Check if crc readed is valid} + {$IFDEF CheckCRC} + RightCRC := update_crc($ffffffff, @ChunkName[0], 4); + RightCRC := update_crc(RightCRC, fData, Size) xor $ffffffff; + Result := RightCRC = CheckCrc; + + {Handle CRC error} + if not Result then + begin + {In case it coult not load chunk} + Owner.RaiseError(EPngInvalidCRC, EPngInvalidCRCText); + exit; + end + {$ELSE}Result := TRUE; {$ENDIF} + +end; + +{TChunktIME implementation} + +{Chunk being loaded from a stream} +function TChunktIME.LoadFromStream(Stream: TStream; + const ChunkName: TChunkName; Size: Integer): Boolean; +begin + {Let ancestor load the data} + Result := inherited LoadFromStream(Stream, ChunkName, Size); + if not Result or (Size <> 7) then exit; {Size must be 7} + + {Reads data} + fYear := ((pByte(Longint(Data) )^) * 256)+ (pByte(Longint(Data) + 1)^); + fMonth := pByte(Longint(Data) + 2)^; + fDay := pByte(Longint(Data) + 3)^; + fHour := pByte(Longint(Data) + 4)^; + fMinute := pByte(Longint(Data) + 5)^; + fSecond := pByte(Longint(Data) + 6)^; +end; + +{Assigns from another TChunk} +procedure TChunktIME.Assign(Source: TChunk); +begin + fYear := TChunktIME(Source).fYear; + fMonth := TChunktIME(Source).fMonth; + fDay := TChunktIME(Source).fDay; + fHour := TChunktIME(Source).fHour; + fMinute := TChunktIME(Source).fMinute; + fSecond := TChunktIME(Source).fSecond; +end; + +{Saving the chunk to a stream} +function TChunktIME.SaveToStream(Stream: TStream): Boolean; +begin + {Update data} + ResizeData(7); {Make sure the size is 7} + pWord(Data)^ := ByteSwap16(Year); + pByte(Longint(Data) + 2)^ := Month; + pByte(Longint(Data) + 3)^ := Day; + pByte(Longint(Data) + 4)^ := Hour; + pByte(Longint(Data) + 5)^ := Minute; + pByte(Longint(Data) + 6)^ := Second; + + {Let inherited save data} + Result := inherited SaveToStream(Stream); +end; + +{TChunkztXt implementation} + +{Loading the chunk from a stream} +function TChunkzTXt.LoadFromStream(Stream: TStream; + const ChunkName: TChunkName; Size: Integer): Boolean; +var + ErrorOutput: String; + CompressionMethod: Byte; + Output: Pointer; + OutputSize: Integer; +begin + {Load data from stream and validate} + Result := inherited LoadFromStream(Stream, ChunkName, Size); + if not Result or (Size < 4) then exit; + fKeyword := PChar(Data); {Get keyword and compression method bellow} + if Longint(fKeyword) = 0 then + CompressionMethod := pByte(Data)^ + else + CompressionMethod := pByte(Longint(fKeyword) + Length(fKeyword))^; + fText := ''; + + {In case the compression is 0 (only one accepted by specs), reads it} + if CompressionMethod = 0 then + begin + Output := nil; + if DecompressZLIB(PChar(Longint(Data) + Length(fKeyword) + 2), + Size - Length(fKeyword) - 2, Output, OutputSize, ErrorOutput) then + begin + SetLength(fText, OutputSize); + CopyMemory(@fText[1], Output, OutputSize); + end {if DecompressZLIB(...}; + FreeMem(Output); + end {if CompressionMethod = 0} + +end; + +{Saving the chunk to a stream} +function TChunkztXt.SaveToStream(Stream: TStream): Boolean; +var + Output: Pointer; + OutputSize: Integer; + ErrorOutput: String; +begin + Output := nil; {Initializes output} + if fText = '' then fText := ' '; + + {Compresses the data} + if CompressZLIB(@fText[1], Length(fText), Owner.CompressionLevel, Output, + OutputSize, ErrorOutput) then + begin + {Size is length from keyword, plus a null character to divide} + {plus the compression method, plus the length of the text (zlib compressed)} + ResizeData(Length(fKeyword) + 2 + OutputSize); + + Fillchar(Data^, DataSize, #0); + {Copies the keyword data} + if Keyword <> '' then + CopyMemory(Data, @fKeyword[1], Length(Keyword)); + {Compression method 0 (inflate/deflate)} + pByte(Ptr(Longint(Data) + Length(Keyword) + 1))^ := 0; + if OutputSize > 0 then + CopyMemory(Ptr(Longint(Data) + Length(Keyword) + 2), Output, OutputSize); + + {Let ancestor calculate crc and save} + Result := SaveData(Stream); + end {if CompressZLIB(...} else Result := False; + + {Frees output} + if Output <> nil then FreeMem(Output) +end; + +{TChunktEXt implementation} + +{Assigns from another text chunk} +procedure TChunktEXt.Assign(Source: TChunk); +begin + fKeyword := TChunktEXt(Source).fKeyword; + fText := TChunktEXt(Source).fText; +end; + +{Loading the chunk from a stream} +function TChunktEXt.LoadFromStream(Stream: TStream; + const ChunkName: TChunkName; Size: Integer): Boolean; +begin + {Load data from stream and validate} + Result := inherited LoadFromStream(Stream, ChunkName, Size); + if not Result or (Size < 3) then exit; + {Get text} + fKeyword := PChar(Data); + SetLength(fText, Size - Length(fKeyword) - 1); + CopyMemory(@fText[1], Ptr(Longint(Data) + Length(fKeyword) + 1), + Length(fText)); +end; + +{Saving the chunk to a stream} +function TChunktEXt.SaveToStream(Stream: TStream): Boolean; +begin + {Size is length from keyword, plus a null character to divide} + {plus the length of the text} + ResizeData(Length(fKeyword) + 1 + Length(fText)); + Fillchar(Data^, DataSize, #0); + {Copy data} + if Keyword <> '' then + CopyMemory(Data, @fKeyword[1], Length(Keyword)); + if Text <> '' then + CopyMemory(Ptr(Longint(Data) + Length(Keyword) + 1), @fText[1], + Length(Text)); + {Let ancestor calculate crc and save} + Result := inherited SaveToStream(Stream); +end; + + +{TChunkIHDR implementation} + +{Chunk being created} +constructor TChunkIHDR.Create(Owner: TPngObject); +begin + {Prepare pointers} + ImageHandle := 0; + ImagePalette := 0; + ImageDC := 0; + + {Call inherited} + inherited Create(Owner); +end; + +{Chunk being destroyed} +destructor TChunkIHDR.Destroy; +begin + {Free memory} + FreeImageData(); + + {Calls TChunk destroy} + inherited Destroy; +end; + +{Copies the palette} +procedure CopyPalette(Source: HPALETTE; Destination: HPALETTE); +var + PaletteSize: Integer; + Entries: Array[Byte] of TPaletteEntry; +begin + PaletteSize := 0; + if GetObject(Source, SizeOf(PaletteSize), @PaletteSize) = 0 then Exit; + if PaletteSize = 0 then Exit; + ResizePalette(Destination, PaletteSize); + GetPaletteEntries(Source, 0, PaletteSize, Entries); + SetPaletteEntries(Destination, 0, PaletteSize, Entries); +end; + +{Assigns from another IHDR chunk} +procedure TChunkIHDR.Assign(Source: TChunk); +begin + {Copy the IHDR data} + if Source is TChunkIHDR then + begin + {Copy IHDR values} + IHDRData := TChunkIHDR(Source).IHDRData; + + {Prepare to hold data by filling BitmapInfo structure and} + {resizing ImageData and ImageAlpha memory allocations} + PrepareImageData(); + + {Copy image data} + CopyMemory(ImageData, TChunkIHDR(Source).ImageData, + BytesPerRow * Integer(Height)); + CopyMemory(ImageAlpha, TChunkIHDR(Source).ImageAlpha, + Integer(Width) * Integer(Height)); + + {Copy palette colors} + BitmapInfo.bmiColors := TChunkIHDR(Source).BitmapInfo.bmiColors; + {Copy palette also} + CopyPalette(TChunkIHDR(Source).ImagePalette, ImagePalette); + end + else + Owner.RaiseError(EPNGError, EPNGCannotAssignChunkText); +end; + +{Release allocated image data} +procedure TChunkIHDR.FreeImageData; +begin + {Free old image data} + if ImageHandle <> 0 then DeleteObject(ImageHandle); + if ImageDC <> 0 then DeleteDC(ImageDC); + if ImageAlpha <> nil then FreeMem(ImageAlpha); + if ImagePalette <> 0 then DeleteObject(ImagePalette); + {$IFDEF Store16bits} + if ExtraImageData <> nil then FreeMem(ExtraImageData); + {$ENDIF} + ImageHandle := 0; ImageDC := 0; ImageAlpha := nil; ImageData := nil; + ImagePalette := 0; ExtraImageData := nil; +end; + +{Chunk being loaded from a stream} +function TChunkIHDR.LoadFromStream(Stream: TStream; const ChunkName: TChunkName; + Size: Integer): Boolean; +begin + {Let TChunk load it} + Result := inherited LoadFromStream(Stream, ChunkName, Size); + if not Result then Exit; + + {Now check values} + {Note: It's recommended by png specification to make sure that the size} + {must be 13 bytes to be valid, but some images with 14 bytes were found} + {which could be loaded by internet explorer and other tools} + if (fDataSize < SIZEOF(TIHdrData)) then + begin + {Ihdr must always have at least 13 bytes} + Result := False; + Owner.RaiseError(EPNGInvalidIHDR, EPNGInvalidIHDRText); + exit; + end; + + {Everything ok, reads IHDR} + IHDRData := pIHDRData(fData)^; + IHDRData.Width := ByteSwap(IHDRData.Width); + IHDRData.Height := ByteSwap(IHDRData.Height); + + {The width and height must not be larger than 65535 pixels} + if (IHDRData.Width > High(Word)) or (IHDRData.Height > High(Word)) then + begin + Result := False; + Owner.RaiseError(EPNGSizeExceeds, EPNGSizeExceedsText); + exit; + end {if IHDRData.Width > High(Word)}; + {Compression method must be 0 (inflate/deflate)} + if (IHDRData.CompressionMethod <> 0) then + begin + Result := False; + Owner.RaiseError(EPNGUnknownCompression, EPNGUnknownCompressionText); + exit; + end; + {Interlace must be either 0 (none) or 7 (adam7)} + if (IHDRData.InterlaceMethod <> 0) and (IHDRData.InterlaceMethod <> 1) then + begin + Result := False; + Owner.RaiseError(EPNGUnknownInterlace, EPNGUnknownInterlaceText); + exit; + end; + + {Updates owner properties} + Owner.InterlaceMethod := TInterlaceMethod(IHDRData.InterlaceMethod); + + {Prepares data to hold image} + PrepareImageData(); +end; + +{Saving the IHDR chunk to a stream} +function TChunkIHDR.SaveToStream(Stream: TStream): Boolean; +begin + {Ignore 2 bits images} + if BitDepth = 2 then BitDepth := 4; + + {It needs to do is update the data with the IHDR data} + {structure containing the write values} + ResizeData(SizeOf(TIHDRData)); + pIHDRData(fData)^ := IHDRData; + {..byteswap 4 byte types} + pIHDRData(fData)^.Width := ByteSwap(pIHDRData(fData)^.Width); + pIHDRData(fData)^.Height := ByteSwap(pIHDRData(fData)^.Height); + {..update interlace method} + pIHDRData(fData)^.InterlaceMethod := Byte(Owner.InterlaceMethod); + {..and then let the ancestor SaveToStream do the hard work} + Result := inherited SaveToStream(Stream); +end; + +{Creates a grayscale palette} +function TChunkIHDR.CreateGrayscalePalette(Bitdepth: Integer): HPalette; +var + j: Integer; + palEntries: TMaxLogPalette; +begin + {Prepares and fills the strucutre} + if Bitdepth = 16 then Bitdepth := 8; + fillchar(palEntries, sizeof(palEntries), 0); + palEntries.palVersion := $300; + palEntries.palNumEntries := 1 shl Bitdepth; + {Fill it with grayscale colors} + for j := 0 to palEntries.palNumEntries - 1 do + begin + palEntries.palPalEntry[j].peRed := + fOwner.GammaTable[MulDiv(j, 255, palEntries.palNumEntries - 1)]; + palEntries.palPalEntry[j].peGreen := palEntries.palPalEntry[j].peRed; + palEntries.palPalEntry[j].peBlue := palEntries.palPalEntry[j].peRed; + end; + {Creates and returns the palette} + Result := CreatePalette(pLogPalette(@palEntries)^); +end; + +{Copies the palette to the Device Independent bitmap header} +procedure TChunkIHDR.PaletteToDIB(Palette: HPalette); +var + j: Integer; + palEntries: TMaxLogPalette; +begin + {Copy colors} + Fillchar(palEntries, sizeof(palEntries), #0); + BitmapInfo.bmiHeader.biClrUsed := GetPaletteEntries(Palette, 0, 256, palEntries.palPalEntry[0]); + for j := 0 to BitmapInfo.bmiHeader.biClrUsed - 1 do + begin + BitmapInfo.bmiColors[j].rgbBlue := palEntries.palPalEntry[j].peBlue; + BitmapInfo.bmiColors[j].rgbRed := palEntries.palPalEntry[j].peRed; + BitmapInfo.bmiColors[j].rgbGreen := palEntries.palPalEntry[j].peGreen; + end; +end; + +{Resizes the image data to fill the color type, bit depth, } +{width and height parameters} +procedure TChunkIHDR.PrepareImageData(); + {Set the bitmap info} + procedure SetInfo(const Bitdepth: Integer; const Palette: Boolean); + begin + + {Copy if the bitmap contain palette entries} + HasPalette := Palette; + {Fill the strucutre} + with BitmapInfo.bmiHeader do + begin + biSize := sizeof(TBitmapInfoHeader); + biHeight := Height; + biWidth := Width; + biPlanes := 1; + biBitCount := BitDepth; + biCompression := BI_RGB; + end {with BitmapInfo.bmiHeader} + end; +begin + {Prepare bitmap info header} + Fillchar(BitmapInfo, sizeof(TMaxBitmapInfo), #0); + {Release old image data} + FreeImageData(); + + {Obtain number of bits for each pixel} + case ColorType of + COLOR_GRAYSCALE, COLOR_PALETTE, COLOR_GRAYSCALEALPHA: + case BitDepth of + {These are supported by windows} + 1, 4, 8: SetInfo(BitDepth, TRUE); + {2 bits for each pixel is not supported by windows bitmap} + 2 : SetInfo(4, TRUE); + {Also 16 bits (2 bytes) for each pixel is not supported} + {and should be transormed into a 8 bit grayscale} + 16 : SetInfo(8, TRUE); + end; + {Only 1 byte (8 bits) is supported} + COLOR_RGB, COLOR_RGBALPHA: SetInfo(24, FALSE); + end {case ColorType}; + {Number of bytes for each scanline} + BytesPerRow := (((BitmapInfo.bmiHeader.biBitCount * Width) + 31) + and not 31) div 8; + + {Build array for alpha information, if necessary} + if (ColorType = COLOR_RGBALPHA) or (ColorType = COLOR_GRAYSCALEALPHA) then + begin + GetMem(ImageAlpha, Integer(Width) * Integer(Height)); + FillChar(ImageAlpha^, Integer(Width) * Integer(Height), #0); + end; + + {Build array for extra byte information} + {$IFDEF Store16bits} + if (BitDepth = 16) then + begin + GetMem(ExtraImageData, BytesPerRow * Integer(Height)); + FillChar(ExtraImageData^, BytesPerRow * Integer(Height), #0); + end; + {$ENDIF} + + {Creates the image to hold the data, CreateDIBSection does a better} + {work in allocating necessary memory} + ImageDC := CreateCompatibleDC(0); + {$IFDEF UseDelphi}Self.Owner.Canvas.Handle := ImageDC;{$ENDIF} + + {In case it is a palette image, create the palette} + if HasPalette then + begin + {Create a standard palette} + if ColorType = COLOR_PALETTE then + ImagePalette := CreateHalfTonePalette(ImageDC) + else + ImagePalette := CreateGrayscalePalette(Bitdepth); + ResizePalette(ImagePalette, 1 shl BitmapInfo.bmiHeader.biBitCount); + BitmapInfo.bmiHeader.biClrUsed := 1 shl BitmapInfo.bmiHeader.biBitCount; + SelectPalette(ImageDC, ImagePalette, False); + RealizePalette(ImageDC); + PaletteTODIB(ImagePalette); + end; + + {Create the device independent bitmap} + ImageHandle := CreateDIBSection(ImageDC, pBitmapInfo(@BitmapInfo)^, + DIB_RGB_COLORS, ImageData, 0, 0); + SelectObject(ImageDC, ImageHandle); + + {Build array and allocate bytes for each row} + fillchar(ImageData^, BytesPerRow * Integer(Height), 0); +end; + +{TChunktRNS implementation} + +{$IFNDEF UseDelphi} +function CompareMem(P1, P2: pByte; const Size: Integer): Boolean; +var i: Integer; +begin + Result := True; + for i := 1 to Size do + begin + if P1^ <> P2^ then Result := False; + inc(P1); inc(P2); + end {for i} +end; +{$ENDIF} + +{Sets the transpararent color} +procedure TChunktRNS.SetTransparentColor(const Value: ColorRef); +var + i: Byte; + LookColor: TRGBQuad; +begin + {Clears the palette values} + Fillchar(PaletteValues, SizeOf(PaletteValues), #0); + {Sets that it uses bit transparency} + fBitTransparency := True; + + + {Depends on the color type} + with Header do + case ColorType of + COLOR_GRAYSCALE: + begin + Self.ResizeData(2); + pWord(@PaletteValues[0])^ := ByteSwap16(GetRValue(Value)); + end; + COLOR_RGB: + begin + Self.ResizeData(6); + pWord(@PaletteValues[0])^ := ByteSwap16(GetRValue(Value)); + pWord(@PaletteValues[2])^ := ByteSwap16(GetGValue(Value)); + pWord(@PaletteValues[4])^ := ByteSwap16(GetBValue(Value)); + end; + COLOR_PALETTE: + begin + {Creates a RGBQuad to search for the color} + LookColor.rgbRed := GetRValue(Value); + LookColor.rgbGreen := GetGValue(Value); + LookColor.rgbBlue := GetBValue(Value); + {Look in the table for the entry} + for i := 0 to BitmapInfo.bmiHeader.biClrUsed - 1 do + if CompareMem(@BitmapInfo.bmiColors[i], @LookColor, 3) then + Break; + {Fill the transparency table} + Fillchar(PaletteValues, i, 255); + Self.ResizeData(i + 1) + + end + end {case / with}; + +end; + +{Returns the transparent color for the image} +function TChunktRNS.GetTransparentColor: ColorRef; +var + PaletteChunk: TChunkPLTE; + i: Integer; + Value: Byte; +begin + Result := 0; {Default: Unknown transparent color} + + {Depends on the color type} + with Header do + case ColorType of + COLOR_GRAYSCALE: + begin + Value := BitmapInfo.bmiColors[PaletteValues[1]].rgbRed; + Result := RGB(Value, Value, Value); + end; + COLOR_RGB: + Result := RGB(fOwner.GammaTable[PaletteValues[1]], + fOwner.GammaTable[PaletteValues[3]], + fOwner.GammaTable[PaletteValues[5]]); + COLOR_PALETTE: + begin + {Obtains the palette chunk} + PaletteChunk := Owner.Chunks.ItemFromClass(TChunkPLTE) as TChunkPLTE; + + {Looks for an entry with 0 transparency meaning that it is the} + {full transparent entry} + for i := 0 to Self.DataSize - 1 do + if PaletteValues[i] = 0 then + with PaletteChunk.GetPaletteItem(i) do + begin + Result := RGB(rgbRed, rgbGreen, rgbBlue); + break + end + end {COLOR_PALETTE} + end {case Header.ColorType}; +end; + +{Saving the chunk to a stream} +function TChunktRNS.SaveToStream(Stream: TStream): Boolean; +begin + {Copy palette into data buffer} + if DataSize <= 256 then + CopyMemory(fData, @PaletteValues[0], DataSize); + + Result := inherited SaveToStream(Stream); +end; + +{Assigns from another chunk} +procedure TChunktRNS.Assign(Source: TChunk); +begin + CopyMemory(@PaletteValues[0], @TChunkTrns(Source).PaletteValues[0], 256); + fBitTransparency := TChunkTrns(Source).fBitTransparency; + inherited Assign(Source); +end; + +{Loads the chunk from a stream} +function TChunktRNS.LoadFromStream(Stream: TStream; const ChunkName: TChunkName; + Size: Integer): Boolean; +var + i, Differ255: Integer; +begin + {Let inherited load} + Result := inherited LoadFromStream(Stream, ChunkName, Size); + + if not Result then Exit; + + {Make sure size is correct} + if Size > 256 then Owner.RaiseError(EPNGInvalidPalette, + EPNGInvalidPaletteText); + + {The unset items should have value 255} + Fillchar(PaletteValues[0], 256, 255); + {Copy the other values} + CopyMemory(@PaletteValues[0], fData, Size); + + {Create the mask if needed} + case Header.ColorType of + {Mask for grayscale and RGB} + COLOR_RGB, COLOR_GRAYSCALE: fBitTransparency := True; + COLOR_PALETTE: + begin + Differ255 := 0; {Count the entries with a value different from 255} + {Tests if it uses bit transparency} + for i := 0 to Size - 1 do + if PaletteValues[i] <> 255 then inc(Differ255); + + {If it has one value different from 255 it is a bit transparency} + fBitTransparency := (Differ255 = 1); + end {COLOR_PALETTE} + end {case Header.ColorType}; + +end; + +{Prepares the image palette} +procedure TChunkIDAT.PreparePalette; +var + Entries: Word; + j : Integer; + palEntries: TMaxLogPalette; +begin + {In case the image uses grayscale, build a grayscale palette} + with Header do + if (ColorType = COLOR_GRAYSCALE) or (ColorType = COLOR_GRAYSCALEALPHA) then + begin + {Calculate total number of palette entries} + Entries := (1 shl Byte(BitmapInfo.bmiHeader.biBitCount)); + Fillchar(palEntries, sizeof(palEntries), #0); + palEntries.palVersion := $300; + palEntries.palNumEntries := Entries; + + FOR j := 0 TO Entries - 1 DO + with palEntries.palPalEntry[j] do + begin + + {Calculate each palette entry} + peRed := fOwner.GammaTable[MulDiv(j, 255, Entries - 1)]; + peGreen := peRed; + peBlue := peRed; + end {with BitmapInfo.bmiColors[j]}; + Owner.SetPalette(CreatePalette(pLogPalette(@palEntries)^)); + end {if ColorType = COLOR_GRAYSCALE..., with Header} +end; + +{Reads from ZLIB} +function TChunkIDAT.IDATZlibRead(var ZLIBStream: TZStreamRec2; + Buffer: Pointer; Count: Integer; var EndPos: Integer; + var crcfile: Cardinal): Integer; +var + ProcResult : Integer; + IDATHeader : Array[0..3] of char; + IDATCRC : Cardinal; +begin + {Uses internal record pointed by ZLIBStream to gather information} + with ZLIBStream, ZLIBStream.zlib do + begin + {Set the buffer the zlib will read into} + next_out := Buffer; + avail_out := Count; + + {Decode until it reach the Count variable} + while avail_out > 0 do + begin + {In case it needs more data and it's in the end of a IDAT chunk,} + {it means that there are more IDAT chunks} + if (fStream.Position = EndPos) and (avail_out > 0) and + (avail_in = 0) then + begin + {End this chunk by reading and testing the crc value} + fStream.Read(IDATCRC, 4); + + {$IFDEF CheckCRC} + if crcfile xor $ffffffff <> Cardinal(ByteSwap(IDATCRC)) then + begin + Result := -1; + Owner.RaiseError(EPNGInvalidCRC, EPNGInvalidCRCText); + exit; + end; + {$ENDIF} + + {Start reading the next chunk} + fStream.Read(EndPos, 4); {Reads next chunk size} + fStream.Read(IDATHeader[0], 4); {Next chunk header} + {It must be a IDAT chunk since image data is required and PNG} + {specification says that multiple IDAT chunks must be consecutive} + if IDATHeader <> 'IDAT' then + begin + Owner.RaiseError(EPNGMissingMultipleIDAT, EPNGMissingMultipleIDATText); + result := -1; + exit; + end; + + {Calculate chunk name part of the crc} + {$IFDEF CheckCRC} + crcfile := update_crc($ffffffff, @IDATHeader[0], 4); + {$ENDIF} + EndPos := fStream.Position + ByteSwap(EndPos); + end; + + + {In case it needs compressed data to read from} + if avail_in = 0 then + begin + {In case it's trying to read more than it is avaliable} + if fStream.Position + ZLIBAllocate > EndPos then + avail_in := fStream.Read(Data^, EndPos - fStream.Position) + else + avail_in := fStream.Read(Data^, ZLIBAllocate); + {Update crc} + {$IFDEF CheckCRC} + crcfile := update_crc(crcfile, Data, avail_in); + {$ENDIF} + + {In case there is no more compressed data to read from} + if avail_in = 0 then + begin + Result := Count - avail_out; + Exit; + end; + + {Set next buffer to read and record current position} + next_in := Data; + + end {if avail_in = 0}; + + ProcResult := inflate(zlib, 0); + + {In case the result was not sucessfull} + if (ProcResult < 0) then + begin + Result := -1; + Owner.RaiseError(EPNGZLIBError, + EPNGZLIBErrorText + zliberrors[procresult]); + exit; + end; + + end {while avail_out > 0}; + + end {with}; + + {If everything gone ok, it returns the count bytes} + Result := Count; +end; + +{TChunkIDAT implementation} + +const + {Adam 7 interlacing values} + RowStart: array[0..6] of Integer = (0, 0, 4, 0, 2, 0, 1); + ColumnStart: array[0..6] of Integer = (0, 4, 0, 2, 0, 1, 0); + RowIncrement: array[0..6] of Integer = (8, 8, 8, 4, 4, 2, 2); + ColumnIncrement: array[0..6] of Integer = (8, 8, 4, 4, 2, 2, 1); + +{Copy interlaced images with 1 byte for R, G, B} +procedure TChunkIDAT.CopyInterlacedRGB8(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + Col: Integer; +begin + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + Dest := pChar(Longint(Dest) + Col * 3); + repeat + {Copy this row} + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest); + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Dest); + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest); + + {Move to next column} + inc(Src, 3); + inc(Dest, ColumnIncrement[Pass] * 3 - 3); + inc(Col, ColumnIncrement[Pass]); + until Col >= ImageWidth; +end; + +{Copy interlaced images with 2 bytes for R, G, B} +procedure TChunkIDAT.CopyInterlacedRGB16(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + Col: Integer; +begin + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + Dest := pChar(Longint(Dest) + Col * 3); + repeat + {Copy this row} + Byte(Dest^) := Owner.GammaTable[pByte(Longint(Src) + 4)^]; inc(Dest); + Byte(Dest^) := Owner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest); + Byte(Dest^) := Owner.GammaTable[pByte(Longint(Src) )^]; inc(Dest); + {$IFDEF Store16bits} + {Copy extra pixel values} + Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 5)^]; inc(Extra); + Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 3)^]; inc(Extra); + Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Extra); + {$ENDIF} + + {Move to next column} + inc(Src, 6); + inc(Dest, ColumnIncrement[Pass] * 3 - 3); + inc(Col, ColumnIncrement[Pass]); + until Col >= ImageWidth; +end; + +{Copy ímages with palette using bit depths 1, 4 or 8} +procedure TChunkIDAT.CopyInterlacedPalette148(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +const + BitTable: Array[1..8] of Integer = ($1, $3, 0, $F, 0, 0, 0, $FF); + StartBit: Array[1..8] of Integer = (7 , 0 , 0, 4, 0, 0, 0, 0); +var + CurBit, Col: Integer; + Dest2: PChar; +begin + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + repeat + {Copy data} + CurBit := StartBit[Header.BitDepth]; + repeat + {Adjust pointer to pixel byte bounds} + Dest2 := pChar(Longint(Dest) + (Header.BitDepth * Col) div 8); + {Copy data} + Byte(Dest2^) := Byte(Dest2^) or + ( ((Byte(Src^) shr CurBit) and BitTable[Header.BitDepth]) + shl (StartBit[Header.BitDepth] - (Col * Header.BitDepth mod 8))); + + {Move to next column} + inc(Col, ColumnIncrement[Pass]); + {Will read next bits} + dec(CurBit, Header.BitDepth); + until CurBit < 0; + + {Move to next byte in source} + inc(Src); + until Col >= ImageWidth; +end; + +{Copy ímages with palette using bit depth 2} +procedure TChunkIDAT.CopyInterlacedPalette2(const Pass: Byte; Src, Dest, + Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + CurBit, Col: Integer; + Dest2: PChar; +begin + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + repeat + {Copy data} + CurBit := 6; + repeat + {Adjust pointer to pixel byte bounds} + Dest2 := pChar(Longint(Dest) + Col div 2); + {Copy data} + Byte(Dest2^) := Byte(Dest2^) or (((Byte(Src^) shr CurBit) and $3) + shl (4 - (4 * Col) mod 8)); + {Move to next column} + inc(Col, ColumnIncrement[Pass]); + {Will read next bits} + dec(CurBit, 2); + until CurBit < 0; + + {Move to next byte in source} + inc(Src); + until Col >= ImageWidth; +end; + +{Copy ímages with grayscale using bit depth 2} +procedure TChunkIDAT.CopyInterlacedGray2(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + CurBit, Col: Integer; + Dest2: PChar; +begin + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + repeat + {Copy data} + CurBit := 6; + repeat + {Adjust pointer to pixel byte bounds} + Dest2 := pChar(Longint(Dest) + Col div 2); + {Copy data} + Byte(Dest2^) := Byte(Dest2^) or ((((Byte(Src^) shr CurBit) shl 2) and $F) + shl (4 - (Col*4) mod 8)); + {Move to next column} + inc(Col, ColumnIncrement[Pass]); + {Will read next bits} + dec(CurBit, 2); + until CurBit < 0; + + {Move to next byte in source} + inc(Src); + until Col >= ImageWidth; +end; + +{Copy ímages with palette using 2 bytes for each pixel} +procedure TChunkIDAT.CopyInterlacedGrayscale16(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + Col: Integer; +begin + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + Dest := pChar(Longint(Dest) + Col); + repeat + {Copy this row} + Dest^ := Src^; inc(Dest); + {$IFDEF Store16bits} + Extra^ := pChar(Longint(Src) + 1)^; inc(Extra); + {$ENDIF} + + {Move to next column} + inc(Src, 2); + inc(Dest, ColumnIncrement[Pass] - 1); + inc(Col, ColumnIncrement[Pass]); + until Col >= ImageWidth; +end; + +{Decodes interlaced RGB alpha with 1 byte for each sample} +procedure TChunkIDAT.CopyInterlacedRGBAlpha8(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + Col: Integer; +begin + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + Dest := pChar(Longint(Dest) + Col * 3); + Trans := pChar(Longint(Trans) + Col); + repeat + {Copy this row and alpha value} + Trans^ := pChar(Longint(Src) + 3)^; + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest); + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Dest); + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest); + + {Move to next column} + inc(Src, 4); + inc(Dest, ColumnIncrement[Pass] * 3 - 3); + inc(Trans, ColumnIncrement[Pass]); + inc(Col, ColumnIncrement[Pass]); + until Col >= ImageWidth; +end; + +{Decodes interlaced RGB alpha with 2 bytes for each sample} +procedure TChunkIDAT.CopyInterlacedRGBAlpha16(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + Col: Integer; +begin + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + Dest := pChar(Longint(Dest) + Col * 3); + Trans := pChar(Longint(Trans) + Col); + repeat + {Copy this row and alpha value} + Trans^ := pChar(Longint(Src) + 6)^; + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 4)^]; inc(Dest); + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest); + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest); + {$IFDEF Store16bits} + {Copy extra pixel values} + Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 5)^]; inc(Extra); + Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 3)^]; inc(Extra); + Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Extra); + {$ENDIF} + + {Move to next column} + inc(Src, 8); + inc(Dest, ColumnIncrement[Pass] * 3 - 3); + inc(Trans, ColumnIncrement[Pass]); + inc(Col, ColumnIncrement[Pass]); + until Col >= ImageWidth; +end; + +{Decodes 8 bit grayscale image followed by an alpha sample} +procedure TChunkIDAT.CopyInterlacedGrayscaleAlpha8(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + Col: Integer; +begin + {Get first column, pointers to the data and enter in loop} + Col := ColumnStart[Pass]; + Dest := pChar(Longint(Dest) + Col); + Trans := pChar(Longint(Trans) + Col); + repeat + {Copy this grayscale value and alpha} + Dest^ := Src^; inc(Src); + Trans^ := Src^; inc(Src); + + {Move to next column} + inc(Dest, ColumnIncrement[Pass]); + inc(Trans, ColumnIncrement[Pass]); + inc(Col, ColumnIncrement[Pass]); + until Col >= ImageWidth; +end; + +{Decodes 16 bit grayscale image followed by an alpha sample} +procedure TChunkIDAT.CopyInterlacedGrayscaleAlpha16(const Pass: Byte; + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + Col: Integer; +begin + {Get first column, pointers to the data and enter in loop} + Col := ColumnStart[Pass]; + Dest := pChar(Longint(Dest) + Col); + Trans := pChar(Longint(Trans) + Col); + repeat + {$IFDEF Store16bits} + Extra^ := pChar(Longint(Src) + 1)^; inc(Extra); + {$ENDIF} + {Copy this grayscale value and alpha, transforming 16 bits into 8} + Dest^ := Src^; inc(Src, 2); + Trans^ := Src^; inc(Src, 2); + + {Move to next column} + inc(Dest, ColumnIncrement[Pass]); + inc(Trans, ColumnIncrement[Pass]); + inc(Col, ColumnIncrement[Pass]); + until Col >= ImageWidth; +end; + +{Decodes an interlaced image} +procedure TChunkIDAT.DecodeInterlacedAdam7(Stream: TStream; + var ZLIBStream: TZStreamRec2; const Size: Integer; var crcfile: Cardinal); +var + CurrentPass: Byte; + PixelsThisRow: Integer; + CurrentRow: Integer; + Trans, Data{$IFDEF Store16bits}, Extra{$ENDIF}: pChar; + CopyProc: procedure(const Pass: Byte; Src, Dest, + Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar) of object; +begin + + CopyProc := nil; {Initialize} + {Determine method to copy the image data} + case Header.ColorType of + {R, G, B values for each pixel} + COLOR_RGB: + case Header.BitDepth of + 8: CopyProc := CopyInterlacedRGB8; + 16: CopyProc := CopyInterlacedRGB16; + end {case Header.BitDepth}; + {Palette} + COLOR_PALETTE, COLOR_GRAYSCALE: + case Header.BitDepth of + 1, 4, 8: CopyProc := CopyInterlacedPalette148; + 2 : if Header.ColorType = COLOR_PALETTE then + CopyProc := CopyInterlacedPalette2 + else + CopyProc := CopyInterlacedGray2; + 16 : CopyProc := CopyInterlacedGrayscale16; + end; + {RGB followed by alpha} + COLOR_RGBALPHA: + case Header.BitDepth of + 8: CopyProc := CopyInterlacedRGBAlpha8; + 16: CopyProc := CopyInterlacedRGBAlpha16; + end; + {Grayscale followed by alpha} + COLOR_GRAYSCALEALPHA: + case Header.BitDepth of + 8: CopyProc := CopyInterlacedGrayscaleAlpha8; + 16: CopyProc := CopyInterlacedGrayscaleAlpha16; + end; + end {case Header.ColorType}; + + {Adam7 method has 7 passes to make the final image} + FOR CurrentPass := 0 TO 6 DO + begin + {Calculates the number of pixels and bytes for this pass row} + PixelsThisRow := (ImageWidth - ColumnStart[CurrentPass] + + ColumnIncrement[CurrentPass] - 1) div ColumnIncrement[CurrentPass]; + Row_Bytes := BytesForPixels(PixelsThisRow, Header.ColorType, + Header.BitDepth); + {Clear buffer for this pass} + ZeroMemory(Row_Buffer[not RowUsed], Row_Bytes); + + {Get current row index} + CurrentRow := RowStart[CurrentPass]; + {Get a pointer to the current row image data} + Data := Ptr(Longint(Header.ImageData) + Header.BytesPerRow * + (ImageHeight - 1 - CurrentRow)); + Trans := Ptr(Longint(Header.ImageAlpha) + ImageWidth * CurrentRow); + {$IFDEF Store16bits} + Extra := Ptr(Longint(Header.ExtraImageData) + Header.BytesPerRow * + (ImageHeight - 1 - CurrentRow)); + {$ENDIF} + + if Row_Bytes > 0 then {There must have bytes for this interlaced pass} + while CurrentRow < ImageHeight do + begin + {Reads this line and filter} + if IDATZlibRead(ZLIBStream, @Row_Buffer[RowUsed][0], Row_Bytes + 1, + EndPos, CRCFile) = 0 then break; + + FilterRow; + {Copy image data} + + CopyProc(CurrentPass, @Row_Buffer[RowUsed][1], Data, Trans + {$IFDEF Store16bits}, Extra{$ENDIF}); + + {Use the other RowBuffer item} + RowUsed := not RowUsed; + + {Move to the next row} + inc(CurrentRow, RowIncrement[CurrentPass]); + {Move pointer to the next line} + dec(Data, RowIncrement[CurrentPass] * Header.BytesPerRow); + inc(Trans, RowIncrement[CurrentPass] * ImageWidth); + {$IFDEF Store16bits} + dec(Extra, RowIncrement[CurrentPass] * Header.BytesPerRow); + {$ENDIF} + end {while CurrentRow < ImageHeight}; + + end {FOR CurrentPass}; + +end; + +{Copy 8 bits RGB image} +procedure TChunkIDAT.CopyNonInterlacedRGB8( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + I: Integer; +begin + FOR I := 1 TO ImageWidth DO + begin + {Copy pixel values} + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest); + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Dest); + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest); + {Move to next pixel} + inc(Src, 3); + end {for I} +end; + +{Copy 16 bits RGB image} +procedure TChunkIDAT.CopyNonInterlacedRGB16( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + I: Integer; +begin + FOR I := 1 TO ImageWidth DO + begin + //Since windows does not supports 2 bytes for + //each R, G, B value, the method will read only 1 byte from it + {Copy pixel values} + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 4)^]; inc(Dest); + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest); + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest); + {$IFDEF Store16bits} + {Copy extra pixel values} + Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 5)^]; inc(Extra); + Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 3)^]; inc(Extra); + Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Extra); + {$ENDIF} + + {Move to next pixel} + inc(Src, 6); + end {for I} +end; + +{Copy types using palettes (1, 4 or 8 bits per pixel)} +procedure TChunkIDAT.CopyNonInterlacedPalette148( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +begin + {It's simple as copying the data} + CopyMemory(Dest, Src, Row_Bytes); +end; + +{Copy grayscale types using 2 bits for each pixel} +procedure TChunkIDAT.CopyNonInterlacedGray2( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + i: Integer; +begin + {2 bits is not supported, this routine will converted into 4 bits} + FOR i := 1 TO Row_Bytes do + begin + Byte(Dest^) := ((Byte(Src^) shr 2) and $F) or ((Byte(Src^)) and $F0); + inc(Dest); + Byte(Dest^) := ((Byte(Src^) shl 2) and $F) or ((Byte(Src^) shl 4) and $F0); + inc(Dest); + inc(Src); + end {FOR i} +end; + +{Copy types using palette with 2 bits for each pixel} +procedure TChunkIDAT.CopyNonInterlacedPalette2( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + i: Integer; +begin + {2 bits is not supported, this routine will converted into 4 bits} + FOR i := 1 TO Row_Bytes do + begin + Byte(Dest^) := ((Byte(Src^) shr 4) and $3) or ((Byte(Src^) shr 2) and $30); + inc(Dest); + Byte(Dest^) := (Byte(Src^) and $3) or ((Byte(Src^) shl 2) and $30); + inc(Dest); + inc(Src); + end {FOR i} +end; + +{Copy grayscale images with 16 bits} +procedure TChunkIDAT.CopyNonInterlacedGrayscale16( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + I: Integer; +begin + FOR I := 1 TO ImageWidth DO + begin + {Windows does not supports 16 bits for each pixel in grayscale} + {mode, so reduce to 8} + Dest^ := Src^; inc(Dest); + {$IFDEF Store16bits} + Extra^ := pChar(Longint(Src) + 1)^; inc(Extra); + {$ENDIF} + + {Move to next pixel} + inc(Src, 2); + end {for I} +end; + +{Copy 8 bits per sample RGB images followed by an alpha byte} +procedure TChunkIDAT.CopyNonInterlacedRGBAlpha8( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + i: Integer; +begin + FOR I := 1 TO ImageWidth DO + begin + {Copy pixel values and transparency} + Trans^ := pChar(Longint(Src) + 3)^; + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest); + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Dest); + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest); + {Move to next pixel} + inc(Src, 4); inc(Trans); + end {for I} +end; + +{Copy 16 bits RGB image with alpha using 2 bytes for each sample} +procedure TChunkIDAT.CopyNonInterlacedRGBAlpha16( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + I: Integer; +begin + FOR I := 1 TO ImageWidth DO + begin + //Copy rgb and alpha values (transforming from 16 bits to 8 bits) + {Copy pixel values} + Trans^ := pChar(Longint(Src) + 6)^; + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 4)^]; inc(Dest); + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) + 2)^]; inc(Dest); + Byte(Dest^) := fOwner.GammaTable[pByte(Longint(Src) )^]; inc(Dest); + {$IFDEF Store16bits} + {Copy extra pixel values} + Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 5)^]; inc(Extra); + Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 3)^]; inc(Extra); + Byte(Extra^) := fOwner.GammaTable[pByte(Longint(Src) + 1)^]; inc(Extra); + {$ENDIF} + {Move to next pixel} + inc(Src, 8); inc(Trans); + end {for I} +end; + +{Copy 8 bits per sample grayscale followed by alpha} +procedure TChunkIDAT.CopyNonInterlacedGrayscaleAlpha8( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + I: Integer; +begin + FOR I := 1 TO ImageWidth DO + begin + {Copy alpha value and then gray value} + Dest^ := Src^; inc(Src); + Trans^ := Src^; inc(Src); + inc(Dest); inc(Trans); + end; +end; + +{Copy 16 bits per sample grayscale followed by alpha} +procedure TChunkIDAT.CopyNonInterlacedGrayscaleAlpha16( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar); +var + I: Integer; +begin + FOR I := 1 TO ImageWidth DO + begin + {Copy alpha value and then gray value} + {$IFDEF Store16bits} + Extra^ := pChar(Longint(Src) + 1)^; inc(Extra); + {$ENDIF} + Dest^ := Src^; inc(Src, 2); + Trans^ := Src^; inc(Src, 2); + inc(Dest); inc(Trans); + end; +end; + +{Decode non interlaced image} +procedure TChunkIDAT.DecodeNonInterlaced(Stream: TStream; + var ZLIBStream: TZStreamRec2; const Size: Integer; var crcfile: Cardinal); +var + j: Cardinal; + Trans, Data{$IFDEF Store16bits}, Extra{$ENDIF}: pChar; + CopyProc: procedure( + Src, Dest, Trans{$IFDEF Store16bits}, Extra{$ENDIF}: pChar) of object; +begin + CopyProc := nil; {Initialize} + {Determines the method to copy the image data} + case Header.ColorType of + {R, G, B values} + COLOR_RGB: + case Header.BitDepth of + 8: CopyProc := CopyNonInterlacedRGB8; + 16: CopyProc := CopyNonInterlacedRGB16; + end; + {Types using palettes} + COLOR_PALETTE, COLOR_GRAYSCALE: + case Header.BitDepth of + 1, 4, 8: CopyProc := CopyNonInterlacedPalette148; + 2 : if Header.ColorType = COLOR_PALETTE then + CopyProc := CopyNonInterlacedPalette2 + else + CopyProc := CopyNonInterlacedGray2; + 16 : CopyProc := CopyNonInterlacedGrayscale16; + end; + {R, G, B followed by alpha} + COLOR_RGBALPHA: + case Header.BitDepth of + 8 : CopyProc := CopyNonInterlacedRGBAlpha8; + 16 : CopyProc := CopyNonInterlacedRGBAlpha16; + end; + {Grayscale followed by alpha} + COLOR_GRAYSCALEALPHA: + case Header.BitDepth of + 8 : CopyProc := CopyNonInterlacedGrayscaleAlpha8; + 16 : CopyProc := CopyNonInterlacedGrayscaleAlpha16; + end; + end; + + {Get the image data pointer} + Longint(Data) := Longint(Header.ImageData) + + Header.BytesPerRow * (ImageHeight - 1); + Trans := Header.ImageAlpha; + {$IFDEF Store16bits} + Longint(Extra) := Longint(Header.ExtraImageData) + + Header.BytesPerRow * (ImageHeight - 1); + {$ENDIF} + {Reads each line} + FOR j := 0 to ImageHeight - 1 do + begin + {Read this line Row_Buffer[RowUsed][0] if the filter type for this line} + if IDATZlibRead(ZLIBStream, @Row_Buffer[RowUsed][0], Row_Bytes + 1, EndPos, + CRCFile) = 0 then break; + + {Filter the current row} + FilterRow; + {Copies non interlaced row to image} + CopyProc(@Row_Buffer[RowUsed][1], Data, Trans{$IFDEF Store16bits}, Extra + {$ENDIF}); + + {Invert line used} + RowUsed := not RowUsed; + dec(Data, Header.BytesPerRow); + {$IFDEF Store16bits}dec(Extra, Header.BytesPerRow);{$ENDIF} + inc(Trans, ImageWidth); + end {for I}; + + +end; + +{Filter the current line} +procedure TChunkIDAT.FilterRow; +var + pp: Byte; + vv, left, above, aboveleft: Integer; + Col: Cardinal; +begin + {Test the filter} + case Row_Buffer[RowUsed]^[0] of + {No filtering for this line} + FILTER_NONE: begin end; + {AND 255 serves only to never let the result be larger than one byte} + {Sub filter} + FILTER_SUB: + FOR Col := Offset + 1 to Row_Bytes DO + Row_Buffer[RowUsed][Col] := (Row_Buffer[RowUsed][Col] + + Row_Buffer[RowUsed][Col - Offset]) and 255; + {Up filter} + FILTER_UP: + FOR Col := 1 to Row_Bytes DO + Row_Buffer[RowUsed][Col] := (Row_Buffer[RowUsed][Col] + + Row_Buffer[not RowUsed][Col]) and 255; + {Average filter} + FILTER_AVERAGE: + FOR Col := 1 to Row_Bytes DO + begin + {Obtains up and left pixels} + above := Row_Buffer[not RowUsed][Col]; + if col - 1 < Offset then + left := 0 + else + Left := Row_Buffer[RowUsed][Col - Offset]; + + {Calculates} + Row_Buffer[RowUsed][Col] := (Row_Buffer[RowUsed][Col] + + (left + above) div 2) and 255; + end; + {Paeth filter} + FILTER_PAETH: + begin + {Initialize} + left := 0; + aboveleft := 0; + {Test each byte} + FOR Col := 1 to Row_Bytes DO + begin + {Obtains above pixel} + above := Row_Buffer[not RowUsed][Col]; + {Obtains left and top-left pixels} + if (col - 1 >= offset) Then + begin + left := row_buffer[RowUsed][col - offset]; + aboveleft := row_buffer[not RowUsed][col - offset]; + end; + + {Obtains current pixel and paeth predictor} + vv := row_buffer[RowUsed][Col]; + pp := PaethPredictor(left, above, aboveleft); + + {Calculates} + Row_Buffer[RowUsed][Col] := (pp + vv) and $FF; + end {for}; + end; + + end {case}; +end; + +{Reads the image data from the stream} +function TChunkIDAT.LoadFromStream(Stream: TStream; const ChunkName: TChunkName; + Size: Integer): Boolean; +var + ZLIBStream: TZStreamRec2; + CRCCheck, + CRCFile : Cardinal; +begin + {Get pointer to the header chunk} + Header := Owner.Chunks.Item[0] as TChunkIHDR; + {Build palette if necessary} + if Header.HasPalette then PreparePalette(); + + {Copy image width and height} + ImageWidth := Header.Width; + ImageHeight := Header.Height; + + {Initialize to calculate CRC} + {$IFDEF CheckCRC} + CRCFile := update_crc($ffffffff, @ChunkName[0], 4); + {$ENDIF} + + Owner.GetPixelInfo(Row_Bytes, Offset); {Obtain line information} + ZLIBStream := ZLIBInitInflate(Stream); {Initializes decompression} + + {Calculate ending position for the current IDAT chunk} + EndPos := Stream.Position + Size; + + {Allocate memory} + GetMem(Row_Buffer[false], Row_Bytes + 1); + GetMem(Row_Buffer[true], Row_Bytes + 1); + ZeroMemory(Row_Buffer[false], Row_bytes + 1); + {Set the variable to alternate the Row_Buffer item to use} + RowUsed := TRUE; + + {Call special methods for the different interlace methods} + case Owner.InterlaceMethod of + imNone: DecodeNonInterlaced(stream, ZLIBStream, Size, crcfile); + imAdam7: DecodeInterlacedAdam7(stream, ZLIBStream, size, crcfile); + end; + + {Free memory} + ZLIBTerminateInflate(ZLIBStream); {Terminates decompression} + FreeMem(Row_Buffer[False], Row_Bytes + 1); + FreeMem(Row_Buffer[True], Row_Bytes + 1); + + {Now checks CRC} + Stream.Read(CRCCheck, 4); + {$IFDEF CheckCRC} + CRCFile := CRCFile xor $ffffffff; + CRCCheck := ByteSwap(CRCCheck); + Result := CRCCheck = CRCFile; + + {Handle CRC error} + if not Result then + begin + {In case it coult not load chunk} + Owner.RaiseError(EPngInvalidCRC, EPngInvalidCRCText); + exit; + end; + {$ELSE}Result := TRUE; {$ENDIF} +end; + +const + IDATHeader: Array[0..3] of char = ('I', 'D', 'A', 'T'); + BUFFER = 5; + +{Saves the IDAT chunk to a stream} +function TChunkIDAT.SaveToStream(Stream: TStream): Boolean; +var + ZLIBStream : TZStreamRec2; +begin + {Get pointer to the header chunk} + Header := Owner.Chunks.Item[0] as TChunkIHDR; + {Copy image width and height} + ImageWidth := Header.Width; + ImageHeight := Header.Height; + Owner.GetPixelInfo(Row_Bytes, Offset); {Obtain line information} + + {Allocate memory} + GetMem(Encode_Buffer[BUFFER], Row_Bytes); + ZeroMemory(Encode_Buffer[BUFFER], Row_Bytes); + {Allocate buffers for the filters selected} + {Filter none will always be calculated to the other filters to work} + GetMem(Encode_Buffer[FILTER_NONE], Row_Bytes); + ZeroMemory(Encode_Buffer[FILTER_NONE], Row_Bytes); + if pfSub in Owner.Filters then + GetMem(Encode_Buffer[FILTER_SUB], Row_Bytes); + if pfUp in Owner.Filters then + GetMem(Encode_Buffer[FILTER_UP], Row_Bytes); + if pfAverage in Owner.Filters then + GetMem(Encode_Buffer[FILTER_AVERAGE], Row_Bytes); + if pfPaeth in Owner.Filters then + GetMem(Encode_Buffer[FILTER_PAETH], Row_Bytes); + + {Initialize ZLIB} + ZLIBStream := ZLIBInitDeflate(Stream, Owner.fCompressionLevel, + Owner.MaxIdatSize); + {Write data depending on the interlace method} + case Owner.InterlaceMethod of + imNone: EncodeNonInterlaced(stream, ZLIBStream); + imAdam7: EncodeInterlacedAdam7(stream, ZLIBStream); + end; + {Terminates ZLIB} + ZLIBTerminateDeflate(ZLIBStream); + + {Release allocated memory} + FreeMem(Encode_Buffer[BUFFER], Row_Bytes); + FreeMem(Encode_Buffer[FILTER_NONE], Row_Bytes); + if pfSub in Owner.Filters then + FreeMem(Encode_Buffer[FILTER_SUB], Row_Bytes); + if pfUp in Owner.Filters then + FreeMem(Encode_Buffer[FILTER_UP], Row_Bytes); + if pfAverage in Owner.Filters then + FreeMem(Encode_Buffer[FILTER_AVERAGE], Row_Bytes); + if pfPaeth in Owner.Filters then + FreeMem(Encode_Buffer[FILTER_PAETH], Row_Bytes); + + {Everything went ok} + Result := True; +end; + +{Writes the IDAT using the settings} +procedure WriteIDAT(Stream: TStream; Data: Pointer; const Length: Cardinal); +var + ChunkLen, CRC: Cardinal; +begin + {Writes IDAT header} + ChunkLen := ByteSwap(Length); + Stream.Write(ChunkLen, 4); {Chunk length} + Stream.Write(IDATHeader[0], 4); {Idat header} + CRC := update_crc($ffffffff, @IDATHeader[0], 4); {Crc part for header} + + {Writes IDAT data and calculates CRC for data} + Stream.Write(Data^, Length); + CRC := Byteswap(update_crc(CRC, Data, Length) xor $ffffffff); + {Writes final CRC} + Stream.Write(CRC, 4); +end; + +{Compress and writes IDAT chunk data} +procedure TChunkIDAT.IDATZlibWrite(var ZLIBStream: TZStreamRec2; + Buffer: Pointer; const Length: Cardinal); +begin + with ZLIBStream, ZLIBStream.ZLIB do + begin + {Set data to be compressed} + next_in := Buffer; + avail_in := Length; + + {Compress all the data avaliable to compress} + while avail_in > 0 do + begin + deflate(ZLIB, Z_NO_FLUSH); + + {The whole buffer was used, save data to stream and restore buffer} + if avail_out = 0 then + begin + {Writes this IDAT chunk} + WriteIDAT(fStream, Data, Owner.MaxIdatSize); + + {Restore buffer} + next_out := Data; + avail_out := Owner.MaxIdatSize; + end {if avail_out = 0}; + + end {while avail_in}; + + end {with ZLIBStream, ZLIBStream.ZLIB} +end; + +{Finishes compressing data to write IDAT chunk} +procedure TChunkIDAT.FinishIDATZlib(var ZLIBStream: TZStreamRec2); +begin + with ZLIBStream, ZLIBStream.ZLIB do + begin + {Set data to be compressed} + next_in := nil; + avail_in := 0; + + while deflate(ZLIB,Z_FINISH) <> Z_STREAM_END do + begin + {Writes this IDAT chunk} + WriteIDAT(fStream, Data, Owner.MaxIdatSize - avail_out); + {Re-update buffer} + next_out := Data; + avail_out := Owner.MaxIdatSize; + end; + + if avail_out < Owner.MaxIdatSize then + {Writes final IDAT} + WriteIDAT(fStream, Data, Owner.MaxIdatSize - avail_out); + + end {with ZLIBStream, ZLIBStream.ZLIB}; +end; + +{Copy memory to encode RGB image with 1 byte for each color sample} +procedure TChunkIDAT.EncodeNonInterlacedRGB8(Src, Dest, Trans: pChar); +var + I: Integer; +begin + FOR I := 1 TO ImageWidth DO + begin + {Copy pixel values} + Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) + 2)^]; inc(Dest); + Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) + 1)^]; inc(Dest); + Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) )^]; inc(Dest); + {Move to next pixel} + inc(Src, 3); + end {for I} +end; + +{Copy memory to encode RGB images with 16 bits for each color sample} +procedure TChunkIDAT.EncodeNonInterlacedRGB16(Src, Dest, Trans: pChar); +var + I: Integer; +begin + FOR I := 1 TO ImageWidth DO + begin + //Now we copy from 1 byte for each sample stored to a 2 bytes (or 1 word) + //for sample + {Copy pixel values} + pWORD(Dest)^ := fOwner.InverseGamma[pByte(Longint(Src) + 2)^]; inc(Dest, 2); + pWORD(Dest)^ := fOwner.InverseGamma[pByte(Longint(Src) + 1)^]; inc(Dest, 2); + pWORD(Dest)^ := fOwner.InverseGamma[pByte(Longint(Src) )^]; inc(Dest, 2); + {Move to next pixel} + inc(Src, 3); + end {for I} + +end; + +{Copy memory to encode types using palettes (1, 4 or 8 bits per pixel)} +procedure TChunkIDAT.EncodeNonInterlacedPalette148(Src, Dest, Trans: pChar); +begin + {It's simple as copying the data} + CopyMemory(Dest, Src, Row_Bytes); +end; + +{Copy memory to encode grayscale images with 2 bytes for each sample} +procedure TChunkIDAT.EncodeNonInterlacedGrayscale16(Src, Dest, Trans: pChar); +var + I: Integer; +begin + FOR I := 1 TO ImageWidth DO + begin + //Now we copy from 1 byte for each sample stored to a 2 bytes (or 1 word) + //for sample + pWORD(Dest)^ := pByte(Longint(Src))^; inc(Dest, 2); + {Move to next pixel} + inc(Src); + end {for I} +end; + +{Encode images using RGB followed by an alpha value using 1 byte for each} +procedure TChunkIDAT.EncodeNonInterlacedRGBAlpha8(Src, Dest, Trans: pChar); +var + i: Integer; +begin + {Copy the data to the destination, including data from Trans pointer} + FOR i := 1 TO ImageWidth do + begin + Byte(Dest^) := Owner.InverseGamma[PByte(Longint(Src) + 2)^]; inc(Dest); + Byte(Dest^) := Owner.InverseGamma[PByte(Longint(Src) + 1)^]; inc(Dest); + Byte(Dest^) := Owner.InverseGamma[PByte(Longint(Src) )^]; inc(Dest); + Dest^ := Trans^; inc(Dest); + inc(Src, 3); inc(Trans); + end {for i}; +end; + +{Encode images using RGB followed by an alpha value using 2 byte for each} +procedure TChunkIDAT.EncodeNonInterlacedRGBAlpha16(Src, Dest, Trans: pChar); +var + i: Integer; +begin + {Copy the data to the destination, including data from Trans pointer} + FOR i := 1 TO ImageWidth do + begin + pWord(Dest)^ := Owner.InverseGamma[PByte(Longint(Src) + 2)^]; inc(Dest, 2); + pWord(Dest)^ := Owner.InverseGamma[PByte(Longint(Src) + 1)^]; inc(Dest, 2); + pWord(Dest)^ := Owner.InverseGamma[PByte(Longint(Src) )^]; inc(Dest, 2); + pWord(Dest)^ := PByte(Longint(Trans) )^; inc(Dest, 2); + inc(Src, 3); inc(Trans); + end {for i}; +end; + +{Encode grayscale images followed by an alpha value using 1 byte for each} +procedure TChunkIDAT.EncodeNonInterlacedGrayscaleAlpha8( + Src, Dest, Trans: pChar); +var + i: Integer; +begin + {Copy the data to the destination, including data from Trans pointer} + FOR i := 1 TO ImageWidth do + begin + Dest^ := Src^; inc(Dest); + Dest^ := Trans^; inc(Dest); + inc(Src); inc(Trans); + end {for i}; +end; + +{Encode grayscale images followed by an alpha value using 2 byte for each} +procedure TChunkIDAT.EncodeNonInterlacedGrayscaleAlpha16( + Src, Dest, Trans: pChar); +var + i: Integer; +begin + {Copy the data to the destination, including data from Trans pointer} + FOR i := 1 TO ImageWidth do + begin + pWord(Dest)^ := pByte(Src)^; inc(Dest, 2); + pWord(Dest)^ := pByte(Trans)^; inc(Dest, 2); + inc(Src); inc(Trans); + end {for i}; +end; + +{Encode non interlaced images} +procedure TChunkIDAT.EncodeNonInterlaced(Stream: TStream; + var ZLIBStream: TZStreamRec2); +var + {Current line} + j: Cardinal; + {Pointers to image data} + Data, Trans: PChar; + {Filter used for this line} + Filter: Byte; + {Method which will copy the data into the buffer} + CopyProc: procedure(Src, Dest, Trans: pChar) of object; +begin + CopyProc := nil; {Initialize to avoid warnings} + {Defines the method to copy the data to the buffer depending on} + {the image parameters} + case Header.ColorType of + {R, G, B values} + COLOR_RGB: + case Header.BitDepth of + 8: CopyProc := EncodeNonInterlacedRGB8; + 16: CopyProc := EncodeNonInterlacedRGB16; + end; + {Palette and grayscale values} + COLOR_GRAYSCALE, COLOR_PALETTE: + case Header.BitDepth of + 1, 4, 8: CopyProc := EncodeNonInterlacedPalette148; + 16: CopyProc := EncodeNonInterlacedGrayscale16; + end; + {RGB with a following alpha value} + COLOR_RGBALPHA: + case Header.BitDepth of + 8: CopyProc := EncodeNonInterlacedRGBAlpha8; + 16: CopyProc := EncodeNonInterlacedRGBAlpha16; + end; + {Grayscale images followed by an alpha} + COLOR_GRAYSCALEALPHA: + case Header.BitDepth of + 8: CopyProc := EncodeNonInterlacedGrayscaleAlpha8; + 16: CopyProc := EncodeNonInterlacedGrayscaleAlpha16; + end; + end {case Header.ColorType}; + + {Get the image data pointer} + Longint(Data) := Longint(Header.ImageData) + + Header.BytesPerRow * (ImageHeight - 1); + Trans := Header.ImageAlpha; + + {Writes each line} + FOR j := 0 to ImageHeight - 1 do + begin + {Copy data into buffer} + CopyProc(Data, @Encode_Buffer[BUFFER][0], Trans); + {Filter data} + Filter := FilterToEncode; + + {Compress data} + IDATZlibWrite(ZLIBStream, @Filter, 1); + IDATZlibWrite(ZLIBStream, @Encode_Buffer[Filter][0], Row_Bytes); + + {Adjust pointers to the actual image data} + dec(Data, Header.BytesPerRow); + inc(Trans, ImageWidth); + end; + + {Compress and finishes copying the remaining data} + FinishIDATZlib(ZLIBStream); +end; + +{Copy memory to encode interlaced images using RGB value with 1 byte for} +{each color sample} +procedure TChunkIDAT.EncodeInterlacedRGB8(const Pass: Byte; + Src, Dest, Trans: pChar); +var + Col: Integer; +begin + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + Src := pChar(Longint(Src) + Col * 3); + repeat + {Copy this row} + Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) + 2)^]; inc(Dest); + Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) + 1)^]; inc(Dest); + Byte(Dest^) := fOwner.InverseGamma[pByte(Longint(Src) )^]; inc(Dest); + + {Move to next column} + inc(Src, ColumnIncrement[Pass] * 3); + inc(Col, ColumnIncrement[Pass]); + until Col >= ImageWidth; +end; + +{Copy memory to encode interlaced RGB images with 2 bytes each color sample} +procedure TChunkIDAT.EncodeInterlacedRGB16(const Pass: Byte; + Src, Dest, Trans: pChar); +var + Col: Integer; +begin + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + Src := pChar(Longint(Src) + Col * 3); + repeat + {Copy this row} + pWord(Dest)^ := Owner.InverseGamma[pByte(Longint(Src) + 2)^]; inc(Dest, 2); + pWord(Dest)^ := Owner.InverseGamma[pByte(Longint(Src) + 1)^]; inc(Dest, 2); + pWord(Dest)^ := Owner.InverseGamma[pByte(Longint(Src) )^]; inc(Dest, 2); + + {Move to next column} + inc(Src, ColumnIncrement[Pass] * 3); + inc(Col, ColumnIncrement[Pass]); + until Col >= ImageWidth; +end; + +{Copy memory to encode interlaced images using palettes using bit depths} +{1, 4, 8 (each pixel in the image)} +procedure TChunkIDAT.EncodeInterlacedPalette148(const Pass: Byte; + Src, Dest, Trans: pChar); +const + BitTable: Array[1..8] of Integer = ($1, $3, 0, $F, 0, 0, 0, $FF); + StartBit: Array[1..8] of Integer = (7 , 0 , 0, 4, 0, 0, 0, 0); +var + CurBit, Col: Integer; + Src2: PChar; +begin + {Clean the line} + fillchar(Dest^, Row_Bytes, #0); + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + with Header.BitmapInfo.bmiHeader do + repeat + {Copy data} + CurBit := StartBit[biBitCount]; + repeat + {Adjust pointer to pixel byte bounds} + Src2 := pChar(Longint(Src) + (biBitCount * Col) div 8); + {Copy data} + Byte(Dest^) := Byte(Dest^) or + (((Byte(Src2^) shr (StartBit[Header.BitDepth] - (biBitCount * Col) + mod 8))) and (BitTable[biBitCount])) shl CurBit; + + {Move to next column} + inc(Col, ColumnIncrement[Pass]); + {Will read next bits} + dec(CurBit, biBitCount); + until CurBit < 0; + + {Move to next byte in source} + inc(Dest); + until Col >= ImageWidth; +end; + +{Copy to encode interlaced grayscale images using 16 bits for each sample} +procedure TChunkIDAT.EncodeInterlacedGrayscale16(const Pass: Byte; + Src, Dest, Trans: pChar); +var + Col: Integer; +begin + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + Src := pChar(Longint(Src) + Col); + repeat + {Copy this row} + pWord(Dest)^ := Byte(Src^); inc(Dest, 2); + + {Move to next column} + inc(Src, ColumnIncrement[Pass]); + inc(Col, ColumnIncrement[Pass]); + until Col >= ImageWidth; +end; + +{Copy to encode interlaced rgb images followed by an alpha value, all using} +{one byte for each sample} +procedure TChunkIDAT.EncodeInterlacedRGBAlpha8(const Pass: Byte; + Src, Dest, Trans: pChar); +var + Col: Integer; +begin + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + Src := pChar(Longint(Src) + Col * 3); + Trans := pChar(Longint(Trans) + Col); + repeat + {Copy this row} + Byte(Dest^) := Owner.InverseGamma[pByte(Longint(Src) + 2)^]; inc(Dest); + Byte(Dest^) := Owner.InverseGamma[pByte(Longint(Src) + 1)^]; inc(Dest); + Byte(Dest^) := Owner.InverseGamma[pByte(Longint(Src) )^]; inc(Dest); + Dest^ := Trans^; inc(Dest); + + {Move to next column} + inc(Src, ColumnIncrement[Pass] * 3); + inc(Trans, ColumnIncrement[Pass]); + inc(Col, ColumnIncrement[Pass]); + until Col >= ImageWidth; +end; + +{Copy to encode interlaced rgb images followed by an alpha value, all using} +{two byte for each sample} +procedure TChunkIDAT.EncodeInterlacedRGBAlpha16(const Pass: Byte; + Src, Dest, Trans: pChar); +var + Col: Integer; +begin + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + Src := pChar(Longint(Src) + Col * 3); + Trans := pChar(Longint(Trans) + Col); + repeat + {Copy this row} + pWord(Dest)^ := pByte(Longint(Src) + 2)^; inc(Dest, 2); + pWord(Dest)^ := pByte(Longint(Src) + 1)^; inc(Dest, 2); + pWord(Dest)^ := pByte(Longint(Src) )^; inc(Dest, 2); + pWord(Dest)^ := pByte(Trans)^; inc(Dest, 2); + + {Move to next column} + inc(Src, ColumnIncrement[Pass] * 3); + inc(Trans, ColumnIncrement[Pass]); + inc(Col, ColumnIncrement[Pass]); + until Col >= ImageWidth; +end; + +{Copy to encode grayscale interlaced images followed by an alpha value, all} +{using 1 byte for each sample} +procedure TChunkIDAT.EncodeInterlacedGrayscaleAlpha8(const Pass: Byte; + Src, Dest, Trans: pChar); +var + Col: Integer; +begin + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + Src := pChar(Longint(Src) + Col); + Trans := pChar(Longint(Trans) + Col); + repeat + {Copy this row} + Dest^ := Src^; inc(Dest); + Dest^ := Trans^; inc(Dest); + + {Move to next column} + inc(Src, ColumnIncrement[Pass]); + inc(Trans, ColumnIncrement[Pass]); + inc(Col, ColumnIncrement[Pass]); + until Col >= ImageWidth; +end; + +{Copy to encode grayscale interlaced images followed by an alpha value, all} +{using 2 bytes for each sample} +procedure TChunkIDAT.EncodeInterlacedGrayscaleAlpha16(const Pass: Byte; + Src, Dest, Trans: pChar); +var + Col: Integer; +begin + {Get first column and enter in loop} + Col := ColumnStart[Pass]; + Src := pChar(Longint(Src) + Col); + Trans := pChar(Longint(Trans) + Col); + repeat + {Copy this row} + pWord(Dest)^ := pByte(Src)^; inc(Dest, 2); + pWord(Dest)^ := pByte(Trans)^; inc(Dest, 2); + + {Move to next column} + inc(Src, ColumnIncrement[Pass]); + inc(Trans, ColumnIncrement[Pass]); + inc(Col, ColumnIncrement[Pass]); + until Col >= ImageWidth; +end; + +{Encode interlaced images} +procedure TChunkIDAT.EncodeInterlacedAdam7(Stream: TStream; + var ZLIBStream: TZStreamRec2); +var + CurrentPass, Filter: Byte; + PixelsThisRow: Integer; + CurrentRow : Integer; + Trans, Data: pChar; + CopyProc: procedure(const Pass: Byte; + Src, Dest, Trans: pChar) of object; +begin + CopyProc := nil; {Initialize to avoid warnings} + {Defines the method to copy the data to the buffer depending on} + {the image parameters} + case Header.ColorType of + {R, G, B values} + COLOR_RGB: + case Header.BitDepth of + 8: CopyProc := EncodeInterlacedRGB8; + 16: CopyProc := EncodeInterlacedRGB16; + end; + {Grayscale and palette} + COLOR_PALETTE, COLOR_GRAYSCALE: + case Header.BitDepth of + 1, 4, 8: CopyProc := EncodeInterlacedPalette148; + 16: CopyProc := EncodeInterlacedGrayscale16; + end; + {RGB followed by alpha} + COLOR_RGBALPHA: + case Header.BitDepth of + 8: CopyProc := EncodeInterlacedRGBAlpha8; + 16: CopyProc := EncodeInterlacedRGBAlpha16; + end; + COLOR_GRAYSCALEALPHA: + {Grayscale followed by alpha} + case Header.BitDepth of + 8: CopyProc := EncodeInterlacedGrayscaleAlpha8; + 16: CopyProc := EncodeInterlacedGrayscaleAlpha16; + end; + end {case Header.ColorType}; + + {Compress the image using the seven passes for ADAM 7} + FOR CurrentPass := 0 TO 6 DO + begin + {Calculates the number of pixels and bytes for this pass row} + PixelsThisRow := (ImageWidth - ColumnStart[CurrentPass] + + ColumnIncrement[CurrentPass] - 1) div ColumnIncrement[CurrentPass]; + Row_Bytes := BytesForPixels(PixelsThisRow, Header.ColorType, + Header.BitDepth); + ZeroMemory(Encode_Buffer[FILTER_NONE], Row_Bytes); + + {Get current row index} + CurrentRow := RowStart[CurrentPass]; + {Get a pointer to the current row image data} + Data := Ptr(Longint(Header.ImageData) + Header.BytesPerRow * + (ImageHeight - 1 - CurrentRow)); + Trans := Ptr(Longint(Header.ImageAlpha) + ImageWidth * CurrentRow); + + {Process all the image rows} + if Row_Bytes > 0 then + while CurrentRow < ImageHeight do + begin + {Copy data into buffer} + CopyProc(CurrentPass, Data, @Encode_Buffer[BUFFER][0], Trans); + {Filter data} + Filter := FilterToEncode; + + {Compress data} + IDATZlibWrite(ZLIBStream, @Filter, 1); + IDATZlibWrite(ZLIBStream, @Encode_Buffer[Filter][0], Row_Bytes); + + {Move to the next row} + inc(CurrentRow, RowIncrement[CurrentPass]); + {Move pointer to the next line} + dec(Data, RowIncrement[CurrentPass] * Header.BytesPerRow); + inc(Trans, RowIncrement[CurrentPass] * ImageWidth); + end {while CurrentRow < ImageHeight} + + end {CurrentPass}; + + {Compress and finishes copying the remaining data} + FinishIDATZlib(ZLIBStream); +end; + +{Filters the row to be encoded and returns the best filter} +function TChunkIDAT.FilterToEncode: Byte; +var + Run, LongestRun, ii, jj: Cardinal; + Last, Above, LastAbove: Byte; +begin + {Selecting more filters using the Filters property from TPngObject} + {increases the chances to the file be much smaller, but decreases} + {the performace} + + {This method will creates the same line data using the different} + {filter methods and select the best} + + {Sub-filter} + if pfSub in Owner.Filters then + for ii := 0 to Row_Bytes - 1 do + begin + {There is no previous pixel when it's on the first pixel, so} + {set last as zero when in the first} + if (ii >= Offset) then + last := Encode_Buffer[BUFFER]^[ii - Offset] + else + last := 0; + Encode_Buffer[FILTER_SUB]^[ii] := Encode_Buffer[BUFFER]^[ii] - last; + end; + + {Up filter} + if pfUp in Owner.Filters then + for ii := 0 to Row_Bytes - 1 do + Encode_Buffer[FILTER_UP]^[ii] := Encode_Buffer[BUFFER]^[ii] - + Encode_Buffer[FILTER_NONE]^[ii]; + + {Average filter} + if pfAverage in Owner.Filters then + for ii := 0 to Row_Bytes - 1 do + begin + {Get the previous pixel, if the current pixel is the first, the} + {previous is considered to be 0} + if (ii >= Offset) then + last := Encode_Buffer[BUFFER]^[ii - Offset] + else + last := 0; + {Get the pixel above} + above := Encode_Buffer[FILTER_NONE]^[ii]; + + {Calculates formula to the average pixel} + Encode_Buffer[FILTER_AVERAGE]^[ii] := Encode_Buffer[BUFFER]^[ii] - + (above + last) div 2 ; + end; + + {Paeth filter (the slower)} + if pfPaeth in Owner.Filters then + begin + {Initialize} + last := 0; + lastabove := 0; + for ii := 0 to Row_Bytes - 1 do + begin + {In case this pixel is not the first in the line obtains the} + {previous one and the one above the previous} + if (ii >= Offset) then + begin + last := Encode_Buffer[BUFFER]^[ii - Offset]; + lastabove := Encode_Buffer[FILTER_NONE]^[ii - Offset]; + end; + {Obtains the pixel above} + above := Encode_Buffer[FILTER_NONE]^[ii]; + {Calculate paeth filter for this byte} + Encode_Buffer[FILTER_PAETH]^[ii] := Encode_Buffer[BUFFER]^[ii] - + PaethPredictor(last, above, lastabove); + end; + end; + + {Now calculates the same line using no filter, which is necessary} + {in order to have data to the filters when the next line comes} + CopyMemory(@Encode_Buffer[FILTER_NONE]^[0], + @Encode_Buffer[BUFFER]^[0], Row_Bytes); + + {If only filter none is selected in the filter list, we don't need} + {to proceed and further} + if (Owner.Filters = [pfNone]) or (Owner.Filters = []) then + begin + Result := FILTER_NONE; + exit; + end {if (Owner.Filters = [pfNone...}; + + {Check which filter is the best by checking which has the larger} + {sequence of the same byte, since they are best compressed} + LongestRun := 0; Result := FILTER_NONE; + for ii := FILTER_NONE TO FILTER_PAETH do + {Check if this filter was selected} + if TFilter(ii) in Owner.Filters then + begin + Run := 0; + {Check if it's the only filter} + if Owner.Filters = [TFilter(ii)] then + begin + Result := ii; + exit; + end; + + {Check using a sequence of four bytes} + for jj := 2 to Row_Bytes - 1 do + if (Encode_Buffer[ii]^[jj] = Encode_Buffer [ii]^[jj-1]) or + (Encode_Buffer[ii]^[jj] = Encode_Buffer [ii]^[jj-2]) then + inc(Run); {Count the number of sequences} + + {Check if this one is the best so far} + if (Run > LongestRun) then + begin + Result := ii; + LongestRun := Run; + end {if (Run > LongestRun)}; + + end {if TFilter(ii) in Owner.Filters}; +end; + +{TChunkPLTE implementation} + +{Returns an item in the palette} +function TChunkPLTE.GetPaletteItem(Index: Byte): TRGBQuad; +begin + {Test if item is valid, if not raise error} + if Index > Count - 1 then + Owner.RaiseError(EPNGError, EPNGUnknownPalEntryText) + else + {Returns the item} + Result := Header.BitmapInfo.bmiColors[Index]; +end; + +{Loads the palette chunk from a stream} +function TChunkPLTE.LoadFromStream(Stream: TStream; + const ChunkName: TChunkName; Size: Integer): Boolean; +type + pPalEntry = ^PalEntry; + PalEntry = record + r, g, b: Byte; + end; +var + j : Integer; {For the FOR} + PalColor : pPalEntry; + palEntries: TMaxLogPalette; +begin + {Let ancestor load data and check CRC} + Result := inherited LoadFromStream(Stream, ChunkName, Size); + if not Result then exit; + + {This chunk must be divisible by 3 in order to be valid} + if (Size mod 3 <> 0) or (Size div 3 > 256) then + begin + {Raise error} + Result := FALSE; + Owner.RaiseError(EPNGInvalidPalette, EPNGInvalidPaletteText); + exit; + end {if Size mod 3 <> 0}; + + {Fill array with the palette entries} + fCount := Size div 3; + Fillchar(palEntries, sizeof(palEntries), #0); + palEntries.palVersion := $300; + palEntries.palNumEntries := fCount; + PalColor := Data; + FOR j := 0 TO fCount - 1 DO + with palEntries.palPalEntry[j] do + begin + peRed := Owner.GammaTable[PalColor.r]; + peGreen := Owner.GammaTable[PalColor.g]; + peBlue := Owner.GammaTable[PalColor.b]; + peFlags := 0; + {Move to next palette entry} + inc(PalColor); + end; + Owner.SetPalette(CreatePalette(pLogPalette(@palEntries)^)); +end; + +{Saves the PLTE chunk to a stream} +function TChunkPLTE.SaveToStream(Stream: TStream): Boolean; +var + J: Integer; + DataPtr: pByte; + BitmapInfo: TMAXBITMAPINFO; + palEntries: TMaxLogPalette; +begin + {Adjust size to hold all the palette items} + if fCount = 0 then fCount := Header.BitmapInfo.bmiHeader.biClrUsed; + ResizeData(fCount * 3); + {Get all the palette entries} + fillchar(palEntries, sizeof(palEntries), #0); + GetPaletteEntries(Header.ImagePalette, 0, 256, palEntries.palPalEntry[0]); + {Copy pointer to data} + DataPtr := fData; + + {Copy palette items} + BitmapInfo := Header.BitmapInfo; + FOR j := 0 TO fCount - 1 DO + with palEntries.palPalEntry[j] do + begin + DataPtr^ := Owner.InverseGamma[peRed]; inc(DataPtr); + DataPtr^ := Owner.InverseGamma[peGreen]; inc(DataPtr); + DataPtr^ := Owner.InverseGamma[peBlue]; inc(DataPtr); + end {with BitmapInfo}; + + {Let ancestor do the rest of the work} + Result := inherited SaveToStream(Stream); +end; + +{Assigns from another PLTE chunk} +procedure TChunkPLTE.Assign(Source: TChunk); +begin + {Copy the number of palette items} + if Source is TChunkPLTE then + fCount := TChunkPLTE(Source).fCount + else + Owner.RaiseError(EPNGError, EPNGCannotAssignChunkText); +end; + +{TChunkgAMA implementation} + +{Assigns from another chunk} +procedure TChunkgAMA.Assign(Source: TChunk); +begin + {Copy the gamma value} + if Source is TChunkgAMA then + Gamma := TChunkgAMA(Source).Gamma + else + Owner.RaiseError(EPNGError, EPNGCannotAssignChunkText); +end; + +{Gamma chunk being created} +constructor TChunkgAMA.Create(Owner: TPngObject); +begin + {Call ancestor} + inherited Create(Owner); + Gamma := 1; {Initial value} +end; + +{Returns gamma value} +function TChunkgAMA.GetValue: Cardinal; +begin + {Make sure that the size is four bytes} + if DataSize <> 4 then + begin + {Adjust size and returns 1} + ResizeData(4); + Result := 1; + end + {If it's right, read the value} + else Result := Cardinal(ByteSwap(pCardinal(Data)^)) +end; + +function Power(Base, Exponent: Extended): Extended; +begin + if Exponent = 0.0 then + Result := 1.0 {Math rule} + else if (Base = 0) or (Exponent = 0) then Result := 0 + else + Result := Exp(Exponent * Ln(Base)); +end; + +{Loading the chunk from a stream} +function TChunkgAMA.LoadFromStream(Stream: TStream; + const ChunkName: TChunkName; Size: Integer): Boolean; +var + i: Integer; + Value: Cardinal; +begin + {Call ancestor and test if it went ok} + Result := inherited LoadFromStream(Stream, ChunkName, Size); + if not Result then exit; + Value := Gamma; + {Build gamma table and inverse table for saving} + if Value <> 0 then + with Owner do + FOR i := 0 TO 255 DO + begin + GammaTable[I] := Round(Power((I / 255), 1 / + (Value / 100000 * 2.2)) * 255); + InverseGamma[Round(Power((I / 255), 1 / + (Value / 100000 * 2.2)) * 255)] := I; + end +end; + +{Sets the gamma value} +procedure TChunkgAMA.SetValue(const Value: Cardinal); +begin + {Make sure that the size is four bytes} + if DataSize <> 4 then ResizeData(4); + {If it's right, set the value} + pCardinal(Data)^ := ByteSwap(Value); +end; + +{TPngObject implementation} + +{Assigns from another object} +procedure TPngObject.Assign(Source: TPersistent); +begin + {Being cleared} + if Source = nil then + ClearChunks + {Assigns contents from another TPNGObject} + else if Source is TPNGObject then + AssignPNG(Source as TPNGObject) + {Copy contents from a TBitmap} + {$IFDEF UseDelphi}else if Source is TBitmap then + with Source as TBitmap do + AssignHandle(Handle, Transparent, + ColorToRGB(TransparentColor)){$ENDIF} + {Unknown source, let ancestor deal with it} + else + inherited; +end; + +{Clear all the chunks in the list} +procedure TPngObject.ClearChunks; +var + i: Integer; +begin + {Initialize gamma} + InitializeGamma(); + {Free all the objects and memory (0 chunks Bug fixed by Noel Sharpe)} + for i := 0 TO Integer(Chunks.Count) - 1 do + TChunk(Chunks.Item[i]).Free; + Chunks.Count := 0; +end; + +{Portable Network Graphics object being created as a blank image} +constructor TPNGObject.CreateBlank(ColorType, BitDepth: Cardinal; + cx, cy: Integer); +var NewIHDR: TChunkIHDR; +begin + {Calls creator} + Create; + {Checks if the parameters are ok} + if not (ColorType in [COLOR_GRAYSCALE, COLOR_RGB, COLOR_PALETTE, + COLOR_GRAYSCALEALPHA, COLOR_RGBALPHA]) or not (BitDepth in + [1,2,4,8, 16]) or ((ColorType = COLOR_PALETTE) and (BitDepth = 16)) or + ((ColorType = COLOR_RGB) and (BitDepth < 8)) then + begin + RaiseError(EPNGInvalidSpec, EInvalidSpec); + exit; + end; + if Bitdepth = 2 then Bitdepth := 4; + + {Add the basis chunks} + InitializeGamma; + BeingCreated := True; + Chunks.Add(TChunkIEND); + NewIHDR := Chunks.Add(TChunkIHDR) as TChunkIHDR; + NewIHDR.IHDRData.ColorType := ColorType; + NewIHDR.IHDRData.BitDepth := BitDepth; + NewIHDR.IHDRData.Width := cx; + NewIHDR.IHDRData.Height := cy; + NewIHDR.PrepareImageData; + if NewIHDR.HasPalette then + TChunkPLTE(Chunks.Add(TChunkPLTE)).fCount := 1 shl BitDepth; + Chunks.Add(TChunkIDAT); + BeingCreated := False; +end; + +{Portable Network Graphics object being created} +constructor TPngObject.Create; +begin + {Let it be created} + inherited Create; + + {Initial properties} + {$IFDEF UseDelphi}fCanvas := TCanvas.Create;{$ENDIF} + fFilters := [pfSub]; + fCompressionLevel := 7; + fInterlaceMethod := imNone; + fMaxIdatSize := High(Word); + {Create chunklist object} + fChunkList := TPngList.Create(Self); + +end; + +{Portable Network Graphics object being destroyed} +destructor TPngObject.Destroy; +begin + {Free object list} + ClearChunks; + fChunkList.Free; + {$IFDEF UseDelphi}if fCanvas <> nil then + fCanvas.Free;{$ENDIF} + + {Call ancestor destroy} + inherited Destroy; +end; + +{Returns linesize and byte offset for pixels} +procedure TPngObject.GetPixelInfo(var LineSize, Offset: Cardinal); +begin + {There must be an Header chunk to calculate size} + if HeaderPresent then + begin + {Calculate number of bytes for each line} + LineSize := BytesForPixels(Header.Width, Header.ColorType, Header.BitDepth); + + {Calculates byte offset} + Case Header.ColorType of + {Grayscale} + COLOR_GRAYSCALE: + If Header.BitDepth = 16 Then + Offset := 2 + Else + Offset := 1 ; + {It always smaller or equal one byte, so it occupes one byte} + COLOR_PALETTE: + offset := 1; + {It might be 3 or 6 bytes} + COLOR_RGB: + offset := 3 * Header.BitDepth Div 8; + {It might be 2 or 4 bytes} + COLOR_GRAYSCALEALPHA: + offset := 2 * Header.BitDepth Div 8; + {4 or 8 bytes} + COLOR_RGBALPHA: + offset := 4 * Header.BitDepth Div 8; + else + Offset := 0; + End ; + + end + else + begin + {In case if there isn't any Header chunk} + Offset := 0; + LineSize := 0; + end; + +end; + +{Returns image height} +function TPngObject.GetHeight: Integer; +begin + {There must be a Header chunk to get the size, otherwise returns 0} + if HeaderPresent then + Result := TChunkIHDR(Chunks.Item[0]).Height + else Result := 0; +end; + +{Returns image width} +function TPngObject.GetWidth: Integer; +begin + {There must be a Header chunk to get the size, otherwise returns 0} + if HeaderPresent then + Result := Header.Width + else Result := 0; +end; + +{Returns if the image is empty} +function TPngObject.GetEmpty: Boolean; +begin + Result := (Chunks.Count = 0); +end; + +{Raises an error} +procedure TPngObject.RaiseError(ExceptionClass: ExceptClass; Text: String); +begin + raise ExceptionClass.Create(Text); +end; + +{Set the maximum size for IDAT chunk} +procedure TPngObject.SetMaxIdatSize(const Value: Integer); +begin + {Make sure the size is at least 65535} + if Value < High(Word) then + fMaxIdatSize := High(Word) else fMaxIdatSize := Value; +end; + +{Draws the image using pixel information from TChunkpHYs} +procedure TPNGObject.DrawUsingPixelInformation(Canvas: TCanvas; Point: TPoint); + function Rect(Left, Top, Right, Bottom: Integer): TRect; + begin + Result.Left := Left; + Result.Top := Top; + Result.Right := Right; + Result.Bottom := Bottom; + end; +var + PPMeterY, PPMeterX: Double; + NewSizeX, NewSizeY: Integer; + DC: HDC; +begin + {Get system information} + DC := GetDC(0); + PPMeterY := GetDeviceCaps(DC, LOGPIXELSY) / 0.0254; + PPMeterX := GetDeviceCaps(DC, LOGPIXELSX) / 0.0254; + ReleaseDC(0, DC); + + {In case it does not has pixel information} + if not HasPixelInformation then + Draw(Canvas, Rect(Point.X, Point.Y, Point.X + Width, + Point.Y + Height)) + else + with PixelInformation do + begin + NewSizeX := Trunc(Self.Width / (PPUnitX / PPMeterX)); + NewSizeY := Trunc(Self.Height / (PPUnitY / PPMeterY)); + Draw(Canvas, Rect(Point.X, Point.Y, Point.X + NewSizeX, + Point.Y + NewSizeY)); + end; +end; + +{$IFNDEF UseDelphi} + {Creates a file stream reading from the filename in the parameter and load} + procedure TPngObject.LoadFromFile(const Filename: String); + var + FileStream: TFileStream; + begin + {Test if the file exists} + if not FileExists(Filename) then + begin + {In case it does not exists, raise error} + RaiseError(EPNGNotExists, EPNGNotExistsText); + exit; + end; + + {Creates the file stream to read} + FileStream := TFileStream.Create(Filename, [fsmRead]); + LoadFromStream(FileStream); {Loads the data} + FileStream.Free; {Free file stream} + end; + + {Saves the current png image to a file} + procedure TPngObject.SaveToFile(const Filename: String); + var + FileStream: TFileStream; + begin + {Creates the file stream to write} + FileStream := TFileStream.Create(Filename, [fsmWrite]); + SaveToStream(FileStream); {Saves the data} + FileStream.Free; {Free file stream} + end; + +{$ENDIF} + +{Returns if it has the pixel information chunk} +function TPngObject.HasPixelInformation: Boolean; +begin + Result := (Chunks.ItemFromClass(TChunkpHYs) as tChunkpHYs) <> nil; +end; + +{Returns the pixel information chunk} +function TPngObject.GetPixelInformation: TChunkpHYs; +begin + Result := Chunks.ItemFromClass(TChunkpHYs) as tChunkpHYs; + if not Assigned(Result) then + begin + Result := Chunks.Add(tChunkpHYs) as tChunkpHYs; + Result.fUnit := utMeter; + end; +end; + +{Returns pointer to the chunk TChunkIHDR which should be the first} +function TPngObject.GetHeader: TChunkIHDR; +begin + {If there is a TChunkIHDR returns it, otherwise returns nil} + if (Chunks.Count <> 0) and (Chunks.Item[0] is TChunkIHDR) then + Result := Chunks.Item[0] as TChunkIHDR + else + begin + {No header, throw error message} + RaiseError(EPNGHeaderNotPresent, EPNGHeaderNotPresentText); + Result := nil + end +end; + +{Draws using partial transparency} +procedure TPngObject.DrawPartialTrans(DC: HDC; Rect: TRect); + {Adjust the rectangle structure} + procedure AdjustRect(var Rect: TRect); + var + t: Integer; + begin + if Rect.Right < Rect.Left then + begin + t := Rect.Right; + Rect.Right := Rect.Left; + Rect.Left := t; + end; + if Rect.Bottom < Rect.Top then + begin + t := Rect.Bottom; + Rect.Bottom := Rect.Top; + Rect.Top := t; + end + end; + +type + {Access to pixels} + TPixelLine = Array[Word] of TRGBQuad; + pPixelLine = ^TPixelLine; +const + {Structure used to create the bitmap} + BitmapInfoHeader: TBitmapInfoHeader = + (biSize: sizeof(TBitmapInfoHeader); + biWidth: 100; + biHeight: 100; + biPlanes: 1; + biBitCount: 32; + biCompression: BI_RGB; + biSizeImage: 0; + biXPelsPerMeter: 0; + biYPelsPerMeter: 0; + biClrUsed: 0; + biClrImportant: 0); +var + {Buffer bitmap creation} + BitmapInfo : TBitmapInfo; + BufferDC : HDC; + BufferBits : Pointer; + OldBitmap, + BufferBitmap: HBitmap; + Header: TChunkIHDR; + + {Transparency/palette chunks} + TransparencyChunk: TChunktRNS; + PaletteChunk: TChunkPLTE; + TransValue, PaletteIndex: Byte; + CurBit: Integer; + Data: PByte; + + {Buffer bitmap modification} + BytesPerRowDest, + BytesPerRowSrc, + BytesPerRowAlpha: Integer; + ImageSource, ImageSourceOrg, + AlphaSource : pByteArray; + ImageData : pPixelLine; + i, j, i2, j2 : Integer; + + {For bitmap stretching} + W, H : Cardinal; + Stretch : Boolean; + FactorX, FactorY: Double; +begin + {Prepares the rectangle structure to stretch draw} + if (Rect.Right = Rect.Left) or (Rect.Bottom = Rect.Top) then exit; + AdjustRect(Rect); + {Gets the width and height} + W := Rect.Right - Rect.Left; + H := Rect.Bottom - Rect.Top; + Header := Self.Header; {Fast access to header} + Stretch := (W <> Header.Width) or (H <> Header.Height); + if Stretch then FactorX := W / Header.Width else FactorX := 1; + if Stretch then FactorY := H / Header.Height else FactorY := 1; + + {Prepare to create the bitmap} + Fillchar(BitmapInfo, sizeof(BitmapInfo), #0); + BitmapInfoHeader.biWidth := W; + BitmapInfoHeader.biHeight := -Integer(H); + BitmapInfo.bmiHeader := BitmapInfoHeader; + + {Create the bitmap which will receive the background, the applied} + {alpha blending and then will be painted on the background} + BufferDC := CreateCompatibleDC(0); + {In case BufferDC could not be created} + if (BufferDC = 0) then RaiseError(EPNGOutMemory, EPNGOutMemoryText); + BufferBitmap := CreateDIBSection(BufferDC, BitmapInfo, DIB_RGB_COLORS, + BufferBits, 0, 0); + {In case buffer bitmap could not be created} + if (BufferBitmap = 0) or (BufferBits = Nil) then + begin + if BufferBitmap <> 0 then DeleteObject(BufferBitmap); + DeleteDC(BufferDC); + RaiseError(EPNGOutMemory, EPNGOutMemoryText); + end; + + {Selects new bitmap and release old bitmap} + OldBitmap := SelectObject(BufferDC, BufferBitmap); + + {Draws the background on the buffer image} + BitBlt(BufferDC, 0, 0, W, H, DC, Rect.Left, Rect.Top, SRCCOPY); + + {Obtain number of bytes for each row} + BytesPerRowAlpha := Header.Width; + BytesPerRowDest := (((BitmapInfo.bmiHeader.biBitCount * W) + 31) + and not 31) div 8; {Number of bytes for each image row in destination} + BytesPerRowSrc := (((Header.BitmapInfo.bmiHeader.biBitCount * Header.Width) + + 31) and not 31) div 8; {Number of bytes for each image row in source} + + {Obtains image pointers} + ImageData := BufferBits; + AlphaSource := Header.ImageAlpha; + Longint(ImageSource) := Longint(Header.ImageData) + + Header.BytesPerRow * Longint(Header.Height - 1); + ImageSourceOrg := ImageSource; + + case Header.BitmapInfo.bmiHeader.biBitCount of + {R, G, B images} + 24: + FOR j := 1 TO H DO + begin + {Process all the pixels in this line} + FOR i := 0 TO W - 1 DO + begin + if Stretch then i2 := trunc(i / FactorX) else i2 := i; + {Optmize when we don´t have transparency} + if (AlphaSource[i2] <> 0) then + if (AlphaSource[i2] = 255) then + ImageData[i] := pRGBQuad(@ImageSource[i2 * 3])^ + else + with ImageData[i] do + begin + rgbRed := (255+ImageSource[2+i2*3] * AlphaSource[i2] + rgbRed * + (not AlphaSource[i2])) shr 8; + rgbGreen := (255+ImageSource[1+i2*3] * AlphaSource[i2] + + rgbGreen * (not AlphaSource[i2])) shr 8; + rgbBlue := (255+ImageSource[i2*3] * AlphaSource[i2] + rgbBlue * + (not AlphaSource[i2])) shr 8; + end; + end; + + {Move pointers} + inc(Longint(ImageData), BytesPerRowDest); + if Stretch then j2 := trunc(j / FactorY) else j2 := j; + Longint(ImageSource) := Longint(ImageSourceOrg) - BytesPerRowSrc * j2; + Longint(AlphaSource) := Longint(Header.ImageAlpha) + + BytesPerRowAlpha * j2; + end; + {Palette images with 1 byte for each pixel} + 1,4,8: if Header.ColorType = COLOR_GRAYSCALEALPHA then + FOR j := 1 TO H DO + begin + {Process all the pixels in this line} + FOR i := 0 TO W - 1 DO + with ImageData[i], Header.BitmapInfo do begin + if Stretch then i2 := trunc(i / FactorX) else i2 := i; + rgbRed := (255 + ImageSource[i2] * AlphaSource[i2] + + rgbRed * (255 - AlphaSource[i2])) shr 8; + rgbGreen := (255 + ImageSource[i2] * AlphaSource[i2] + + rgbGreen * (255 - AlphaSource[i2])) shr 8; + rgbBlue := (255 + ImageSource[i2] * AlphaSource[i2] + + rgbBlue * (255 - AlphaSource[i2])) shr 8; + end; + + {Move pointers} + Longint(ImageData) := Longint(ImageData) + BytesPerRowDest; + if Stretch then j2 := trunc(j / FactorY) else j2 := j; + Longint(ImageSource) := Longint(ImageSourceOrg) - BytesPerRowSrc * j2; + Longint(AlphaSource) := Longint(Header.ImageAlpha) + + BytesPerRowAlpha * j2; + end + else {Palette images} + begin + {Obtain pointer to the transparency chunk} + TransparencyChunk := TChunktRNS(Chunks.ItemFromClass(TChunktRNS)); + PaletteChunk := TChunkPLTE(Chunks.ItemFromClass(TChunkPLTE)); + + FOR j := 1 TO H DO + begin + {Process all the pixels in this line} + i := 0; + repeat + CurBit := 0; + if Stretch then i2 := trunc(i / FactorX) else i2 := i; + Data := @ImageSource[i2]; + + repeat + {Obtains the palette index} + case Header.BitDepth of + 1: PaletteIndex := (Data^ shr (7-(I Mod 8))) and 1; + 2,4: PaletteIndex := (Data^ shr ((1-(I Mod 2))*4)) and $0F; + else PaletteIndex := Data^; + end; + + {Updates the image with the new pixel} + with ImageData[i] do + begin + TransValue := TransparencyChunk.PaletteValues[PaletteIndex]; + rgbRed := (255 + PaletteChunk.Item[PaletteIndex].rgbRed * + TransValue + rgbRed * (255 - TransValue)) shr 8; + rgbGreen := (255 + PaletteChunk.Item[PaletteIndex].rgbGreen * + TransValue + rgbGreen * (255 - TransValue)) shr 8; + rgbBlue := (255 + PaletteChunk.Item[PaletteIndex].rgbBlue * + TransValue + rgbBlue * (255 - TransValue)) shr 8; + end; + + {Move to next data} + inc(i); inc(CurBit, Header.BitmapInfo.bmiHeader.biBitCount); + until CurBit >= 8; + {Move to next source data} + //inc(Data); + until i >= Integer(W); + + {Move pointers} + Longint(ImageData) := Longint(ImageData) + BytesPerRowDest; + if Stretch then j2 := trunc(j / FactorY) else j2 := j; + Longint(ImageSource) := Longint(ImageSourceOrg) - BytesPerRowSrc * j2; + end + end {Palette images} + end {case Header.BitmapInfo.bmiHeader.biBitCount}; + + {Draws the new bitmap on the foreground} + BitBlt(DC, Rect.Left, Rect.Top, W, H, BufferDC, 0, 0, SRCCOPY); + + {Free bitmap} + SelectObject(BufferDC, OldBitmap); + DeleteObject(BufferBitmap); + DeleteDC(BufferDC); +end; + +{Draws the image into a canvas} +procedure TPngObject.Draw(ACanvas: TCanvas; const Rect: TRect); +var + Header: TChunkIHDR; +begin + {Quit in case there is no header, otherwise obtain it} + if Empty then Exit; + Header := Chunks.GetItem(0) as TChunkIHDR; + + {Copy the data to the canvas} + case Self.TransparencyMode of + {$IFDEF PartialTransparentDraw} + ptmPartial: + DrawPartialTrans(ACanvas{$IFDEF UseDelphi}.Handle{$ENDIF}, Rect); + {$ENDIF} + ptmBit: DrawTransparentBitmap(ACanvas{$IFDEF UseDelphi}.Handle{$ENDIF}, + Header.ImageData, Header.BitmapInfo.bmiHeader, + pBitmapInfo(@Header.BitmapInfo), Rect, + {$IFDEF UseDelphi}ColorToRGB({$ENDIF}TransparentColor) + {$IFDEF UseDelphi}){$ENDIF} + else + begin + SetStretchBltMode(ACanvas{$IFDEF UseDelphi}.Handle{$ENDIF}, COLORONCOLOR); + StretchDiBits(ACanvas{$IFDEF UseDelphi}.Handle{$ENDIF}, Rect.Left, + Rect.Top, Rect.Right - Rect.Left, Rect.Bottom - Rect.Top, 0, 0, + Header.Width, Header.Height, Header.ImageData, + pBitmapInfo(@Header.BitmapInfo)^, DIB_RGB_COLORS, SRCCOPY) + end + end {case} +end; + +{Characters for the header} +const + PngHeader: Array[0..7] of Char = (#137, #80, #78, #71, #13, #10, #26, #10); + +{Loads the image from a stream of data} +procedure TPngObject.LoadFromStream(Stream: TStream); +var + Header : Array[0..7] of Char; + HasIDAT : Boolean; + + {Chunks reading} + ChunkCount : Cardinal; + ChunkLength: Cardinal; + ChunkName : TChunkName; +begin + {Initialize before start loading chunks} + ChunkCount := 0; + ClearChunks(); + {Reads the header} + Stream.Read(Header[0], 8); + + {Test if the header matches} + if Header <> PngHeader then + begin + RaiseError(EPNGInvalidFileHeader, EPNGInvalidFileHeaderText); + Exit; + end; + + + HasIDAT := FALSE; + Chunks.Count := 10; + + {Load chunks} + repeat + inc(ChunkCount); {Increment number of chunks} + if Chunks.Count < ChunkCount then {Resize the chunks list if needed} + Chunks.Count := Chunks.Count + 10; + + {Reads chunk length and invert since it is in network order} + {also checks the Read method return, if it returns 0, it} + {means that no bytes was readed, probably because it reached} + {the end of the file} + if Stream.Read(ChunkLength, 4) = 0 then + begin + {In case it found the end of the file here} + Chunks.Count := ChunkCount - 1; + RaiseError(EPNGUnexpectedEnd, EPNGUnexpectedEndText); + end; + + ChunkLength := ByteSwap(ChunkLength); + {Reads chunk name} + Stream.Read(Chunkname, 4); + + {Here we check if the first chunk is the Header which is necessary} + {to the file in order to be a valid Portable Network Graphics image} + if (ChunkCount = 1) and (ChunkName <> 'IHDR') then + begin + Chunks.Count := ChunkCount - 1; + RaiseError(EPNGIHDRNotFirst, EPNGIHDRNotFirstText); + exit; + end; + + {Has a previous IDAT} + if (HasIDAT and (ChunkName = 'IDAT')) or (ChunkName = 'cHRM') then + begin + dec(ChunkCount); + Stream.Seek(ChunkLength + 4, soFromCurrent); + Continue; + end; + {Tell it has an IDAT chunk} + if ChunkName = 'IDAT' then HasIDAT := TRUE; + + {Creates object for this chunk} + Chunks.SetItem(ChunkCount - 1, CreateClassChunk(Self, ChunkName)); + + {Check if the chunk is critical and unknown} + {$IFDEF ErrorOnUnknownCritical} + if (TChunk(Chunks.Item[ChunkCount - 1]).ClassType = TChunk) and + ((Byte(ChunkName[0]) AND $20) = 0) and (ChunkName <> '') then + begin + Chunks.Count := ChunkCount; + RaiseError(EPNGUnknownCriticalChunk, EPNGUnknownCriticalChunkText); + end; + {$ENDIF} + + {Loads it} + try if not TChunk(Chunks.Item[ChunkCount - 1]).LoadFromStream(Stream, + ChunkName, ChunkLength) then break; + except + Chunks.Count := ChunkCount; + raise; + end; + + {Terminates when it reaches the IEND chunk} + until (ChunkName = 'IEND'); + + {Resize the list to the appropriate size} + Chunks.Count := ChunkCount; + + {Check if there is data} + if not HasIDAT then + RaiseError(EPNGNoImageData, EPNGNoImageDataText); +end; + +{Changing height is not supported} +procedure TPngObject.SetHeight(Value: Integer); +begin + Resize(Width, Value) +end; + +{Changing width is not supported} +procedure TPngObject.SetWidth(Value: Integer); +begin + Resize(Value, Height) +end; + +{$IFDEF UseDelphi} +{Saves to clipboard format (thanks to Antoine Pottern)} +procedure TPNGObject.SaveToClipboardFormat(var AFormat: Word; + var AData: THandle; var APalette: HPalette); +begin + with TBitmap.Create do + try + Width := Self.Width; + Height := Self.Height; + Self.Draw(Canvas, Rect(0, 0, Width, Height)); + SaveToClipboardFormat(AFormat, AData, APalette); + finally + Free; + end {try} +end; + +{Loads data from clipboard} +procedure TPngObject.LoadFromClipboardFormat(AFormat: Word; + AData: THandle; APalette: HPalette); +begin + with TBitmap.Create do + try + LoadFromClipboardFormat(AFormat, AData, APalette); + Self.AssignHandle(Handle, False, 0); + finally + Free; + end {try} +end; + +{Returns if the image is transparent} +function TPngObject.GetTransparent: Boolean; +begin + Result := (TransparencyMode <> ptmNone); +end; + +{$ENDIF} + +{Saving the PNG image to a stream of data} +procedure TPngObject.SaveToStream(Stream: TStream); +var + j: Integer; +begin + {Reads the header} + Stream.Write(PNGHeader[0], 8); + {Write each chunk} + FOR j := 0 TO Chunks.Count - 1 DO + Chunks.Item[j].SaveToStream(Stream) +end; + +{Prepares the Header chunk} +procedure BuildHeader(Header: TChunkIHDR; Handle: HBitmap; Info: pBitmap); +var + DC: HDC; +begin + {Set width and height} + Header.Width := Info.bmWidth; + Header.Height := abs(Info.bmHeight); + {Set bit depth} + if Info.bmBitsPixel >= 16 then + Header.BitDepth := 8 else Header.BitDepth := Info.bmBitsPixel; + {Set color type} + if Info.bmBitsPixel >= 16 then + Header.ColorType := COLOR_RGB else Header.ColorType := COLOR_PALETTE; + {Set other info} + Header.CompressionMethod := 0; {deflate/inflate} + Header.InterlaceMethod := 0; {no interlace} + + {Prepares bitmap headers to hold data} + Header.PrepareImageData(); + {Copy image data} + DC := CreateCompatibleDC(0); + GetDIBits(DC, Handle, 0, Header.Height, Header.ImageData, + pBitmapInfo(@Header.BitmapInfo)^, DIB_RGB_COLORS); + + DeleteDC(DC); +end; + +{Loads the image from a resource} +procedure TPngObject.LoadFromResourceName(Instance: HInst; + const Name: String); +var + ResStream: TResourceStream; +begin + {Creates an especial stream to load from the resource} + try ResStream := TResourceStream.Create(Instance, Name, RT_RCDATA); + except RaiseError(EPNGCouldNotLoadResource, EPNGCouldNotLoadResourceText); + exit; end; + + {Loads the png image from the resource} + try + LoadFromStream(ResStream); + finally + ResStream.Free; + end; +end; + +{Loads the png from a resource ID} +procedure TPngObject.LoadFromResourceID(Instance: HInst; ResID: Integer); +begin + LoadFromResourceName(Instance, String(ResID)); +end; + +{Assigns this tpngobject to another object} +procedure TPngObject.AssignTo(Dest: TPersistent); +{$IFDEF UseDelphi} + function DetectPixelFormat: TPixelFormat; + begin + with Header do + begin + {Always use 24bits for partial transparency} + if TransparencyMode = ptmPartial then + DetectPixelFormat := pf24bit + else + case BitDepth of + {Only supported by COLOR_PALETTE} + 1: DetectPixelFormat := pf1bit; + 2, 4: DetectPixelFormat := pf4bit; + {8 may be palette or r, g, b values} + 8, 16: + case ColorType of + COLOR_RGB, COLOR_GRAYSCALE: DetectPixelFormat := pf24bit; + COLOR_PALETTE: DetectPixelFormat := pf8bit; + else raise Exception.Create(''); + end {case ColorFormat of} + else raise Exception.Create(''); + end {case BitDepth of} + end {with Header} + end; +var + TRNS: TChunkTRNS; +{$ENDIF} +begin + {If the destination is also a TPNGObject make it assign} + {this one} + if Dest is TPNGObject then + TPNGObject(Dest).AssignPNG(Self) + {$IFDEF UseDelphi} + {In case the destination is a bitmap} + else if (Dest is TBitmap) and HeaderPresent then + begin + {Copies the handle using CopyImage API} + TBitmap(Dest).PixelFormat := DetectPixelFormat; + TBitmap(Dest).Width := Width; + TBitmap(Dest).Height := Height; + TBitmap(Dest).Canvas.Draw(0, 0, Self); + + {Copy transparency mode} + if (TransparencyMode = ptmBit) then + begin + TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS; + TBitmap(Dest).TransparentColor := TRNS.TransparentColor; + TBitmap(Dest).Transparent := True + end {if (TransparencyMode = ptmBit)} + + end + else + {Unknown destination kind} + inherited AssignTo(Dest); + {$ENDIF} +end; + +{Assigns from a bitmap object} +procedure TPngObject.AssignHandle(Handle: HBitmap; Transparent: Boolean; + TransparentColor: ColorRef); +var + BitmapInfo: Windows.TBitmap; + {Chunks} + Header: TChunkIHDR; + PLTE: TChunkPLTE; + IDAT: TChunkIDAT; + IEND: TChunkIEND; + TRNS: TChunkTRNS; + i: Integer; + palEntries : TMaxLogPalette; +begin + {Obtain bitmap info} + GetObject(Handle, SizeOf(BitmapInfo), @BitmapInfo); + + {Clear old chunks and prepare} + ClearChunks(); + + {Create the chunks} + Header := TChunkIHDR.Create(Self); + + {This method will fill the Header chunk with bitmap information} + {and copy the image data} + BuildHeader(Header, Handle, @BitmapInfo); + + if Header.HasPalette then PLTE := TChunkPLTE.Create(Self) else PLTE := nil; + if Transparent then TRNS := TChunkTRNS.Create(Self) else TRNS := nil; + IDAT := TChunkIDAT.Create(Self); + IEND := TChunkIEND.Create(Self); + + {Add chunks} + TPNGPointerList(Chunks).Add(Header); + if Header.HasPalette then TPNGPointerList(Chunks).Add(PLTE); + if Transparent then TPNGPointerList(Chunks).Add(TRNS); + TPNGPointerList(Chunks).Add(IDAT); + TPNGPointerList(Chunks).Add(IEND); + + {In case there is a image data, set the PLTE chunk fCount variable} + {to the actual number of palette colors which is 2^(Bits for each pixel)} + if Header.HasPalette then + begin + PLTE.fCount := 1 shl BitmapInfo.bmBitsPixel; + + {Create and set palette} + fillchar(palEntries, sizeof(palEntries), 0); + palEntries.palVersion := $300; + palEntries.palNumEntries := 1 shl BitmapInfo.bmBitsPixel; + for i := 0 to palEntries.palNumEntries - 1 do + begin + palEntries.palPalEntry[i].peRed := Header.BitmapInfo.bmiColors[i].rgbRed; + palEntries.palPalEntry[i].peGreen := Header.BitmapInfo.bmiColors[i].rgbGreen; + palEntries.palPalEntry[i].peBlue := Header.BitmapInfo.bmiColors[i].rgbBlue; + end; + DoSetPalette(CreatePalette(pLogPalette(@palEntries)^), false); + end; + + {In case it is a transparent bitmap, prepares it} + if Transparent then TRNS.TransparentColor := TransparentColor; +end; + +{Assigns from another PNG} +procedure TPngObject.AssignPNG(Source: TPNGObject); +var + J: Integer; +begin + {Copy properties} + InterlaceMethod := Source.InterlaceMethod; + MaxIdatSize := Source.MaxIdatSize; + CompressionLevel := Source.CompressionLevel; + Filters := Source.Filters; + + {Clear old chunks and prepare} + ClearChunks(); + Chunks.Count := Source.Chunks.Count; + {Create chunks and makes a copy from the source} + FOR J := 0 TO Chunks.Count - 1 DO + with Source.Chunks do + begin + Chunks.SetItem(J, TChunkClass(TChunk(Item[J]).ClassType).Create(Self)); + TChunk(Chunks.Item[J]).Assign(TChunk(Item[J])); + end {with}; +end; + +{Returns a alpha data scanline} +function TPngObject.GetAlphaScanline(const LineIndex: Integer): pByteArray; +begin + with Header do + if (ColorType = COLOR_RGBALPHA) or (ColorType = COLOR_GRAYSCALEALPHA) then + Longint(Result) := Longint(ImageAlpha) + (LineIndex * Longint(Width)) + else Result := nil; {In case the image does not use alpha information} +end; + +{$IFDEF Store16bits} +{Returns a png data extra scanline} +function TPngObject.GetExtraScanline(const LineIndex: Integer): Pointer; +begin + with Header do + Longint(Result) := (Longint(ExtraImageData) + ((Longint(Height) - 1) * + BytesPerRow)) - (LineIndex * BytesPerRow); +end; +{$ENDIF} + +{Returns a png data scanline} +function TPngObject.GetScanline(const LineIndex: Integer): Pointer; +begin + with Header do + Longint(Result) := (Longint(ImageData) + ((Longint(Height) - 1) * + BytesPerRow)) - (LineIndex * BytesPerRow); +end; + +{Initialize gamma table} +procedure TPngObject.InitializeGamma; +var + i: Integer; +begin + {Build gamma table as if there was no gamma} + FOR i := 0 to 255 do + begin + GammaTable[i] := i; + InverseGamma[i] := i; + end {for i} +end; + +{Returns the transparency mode used by this png} +function TPngObject.GetTransparencyMode: TPNGTransparencyMode; +var + TRNS: TChunkTRNS; +begin + with Header do + begin + Result := ptmNone; {Default result} + {Gets the TRNS chunk pointer} + TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS; + + {Test depending on the color type} + case ColorType of + {This modes are always partial} + COLOR_RGBALPHA, COLOR_GRAYSCALEALPHA: Result := ptmPartial; + {This modes support bit transparency} + COLOR_RGB, COLOR_GRAYSCALE: if TRNS <> nil then Result := ptmBit; + {Supports booth translucid and bit} + COLOR_PALETTE: + {A TRNS chunk must be present, otherwise it won't support transparency} + if TRNS <> nil then + if TRNS.BitTransparency then + Result := ptmBit else Result := ptmPartial + end {case} + + end {with Header} +end; + +{Add a text chunk} +procedure TPngObject.AddtEXt(const Keyword, Text: String); +var + TextChunk: TChunkTEXT; +begin + TextChunk := Chunks.Add(TChunkText) as TChunkTEXT; + TextChunk.Keyword := Keyword; + TextChunk.Text := Text; +end; + +{Add a text chunk} +procedure TPngObject.AddzTXt(const Keyword, Text: String); +var + TextChunk: TChunkzTXt; +begin + TextChunk := Chunks.Add(TChunkzTXt) as TChunkzTXt; + TextChunk.Keyword := Keyword; + TextChunk.Text := Text; +end; + +{Removes the image transparency} +procedure TPngObject.RemoveTransparency; +var + TRNS: TChunkTRNS; +begin + {Removes depending on the color type} + with Header do + case ColorType of + {Palette uses the TChunktRNS to store alpha} + COLOR_PALETTE: + begin + TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS; + if TRNS <> nil then Chunks.RemoveChunk(TRNS) + end; + {Png allocates different memory space to hold alpha information} + {for these types} + COLOR_GRAYSCALEALPHA, COLOR_RGBALPHA: + begin + {Transform into the appropriate color type} + if ColorType = COLOR_GRAYSCALEALPHA then + ColorType := COLOR_GRAYSCALE + else ColorType := COLOR_RGB; + {Free the pointer data} + if ImageAlpha <> nil then FreeMem(ImageAlpha); + ImageAlpha := nil + end + end +end; + +{Generates alpha information} +procedure TPngObject.CreateAlpha; +var + TRNS: TChunkTRNS; +begin + {Generates depending on the color type} + with Header do + case ColorType of + {Png allocates different memory space to hold alpha information} + {for these types} + COLOR_GRAYSCALE, COLOR_RGB: + begin + {Transform into the appropriate color type} + if ColorType = COLOR_GRAYSCALE then + ColorType := COLOR_GRAYSCALEALPHA + else ColorType := COLOR_RGBALPHA; + {Allocates memory to hold alpha information} + GetMem(ImageAlpha, Integer(Width) * Integer(Height)); + FillChar(ImageAlpha^, Integer(Width) * Integer(Height), #255); + end; + {Palette uses the TChunktRNS to store alpha} + COLOR_PALETTE: + begin + {Gets/creates TRNS chunk} + if Chunks.ItemFromClass(TChunkTRNS) = nil then + TRNS := Chunks.Add(TChunkTRNS) as TChunkTRNS + else + TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS; + + {Prepares the TRNS chunk} + with TRNS do + begin + ResizeData(256); + Fillchar(PaletteValues[0], 256, 255); + fDataSize := 1 shl Header.BitDepth; + fBitTransparency := False + end {with Chunks.Add}; + end; + end {case Header.ColorType} + +end; + +{Returns transparent color} +function TPngObject.GetTransparentColor: TColor; +var + TRNS: TChunkTRNS; +begin + TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS; + {Reads the transparency chunk to get this info} + if Assigned(TRNS) then Result := TRNS.TransparentColor + else Result := 0 +end; + +{$OPTIMIZATION OFF} +procedure TPngObject.SetTransparentColor(const Value: TColor); +var + TRNS: TChunkTRNS; +begin + if HeaderPresent then + {Tests the ColorType} + case Header.ColorType of + {Not allowed for this modes} + COLOR_RGBALPHA, COLOR_GRAYSCALEALPHA: Self.RaiseError( + EPNGCannotChangeTransparent, EPNGCannotChangeTransparentText); + {Allowed} + COLOR_PALETTE, COLOR_RGB, COLOR_GRAYSCALE: + begin + TRNS := Chunks.ItemFromClass(TChunkTRNS) as TChunkTRNS; + if not Assigned(TRNS) then TRNS := Chunks.Add(TChunkTRNS) as TChunkTRNS; + + {Sets the transparency value from TRNS chunk} + TRNS.TransparentColor := {$IFDEF UseDelphi}ColorToRGB({$ENDIF}Value + {$IFDEF UseDelphi}){$ENDIF} + end {COLOR_PALETTE, COLOR_RGB, COLOR_GRAYSCALE)} + end {case} +end; + +{Returns if header is present} +function TPngObject.HeaderPresent: Boolean; +begin + Result := ((Chunks.Count <> 0) and (Chunks.Item[0] is TChunkIHDR)) +end; + +{Returns pixel for png using palette and grayscale} +function GetByteArrayPixel(const png: TPngObject; const X, Y: Integer): TColor; +var + ByteData: Byte; + DataDepth: Byte; +begin + with png, Header do + begin + {Make sure the bitdepth is not greater than 8} + DataDepth := BitDepth; + if DataDepth > 8 then DataDepth := 8; + {Obtains the byte containing this pixel} + ByteData := pByteArray(png.Scanline[Y])^[X div (8 div DataDepth)]; + {Moves the bits we need to the right} + ByteData := (ByteData shr ((8 - DataDepth) - + (X mod (8 div DataDepth)) * DataDepth)); + {Discard the unwanted pixels} + ByteData:= ByteData and ($FF shr (8 - DataDepth)); + + {For palette mode map the palette entry and for grayscale convert and + returns the intensity} + case ColorType of + COLOR_PALETTE: + with TChunkPLTE(png.Chunks.ItemFromClass(TChunkPLTE)).Item[ByteData] do + Result := rgb(GammaTable[rgbRed], GammaTable[rgbGreen], + GammaTable[rgbBlue]); + COLOR_GRAYSCALE: + begin + if BitDepth = 1 + then ByteData := GammaTable[Byte(ByteData * 255)] + else ByteData := GammaTable[Byte(ByteData * ((1 shl DataDepth) + 1))]; + Result := rgb(ByteData, ByteData, ByteData); + end; + else Result := 0; + end {case}; + end {with} +end; + +{In case vcl units are not being used} +{$IFNDEF UseDelphi} +function ColorToRGB(const Color: TColor): COLORREF; +begin + Result := Color +end; +{$ENDIF} + +{Sets a pixel for grayscale and palette pngs} +procedure SetByteArrayPixel(const png: TPngObject; const X, Y: Integer; + const Value: TColor); +const + ClearFlag: Array[1..8] of Integer = (1, 3, 0, 15, 0, 0, 0, $FF); +var + ByteData: pByte; + DataDepth: Byte; + ValEntry: Byte; +begin + with png.Header do + begin + {Map into a palette entry} + ValEntry := GetNearestPaletteIndex(Png.Palette, ColorToRGB(Value)); + + {16 bits grayscale extra bits are discarted} + DataDepth := BitDepth; + if DataDepth > 8 then DataDepth := 8; + {Gets a pointer to the byte we intend to change} + ByteData := @pByteArray(png.Scanline[Y])^[X div (8 div DataDepth)]; + {Clears the old pixel data} + ByteData^ := ByteData^ and not (ClearFlag[DataDepth] shl ((8 - DataDepth) - + (X mod (8 div DataDepth)) * DataDepth)); + + {Setting the new pixel} + ByteData^ := ByteData^ or (ValEntry shl ((8 - DataDepth) - + (X mod (8 div DataDepth)) * DataDepth)); + end {with png.Header} +end; + +{Returns pixel when png uses RGB} +function GetRGBLinePixel(const png: TPngObject; + const X, Y: Integer): TColor; +begin + with pRGBLine(png.Scanline[Y])^[X] do + Result := RGB(rgbtRed, rgbtGreen, rgbtBlue) +end; + +{Sets pixel when png uses RGB} +procedure SetRGBLinePixel(const png: TPngObject; + const X, Y: Integer; Value: TColor); +begin + with pRGBLine(png.Scanline[Y])^[X] do + begin + rgbtRed := GetRValue(Value); + rgbtGreen := GetGValue(Value); + rgbtBlue := GetBValue(Value) + end +end; + +{Returns pixel when png uses grayscale} +function GetGrayLinePixel(const png: TPngObject; + const X, Y: Integer): TColor; +var + B: Byte; +begin + B := PByteArray(png.Scanline[Y])^[X]; + Result := RGB(B, B, B); +end; + +{Sets pixel when png uses grayscale} +procedure SetGrayLinePixel(const png: TPngObject; + const X, Y: Integer; Value: TColor); +begin + PByteArray(png.Scanline[Y])^[X] := GetRValue(Value); +end; + +{Resizes the PNG image} +procedure TPngObject.Resize(const CX, CY: Integer); + function Min(const A, B: Integer): Integer; + begin + if A < B then Result := A else Result := B; + end; +var + Header: TChunkIHDR; + Line, NewBytesPerRow: Integer; + NewHandle: HBitmap; + NewDC: HDC; + NewImageData: Pointer; + NewImageAlpha: Pointer; + NewImageExtra: Pointer; +begin + if (CX > 0) and (CY > 0) then + begin + {Gets some actual information} + Header := Self.Header; + + {Creates the new image} + NewDC := CreateCompatibleDC(Header.ImageDC); + Header.BitmapInfo.bmiHeader.biWidth := cx; + Header.BitmapInfo.bmiHeader.biHeight := cy; + NewHandle := CreateDIBSection(NewDC, pBitmapInfo(@Header.BitmapInfo)^, + DIB_RGB_COLORS, NewImageData, 0, 0); + SelectObject(NewDC, NewHandle); + {$IFDEF UseDelphi}Canvas.Handle := NewDC;{$ENDIF} + NewBytesPerRow := (((Header.BitmapInfo.bmiHeader.biBitCount * cx) + 31) + and not 31) div 8; + + {Copies the image data} + for Line := 0 to Min(CY - 1, Height - 1) do + CopyMemory(Ptr(Longint(NewImageData) + (Longint(CY) - 1) * + NewBytesPerRow - (Line * NewBytesPerRow)), Scanline[Line], + Min(NewBytesPerRow, Header.BytesPerRow)); + + {Build array for alpha information, if necessary} + if (Header.ColorType = COLOR_RGBALPHA) or + (Header.ColorType = COLOR_GRAYSCALEALPHA) then + begin + GetMem(NewImageAlpha, CX * CY); + Fillchar(NewImageAlpha^, CX * CY, 255); + for Line := 0 to Min(CY - 1, Height - 1) do + CopyMemory(Ptr(Longint(NewImageAlpha) + (Line * CX)), + AlphaScanline[Line], Min(CX, Width)); + FreeMem(Header.ImageAlpha); + Header.ImageAlpha := NewImageAlpha; + end; + + {$IFDEF Store16bits} + if (Header.BitDepth = 16) then + begin + GetMem(NewImageExtra, CX * CY); + Fillchar(NewImageExtra^, CX * CY, 0); + for Line := 0 to Min(CY - 1, Height - 1) do + CopyMemory(Ptr(Longint(NewImageExtra) + (Line * CX)), + ExtraScanline[Line], Min(CX, Width)); + FreeMem(Header.ExtraImageData); + Header.ExtraImageData := NewImageExtra; + end; + {$ENDIF} + + {Deletes the old image} + DeleteObject(Header.ImageHandle); + DeleteDC(Header.ImageDC); + + {Prepares the header to get the new image} + Header.BytesPerRow := NewBytesPerRow; + Header.IHDRData.Width := CX; + Header.IHDRData.Height := CY; + Header.ImageData := NewImageData; + + {Replaces with the new image} + Header.ImageHandle := NewHandle; + Header.ImageDC := NewDC; + end + else + {The new size provided is invalid} + RaiseError(EPNGInvalidNewSize, EInvalidNewSize) + +end; + +{Sets a pixel} +procedure TPngObject.SetPixels(const X, Y: Integer; const Value: TColor); +begin + if ((X >= 0) and (X <= Width - 1)) and + ((Y >= 0) and (Y <= Height - 1)) then + with Header do + begin + if ColorType in [COLOR_GRAYSCALE, COLOR_PALETTE] then + SetByteArrayPixel(Self, X, Y, Value) + else if ColorType in [COLOR_GRAYSCALEALPHA] then + SetGrayLinePixel(Self, X, Y, Value) + else + SetRGBLinePixel(Self, X, Y, Value) + end {with} +end; + + +{Returns a pixel} +function TPngObject.GetPixels(const X, Y: Integer): TColor; +begin + if ((X >= 0) and (X <= Width - 1)) and + ((Y >= 0) and (Y <= Height - 1)) then + with Header do + begin + if ColorType in [COLOR_GRAYSCALE, COLOR_PALETTE] then + Result := GetByteArrayPixel(Self, X, Y) + else if ColorType in [COLOR_GRAYSCALEALPHA] then + Result := GetGrayLinePixel(Self, X, Y) + else + Result := GetRGBLinePixel(Self, X, Y) + end {with} + else Result := 0 +end; + +{Returns the image palette} +function TPngObject.GetPalette: HPALETTE; +begin + Result := Header.ImagePalette; +end; + +{Assigns from another TChunk} +procedure TChunkpHYs.Assign(Source: TChunk); +begin + fPPUnitY := TChunkpHYs(Source).fPPUnitY; + fPPUnitX := TChunkpHYs(Source).fPPUnitX; + fUnit := TChunkpHYs(Source).fUnit; +end; + +{Loads the chunk from a stream} +function TChunkpHYs.LoadFromStream(Stream: TStream; const ChunkName: TChunkName; + Size: Integer): Boolean; +begin + {Let ancestor load the data} + Result := inherited LoadFromStream(Stream, ChunkName, Size); + if not Result or (Size <> 9) then exit; {Size must be 9} + + {Reads data} + fPPUnitX := ByteSwap(pCardinal(Longint(Data))^); + fPPUnitY := ByteSwap(pCardinal(Longint(Data) + 4)^); + fUnit := pUnitType(Longint(Data) + 8)^; +end; + +{Saves the chunk to a stream} +function TChunkpHYs.SaveToStream(Stream: TStream): Boolean; +begin + {Update data} + ResizeData(9); {Make sure the size is 9} + pCardinal(Data)^ := ByteSwap(fPPUnitX); + pCardinal(Longint(Data) + 4)^ := ByteSwap(fPPUnitY); + pUnitType(Longint(Data) + 8)^ := fUnit; + + {Let inherited save data} + Result := inherited SaveToStream(Stream); +end; + +procedure TPngObject.DoSetPalette(Value: HPALETTE; const UpdateColors: boolean); +begin + if (Header.HasPalette) then + begin + {Update the palette entries} + if UpdateColors then + Header.PaletteToDIB(Value); + + {Resize the new palette} + SelectPalette(Header.ImageDC, Value, False); + RealizePalette(Header.ImageDC); + + {Replaces} + DeleteObject(Header.ImagePalette); + Header.ImagePalette := Value; + end +end; + +{Set palette based on a windows palette handle} +procedure TPngObject.SetPalette(Value: HPALETTE); +begin + DoSetPalette(Value, true); +end; + +{Returns the library version} +function TPNGObject.GetLibraryVersion: String; +begin + Result := LibraryVersion +end; + +initialization + {Initialize} + ChunkClasses := nil; + {crc table has not being computed yet} + crc_table_computed := FALSE; + {Register the necessary chunks for png} + RegisterCommonChunks; + {Registers TPNGObject to use with TPicture} + {$IFDEF UseDelphi}{$IFDEF RegisterGraphic} + TPicture.RegisterFileFormat('PNG', 'Portable Network Graphics', TPNGObject); + {$ENDIF}{$ENDIF} +finalization + {$IFDEF UseDelphi}{$IFDEF RegisterGraphic} + TPicture.UnregisterGraphicClass(TPNGObject); + {$ENDIF}{$ENDIF} + {Free chunk classes} + FreeChunkClassList; +end. + + diff --git a/thirparty/pnglang.pas b/thirparty/pnglang.pas new file mode 100644 index 0000000..57965d0 --- /dev/null +++ b/thirparty/pnglang.pas @@ -0,0 +1,355 @@ +{Portable Network Graphics Delphi Language Info (24 July 2002)} + +{Feel free to change the text bellow to adapt to your language} +{Also if you have a translation to other languages and want to} +{share it, send me: gubadaud@terra.com.br } +unit pnglang; + +interface + +{$DEFINE English} +{.$DEFINE Polish} +{.$DEFINE Portuguese} +{.$DEFINE German} +{.$DEFINE French} +{.$DEFINE Slovenian} + +{Language strings for english} +resourcestring + {$IFDEF Polish} + EPngInvalidCRCText = 'Ten obraz "Portable Network Graphics" jest nieprawid³owy ' + + 'poniewa¿ zawiera on nieprawid³owe czêœci danych (b³¹d crc)'; + EPNGInvalidIHDRText = 'Obraz "Portable Network Graphics" nie mo¿e zostaæ ' + + 'wgrany poniewa¿ jedna z czêœci danych (ihdr) mo¿e byæ uszkodzona'; + EPNGMissingMultipleIDATText = 'Obraz "Portable Network Graphics" jest ' + + 'nieprawid³owy poniewa¿ brakuje w nim czêœci obrazu.'; + EPNGZLIBErrorText = 'Nie mo¿na zdekompresowaæ obrazu poniewa¿ zawiera ' + + 'b³êdnie zkompresowane dane.'#13#10 + ' Opis b³êdu: '; + EPNGInvalidPaletteText = 'Obraz "Portable Network Graphics" zawiera ' + + 'niew³aœciw¹ paletê.'; + EPNGInvalidFileHeaderText = 'Plik który jest odczytywany jest nieprawid³owym '+ + 'obrazem "Portable Network Graphics" poniewa¿ zawiera nieprawid³owy nag³ówek.' + + ' Plik mo¿ê byæ uszkodzony, spróbuj pobraæ go ponownie.'; + EPNGIHDRNotFirstText = 'Obraz "Portable Network Graphics" nie jest ' + + 'obs³ugiwany lub mo¿e byæ niew³aœciwy.'#13#10 + '(stopka IHDR nie jest pierwsza)'; + EPNGNotExistsText = 'Plik png nie mo¿e zostaæ wgrany poniewa¿ nie ' + + 'istnieje.'; + EPNGSizeExceedsText = 'Obraz "Portable Network Graphics" nie jest ' + + 'obs³ugiwany poniewa¿ jego szerokoœæ lub wysokoœæ przekracza maksimum ' + + 'rozmiaru, który wynosi 65535 pikseli d³ugoœci.'; + EPNGUnknownPalEntryText = 'Nie znaleziono wpisów palety.'; + EPNGMissingPaletteText = 'Obraz "Portable Network Graphics" nie mo¿e zostaæ ' + + 'wgrany poniewa¿ u¿ywa tabeli kolorów której brakuje.'; + EPNGUnknownCriticalChunkText = 'Obraz "Portable Network Graphics" ' + + 'zawiera nieznan¹ krytyczn¹ czêœæ która nie mo¿e zostaæ odkodowana.'; + EPNGUnknownCompressionText = 'Obraz "Portable Network Graphics" jest ' + + 'skompresowany nieznanym schemat który nie mo¿e zostaæ odszyfrowany.'; + EPNGUnknownInterlaceText = 'Obraz "Portable Network Graphics" u¿ywa ' + + 'nie znany schamat przeplatania który nie mo¿e zostaæ odszyfrowany.'; + EPNGCannotAssignChunkText = 'Stopka mysi byæ kompatybilna aby zosta³a wyznaczona.'; + EPNGUnexpectedEndText = 'Obraz "Portable Network Graphics" jest nieprawid³owy ' + + 'poniewa¿ dekoder znalaz³ niespodziewanie koniec pliku.'; + EPNGNoImageDataText = 'Obraz "Portable Network Graphics" nie zawiera' + + 'danych.'; + EPNGCannotAddChunkText = 'Program próbuje dodaæ krytyczn¹ ' + + 'stopkê do aktualnego obrazu co jest niedozwolone.'; + EPNGCannotAddInvalidImageText = 'Nie mo¿na dodaæ nowej stopki ' + + 'poniewa¿ aktualny obraz jest nieprawid³owy.'; + EPNGCouldNotLoadResourceText = 'Obraz png nie mo¿e zostaæ za³adowany z' + + 'zasobów o podanym ID.'; + EPNGOutMemoryText = 'Niektóre operacje nie mog¹ zostaæ zrealizowane poniewa¿ ' + + 'systemowi brakuje zasobów. Zamknij kilka okien i spróbuj ponownie.'; + EPNGCannotChangeTransparentText = 'Ustawienie bitu przezroczystego koloru jest ' + + 'zabronione dla obrazów png zawieraj¹cych wartoœæ alpha dla ka¿dego piksela ' + + '(COLOR_RGBALPHA i COLOR_GRAYSCALEALPHA)'; + EPNGHeaderNotPresentText = 'Ta operacja jest niedozwolona poniewa¿ ' + + 'aktualny obraz zawiera niew³aœciwy nag³ówek.'; + EInvalidNewSize = 'The new size provided for image resizing is invalid.'; + EInvalidSpec = 'The "Portable Network Graphics" could not be created ' + + 'because invalid image type parameters have being provided.'; + {$ENDIF} + + {$IFDEF English} + EPngInvalidCRCText = 'This "Portable Network Graphics" image is not valid ' + + 'because it contains invalid pieces of data (crc error)'; + EPNGInvalidIHDRText = 'The "Portable Network Graphics" image could not be ' + + 'loaded because one of its main piece of data (ihdr) might be corrupted'; + EPNGMissingMultipleIDATText = 'This "Portable Network Graphics" image is ' + + 'invalid because it has missing image parts.'; + EPNGZLIBErrorText = 'Could not decompress the image because it contains ' + + 'invalid compressed data.'#13#10 + ' Description: '; + EPNGInvalidPaletteText = 'The "Portable Network Graphics" image contains ' + + 'an invalid palette.'; + EPNGInvalidFileHeaderText = 'The file being readed is not a valid '+ + '"Portable Network Graphics" image because it contains an invalid header.' + + ' This file may be corruped, try obtaining it again.'; + EPNGIHDRNotFirstText = 'This "Portable Network Graphics" image is not ' + + 'supported or it might be invalid.'#13#10 + '(IHDR chunk is not the first)'; + EPNGNotExistsText = 'The png file could not be loaded because it does not ' + + 'exists.'; + EPNGSizeExceedsText = 'This "Portable Network Graphics" image is not ' + + 'supported because either it''s width or height exceeds the maximum ' + + 'size, which is 65535 pixels length.'; + EPNGUnknownPalEntryText = 'There is no such palette entry.'; + EPNGMissingPaletteText = 'This "Portable Network Graphics" could not be ' + + 'loaded because it uses a color table which is missing.'; + EPNGUnknownCriticalChunkText = 'This "Portable Network Graphics" image ' + + 'contains an unknown critical part which could not be decoded.'; + EPNGUnknownCompressionText = 'This "Portable Network Graphics" image is ' + + 'encoded with an unknown compression scheme which could not be decoded.'; + EPNGUnknownInterlaceText = 'This "Portable Network Graphics" image uses ' + + 'an unknown interlace scheme which could not be decoded.'; + EPNGCannotAssignChunkText = 'The chunks must be compatible to be assigned.'; + EPNGUnexpectedEndText = 'This "Portable Network Graphics" image is invalid ' + + 'because the decoder found an unexpected end of the file.'; + EPNGNoImageDataText = 'This "Portable Network Graphics" image contains no ' + + 'data.'; + EPNGCannotAddChunkText = 'The program tried to add a existent critical ' + + 'chunk to the current image which is not allowed.'; + EPNGCannotAddInvalidImageText = 'It''s not allowed to add a new chunk ' + + 'because the current image is invalid.'; + EPNGCouldNotLoadResourceText = 'The png image could not be loaded from the ' + + 'resource ID.'; + EPNGOutMemoryText = 'Some operation could not be performed because the ' + + 'system is out of resources. Close some windows and try again.'; + EPNGCannotChangeTransparentText = 'Setting bit transparency color is not ' + + 'allowed for png images containing alpha value for each pixel ' + + '(COLOR_RGBALPHA and COLOR_GRAYSCALEALPHA)'; + EPNGHeaderNotPresentText = 'This operation is not valid because the ' + + 'current image contains no valid header.'; + EInvalidNewSize = 'The new size provided for image resizing is invalid.'; + EInvalidSpec = 'The "Portable Network Graphics" could not be created ' + + 'because invalid image type parameters have being provided.'; + {$ENDIF} + {$IFDEF Portuguese} + EPngInvalidCRCText = 'Essa imagem "Portable Network Graphics" não é válida ' + + 'porque contém chunks inválidos de dados (erro crc)'; + EPNGInvalidIHDRText = 'A imagem "Portable Network Graphics" não pode ser ' + + 'carregada porque um dos seus chunks importantes (ihdr) pode estar '+ + 'inválido'; + EPNGMissingMultipleIDATText = 'Essa imagem "Portable Network Graphics" é ' + + 'inválida porque tem chunks de dados faltando.'; + EPNGZLIBErrorText = 'Não foi possível descomprimir os dados da imagem ' + + 'porque ela contém dados inválidos.'#13#10 + ' Descrição: '; + EPNGInvalidPaletteText = 'A imagem "Portable Network Graphics" contém ' + + 'uma paleta inválida.'; + EPNGInvalidFileHeaderText = 'O arquivo sendo lido não é uma imagem '+ + '"Portable Network Graphics" válida porque contém um cabeçalho inválido.' + + ' O arquivo pode estar corrompida, tente obter ela novamente.'; + EPNGIHDRNotFirstText = 'Essa imagem "Portable Network Graphics" não é ' + + 'suportada ou pode ser inválida.'#13#10 + '(O chunk IHDR não é o ' + + 'primeiro)'; + EPNGNotExistsText = 'A imagem png não pode ser carregada porque ela não ' + + 'existe.'; + EPNGSizeExceedsText = 'Essa imagem "Portable Network Graphics" não é ' + + 'suportada porque a largura ou a altura ultrapassam o tamanho máximo, ' + + 'que é de 65535 pixels de diâmetro.'; + EPNGUnknownPalEntryText = 'Não existe essa entrada de paleta.'; + EPNGMissingPaletteText = 'Essa imagem "Portable Network Graphics" não pode ' + + 'ser carregada porque usa uma paleta que está faltando.'; + EPNGUnknownCriticalChunkText = 'Essa imagem "Portable Network Graphics" ' + + 'contém um chunk crítico desconheçido que não pode ser decodificado.'; + EPNGUnknownCompressionText = 'Essa imagem "Portable Network Graphics" está ' + + 'codificada com um esquema de compressão desconheçido e não pode ser ' + + 'decodificada.'; + EPNGUnknownInterlaceText = 'Essa imagem "Portable Network Graphics" usa um ' + + 'um esquema de interlace que não pode ser decodificado.'; + EPNGCannotAssignChunkText = 'Os chunk devem ser compatíveis para serem ' + + 'copiados.'; + EPNGUnexpectedEndText = 'Essa imagem "Portable Network Graphics" é ' + + 'inválida porque o decodificador encontrou um fim inesperado.'; + EPNGNoImageDataText = 'Essa imagem "Portable Network Graphics" não contém ' + + 'dados.'; + EPNGCannotAddChunkText = 'O programa tentou adicionar um chunk crítico ' + + 'já existente para a imagem atual, oque não é permitido.'; + EPNGCannotAddInvalidImageText = 'Não é permitido adicionar um chunk novo ' + + 'porque a imagem atual é inválida.'; + EPNGCouldNotLoadResourceText = 'A imagem png não pode ser carregada apartir' + + ' do resource.'; + EPNGOutMemoryText = 'Uma operação não pode ser completada porque o sistema ' + + 'está sem recursos. Fecha algumas janelas e tente novamente.'; + EPNGCannotChangeTransparentText = 'Definir transparência booleana não é ' + + 'permitido para imagens png contendo informação alpha para cada pixel ' + + '(COLOR_RGBALPHA e COLOR_GRAYSCALEALPHA)'; + EPNGHeaderNotPresentText = 'Essa operação não é válida porque a ' + + 'imagem atual não contém um cabeçalho válido.'; + EInvalidNewSize = 'O novo tamanho fornecido para o redimensionamento de ' + + 'imagem é inválido.'; + EInvalidSpec = 'A imagem "Portable Network Graphics" não pode ser criada ' + + 'porque parâmetros de tipo de imagem inválidos foram usados.'; + {$ENDIF} + {Language strings for German} + {$IFDEF German} + EPngInvalidCRCText = 'Dieses "Portable Network Graphics" Bild ist ' + + 'ungültig, weil Teile der Daten fehlerhaft sind (CRC-Fehler)'; + EPNGInvalidIHDRText = 'Dieses "Portable Network Graphics" Bild konnte ' + + 'nicht geladen werden, weil wahrscheinlich einer der Hauptdatenbreiche ' + + '(IHDR) beschädigt ist'; + EPNGMissingMultipleIDATText = 'Dieses "Portable Network Graphics" Bild ' + + 'ist ungültig, weil Grafikdaten fehlen.'; + EPNGZLIBErrorText = 'Die Grafik konnte nicht entpackt werden, weil Teile der ' + + 'komprimierten Daten fehlerhaft sind.'#13#10 + ' Beschreibung: '; + EPNGInvalidPaletteText = 'Das "Portable Network Graphics" Bild enthält ' + + 'eine ungültige Palette.'; + EPNGInvalidFileHeaderText = 'Die Datei, die gelesen wird, ist kein ' + + 'gültiges "Portable Network Graphics" Bild, da es keinen gültigen ' + + 'Header enthält. Die Datei könnte beschädigt sein, versuchen Sie, ' + + 'eine neue Kopie zu bekommen.'; + EPNGIHDRNotFirstText = 'Dieses "Portable Network Graphics" Bild wird ' + + 'nicht unterstützt oder ist ungültig.'#13#10 + + '(Der IHDR-Abschnitt ist nicht der erste Abschnitt in der Datei).'; + EPNGNotExistsText = 'Die PNG Datei konnte nicht geladen werden, da sie ' + + 'nicht existiert.'; + EPNGSizeExceedsText = 'Dieses "Portable Network Graphics" Bild wird nicht ' + + 'unterstützt, weil entweder seine Breite oder seine Höhe das Maximum von ' + + '65535 Pixeln überschreitet.'; + EPNGUnknownPalEntryText = 'Es gibt keinen solchen Palettenwert.'; + EPNGMissingPaletteText = 'Dieses "Portable Network Graphics" Bild konnte ' + + 'nicht geladen werden, weil die benötigte Farbtabelle fehlt.'; + EPNGUnknownCriticalChunkText = 'Dieses "Portable Network Graphics" Bild ' + + 'enhält einen unbekannten aber notwendigen Teil, welcher nicht entschlüsselt ' + + 'werden kann.'; + EPNGUnknownCompressionText = 'Dieses "Portable Network Graphics" Bild ' + + 'wurde mit einem unbekannten Komprimierungsalgorithmus kodiert, welcher ' + + 'nicht entschlüsselt werden kann.'; + EPNGUnknownInterlaceText = 'Dieses "Portable Network Graphics" Bild ' + + 'benutzt ein unbekanntes Interlace-Schema, welches nicht entschlüsselt ' + + 'werden kann.'; + EPNGCannotAssignChunkText = 'Die Abschnitte müssen kompatibel sein, damit ' + + 'sie zugewiesen werden können.'; + EPNGUnexpectedEndText = 'Dieses "Portable Network Graphics" Bild ist ' + + 'ungültig: Der Dekoder ist unerwartete auf das Ende der Datei gestoßen.'; + EPNGNoImageDataText = 'Dieses "Portable Network Graphics" Bild enthält ' + + 'keine Daten.'; + EPNGCannotAddChunkText = 'Das Programm versucht einen existierenden und ' + + 'notwendigen Abschnitt zum aktuellen Bild hinzuzufügen. Dies ist nicht ' + + 'zulässig.'; + EPNGCannotAddInvalidImageText = 'Es ist nicht zulässig, einem ungültigen ' + + 'Bild einen neuen Abschnitt hinzuzufügen.'; + EPNGCouldNotLoadResourceText = 'Das PNG Bild konnte nicht aus den ' + + 'Resourcendaten geladen werden.'; + EPNGOutMemoryText = 'Es stehen nicht genügend Resourcen im System zur ' + + 'Verfügung, um die Operation auszuführen. Schließen Sie einige Fenster '+ + 'und versuchen Sie es erneut.'; + EPNGCannotChangeTransparentText = 'Das Setzen der Bit-' + + 'Transparent-Farbe ist für PNG-Images die Alpha-Werte für jedes ' + + 'Pixel enthalten (COLOR_RGBALPHA und COLOR_GRAYSCALEALPHA) nicht ' + + 'zulässig'; + EPNGHeaderNotPresentText = 'Die Datei, die gelesen wird, ist kein ' + + 'gültiges "Portable Network Graphics" Bild, da es keinen gültigen ' + + 'Header enthält.'; + EInvalidNewSize = 'The new size provided for image resizing is invalid.'; + EInvalidSpec = 'The "Portable Network Graphics" could not be created ' + + 'because invalid image type parameters have being provided.'; + {$ENDIF} + {Language strings for French} + {$IFDEF French} + EPngInvalidCRCText = 'Cette image "Portable Network Graphics" n''est pas valide ' + + 'car elle contient des données invalides (erreur crc)'; + EPNGInvalidIHDRText = 'Cette image "Portable Network Graphics" n''a pu être ' + + 'chargée car l''une de ses principale donnée (ihdr) doit être corrompue'; + EPNGMissingMultipleIDATText = 'Cette image "Portable Network Graphics" est ' + + 'invalide car elle contient des parties d''image manquantes.'; + EPNGZLIBErrorText = 'Impossible de décompresser l''image car elle contient ' + + 'des données compressées invalides.'#13#10 + ' Description: '; + EPNGInvalidPaletteText = 'L''image "Portable Network Graphics" contient ' + + 'une palette invalide.'; + EPNGInvalidFileHeaderText = 'Le fichier actuellement lu est une image '+ + '"Portable Network Graphics" invalide car elle contient un en-tête invalide.' + + ' Ce fichier doit être corrompu, essayer de l''obtenir à nouveau.'; + EPNGIHDRNotFirstText = 'Cette image "Portable Network Graphics" n''est pas ' + + 'supportée ou doit être invalide.'#13#10 + '(la partie IHDR n''est pas la première)'; + EPNGNotExistsText = 'Le fichier png n''a pu être chargé car il n''éxiste pas.'; + EPNGSizeExceedsText = 'Cette image "Portable Network Graphics" n''est pas supportée ' + + 'car sa longueur ou sa largeur excède la taille maximale, qui est de 65535 pixels.'; + EPNGUnknownPalEntryText = 'Il n''y a aucune entrée pour cette palette.'; + EPNGMissingPaletteText = 'Cette image "Portable Network Graphics" n''a pu être ' + + 'chargée car elle utilise une table de couleur manquante.'; + EPNGUnknownCriticalChunkText = 'Cette image "Portable Network Graphics" ' + + 'contient une partie critique inconnue qui n'' pu être décodée.'; + EPNGUnknownCompressionText = 'Cette image "Portable Network Graphics" est ' + + 'encodée à l''aide d''un schémas de compression inconnu qui ne peut être décodé.'; + EPNGUnknownInterlaceText = 'Cette image "Portable Network Graphics" utilise ' + + 'un schémas d''entrelacement inconnu qui ne peut être décodé.'; + EPNGCannotAssignChunkText = 'Ce morceau doit être compatible pour être assigné.'; + EPNGUnexpectedEndText = 'Cette image "Portable Network Graphics" est invalide ' + + 'car le decodeur est arrivé à une fin de fichier non attendue.'; + EPNGNoImageDataText = 'Cette image "Portable Network Graphics" ne contient pas de ' + + 'données.'; + EPNGCannotAddChunkText = 'Le programme a essayé d''ajouter un morceau critique existant ' + + 'à l''image actuelle, ce qui n''est pas autorisé.'; + EPNGCannotAddInvalidImageText = 'Il n''est pas permis d''ajouter un nouveau morceau ' + + 'car l''image actuelle est invalide.'; + EPNGCouldNotLoadResourceText = 'L''image png n''a pu être chargée depuis ' + + 'l''ID ressource.'; + EPNGOutMemoryText = 'Certaines opérations n''ont pu être effectuée car le ' + + 'système n''a plus de ressources. Fermez quelques fenêtres et essayez à nouveau.'; + EPNGCannotChangeTransparentText = 'Définir le bit de transparence n''est pas ' + + 'permis pour des images png qui contiennent une valeur alpha pour chaque pixel ' + + '(COLOR_RGBALPHA et COLOR_GRAYSCALEALPHA)'; + EPNGHeaderNotPresentText = 'Cette opération n''est pas valide car l''image ' + + 'actuelle ne contient pas de header valide.'; + EPNGAlphaNotSupportedText = 'Le type de couleur de l''image "Portable Network Graphics" actuelle ' + + 'contient déjà des informations alpha ou il ne peut être converti.'; + EInvalidNewSize = 'The new size provided for image resizing is invalid.'; + EInvalidSpec = 'The "Portable Network Graphics" could not be created ' + + 'because invalid image type parameters have being provided.'; + {$ENDIF} + {Language strings for slovenian} + {$IFDEF Slovenian} + EPngInvalidCRCText = 'Ta "Portable Network Graphics" slika je neveljavna, ' + + 'ker vsebuje neveljavne dele podatkov (CRC napaka).'; + EPNGInvalidIHDRText = 'Slike "Portable Network Graphics" ni bilo možno ' + + 'naložiti, ker je eden od glavnih delov podatkov (IHDR) verjetno pokvarjen.'; + EPNGMissingMultipleIDATText = 'Ta "Portable Network Graphics" slika je ' + + 'naveljavna, ker manjkajo deli slike.'; + EPNGZLIBErrorText = 'Ne morem raztegniti slike, ker vsebuje ' + + 'neveljavne stisnjene podatke.'#13#10 + ' Opis: '; + EPNGInvalidPaletteText = 'Slika "Portable Network Graphics" vsebuje ' + + 'neveljavno barvno paleto.'; + EPNGInvalidFileHeaderText = 'Datoteka za branje ni veljavna '+ + '"Portable Network Graphics" slika, ker vsebuje neveljavno glavo.' + + ' Datoteka je verjetno pokvarjena, poskusite jo ponovno naložiti.'; + EPNGIHDRNotFirstText = 'Ta "Portable Network Graphics" slika ni ' + + 'podprta ali pa je neveljavna.'#13#10 + '(IHDR del datoteke ni prvi).'; + EPNGNotExistsText = 'Ne morem naložiti png datoteke, ker ta ne ' + + 'obstaja.'; + EPNGSizeExceedsText = 'Ta "Portable Network Graphics" slika ni ' + + 'podprta, ker ali njena širina ali višina presega najvecjo možno vrednost ' + + '65535 pik.'; + EPNGUnknownPalEntryText = 'Slika nima vnešene take barvne palete.'; + EPNGMissingPaletteText = 'Te "Portable Network Graphics" ne morem ' + + 'naložiti, ker uporablja manjkajoco barvno paleto.'; + EPNGUnknownCriticalChunkText = 'Ta "Portable Network Graphics" slika ' + + 'vsebuje neznan kriticni del podatkov, ki ga ne morem prebrati.'; + EPNGUnknownCompressionText = 'Ta "Portable Network Graphics" slika je ' + + 'kodirana z neznano kompresijsko shemo, ki je ne morem prebrati.'; + EPNGUnknownInterlaceText = 'Ta "Portable Network Graphics" slika uporablja ' + + 'neznano shemo za preliv, ki je ne morem prebrati.'; + EPNGCannotAssignChunkText = Košcki morajo biti med seboj kompatibilni za prireditev vrednosti.'; + EPNGUnexpectedEndText = 'Ta "Portable Network Graphics" slika je neveljavna, ' + + 'ker je bralnik prišel do nepricakovanega konca datoteke.'; + EPNGNoImageDataText = 'Ta "Portable Network Graphics" ne vsebuje nobenih ' + + 'podatkov.'; + EPNGCannotAddChunkText = 'Program je poskusil dodati obstojeci kriticni ' + + 'kos podatkov k trenutni sliki, kar ni dovoljeno.'; + EPNGCannotAddInvalidImageText = 'Ni dovoljeno dodati nov kos podatkov, ' + + 'ker trenutna slika ni veljavna.'; + EPNGCouldNotLoadResourceText = 'Ne morem naložiti png slike iz ' + + 'skladišca.'; + EPNGOutMemoryText = 'Ne morem izvesti operacije, ker je ' + + 'sistem ostal brez resorjev. Zaprite nekaj oken in poskusite znova.'; + EPNGCannotChangeTransparentText = 'Ni dovoljeno nastaviti prosojnosti posamezne barve ' + + 'za png slike, ki vsebujejo alfa prosojno vrednost za vsako piko ' + + '(COLOR_RGBALPHA and COLOR_GRAYSCALEALPHA)'; + EPNGHeaderNotPresentText = 'Ta operacija ni veljavna, ker ' + + 'izbrana slika ne vsebuje veljavne glave.'; + EInvalidNewSize = 'The new size provided for image resizing is invalid.'; + EInvalidSpec = 'The "Portable Network Graphics" could not be created ' + + 'because invalid image type parameters have being provided.'; + {$ENDIF} + + +implementation + +end. diff --git a/thirparty/versions.inc b/thirparty/versions.inc new file mode 100644 index 0000000..eaf8e42 --- /dev/null +++ b/thirparty/versions.inc @@ -0,0 +1,1380 @@ +{$IFNDEF JEDI_INC} +{$DEFINE JEDI_INC} + +{**************************************************************************************************} +{ } +{ The contents of this file are 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/ } +{ } +{ 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. } +{ } +{ The Original Code is: jedi.inc. } +{ The Initial Developer of the Original Code is Project JEDI http://www.delphi-jedi.org } +{ } +{ Alternatively, the contents of this file may be used under the terms of the GNU Lesser General } +{ Public License (the "LGPL License"), in which case the provisions of the LGPL License are } +{ applicable instead of those above. If you wish to allow use of your version of this file only } +{ under the terms of the LGPL License and not to allow others to use your version of this file } +{ under the MPL, indicate your decision by deleting the provisions above and replace them with } +{ the notice and other provisions required by the LGPL License. If you do not delete the } +{ provisions above, a recipient may use your version of this file under either the MPL or the } +{ LGPL License. } +{ } +{ For more information about the LGPL: http://www.gnu.org/copyleft/lesser.html } +{ } +{**************************************************************************************************} +{ } +{ This file defines various generic compiler directives used in different libraries, e.g. in the } +{ JEDI Code Library (JCL) and JEDI Visual Component Library Library (JVCL). The directives in } +{ this file are of generic nature and consist mostly of mappings from the VERXXX directives } +{ defined by Delphi, C++Builder and FPC to friendly names such as DELPHI5 and } +{ SUPPORTS_WIDESTRING. These friendly names are subsequently used in the libraries to test for } +{ compiler versions and/or whether the compiler supports certain features (such as widestrings or } +{ 64 bit integers. The libraries provide an additional, library specific, include file. For the } +{ JCL e.g. this is jcl.inc. These files should be included in source files instead of this file } +{ (which is pulled in automatically). } +{ } +{**************************************************************************************************} +{ } +{ Last modified: $Date:: 2011-09-02 22:19:11 +0200 (ven., 02 sept. 2011) $ } +{ Revision: $Rev:: 140 $ } +{ Author: $Author:: outchy $ } +{ } +{**************************************************************************************************} + +(* + +- Development environment directives + + This file defines two directives to indicate which development environment the + library is being compiled with. Currently this can either be Delphi, Kylix, + C++Builder or FPC. + + Directive Description + ------------------------------------------------------------------------------ + DELPHI Defined if compiled with Delphi + KYLIX Defined if compiled with Kylix + DELPHICOMPILER Defined if compiled with Delphi or Kylix/Delphi + BCB Defined if compiled with C++Builder + CPPBUILDER Defined if compiled with C++Builder (alias for BCB) + BCBCOMPILER Defined if compiled with C++Builder or Kylix/C++ + DELPHILANGUAGE Defined if compiled with Delphi, Kylix or C++Builder + BORLAND Defined if compiled with Delphi, Kylix or C++Builder + FPC Defined if compiled with FPC + +- Platform Directives + + Platform directives are not all explicitly defined in this file, some are + defined by the compiler itself. They are listed here only for completeness. + + Directive Description + ------------------------------------------------------------------------------ + WIN32 Defined when target platform is 32 bit Windows + WIN64 Defined when target platform is 64 bit Windows + MSWINDOWS Defined when target platform is 32 bit Windows + LINUX Defined when target platform is Linux + UNIX Defined when target platform is Unix-like (including Linux) + CLR Defined when target platform is .NET + +- Architecture directives. These are auto-defined by FPC + CPU32 and CPU64 are mostly for generic pointer size dependant differences rather + than for a specific architecture. + + CPU386 Defined when target platform is native x86 (win32) + CPUx86_64 Defined when target platform is native x86_64 (win64) + CPU32 Defined when target is 32-bit + CPU64 Defined when target is 64-bit + CPUASM Defined when target assembler is available + +- Visual library Directives + + The following directives indicate for a visual library. In a Delphi/BCB + (Win32) application you need to define the VisualCLX symbol in the project + options, if you want to use the VisualCLX library. Alternatively you can use + the IDE expert, which is distributed with the JCL to do this automatically. + + Directive Description + ------------------------------------------------------------------------------ + VCL Defined for Delphi/BCB (Win32) exactly if VisualCLX is not defined + VisualCLX Defined for Kylix; needs to be defined for Delphi/BCB to + use JCL with VisualCLX applications. + + +- Other cross-platform related defines + + These symbols are intended to help in writing portable code. + + Directive Description + ------------------------------------------------------------------------------ + PUREPASCAL Code is machine-independent (as opposed to assembler code) + Win32API Code is specific for the Win32 API; + use instead of "{$IFNDEF CLR} {$IFDEF MSWINDOWS}" constructs + + +- Delphi Versions + + The following directives are direct mappings from the VERXXX directives to a + friendly name of the associated compiler. These directives are only defined if + the compiler is Delphi (ie DELPHI is defined). + + Directive Description + ------------------------------------------------------------------------------ + DELPHI1 Defined when compiling with Delphi 1 (Codename WASABI/MANGO) + DELPHI2 Defined when compiling with Delphi 2 (Codename POLARIS) + DELPHI3 Defined when compiling with Delphi 3 (Codename IVORY) + DELPHI4 Defined when compiling with Delphi 4 (Codename ALLEGRO) + DELPHI5 Defined when compiling with Delphi 5 (Codename ARGUS) + DELPHI6 Defined when compiling with Delphi 6 (Codename ILLIAD) + DELPHI7 Defined when compiling with Delphi 7 (Codename AURORA) + DELPHI8 Defined when compiling with Delphi 8 (Codename OCTANE) + DELPHI2005 Defined when compiling with Delphi 2005 (Codename DIAMONDBACK) + DELPHI9 Alias for DELPHI2005 + DELPHI10 Defined when compiling with Delphi 2006 (Codename DEXTER) + DELPHI2006 Alias for DELPHI10 + DELPHI11 Defined when compiling with Delphi 2007 for Win32 (Codename SPACELY) + DELPHI2007 Alias for DELPHI11 + DELPHI12 Defined when compiling with Delphi 2009 for Win32 (Codename TIBURON) + DELPHI2009 Alias for DELPHI12 + DELPHI14 Defined when compiling with Delphi 2010 for Win32 (Codename WEAVER) + DELPHI2010 Alias for DELPHI14 + DELPHI15 Defined when compiling with Delphi XE for Win32 (Codename FULCRUM) + DELPHIXE Alias for DELPHI15 + DELPHI16 Defined when compiling with Delphi XE2 for Win32 (Codename PULSAR) + DELPHIXE2 Alias for DELPHI16 + DELPHI1_UP Defined when compiling with Delphi 1 or higher + DELPHI2_UP Defined when compiling with Delphi 2 or higher + DELPHI3_UP Defined when compiling with Delphi 3 or higher + DELPHI4_UP Defined when compiling with Delphi 4 or higher + DELPHI5_UP Defined when compiling with Delphi 5 or higher + DELPHI6_UP Defined when compiling with Delphi 6 or higher + DELPHI7_UP Defined when compiling with Delphi 7 or higher + DELPHI8_UP Defined when compiling with Delphi 8 or higher + DELPHI2005_UP Defined when compiling with Delphi 2005 or higher + DELPHI9_UP Alias for DELPHI2005_UP + DELPHI10_UP Defined when compiling with Delphi 2006 or higher + DELPHI2006_UP Alias for DELPHI10_UP + DELPHI11_UP Defined when compiling with Delphi 2007 for Win32 or higher + DELPHI2007_UP Alias for DELPHI11_UP + DELPHI12_UP Defined when compiling with Delphi 2009 for Win32 or higher + DELPHI2009_UP Alias for DELPHI12_UP + DELPHI14_UP Defined when compiling with Delphi 2010 for Win32 or higher + DELPHI2010_UP Alias for DELPHI14_UP + DELPHI15_UP Defined when compiling with Delphi XE for Win32 or higher + DELPHIXE_UP Alias for DELPHI15_UP + DELPHI16_UP Defined when compiling with Delphi XE2 for Win32 or higher + DELPHIXE2_UP Alias for DELPHI16_UP + + +- Kylix Versions + + The following directives are direct mappings from the VERXXX directives to a + friendly name of the associated compiler. These directives are only defined if + the compiler is Kylix (ie KYLIX is defined). + + Directive Description + ------------------------------------------------------------------------------ + KYLIX1 Defined when compiling with Kylix 1 + KYLIX2 Defined when compiling with Kylix 2 + KYLIX3 Defined when compiling with Kylix 3 (Codename CORTEZ) + KYLIX1_UP Defined when compiling with Kylix 1 or higher + KYLIX2_UP Defined when compiling with Kylix 2 or higher + KYLIX3_UP Defined when compiling with Kylix 3 or higher + + +- Delphi Compiler Versions (Delphi / Kylix, not in BCB mode) + + Directive Description + ------------------------------------------------------------------------------ + DELPHICOMPILER1 Defined when compiling with Delphi 1 + DELPHICOMPILER2 Defined when compiling with Delphi 2 + DELPHICOMPILER3 Defined when compiling with Delphi 3 + DELPHICOMPILER4 Defined when compiling with Delphi 4 + DELPHICOMPILER5 Defined when compiling with Delphi 5 + DELPHICOMPILER6 Defined when compiling with Delphi 6 or Kylix 1, 2 or 3 + DELPHICOMPILER7 Defined when compiling with Delphi 7 + DELPHICOMPILER8 Defined when compiling with Delphi 8 + DELPHICOMPILER9 Defined when compiling with Delphi 2005 + DELPHICOMPILER10 Defined when compiling with Delphi Personality of BDS 4.0 + DELPHICOMPILER11 Defined when compiling with Delphi 2007 for Win32 + DELPHICOMPILER12 Defined when compiling with Delphi Personality of BDS 6.0 + DELPHICOMPILER14 Defined when compiling with Delphi Personality of BDS 7.0 + DELPHICOMPILER15 Defined when compiling with Delphi Personality of BDS 8.0 + DELPHICOMPILER16 Defined when compiling with Delphi Personality of BDS 9.0 + DELPHICOMPILER1_UP Defined when compiling with Delphi 1 or higher + DELPHICOMPILER2_UP Defined when compiling with Delphi 2 or higher + DELPHICOMPILER3_UP Defined when compiling with Delphi 3 or higher + DELPHICOMPILER4_UP Defined when compiling with Delphi 4 or higher + DELPHICOMPILER5_UP Defined when compiling with Delphi 5 or higher + DELPHICOMPILER6_UP Defined when compiling with Delphi 6 or Kylix 1, 2 or 3 or higher + DELPHICOMPILER7_UP Defined when compiling with Delphi 7 or higher + DELPHICOMPILER8_UP Defined when compiling with Delphi 8 or higher + DELPHICOMPILER9_UP Defined when compiling with Delphi 2005 + DELPHICOMPILER10_UP Defined when compiling with Delphi 2006 or higher + DELPHICOMPILER11_UP Defined when compiling with Delphi 2007 for Win32 or higher + DELPHICOMPILER12_UP Defined when compiling with Delphi 2009 for Win32 or higher + DELPHICOMPILER14_UP Defined when compiling with Delphi 2010 for Win32 or higher + DELPHICOMPILER15_UP Defined when compiling with Delphi XE for Win32 or higher + DELPHICOMPILER16_UP Defined when compiling with Delphi XE2 for Win32 or higher + + +- C++Builder Versions + + The following directives are direct mappings from the VERXXX directives to a + friendly name of the associated compiler. These directives are only defined if + the compiler is C++Builder (ie BCB is defined). + + Directive Description + ------------------------------------------------------------------------------ + BCB1 Defined when compiling with C++Builder 1 + BCB3 Defined when compiling with C++Builder 3 + BCB4 Defined when compiling with C++Builder 4 + BCB5 Defined when compiling with C++Builder 5 (Codename RAMPAGE) + BCB6 Defined when compiling with C++Builder 6 (Codename RIPTIDE) + BCB10 Defined when compiling with C++Builder Personality of BDS 4.0 (also known as C++Builder 2006) (Codename DEXTER) + BCB11 Defined when compiling with C++Builder Personality of RAD Studio 2007 (also known as C++Builder 2007) (Codename COGSWELL) + BCB12 Defined when compiling with C++Builder Personality of RAD Studio 2009 (also known as C++Builder 2009) (Codename TIBURON) + BCB14 Defined when compiling with C++Builder Personality of RAD Studio 2010 (also known as C++Builder 2010) (Codename WEAVER) + BCB15 Defined when compiling with C++Builder Personality of RAD Studio XE (also known as C++Builder XE) (Codename FULCRUM) + BCB16 Defined when compiling with C++Builder Personality of RAD Studio XE2 (also known as C++Builder XE2) (Codename PULSAR) + BCB1_UP Defined when compiling with C++Builder 1 or higher + BCB3_UP Defined when compiling with C++Builder 3 or higher + BCB4_UP Defined when compiling with C++Builder 4 or higher + BCB5_UP Defined when compiling with C++Builder 5 or higher + BCB6_UP Defined when compiling with C++Builder 6 or higher + BCB10_UP Defined when compiling with C++Builder Personality of BDS 4.0 or higher + BCB11_UP Defined when compiling with C++Builder Personality of RAD Studio 2007 or higher + BCB12_UP Defined when compiling with C++Builder Personality of RAD Studio 2009 or higher + BCB14_UP Defined when compiling with C++Builder Personality of RAD Studio 2010 or higher + BCB15_UP Defined when compiling with C++Builder Personality of RAD Studio XE or higher + BCB16_UP Defined when compiling with C++Builder Personality of RAD Studio XE2 or higher + + +- RAD Studio / Borland Developer Studio Versions + + The following directives are direct mappings from the VERXXX directives to a + friendly name of the associated IDE. These directives are only defined if + the IDE is Borland Developer Studio Version 2 or above. + + Note: Borland Developer Studio 2006 is marketed as Delphi 2006 or C++Builder 2006, + but those provide only different labels for identical content. + + Directive Description + ------------------------------------------------------------------------------ + BDS Defined when compiling with BDS version of dcc32.exe (Codename SIDEWINDER) + BDS2 Defined when compiling with BDS 2.0 (Delphi 8) (Codename OCTANE) + BDS3 Defined when compiling with BDS 3.0 (Delphi 2005) (Codename DIAMONDBACK) + BDS4 Defined when compiling with BDS 4.0 (Borland Developer Studio 2006) (Codename DEXTER) + BDS5 Defined when compiling with BDS 5.0 (CodeGear RAD Studio 2007) (Codename HIGHLANDER) + BDS6 Defined when compiling with BDS 6.0 (CodeGear RAD Studio 2009) (Codename TIBURON) + BDS7 Defined when compiling with BDS 7.0 (Embarcadero RAD Studio 2010) (Codename WEAVER) + BDS8 Defined when compiling with BDS 8.0 (Embarcadero RAD Studio XE) (Codename FULCRUM) + BDS9 Defined when compiling with BDS 9.0 (Embarcadero RAD Studio XE2) (Codename PULSAR) + BDS2_UP Defined when compiling with BDS 2.0 or higher + BDS3_UP Defined when compiling with BDS 3.0 or higher + BDS4_UP Defined when compiling with BDS 4.0 or higher + BDS5_UP Defined when compiling with BDS 5.0 or higher + BDS6_UP Defined when compiling with BDS 6.0 or higher + BDS7_UP Defined when compiling with BDS 7.0 or higher + BDS8_UP Defined when compiling with BDS 8.0 or higher + BDS9_UP Defined when compiling with BDS 9.0 or higher + +- Compiler Versions + + The following directives are direct mappings from the VERXXX directives to a + friendly name of the associated compiler. Unlike the DELPHI_X and BCB_X + directives, these directives are indepedent of the development environment. + That is, they are defined regardless of whether compilation takes place using + Delphi or C++Builder. + + Directive Description + ------------------------------------------------------------------------------ + COMPILER1 Defined when compiling with Delphi 1 + COMPILER2 Defined when compiling with Delphi 2 or C++Builder 1 + COMPILER3 Defined when compiling with Delphi 3 + COMPILER35 Defined when compiling with C++Builder 3 + COMPILER4 Defined when compiling with Delphi 4 or C++Builder 4 + COMPILER5 Defined when compiling with Delphi 5 or C++Builder 5 + COMPILER6 Defined when compiling with Delphi 6 or C++Builder 6 + COMPILER7 Defined when compiling with Delphi 7 + COMPILER8 Defined when compiling with Delphi 8 + COMPILER9 Defined when compiling with Delphi 9 + COMPILER10 Defined when compiling with Delphi or C++Builder Personalities of BDS 4.0 + COMPILER11 Defined when compiling with Delphi or C++Builder Personalities of BDS 5.0 + COMPILER12 Defined when compiling with Delphi or C++Builder Personalities of BDS 6.0 + COMPILER14 Defined when compiling with Delphi or C++Builder Personalities of BDS 7.0 + COMPILER15 Defined when compiling with Delphi or C++Builder Personalities of BDS 8.0 + COMPILER16 Defined when compiling with Delphi or C++Builder Personalities of BDS 9.0 + COMPILER1_UP Defined when compiling with Delphi 1 or higher + COMPILER2_UP Defined when compiling with Delphi 2 or C++Builder 1 or higher + COMPILER3_UP Defined when compiling with Delphi 3 or higher + COMPILER35_UP Defined when compiling with C++Builder 3 or higher + COMPILER4_UP Defined when compiling with Delphi 4 or C++Builder 4 or higher + COMPILER5_UP Defined when compiling with Delphi 5 or C++Builder 5 or higher + COMPILER6_UP Defined when compiling with Delphi 6 or C++Builder 6 or higher + COMPILER7_UP Defined when compiling with Delphi 7 + COMPILER8_UP Defined when compiling with Delphi 8 + COMPILER9_UP Defined when compiling with Delphi Personalities of BDS 3.0 + COMPILER10_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 4.0 or higher + COMPILER11_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 5.0 or higher + COMPILER12_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 6.0 or higher + COMPILER14_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 7.0 or higher + COMPILER15_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 8.0 or higher + COMPILER16_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 9.0 or higher + + +- RTL Versions + + Use e.g. following to determine the exact RTL version since version 14.0: + {$IFDEF CONDITIONALEXPRESSIONS} + {$IF Declared(RTLVersion) and (RTLVersion >= 14.2)} + // code for Delphi 6.02 or higher, Kylix 2 or higher, C++Builder 6 or higher + ... + {$IFEND} + {$ENDIF} + + Directive Description + ------------------------------------------------------------------------------ + RTL80_UP Defined when compiling with Delphi 1 or higher + RTL90_UP Defined when compiling with Delphi 2 or higher + RTL93_UP Defined when compiling with C++Builder 1 or higher + RTL100_UP Defined when compiling with Delphi 3 or higher + RTL110_UP Defined when compiling with C++Builder 3 or higher + RTL120_UP Defined when compiling with Delphi 4 or higher + RTL125_UP Defined when compiling with C++Builder 4 or higher + RTL130_UP Defined when compiling with Delphi 5 or C++Builder 5 or higher + RTL140_UP Defined when compiling with Delphi 6, Kylix 1, 2 or 3 or C++Builder 6 or higher + RTL150_UP Defined when compiling with Delphi 7 or higher + RTL160_UP Defined when compiling with Delphi 8 or higher + RTL170_UP Defined when compiling with Delphi Personalities of BDS 3.0 or higher + RTL180_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 4.0 or higher + RTL185_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 5.0 or higher + RTL190_UP Defined when compiling with Delphi.NET of BDS 5.0 or higher + RTL200_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 6.0 or higher + RTL210_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 7.0 or higher + RTL220_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 8.0 or higher + RTL230_UP Defined when compiling with Delphi or C++Builder Personalities of BDS 9.0 or higher + + +- CLR Versions + + Directive Description + ------------------------------------------------------------------------------ + CLR Defined when compiling for .NET + CLR10 Defined when compiling for .NET 1.0 (may be overriden by FORCE_CLR10) + CLR10_UP Defined when compiling for .NET 1.0 or higher + CLR11 Defined when compiling for .NET 1.1 (may be overriden by FORCE_CLR11) + CLR11_UP Defined when compiling for .NET 1.1 or higher + CLR20 Defined when compiling for .NET 2.0 (may be overriden by FORCE_CLR20) + CLR20_UP Defined when compiling for .NET 2.0 or higher + + +- Feature Directives + + The features directives are used to test if the compiler supports specific + features, such as method overloading, and adjust the sources accordingly. Use + of these directives is preferred over the use of the DELPHI and COMPILER + directives. + + Directive Description + ------------------------------------------------------------------------------ + SUPPORTS_CONSTPARAMS Compiler supports const parameters (D1+) + SUPPORTS_SINGLE Compiler supports the Single type (D1+) + SUPPORTS_DOUBLE Compiler supports the Double type (D1+) + SUPPORTS_EXTENDED Compiler supports the Extended type (D1+) + SUPPORTS_CURRENCY Compiler supports the Currency type (D2+) + SUPPORTS_THREADVAR Compiler supports threadvar declarations (D2+) + SUPPORTS_OUTPARAMS Compiler supports out parameters (D3+) + SUPPORTS_VARIANT Compiler supports variant (D2+) + SUPPORTS_WIDECHAR Compiler supports the WideChar type (D2+) + SUPPORTS_WIDESTRING Compiler supports the WideString type (D3+/BCB3+) + SUPPORTS_INTERFACE Compiler supports interfaces (D3+/BCB3+) + SUPPORTS_DISPINTERFACE Compiler supports dispatch interfaces (D3+/BCB3+) + SUPPORTS_DISPID Compiler supports dispatch ids (D3+/BCB3+/FPC) + SUPPORTS_EXTSYM Compiler supports the $EXTERNALSYM directive (D4+/BCB3+) + SUPPORTS_NODEFINE Compiler supports the $NODEFINE directive (D4+/BCB3+) + SUPPORTS_LONGWORD Compiler supports the LongWord type (unsigned 32 bit) (D4+/BCB4+) + SUPPORTS_INT64 Compiler supports the Int64 type (D4+/BCB4+) + SUPPORTS_UINT64 Compiler supports the UInt64 type (D XE+ ?) + SUPPORTS_DYNAMICARRAYS Compiler supports dynamic arrays (D4+/BCB4+) + SUPPORTS_DEFAULTPARAMS Compiler supports default parameters (D4+/BCB4+) + SUPPORTS_OVERLOAD Compiler supports overloading (D4+/BCB4+) + SUPPORTS_IMPLEMENTS Compiler supports implements (D4+/BCB4+) + SUPPORTS_DEPRECATED Compiler supports the deprecated directive (D6+/BCB6+) + SUPPORTS_PLATFORM Compiler supports the platform directive (D6+/BCB6+) + SUPPORTS_LIBRARY Compiler supports the library directive (D6+/BCB6+/FPC) + SUPPORTS_LOCAL Compiler supports the local directive (D6+/BCB6+) + SUPPORTS_SETPEFLAGS Compiler supports the SetPEFlags directive (D6+/BCB6+) + SUPPORTS_EXPERIMENTAL_WARNINGS Compiler supports the WARN SYMBOL_EXPERIMENTAL and WARN UNIT_EXPERIMENTAL directives (D6+/BCB6+) + SUPPORTS_INLINE Compiler supports the inline directive (D9+/FPC) + SUPPORTS_FOR_IN Compiler supports for in loops (D9+) + SUPPORTS_NESTED_CONSTANTS Compiler supports nested constants (D9+) + SUPPORTS_NESTED_TYPES Compiler supports nested types (D9+) + SUPPORTS_REGION Compiler supports the REGION and ENDREGION directives (D9+) + SUPPORTS_ENHANCED_RECORDS Compiler supports class [operator|function|procedure] for record types (D9.NET, D10+) + SUPPORTS_CLASS_FIELDS Compiler supports class fields (D9.NET, D10+) + SUPPORTS_CLASS_HELPERS Compiler supports class helpers (D9.NET, D10+) + SUPPORTS_CLASS_OPERATORS Compiler supports class operators (D9.NET, D10+) + SUPPORTS_CLASS_CTORDTORS Compiler supports class contructors/destructors (D14+) + SUPPORTS_STRICT Compiler supports strict keyword (D9.NET, D10+) + SUPPORTS_STATIC Compiler supports static keyword (D9.NET, D10+) + SUPPORTS_FINAL Compiler supports final keyword (D9.NET, D10+) + SUPPORTS_METHODINFO Compiler supports the METHODINFO directives (D10+) + SUPPORTS_GENERICS Compiler supports generic implementations (D11.NET, D12+) + SUPPORTS_DEPRECATED_DETAILS Compiler supports additional text for the deprecated directive (D11.NET, D12+) + ACCEPT_DEPRECATED Compiler supports or ignores the deprecated directive (D6+/BCB6+/FPC) + ACCEPT_PLATFORM Compiler supports or ignores the platform directive (D6+/BCB6+/FPC) + ACCEPT_LIBRARY Compiler supports or ignores the library directive (D6+/BCB6+) + SUPPORTS_CUSTOMVARIANTS Compiler supports custom variants (D6+/BCB6+) + SUPPORTS_VARARGS Compiler supports varargs (D6+/BCB6+) + SUPPORTS_ENUMVALUE Compiler supports assigning ordinalities to values of enums (D6+/BCB6+) + SUPPORTS_DEPRECATED_WARNINGS Compiler supports deprecated warnings (D6+/BCB6+) + SUPPORTS_LIBRARY_WARNINGS Compiler supports library warnings (D6+/BCB6+) + SUPPORTS_PLATFORM_WARNINGS Compiler supports platform warnings (D6+/BCB6+) + SUPPORTS_UNSAFE_WARNINGS Compiler supports unsafe warnings (D7) + SUPPORTS_WEAKPACKAGEUNIT Compiler supports the WEAKPACKAGEUNIT directive + SUPPORTS_COMPILETIME_MESSAGES Compiler supports the MESSAGE directive + SUPPORTS_PACKAGES Compiler supports Packages + HAS_UNIT_LIBC Unit Libc exists (Kylix, FPC on Linux/x86) + HAS_UNIT_RTLCONSTS Unit RTLConsts exists (D6+/BCB6+/FPC) + HAS_UNIT_TYPES Unit Types exists (D6+/BCB6+/FPC) + HAS_UNIT_VARIANTS Unit Variants exists (D6+/BCB6+/FPC) + HAS_UNIT_STRUTILS Unit StrUtils exists (D6+/BCB6+/FPC) + HAS_UNIT_DATEUTILS Unit DateUtils exists (D6+/BCB6+/FPC) + HAS_UNIT_CONTNRS Unit contnrs exists (D6+/BCB6+/FPC) + HAS_UNIT_HTTPPROD Unit HTTPProd exists (D9+) + HAS_UNIT_GIFIMG Unit GifImg exists (D11+) + HAS_UNIT_ANSISTRINGS Unit AnsiStrings exists (D12+) + HAS_UNIT_PNGIMAGE Unit PngImage exists (D12+) + HAS_UNIT_CHARACTER Unit Character exists (D12+) + XPLATFORM_RTL The RTL supports crossplatform function names (e.g. RaiseLastOSError) (D6+/BCB6+/FPC) + SUPPORTS_UNICODE string type is aliased to an unicode string (WideString or UnicodeString) (DX.NET, D12+) + SUPPORTS_UNICODE_STRING Compiler supports UnicodeString (D12+) + SUPPORTS_INT_ALIASES Types Int8, Int16, Int32, UInt8, UInt16 and UInt32 are defined in the unit System (D12+) + HAS_UNIT_RTTI Unit RTTI is available (D14+) + SUPPORTS_CAST_INTERFACE_TO_OBJ The compiler supports casts from interfaces to objects (D14+) + SUPPORTS_DELAYED_LOADING The compiler generates stubs for delaying imported function loads (D14+) + HAS_UNIT_SYSTEM_UITYPES Unit System.UITypes is available (D16+) + + +- Compiler Settings + + The compiler settings directives indicate whether a specific compiler setting + is in effect. This facilitates changing compiler settings locally in a more + compact and readible manner. + + Directive Description + ------------------------------------------------------------------------------ + ALIGN_ON Compiling in the A+ state (no alignment) + BOOLEVAL_ON Compiling in the B+ state (complete boolean evaluation) + ASSERTIONS_ON Compiling in the C+ state (assertions on) + DEBUGINFO_ON Compiling in the D+ state (debug info generation on) + IMPORTEDDATA_ON Compiling in the G+ state (creation of imported data references) + LONGSTRINGS_ON Compiling in the H+ state (string defined as AnsiString) + IOCHECKS_ON Compiling in the I+ state (I/O checking enabled) + WRITEABLECONST_ON Compiling in the J+ state (typed constants can be modified) + LOCALSYMBOLS Compiling in the L+ state (local symbol generation) + LOCALSYMBOLS_ON Alias of LOCALSYMBOLS + TYPEINFO_ON Compiling in the M+ state (RTTI generation on) + OPTIMIZATION_ON Compiling in the O+ state (code optimization on) + OPENSTRINGS_ON Compiling in the P+ state (variable string parameters are openstrings) + OVERFLOWCHECKS_ON Compiling in the Q+ state (overflow checing on) + RANGECHECKS_ON Compiling in the R+ state (range checking on) + TYPEDADDRESS_ON Compiling in the T+ state (pointers obtained using the @ operator are typed) + SAFEDIVIDE_ON Compiling in the U+ state (save FDIV instruction through RTL emulation) + VARSTRINGCHECKS_ON Compiling in the V+ state (type checking of shortstrings) + STACKFRAMES_ON Compiling in the W+ state (generation of stack frames) + EXTENDEDSYNTAX_ON Compiling in the X+ state (Delphi extended syntax enabled) +*) + +{$DEFINE BORLAND} + +{ Set FreePascal to Delphi mode } +{$IFDEF FPC} + {$MODE DELPHI} + {$ASMMODE Intel} + {$UNDEF BORLAND} + {$DEFINE CPUASM} + // FPC defines CPU32, CPU64 and Unix automatically +{$ENDIF} + +{$IFDEF BORLAND} + {$IFDEF LINUX} + {$DEFINE KYLIX} + {$ENDIF LINUX} + {$IFNDEF CLR} + {$IFNDEF CPUX86} + {$IFNDEF CPUX64} + {$DEFINE CPU386} // For Borland compilers select the x86 compat assembler by default + {$DEFINE CPU32} // Assume Borland compilers are 32-bit (rather than 64-bit) + {$DEFINE CPUASM} + {$ELSE ~CPUX64} + {$DEFINE CPU64} + {$DEFINE CPUASM} + {$DEFINE DELPHI64_TEMPORARY} + {$ENDIF ~CPUX64} + {$ELSE ~CPUX86} + {$DEFINE CPU386} + {$DEFINE CPU32} + {$DEFINE CPUASM} + {$ENDIF ~CPUX86} + {$ENDIF ~CLR} +{$ENDIF BORLAND} + +{------------------------------------------------------------------------------} +{ VERXXX to COMPILERX, DELPHIX and BCBX mappings } +{------------------------------------------------------------------------------} + +{$IFDEF BORLAND} + {$IFDEF KYLIX} + {$I kylix.inc} // FPC incompatible stuff + {$ELSE ~KYLIX} + + {$DEFINE UNKNOWN_COMPILER_VERSION} + + {$IFDEF VER80} + {$DEFINE COMPILER1} + {$DEFINE DELPHI1} + {$DEFINE DELPHICOMPILER1} + {$DEFINE RTL80_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER90} + {$DEFINE COMPILER2} + {$DEFINE DELPHI2} + {$DEFINE DELPHICOMPILER2} + {$DEFINE RTL90_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER93} + {$DEFINE COMPILER2} + {$DEFINE BCB1} + {$DEFINE BCB} + {$DEFINE RTL93_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER100} + {$DEFINE COMPILER3} + {$DEFINE DELPHI3} + {$DEFINE DELPHICOMPILER3} + {$DEFINE RTL100_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER110} + {$DEFINE COMPILER35} + {$DEFINE BCB3} + {$DEFINE BCB} + {$DEFINE RTL110_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER120} + {$DEFINE COMPILER4} + {$DEFINE DELPHI4} + {$DEFINE DELPHICOMPILER4} + {$DEFINE RTL120_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER125} + {$DEFINE COMPILER4} + {$DEFINE BCB4} + {$DEFINE BCB} + {$DEFINE RTL125_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER130} + {$DEFINE COMPILER5} + {$IFDEF BCB} + {$DEFINE BCB5} + {$ELSE} + {$DEFINE DELPHI5} + {$DEFINE DELPHICOMPILER5} + {$ENDIF} + {$DEFINE RTL130_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER140} + {$DEFINE COMPILER6} + {$IFDEF BCB} + {$DEFINE BCB6} + {$ELSE} + {$DEFINE DELPHI6} + {$DEFINE DELPHICOMPILER6} + {$ENDIF} + {$DEFINE RTL140_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER150} + {$DEFINE COMPILER7} + {$DEFINE DELPHI7} + {$DEFINE DELPHICOMPILER7} + {$DEFINE RTL150_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER160} + {$DEFINE BDS2} + {$DEFINE BDS} + {$IFDEF CLR} + {$DEFINE CLR10} + {$ENDIF CLR} + {$DEFINE COMPILER8} + {$DEFINE DELPHI8} + {$DEFINE DELPHICOMPILER8} + {$DEFINE RTL160_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER170} + {$DEFINE BDS3} + {$DEFINE BDS} + {$IFDEF CLR} + {$DEFINE CLR11} + {$ENDIF CLR} + {$DEFINE COMPILER9} + {$DEFINE DELPHI9} + {$DEFINE DELPHI2005} // synonym to DELPHI9 + {$DEFINE DELPHICOMPILER9} + {$DEFINE RTL170_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER180} + {$DEFINE BDS} + {$IFDEF CLR} + {$DEFINE CLR11} + {$ENDIF CLR} + {$IFDEF VER185} + {$DEFINE BDS5} + {$DEFINE COMPILER11} + {$IFDEF BCB} + {$DEFINE BCB11} + {$ELSE} + {$DEFINE DELPHI11} + {$DEFINE DELPHI2007} // synonym to DELPHI11 + {$DEFINE DELPHICOMPILER11} + {$ENDIF} + {$DEFINE RTL185_UP} + {$ELSE ~~VER185} + {$DEFINE BDS4} + {$DEFINE COMPILER10} + {$IFDEF BCB} + {$DEFINE BCB10} + {$ELSE} + {$DEFINE DELPHI10} + {$DEFINE DELPHI2006} // synonym to DELPHI10 + {$DEFINE DELPHICOMPILER10} + {$ENDIF} + {$DEFINE RTL180_UP} + {$ENDIF ~VER185} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$IFDEF VER190} // Delphi 2007 for .NET + {$DEFINE BDS} + {$DEFINE BDS5} + {$IFDEF CLR} + {$DEFINE CLR20} + {$ENDIF CLR} + {$DEFINE COMPILER11} + {$DEFINE DELPHI11} + {$DEFINE DELPHI2007} // synonym to DELPHI11 + {$DEFINE DELPHICOMPILER11} + {$DEFINE RTL190_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF VER190} + + {$IFDEF VER200} // RAD Studio 2009 + {$DEFINE BDS} + {$DEFINE BDS6} + {$IFDEF CLR} + {$DEFINE CLR20} + {$ENDIF CLR} + {$DEFINE COMPILER12} + {$IFDEF BCB} + {$DEFINE BCB12} + {$ELSE} + {$DEFINE DELPHI12} + {$DEFINE DELPHI2009} // synonym to DELPHI12 + {$DEFINE DELPHICOMPILER12} + {$ENDIF BCB} + {$IFDEF CLR} + {$DEFINE RTL190_UP} + {$ELSE} + {$DEFINE RTL200_UP} + {$ENDIF} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF VER200} + + {$IFDEF VER210} // RAD Studio 2010 + {$DEFINE BDS} + {$DEFINE BDS7} + {$DEFINE COMPILER14} + {$IFDEF BCB} + {$DEFINE BCB14} + {$ELSE} + {$DEFINE DELPHI14} + {$DEFINE DELPHI2010} // synonym to DELPHI14 + {$DEFINE DELPHICOMPILER14} + {$ENDIF BCB} + {$DEFINE RTL210_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF VER210} + + {$IFDEF VER220} // RAD Studio XE + {$DEFINE BDS} + {$DEFINE BDS8} + {$DEFINE COMPILER15} + {$IFDEF BCB} + {$DEFINE BCB15} + {$ELSE} + {$DEFINE DELPHI15} + {$DEFINE DELPHIXE} // synonym to DELPHI15 + {$DEFINE DELPHICOMPILER15} + {$ENDIF BCB} + {$DEFINE RTL220_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF VER220} + + {$IFDEF VER230} // RAD Studio XE2 + {$DEFINE BDS} + {$DEFINE BDS9} + {$DEFINE COMPILER16} + {$IFDEF BCB} + {$DEFINE BCB16} + {$ELSE} + {$DEFINE DELPHI16} + {$DEFINE DELPHIXE2} // synonym to DELPHI16 + {$DEFINE DELPHICOMPILER16} + {$ENDIF BCB} + {$DEFINE RTL230_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF VER230} + + {$IFDEF UNKNOWN_COMPILER_VERSION} // adjust for newer version (always use latest version) + {$DEFINE BDS} + {$DEFINE BDS9} + {$DEFINE COMPILER16} + {$IFDEF BCB} + {$DEFINE BCB16} + {$ELSE} + {$DEFINE DELPHI16} + {$DEFINE DELPHIXE2} // synonym to DELPHI16 + {$DEFINE DELPHICOMPILER16} + {$ENDIF BCB} + {$DEFINE RTL230_UP} + {$UNDEF UNKNOWN_COMPILER_VERSION} + {$ENDIF} + + {$ENDIF ~KYLIX} + + {$IFDEF BCB} + {$DEFINE CPPBUILDER} + {$DEFINE BCBCOMPILER} + {$ELSE ~BCB} + {$DEFINE DELPHI} + {$DEFINE DELPHICOMPILER} + {$ENDIF ~BCB} + +{$ENDIF BORLAND} + +{------------------------------------------------------------------------------} +{ DELPHIX_UP from DELPHIX mappings } +{------------------------------------------------------------------------------} + +{$IFDEF DELPHI16} {$DEFINE DELPHI16_UP} {$ENDIF} +{$IFDEF DELPHI15} {$DEFINE DELPHI15_UP} {$ENDIF} +{$IFDEF DELPHI14} {$DEFINE DELPHI14_UP} {$ENDIF} +{$IFDEF DELPHI12} {$DEFINE DELPHI12_UP} {$ENDIF} +{$IFDEF DELPHI11} {$DEFINE DELPHI11_UP} {$ENDIF} +{$IFDEF DELPHI10} {$DEFINE DELPHI10_UP} {$ENDIF} +{$IFDEF DELPHI9} {$DEFINE DELPHI9_UP} {$ENDIF} +{$IFDEF DELPHI8} {$DEFINE DELPHI8_UP} {$ENDIF} +{$IFDEF DELPHI7} {$DEFINE DELPHI7_UP} {$ENDIF} +{$IFDEF DELPHI6} {$DEFINE DELPHI6_UP} {$ENDIF} +{$IFDEF DELPHI5} {$DEFINE DELPHI5_UP} {$ENDIF} +{$IFDEF DELPHI4} {$DEFINE DELPHI4_UP} {$ENDIF} +{$IFDEF DELPHI3} {$DEFINE DELPHI3_UP} {$ENDIF} +{$IFDEF DELPHI2} {$DEFINE DELPHI2_UP} {$ENDIF} +{$IFDEF DELPHI1} {$DEFINE DELPHI1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ DELPHIX_UP from DELPHIX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF DELPHI16_UP} + {$DEFINE DELPHIXE2_UP} // synonym to DELPHI16_UP + {$DEFINE DELPHI15_UP} +{$ENDIF} + +{$IFDEF DELPHI15_UP} + {$DEFINE DELPHIXE_UP} // synonym to DELPHI15_UP + {$DEFINE DELPHI14_UP} +{$ENDIF} + +{$IFDEF DELPHI14_UP} + {$DEFINE DELPHI2010_UP} // synonym to DELPHI14_UP + {$DEFINE DELPHI12_UP} +{$ENDIF} + +{$IFDEF DELPHI12_UP} + {$DEFINE DELPHI2009_UP} // synonym to DELPHI12_UP + {$DEFINE DELPHI11_UP} +{$ENDIF} + +{$IFDEF DELPHI11_UP} + {$DEFINE DELPHI2007_UP} // synonym to DELPHI11_UP + {$DEFINE DELPHI10_UP} +{$ENDIF} + +{$IFDEF DELPHI10_UP} + {$DEFINE DELPHI2006_UP} // synonym to DELPHI10_UP + {$DEFINE DELPHI9_UP} +{$ENDIF} + +{$IFDEF DELPHI9_UP} + {$DEFINE DELPHI2005_UP} // synonym to DELPHI9_UP + {$DEFINE DELPHI8_UP} +{$ENDIF} + +{$IFDEF DELPHI8_UP} {$DEFINE DELPHI7_UP} {$ENDIF} +{$IFDEF DELPHI7_UP} {$DEFINE DELPHI6_UP} {$ENDIF} +{$IFDEF DELPHI6_UP} {$DEFINE DELPHI5_UP} {$ENDIF} +{$IFDEF DELPHI5_UP} {$DEFINE DELPHI4_UP} {$ENDIF} +{$IFDEF DELPHI4_UP} {$DEFINE DELPHI3_UP} {$ENDIF} +{$IFDEF DELPHI3_UP} {$DEFINE DELPHI2_UP} {$ENDIF} +{$IFDEF DELPHI2_UP} {$DEFINE DELPHI1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ BCBX_UP from BCBX mappings } +{------------------------------------------------------------------------------} + +{$IFDEF BCB16} {$DEFINE BCB16_UP} {$ENDIF} +{$IFDEF BCB15} {$DEFINE BCB15_UP} {$ENDIF} +{$IFDEF BCB14} {$DEFINE BCB14_UP} {$ENDIF} +{$IFDEF BCB12} {$DEFINE BCB12_UP} {$ENDIF} +{$IFDEF BCB11} {$DEFINE BCB11_UP} {$ENDIF} +{$IFDEF BCB10} {$DEFINE BCB10_UP} {$ENDIF} +{$IFDEF BCB6} {$DEFINE BCB6_UP} {$ENDIF} +{$IFDEF BCB5} {$DEFINE BCB5_UP} {$ENDIF} +{$IFDEF BCB4} {$DEFINE BCB4_UP} {$ENDIF} +{$IFDEF BCB3} {$DEFINE BCB3_UP} {$ENDIF} +{$IFDEF BCB1} {$DEFINE BCB1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ BCBX_UP from BCBX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF BCB16_UP} {$DEFINE BCB15_UP} {$ENDIF} +{$IFDEF BCB15_UP} {$DEFINE BCB14_UP} {$ENDIF} +{$IFDEF BCB14_UP} {$DEFINE BCB12_UP} {$ENDIF} +{$IFDEF BCB12_UP} {$DEFINE BCB11_UP} {$ENDIF} +{$IFDEF BCB11_UP} {$DEFINE BCB10_UP} {$ENDIF} +{$IFDEF BCB10_UP} {$DEFINE BCB6_UP} {$ENDIF} +{$IFDEF BCB6_UP} {$DEFINE BCB5_UP} {$ENDIF} +{$IFDEF BCB5_UP} {$DEFINE BCB4_UP} {$ENDIF} +{$IFDEF BCB4_UP} {$DEFINE BCB3_UP} {$ENDIF} +{$IFDEF BCB3_UP} {$DEFINE BCB1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ BDSX_UP from BDSX mappings } +{------------------------------------------------------------------------------} + +{$IFDEF BDS9} {$DEFINE BDS9_UP} {$ENDIF} +{$IFDEF BDS8} {$DEFINE BDS8_UP} {$ENDIF} +{$IFDEF BDS7} {$DEFINE BDS7_UP} {$ENDIF} +{$IFDEF BDS6} {$DEFINE BDS6_UP} {$ENDIF} +{$IFDEF BDS5} {$DEFINE BDS5_UP} {$ENDIF} +{$IFDEF BDS4} {$DEFINE BDS4_UP} {$ENDIF} +{$IFDEF BDS3} {$DEFINE BDS3_UP} {$ENDIF} +{$IFDEF BDS2} {$DEFINE BDS2_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ BDSX_UP from BDSX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF BDS9_UP} {$DEFINE BDS8_UP} {$ENDIF} +{$IFDEF BDS8_UP} {$DEFINE BDS7_UP} {$ENDIF} +{$IFDEF BDS7_UP} {$DEFINE BDS6_UP} {$ENDIF} +{$IFDEF BDS6_UP} {$DEFINE BDS5_UP} {$ENDIF} +{$IFDEF BDS5_UP} {$DEFINE BDS4_UP} {$ENDIF} +{$IFDEF BDS4_UP} {$DEFINE BDS3_UP} {$ENDIF} +{$IFDEF BDS3_UP} {$DEFINE BDS2_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ DELPHICOMPILERX_UP from DELPHICOMPILERX mappings } +{------------------------------------------------------------------------------} + +{$IFDEF DELPHICOMPILER16} {$DEFINE DELPHICOMPILER16_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER15} {$DEFINE DELPHICOMPILER15_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER14} {$DEFINE DELPHICOMPILER14_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER12} {$DEFINE DELPHICOMPILER12_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER11} {$DEFINE DELPHICOMPILER11_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER10} {$DEFINE DELPHICOMPILER10_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER9} {$DEFINE DELPHICOMPILER9_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER8} {$DEFINE DELPHICOMPILER8_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER7} {$DEFINE DELPHICOMPILER7_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER6} {$DEFINE DELPHICOMPILER6_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER5} {$DEFINE DELPHICOMPILER5_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER4} {$DEFINE DELPHICOMPILER4_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER3} {$DEFINE DELPHICOMPILER3_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER2} {$DEFINE DELPHICOMPILER2_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER1} {$DEFINE DELPHICOMPILER1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ DELPHICOMPILERX_UP from DELPHICOMPILERX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF DELPHICOMPILER16_UP} {$DEFINE DELPHICOMPILER15_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER15_UP} {$DEFINE DELPHICOMPILER14_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER14_UP} {$DEFINE DELPHICOMPILER12_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER12_UP} {$DEFINE DELPHICOMPILER11_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER11_UP} {$DEFINE DELPHICOMPILER10_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER10_UP} {$DEFINE DELPHICOMPILER9_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER9_UP} {$DEFINE DELPHICOMPILER8_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER8_UP} {$DEFINE DELPHICOMPILER7_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER8_UP} {$DEFINE DELPHICOMPILER7_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER7_UP} {$DEFINE DELPHICOMPILER6_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER6_UP} {$DEFINE DELPHICOMPILER5_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER5_UP} {$DEFINE DELPHICOMPILER4_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER4_UP} {$DEFINE DELPHICOMPILER3_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER3_UP} {$DEFINE DELPHICOMPILER2_UP} {$ENDIF} +{$IFDEF DELPHICOMPILER2_UP} {$DEFINE DELPHICOMPILER1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ COMPILERX_UP from COMPILERX mappings } +{------------------------------------------------------------------------------} + +{$IFDEF COMPILER16} {$DEFINE COMPILER16_UP} {$ENDIF} +{$IFDEF COMPILER15} {$DEFINE COMPILER15_UP} {$ENDIF} +{$IFDEF COMPILER14} {$DEFINE COMPILER14_UP} {$ENDIF} +{$IFDEF COMPILER12} {$DEFINE COMPILER12_UP} {$ENDIF} +{$IFDEF COMPILER11} {$DEFINE COMPILER11_UP} {$ENDIF} +{$IFDEF COMPILER10} {$DEFINE COMPILER10_UP} {$ENDIF} +{$IFDEF COMPILER9} {$DEFINE COMPILER9_UP} {$ENDIF} +{$IFDEF COMPILER8} {$DEFINE COMPILER8_UP} {$ENDIF} +{$IFDEF COMPILER7} {$DEFINE COMPILER7_UP} {$ENDIF} +{$IFDEF COMPILER6} {$DEFINE COMPILER6_UP} {$ENDIF} +{$IFDEF COMPILER5} {$DEFINE COMPILER5_UP} {$ENDIF} +{$IFDEF COMPILER4} {$DEFINE COMPILER4_UP} {$ENDIF} +{$IFDEF COMPILER35} {$DEFINE COMPILER35_UP} {$ENDIF} +{$IFDEF COMPILER3} {$DEFINE COMPILER3_UP} {$ENDIF} +{$IFDEF COMPILER2} {$DEFINE COMPILER2_UP} {$ENDIF} +{$IFDEF COMPILER1} {$DEFINE COMPILER1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ COMPILERX_UP from COMPILERX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF COMPILER16_UP} {$DEFINE COMPILER15_UP} {$ENDIF} +{$IFDEF COMPILER15_UP} {$DEFINE COMPILER14_UP} {$ENDIF} +{$IFDEF COMPILER14_UP} {$DEFINE COMPILER12_UP} {$ENDIF} +{$IFDEF COMPILER12_UP} {$DEFINE COMPILER11_UP} {$ENDIF} +{$IFDEF COMPILER11_UP} {$DEFINE COMPILER10_UP} {$ENDIF} +{$IFDEF COMPILER10_UP} {$DEFINE COMPILER9_UP} {$ENDIF} +{$IFDEF COMPILER9_UP} {$DEFINE COMPILER8_UP} {$ENDIF} +{$IFDEF COMPILER8_UP} {$DEFINE COMPILER7_UP} {$ENDIF} +{$IFDEF COMPILER7_UP} {$DEFINE COMPILER6_UP} {$ENDIF} +{$IFDEF COMPILER6_UP} {$DEFINE COMPILER5_UP} {$ENDIF} +{$IFDEF COMPILER5_UP} {$DEFINE COMPILER4_UP} {$ENDIF} +{$IFDEF COMPILER4_UP} {$DEFINE COMPILER35_UP} {$ENDIF} +{$IFDEF COMPILER35_UP} {$DEFINE COMPILER3_UP} {$ENDIF} +{$IFDEF COMPILER3_UP} {$DEFINE COMPILER2_UP} {$ENDIF} +{$IFDEF COMPILER2_UP} {$DEFINE COMPILER1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ RTLX_UP from RTLX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF RTL230_UP} {$DEFINE RTL220_UP} {$ENDIF} +{$IFDEF RTL220_UP} {$DEFINE RTL210_UP} {$ENDIF} +{$IFDEF RTL210_UP} {$DEFINE RTL200_UP} {$ENDIF} +{$IFDEF RTL200_UP} {$DEFINE RTL190_UP} {$ENDIF} +{$IFDEF RTL190_UP} {$DEFINE RTL185_UP} {$ENDIF} +{$IFDEF RTL185_UP} {$DEFINE RTL180_UP} {$ENDIF} +{$IFDEF RTL180_UP} {$DEFINE RTL170_UP} {$ENDIF} +{$IFDEF RTL170_UP} {$DEFINE RTL160_UP} {$ENDIF} +{$IFDEF RTL160_UP} {$DEFINE RTL150_UP} {$ENDIF} +{$IFDEF RTL150_UP} {$DEFINE RTL145_UP} {$ENDIF} +{$IFDEF RTL145_UP} {$DEFINE RTL142_UP} {$ENDIF} +{$IFDEF RTL142_UP} {$DEFINE RTL140_UP} {$ENDIF} +{$IFDEF RTL140_UP} {$DEFINE RTL130_UP} {$ENDIF} +{$IFDEF RTL130_UP} {$DEFINE RTL125_UP} {$ENDIF} +{$IFDEF RTL125_UP} {$DEFINE RTL120_UP} {$ENDIF} +{$IFDEF RTL120_UP} {$DEFINE RTL110_UP} {$ENDIF} +{$IFDEF RTL110_UP} {$DEFINE RTL100_UP} {$ENDIF} +{$IFDEF RTL100_UP} {$DEFINE RTL93_UP} {$ENDIF} +{$IFDEF RTL93_UP} {$DEFINE RTL90_UP} {$ENDIF} +{$IFDEF RTL90_UP} {$DEFINE RTL80_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ Check for CLR overrides of default detection } +{------------------------------------------------------------------------------} + +{$IFDEF CLR} + {$IFDEF FORCE_CLR10} + {$DEFINE CLR10} + {$UNDEF CLR11} + {$UNDEF CLR20} + {$ENDIF FORCE_CLR10} + + {$IFDEF FORCE_CLR11} + {$UNDEF CLR10} + {$DEFINE CLR11} + {$UNDEF CLR20} + {$ENDIF FORCE_CLR11} + + {$IFDEF FORCE_CLR20} + {$UNDEF CLR10} + {$UNDEF CLR11} + {$DEFINE CLR20} + {$ENDIF FORCE_CLR20} +{$ENDIF CLR} + +{------------------------------------------------------------------------------} +{ CLRX from CLRX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF CLR10} {$DEFINE CLR10_UP} {$ENDIF} +{$IFDEF CLR11} {$DEFINE CLR11_UP} {$ENDIF} +{$IFDEF CLR20} {$DEFINE CLR20_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ CLRX_UP from CLRX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF CLR20_UP} {$DEFINE CLR11_UP} {$ENDIF} +{$IFDEF CLR11_UP} {$DEFINE CLR10_UP} {$ENDIF} + +{------------------------------------------------------------------------------} + +{$IFDEF DELPHICOMPILER} + {$DEFINE DELPHILANGUAGE} +{$ENDIF} + +{$IFDEF BCBCOMPILER} + {$DEFINE DELPHILANGUAGE} +{$ENDIF} + +{------------------------------------------------------------------------------} +{ KYLIXX_UP from KYLIXX mappings } +{------------------------------------------------------------------------------} + +{$IFDEF KYLIX3} {$DEFINE KYLIX3_UP} {$ENDIF} +{$IFDEF KYLIX2} {$DEFINE KYLIX2_UP} {$ENDIF} +{$IFDEF KYLIX1} {$DEFINE KYLIX1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ KYLIXX_UP from KYLIXX_UP mappings } +{------------------------------------------------------------------------------} + +{$IFDEF KYLIX3_UP} {$DEFINE KYLIX2_UP} {$ENDIF} +{$IFDEF KYLIX2_UP} {$DEFINE KYLIX1_UP} {$ENDIF} + +{------------------------------------------------------------------------------} +{ Map COMPILERX_UP to friendly feature names } +{------------------------------------------------------------------------------} + +{$IFDEF FPC} + {$IFDEF VER1_0} + Please use FPC 2.0 or higher to compile this. + {$ELSE} + {$DEFINE SUPPORTS_OUTPARAMS} + {$DEFINE SUPPORTS_WIDECHAR} + {$DEFINE SUPPORTS_WIDESTRING} + {$IFDEF HASINTF} + {$DEFINE SUPPORTS_INTERFACE} + {$ENDIF} + {$IFDEF HASVARIANT} + {$DEFINE SUPPORTS_VARIANT} + {$ENDIF} + {$IFDEF FPC_HAS_TYPE_SINGLE} + {$DEFINE SUPPORTS_SINGLE} + {$ENDIF} + {$IFDEF FPC_HAS_TYPE_DOUBLE} + {$DEFINE SUPPORTS_DOUBLE} + {$ENDIF} + {$IFDEF FPC_HAS_TYPE_EXTENDED} + {$DEFINE SUPPORTS_EXTENDED} + {$ENDIF} + {$IFDEF HASCURRENCY} + {$DEFINE SUPPORTS_CURRENCY} + {$ENDIF} + {$DEFINE SUPPORTS_THREADVAR} + {$DEFINE SUPPORTS_CONSTPARAMS} + {$DEFINE SUPPORTS_LONGWORD} + {$DEFINE SUPPORTS_INT64} + {$DEFINE SUPPORTS_DYNAMICARRAYS} + {$DEFINE SUPPORTS_DEFAULTPARAMS} + {$DEFINE SUPPORTS_OVERLOAD} + {$DEFINE ACCEPT_DEPRECATED} // 2.2 also gives warnings + {$DEFINE ACCEPT_PLATFORM} // 2.2 also gives warnings + {$DEFINE ACCEPT_LIBRARY} + {$DEFINE SUPPORTS_EXTSYM} + {$DEFINE SUPPORTS_NODEFINE} + + {$DEFINE SUPPORTS_CUSTOMVARIANTS} + {$DEFINE SUPPORTS_VARARGS} + {$DEFINE SUPPORTS_ENUMVALUE} + {$IFDEF LINUX} + {$DEFINE HAS_UNIT_LIBC} + {$ENDIF LINUX} + {$DEFINE HAS_UNIT_CONTNRS} + {$DEFINE HAS_UNIT_TYPES} + {$DEFINE HAS_UNIT_VARIANTS} + {$DEFINE HAS_UNIT_STRUTILS} + {$DEFINE HAS_UNIT_DATEUTILS} + {$DEFINE HAS_UNIT_RTLCONSTS} + + {$DEFINE XPLATFORM_RTL} + + {$IFDEF VER2_2} + {$DEFINE SUPPORTS_DISPINTERFACE} + {$DEFINE SUPPORTS_IMPLEMENTS} + {$DEFINE SUPPORTS_DISPID} + {$ELSE} + {$UNDEF SUPPORTS_DISPINTERFACE} + {$UNDEF SUPPORTS_IMPLEMENTS} + {$endif} + {$UNDEF SUPPORTS_UNSAFE_WARNINGS} + {$ENDIF} +{$ENDIF FPC} + +{$IFDEF CLR} + {$DEFINE SUPPORTS_UNICODE} +{$ENDIF CLR} + +{$IFDEF COMPILER1_UP} + {$DEFINE SUPPORTS_CONSTPARAMS} + {$DEFINE SUPPORTS_SINGLE} + {$DEFINE SUPPORTS_DOUBLE} + {$DEFINE SUPPORTS_EXTENDED} + {$DEFINE SUPPORTS_PACKAGES} +{$ENDIF COMPILER1_UP} + +{$IFDEF COMPILER2_UP} + {$DEFINE SUPPORTS_CURRENCY} + {$DEFINE SUPPORTS_THREADVAR} + {$DEFINE SUPPORTS_VARIANT} + {$DEFINE SUPPORTS_WIDECHAR} +{$ENDIF COMPILER2_UP} + +{$IFDEF COMPILER3_UP} + {$DEFINE SUPPORTS_OUTPARAMS} + {$DEFINE SUPPORTS_WIDESTRING} + {$DEFINE SUPPORTS_INTERFACE} + {$DEFINE SUPPORTS_DISPINTERFACE} + {$DEFINE SUPPORTS_DISPID} + {$DEFINE SUPPORTS_WEAKPACKAGEUNIT} +{$ENDIF COMPILER3_UP} + +{$IFDEF COMPILER35_UP} + {$DEFINE SUPPORTS_EXTSYM} + {$DEFINE SUPPORTS_NODEFINE} +{$ENDIF COMPILER35_UP} + +{$IFDEF COMPILER4_UP} + {$DEFINE SUPPORTS_LONGWORD} + {$DEFINE SUPPORTS_INT64} + {$DEFINE SUPPORTS_DYNAMICARRAYS} + {$DEFINE SUPPORTS_DEFAULTPARAMS} + {$DEFINE SUPPORTS_OVERLOAD} + {$DEFINE SUPPORTS_IMPLEMENTS} +{$ENDIF COMPILER4_UP} + +{$IFDEF COMPILER6_UP} + {$DEFINE SUPPORTS_DEPRECATED} + {$DEFINE SUPPORTS_LIBRARY} + {$DEFINE SUPPORTS_PLATFORM} + {$DEFINE SUPPORTS_LOCAL} + {$DEFINE SUPPORTS_SETPEFLAGS} + {$DEFINE SUPPORTS_EXPERIMENTAL_WARNINGS} + {$DEFINE ACCEPT_DEPRECATED} + {$DEFINE ACCEPT_PLATFORM} + {$DEFINE ACCEPT_LIBRARY} + {$DEFINE SUPPORTS_DEPRECATED_WARNINGS} + {$DEFINE SUPPORTS_LIBRARY_WARNINGS} + {$DEFINE SUPPORTS_PLATFORM_WARNINGS} + {$DEFINE SUPPORTS_CUSTOMVARIANTS} + {$DEFINE SUPPORTS_VARARGS} + {$DEFINE SUPPORTS_ENUMVALUE} + {$DEFINE SUPPORTS_COMPILETIME_MESSAGES} +{$ENDIF COMPILER6_UP} + +{$IFDEF COMPILER7_UP} + {$DEFINE SUPPORTS_UNSAFE_WARNINGS} +{$ENDIF COMPILER7_UP} + +{$IFDEF COMPILER9_UP} + {$DEFINE SUPPORTS_FOR_IN} + {$DEFINE SUPPORTS_INLINE} + {$DEFINE SUPPORTS_NESTED_CONSTANTS} + {$DEFINE SUPPORTS_NESTED_TYPES} + {$DEFINE SUPPORTS_REGION} + {$IFDEF CLR} + {$DEFINE SUPPORTS_ENHANCED_RECORDS} + {$DEFINE SUPPORTS_CLASS_FIELDS} + {$DEFINE SUPPORTS_CLASS_HELPERS} + {$DEFINE SUPPORTS_CLASS_OPERATORS} + {$DEFINE SUPPORTS_STRICT} + {$DEFINE SUPPORTS_STATIC} + {$DEFINE SUPPORTS_FINAL} + {$ENDIF CLR} +{$ENDIF COMPILER9_UP} + +{$IFDEF COMPILER10_UP} + {$DEFINE SUPPORTS_ENHANCED_RECORDS} + {$DEFINE SUPPORTS_CLASS_FIELDS} + {$DEFINE SUPPORTS_CLASS_HELPERS} + {$DEFINE SUPPORTS_CLASS_OPERATORS} + {$DEFINE SUPPORTS_STRICT} + {$DEFINE SUPPORTS_STATIC} + {$DEFINE SUPPORTS_FINAL} + {$DEFINE SUPPORTS_METHODINFO} +{$ENDIF COMPILER10_UP} + +{$IFDEF COMPILER11_UP} + {$IFDEF CLR} + {$DEFINE SUPPORTS_GENERICS} + {$DEFINE SUPPORTS_DEPRECATED_DETAILS} + {$ENDIF CLR} +{$ENDIF COMPILER11_UP} + +{$IFDEF COMPILER12_UP} + {$DEFINE SUPPORTS_GENERICS} + {$DEFINE SUPPORTS_DEPRECATED_DETAILS} + {$DEFINE SUPPORTS_INT_ALIASES} + {$IFNDEF CLR} + {$DEFINE SUPPORTS_UNICODE} + {$DEFINE SUPPORTS_UNICODE_STRING} + {$ENDIF CLR} +{$ENDIF COMPILER12_UP} + +{$IFDEF COMPILER14_UP} + {$DEFINE SUPPORTS_CLASS_CTORDTORS} + {$DEFINE HAS_UNIT_RTTI} + {$DEFINE SUPPORTS_CAST_INTERFACE_TO_OBJ} + {$DEFINE SUPPORTS_DELAYED_LOADING} +{$ENDIF COMPILER14_UP} + +{$IFDEF COMPILER16_UP} + {$DEFINE USE_64BIT_TYPES} +{$ENDIF COMPILER16_UP} + +{$IFDEF RTL130_UP} + {$DEFINE HAS_UNIT_CONTNRS} +{$ENDIF RTL130_UP} + +{$IFDEF RTL140_UP} + {$IFDEF LINUX} + {$DEFINE HAS_UNIT_LIBC} + {$ENDIF LINUX} + {$DEFINE HAS_UNIT_RTLCONSTS} + {$DEFINE HAS_UNIT_TYPES} + {$DEFINE HAS_UNIT_VARIANTS} + {$DEFINE HAS_UNIT_STRUTILS} + {$DEFINE HAS_UNIT_DATEUTILS} + {$DEFINE XPLATFORM_RTL} +{$ENDIF RTL140_UP} + +{$IFDEF RTL170_UP} + {$DEFINE HAS_UNIT_HTTPPROD} +{$ENDIF RTL170_UP} + +{$IFDEF RTL185_UP} + {$DEFINE HAS_UNIT_GIFIMG} +{$ENDIF RTL185_UP} + +{$IFDEF RTL200_UP} + {$DEFINE HAS_UNIT_ANSISTRINGS} + {$DEFINE HAS_UNIT_PNGIMAGE} + {$DEFINE HAS_UNIT_CHARACTER} +{$ENDIF RTL200_UP} + +{$IFDEF RTL220_UP} + {$DEFINE SUPPORTS_UINT64} +{$ENDIF RTL220_UP} + +{$IFDEF RTL230_UP} + {$DEFINE HAS_UNITSCOPE} + {$DEFINE HAS_UNIT_SYSTEM_UITYPES} +{$ENDIF RTL230_UP} + +{------------------------------------------------------------------------------} +{ Cross-platform related defines } +{------------------------------------------------------------------------------} + +{$IFNDEF CPUASM} + {$DEFINE PUREPASCAL} +{$ENDIF ~CPUASM} + +{$IFDEF WIN32} + {$DEFINE MSWINDOWS} // predefined for D6+/BCB6+ + {$DEFINE Win32API} +{$ENDIF} + +{$IFDEF DELPHILANGUAGE} + {$IFDEF LINUX} + {$DEFINE UNIX} + {$ENDIF} + + {$IFNDEF CONSOLE} + {$IFDEF LINUX} + {$DEFINE VisualCLX} + {$ENDIF} + {$IFNDEF VisualCLX} + {$DEFINE VCL} + {$ENDIF} + {$ENDIF ~CONSOLE} +{$ENDIF DELPHILANGUAGE} + +{------------------------------------------------------------------------------} +{ Compiler settings } +{------------------------------------------------------------------------------} + +{$IFOPT A+} {$DEFINE ALIGN_ON} {$ENDIF} +{$IFOPT B+} {$DEFINE BOOLEVAL_ON} {$ENDIF} +{$IFDEF COMPILER2_UP} + {$IFOPT C+} {$DEFINE ASSERTIONS_ON} {$ENDIF} +{$ENDIF} +{$IFOPT D+} {$DEFINE DEBUGINFO_ON} {$ENDIF} +{$IFOPT G+} {$DEFINE IMPORTEDDATA_ON} {$ENDIF} +{$IFDEF COMPILER2_UP} + {$IFOPT H+} {$DEFINE LONGSTRINGS_ON} {$ENDIF} +{$ENDIF} + +// Hints +{$IFOPT I+} {$DEFINE IOCHECKS_ON} {$ENDIF} +{$IFDEF COMPILER2_UP} + {$IFOPT J+} {$DEFINE WRITEABLECONST_ON} {$ENDIF} +{$ENDIF} +{$IFOPT L+} {$DEFINE LOCALSYMBOLS} {$DEFINE LOCALSYMBOLS_ON} {$ENDIF} +{$IFOPT M+} {$DEFINE TYPEINFO_ON} {$ENDIF} +{$IFOPT O+} {$DEFINE OPTIMIZATION_ON} {$ENDIF} +{$IFOPT P+} {$DEFINE OPENSTRINGS_ON} {$ENDIF} +{$IFOPT Q+} {$DEFINE OVERFLOWCHECKS_ON} {$ENDIF} +{$IFOPT R+} {$DEFINE RANGECHECKS_ON} {$ENDIF} + +// Real compatibility +{$IFOPT T+} {$DEFINE TYPEDADDRESS_ON} {$ENDIF} +{$IFOPT U+} {$DEFINE SAFEDIVIDE_ON} {$ENDIF} +{$IFOPT V+} {$DEFINE VARSTRINGCHECKS_ON} {$ENDIF} +{$IFOPT W+} {$DEFINE STACKFRAMES_ON} {$ENDIF} + +// Warnings +{$IFOPT X+} {$DEFINE EXTENDEDSYNTAX_ON} {$ENDIF} + +// for Delphi/BCB trial versions remove the point from the line below +{.$UNDEF SUPPORTS_WEAKPACKAGEUNIT} + +{$ENDIF ~JEDI_INC} diff --git a/thirparty/zlibpas.pas b/thirparty/zlibpas.pas new file mode 100644 index 0000000..f62838f --- /dev/null +++ b/thirparty/zlibpas.pas @@ -0,0 +1,156 @@ +{Portable Network Graphics Delphi ZLIB linking (16 May 2002) } + +{This unit links ZLIB to pngimage unit in order to implement } +{the library. It's now using the new ZLIB version, 1.1.4 } +{Note: The .obj files must be located in the subdirectory \obj} + +unit zlibpas; + +interface + +type + + TAlloc = function (AppData: Pointer; Items, Size: Integer): Pointer; + TFree = procedure (AppData, Block: Pointer); + + // Internal structure. Ignore. + TZStreamRec = packed record + next_in: PChar; // next input byte + avail_in: Integer; // number of bytes available at next_in + total_in: Integer; // total nb of input bytes read so far + + next_out: PChar; // next output byte should be put here + avail_out: Integer; // remaining free space at next_out + total_out: Integer; // total nb of bytes output so far + + msg: PChar; // last error message, NULL if no error + internal: Pointer; // not visible by applications + + zalloc: TAlloc; // used to allocate the internal state + zfree: TFree; // used to free the internal state + AppData: Pointer; // private data object passed to zalloc and zfree + + data_type: Integer; // best guess about the data type: ascii or binary + adler: Integer; // adler32 value of the uncompressed data + reserved: Integer; // reserved for future use + end; + +function inflateInit_(var strm: TZStreamRec; version: PChar; + recsize: Integer): Integer; forward; +function inflate(var strm: TZStreamRec; flush: Integer): Integer; forward; +function inflateEnd(var strm: TZStreamRec): Integer; forward; +function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar; + recsize: Integer): Integer; forward; +function deflate(var strm: TZStreamRec; flush: Integer): Integer; forward; +function deflateEnd(var strm: TZStreamRec): Integer; forward; + +const + zlib_version = '1.2.3'; + + +const + Z_NO_FLUSH = 0; + Z_PARTIAL_FLUSH = 1; + Z_SYNC_FLUSH = 2; + Z_FULL_FLUSH = 3; + Z_FINISH = 4; + + Z_OK = 0; + Z_STREAM_END = 1; + Z_NEED_DICT = 2; + Z_ERRNO = (-1); + Z_STREAM_ERROR = (-2); + Z_DATA_ERROR = (-3); + Z_MEM_ERROR = (-4); + Z_BUF_ERROR = (-5); + Z_VERSION_ERROR = (-6); + + Z_NO_COMPRESSION = 0; + Z_BEST_SPEED = 1; + Z_BEST_COMPRESSION = 9; + Z_DEFAULT_COMPRESSION = (-1); + + Z_FILTERED = 1; + Z_HUFFMAN_ONLY = 2; + Z_DEFAULT_STRATEGY = 0; + + Z_BINARY = 0; + Z_ASCII = 1; + Z_UNKNOWN = 2; + + Z_DEFLATED = 8; + + _z_errmsg: array[0..9] of PChar = ( + 'need dictionary', // Z_NEED_DICT (2) + 'stream end', // Z_STREAM_END (1) + '', // Z_OK (0) + 'file error', // Z_ERRNO (-1) + 'stream error', // Z_STREAM_ERROR (-2) + 'data error', // Z_DATA_ERROR (-3) + 'insufficient memory', // Z_MEM_ERROR (-4) + 'buffer error', // Z_BUF_ERROR (-5) + 'incompatible version', // Z_VERSION_ERROR (-6) + '' + ); + +implementation + +{$L obj\adler32.obj} +{$L obj\deflate.obj} +{$L obj\infback.obj} +{$L obj\inffast.obj} +{$L obj\inflate.obj} +{$L obj\inftrees.obj} +{$L obj\trees.obj} +{$L obj\compress.obj} +{$L obj\crc32.obj} + + + +function adler32(adler: LongInt; const buf: PChar; len: Integer): LongInt; external; + +procedure _memset(P: Pointer; B: Byte; count: Integer);cdecl; +begin + FillChar(P^, count, B); +end; + +procedure _memcpy(dest, source: Pointer; count: Integer);cdecl; +begin + Move(source^, dest^, count); +end; + + +// deflate compresses data +function deflateInit_(var strm: TZStreamRec; level: Integer; version: PChar; + recsize: Integer): Integer; external; +function deflate(var strm: TZStreamRec; flush: Integer): Integer; external; +function deflateEnd(var strm: TZStreamRec): Integer; external; + +// inflate decompresses data +function inflateInit_(var strm: TZStreamRec; version: PChar; + recsize: Integer): Integer; external; +function inflate(var strm: TZStreamRec; flush: Integer): Integer; external; +function inflateEnd(var strm: TZStreamRec): Integer; external; +function inflateReset(var strm: TZStreamRec): Integer; external; + + +function zcalloc(AppData: Pointer; Items, Size: Integer): Pointer; +begin + GetMem(Result, Items*Size); +end; + +procedure zcfree(AppData, Block: Pointer); +begin + FreeMem(Block); +end; + +end. + + + + + + + + +