├── Demos
├── Color wheel
│ ├── Delphi
│ │ └── src
│ │ │ ├── ColorWheel.pas
│ │ │ ├── ColorWheel_Test.dpr
│ │ │ ├── main.dfm
│ │ │ └── main.pas
│ └── Lazarus
│ │ ├── ColorWheel_Test32.exe
│ │ ├── info.txt
│ │ └── src
│ │ ├── ColorWheel.pas
│ │ ├── ColorWheel_Test.ico
│ │ ├── ColorWheel_Test.lpi
│ │ ├── ColorWheel_Test.lpr
│ │ ├── ColorWheel_Test.lps
│ │ ├── ColorWheel_Test.res
│ │ ├── main.lfm
│ │ └── main.pas
└── Original demo
│ ├── Bin
│ ├── Apple.gif
│ ├── Bird.bmp
│ ├── Bird.png
│ ├── Cereal.gif
│ ├── Collage.png
│ ├── ColorBars.bmp
│ ├── ColorBars2.bmp
│ ├── ColorBars3.bmp
│ ├── ColorBars4.bmp
│ ├── FakePhoto.jpg
│ ├── FakePhoto2.jpg
│ ├── GdiPlus10.exe
│ ├── GdiPlus11.exe
│ ├── GrapeBunch.bmp
│ ├── GrapeBunch001.jpg
│ ├── GrapeBunch050.jpg
│ ├── GrapeBunch100.jpg
│ ├── Grapes.jpg
│ ├── House.png
│ ├── HouseAndTree.gif
│ ├── ImageFile.jpg
│ ├── ImageFileR90.jpg
│ ├── ImageFileSmall.jpg
│ ├── Iron.jpg
│ ├── MultiFrame.tif
│ ├── RemapInput.bmp
│ ├── SampleMetafile.emf
│ ├── SampleMetafileRecording.emf
│ ├── Shapes.bmp
│ ├── Stripes.bmp
│ ├── Texture.bmp
│ ├── Texture.jpg
│ └── Texture1.jpg
│ ├── GdiPlus10
│ ├── Alpha Blending Lines and Fills
│ │ ├── uDemoColorMatrixAlpha.pas
│ │ ├── uDemoCompositingMode.pas
│ │ ├── uDemoIndividualAlpha.pas
│ │ ├── uDemoSemitransparentBrushes.pas
│ │ └── uDemoSemitransparentLines.pas
│ ├── Constructing and Drawing Curves
│ │ ├── uDemoBezierSplines.pas
│ │ └── uDemoCardinalSplines.pas
│ ├── Constructing and Drawing Paths
│ │ ├── uDemoCreateFigures.pas
│ │ └── uDemoFillOpenFigures.pas
│ ├── FMain.dfm
│ ├── FMain.pas
│ ├── Filling Shapes with a Gradient Brush
│ │ ├── uDemoGradientGamma.pas
│ │ ├── uDemoLinearGradient.pas
│ │ └── uDemoPathGradient.pas
│ ├── GdiPlus10.dpr
│ ├── GdiPlus10.dproj
│ ├── GdiPlus10.res
│ ├── GdiPlus10_Icon.ico
│ ├── Getting Started
│ │ ├── uDemoDrawLine.pas
│ │ └── uDemoDrawString.pas
│ ├── Printing
│ │ └── uDemoPrintGdiPlusOutput.pas
│ ├── Recoloring
│ │ ├── uDemoColorMatrixTransform.pas
│ │ ├── uDemoColorRemapTable.pas
│ │ ├── uDemoRotatingColors.pas
│ │ ├── uDemoScalingColors.pas
│ │ ├── uDemoShearingColors.pas
│ │ └── uDemoTranslatingColors.pas
│ ├── Transformations
│ │ ├── uDemoTransformationOrder.pas
│ │ └── uDemoWorldTransformations.pas
│ ├── Using Graphics Containers
│ │ ├── uDemoGraphicsState.pas
│ │ └── uDemoNestedContainers.pas
│ ├── Using Image Encoders and Decoders
│ │ ├── Encoder Parameters
│ │ │ ├── uDemoAllEncoderParameters.pas
│ │ │ ├── uDemoEncoderParameters.pas
│ │ │ └── uDemoEncoderValue.pas
│ │ ├── uDemoBmpToPng.pas
│ │ ├── uDemoCreateMultiFrame.pas
│ │ ├── uDemoGetEncoderClsid.pas
│ │ ├── uDemoJpegCompression.pas
│ │ ├── uDemoListInstalledDecoders.pas
│ │ ├── uDemoListInstalledEncoders.pas
│ │ └── uDemoTransformJpeg.pas
│ ├── Using Images, Bitmaps and Metafiles
│ │ ├── uDemoAvoidAutomaticScaling.pas
│ │ ├── uDemoCachedBitmap.pas
│ │ ├── uDemoCropAndScaleImages.pas
│ │ ├── uDemoInterpolationMode.pas
│ │ ├── uDemoLoadDisplayBitmap.pas
│ │ ├── uDemoLoadDisplayMetafile.pas
│ │ ├── uDemoReadWriteMetaData.pas
│ │ ├── uDemoRecordMetafiles.pas
│ │ ├── uDemoRotateReflectSkew.pas
│ │ └── uDemoThumbnails.pas
│ ├── Using Regions
│ │ ├── uDemoClipRegion.pas
│ │ └── uDemoHitTestRegion.pas
│ ├── Using Text and Fonts
│ │ ├── uDemoAntialiasingText.pas
│ │ ├── uDemoConstructingFonts.pas
│ │ ├── uDemoDrawingText.pas
│ │ ├── uDemoFontMetrics.pas
│ │ ├── uDemoFormattingText.pas
│ │ ├── uDemoInstalledFonts.pas
│ │ └── uDemoPrivateFontCollection.pas
│ ├── Using a Brush to Fill Shapes
│ │ ├── uDemoFillHatchPattern.pas
│ │ ├── uDemoFillImageTexture.pas
│ │ ├── uDemoFillSolidColor.pas
│ │ └── uDemoTileImage.pas
│ ├── Using a Pen to Draw Lines and Shapes
│ │ ├── uDemoCustomDashedLine.pas
│ │ ├── uDemoDrawLineCaps.pas
│ │ ├── uDemoDrawLinesAndRectangles.pas
│ │ ├── uDemoJoiningLines.pas
│ │ ├── uDemoLineTexture.pas
│ │ └── uDemoPenWidthAndAlignment.pas
│ ├── uDemo.pas
│ └── uSourceCodeConverter.pas
│ └── GdiPlus11
│ ├── Bitmap Effects
│ ├── uDemoBlur.pas
│ ├── uDemoBrightnessContrast.pas
│ ├── uDemoColorBalance.pas
│ ├── uDemoColorCurve.pas
│ ├── uDemoColorLUT.pas
│ ├── uDemoColorMatrix.pas
│ ├── uDemoHueSaturationLightness.pas
│ ├── uDemoLevels.pas
│ ├── uDemoRedEyeCorrection.pas
│ ├── uDemoSharpen.pas
│ └── uDemoTint.pas
│ ├── Enhancements
│ ├── uDemoAntialiasing.pas
│ ├── uDemoHistogram.pas
│ └── uDemoPixelFormatConversion.pas
│ ├── FMain.dfm
│ ├── FMain.pas
│ ├── GdiPlus11.dpr
│ ├── GdiPlus11.dproj
│ ├── GdiPlus11.res
│ ├── GdiPlus11_Icon.ico
│ ├── uDemo.pas
│ └── uSourceCodeConverter.pas
├── Doc
├── GdiPlus10.gif
├── GdiPlus11.gif
├── License.txt
└── ReadMe.htm
├── Lib
├── GdiPlus.pas
├── GdiPlus11.RES
├── GdiPlus11.manifest
├── GdiPlus11.rc
├── GdiPlusHelpers.pas
├── GdiPlus_DCC.inc
└── GdiPlus_FPC.inc
├── Readme.md
├── clean_DCU.bat
├── clean_FPC.bat
├── gdiplus.url
├── img
├── demo1.png
└── demo2.png
├── packages
└── Lazarus
│ ├── lazgdiplus.lpk
│ └── lazgdiplus.pas
└── version.txt
/Demos/Color wheel/Delphi/src/ColorWheel_Test.dpr:
--------------------------------------------------------------------------------
1 | program ColorWheel_Test;
2 |
3 | {$IF CompilerVersion >= 21.0}
4 | {$WEAKLINKRTTI ON}
5 | {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
6 | {$IFEND}
7 |
8 | {$SetPEFlags 1} // IMAGE_FILE_RELOCS_STRIPPED
9 | {$SetPEFlags $20} // IMAGE_FILE_LARGE_ADDRESS_AWARE
10 |
11 | uses
12 | Forms, Main;
13 |
14 | {$R *.res}
15 |
16 | begin
17 | Application.Initialize;
18 | Application.MainFormOnTaskbar := True;
19 | Application.CreateForm(TFormMain, FormMain);
20 | Application.Run;
21 | end.
22 |
23 |
--------------------------------------------------------------------------------
/Demos/Color wheel/Lazarus/ColorWheel_Test32.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Color wheel/Lazarus/ColorWheel_Test32.exe
--------------------------------------------------------------------------------
/Demos/Color wheel/Lazarus/info.txt:
--------------------------------------------------------------------------------
1 |
2 | To compile, you need:
3 | 1. JPLib: https://github.com/jackdp/JPLib
4 | 2. JPPack: https://github.com/jackdp/JPPack
5 |
--------------------------------------------------------------------------------
/Demos/Color wheel/Lazarus/src/ColorWheel_Test.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Color wheel/Lazarus/src/ColorWheel_Test.ico
--------------------------------------------------------------------------------
/Demos/Color wheel/Lazarus/src/ColorWheel_Test.lpi:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
--------------------------------------------------------------------------------
/Demos/Color wheel/Lazarus/src/ColorWheel_Test.lpr:
--------------------------------------------------------------------------------
1 | program ColorWheel_Test;
2 |
3 | {$mode delphi}{$H+}
4 |
5 | uses
6 | {$IFDEF UNIX}{$IFDEF UseCThreads}
7 | cthreads,
8 | {$ENDIF}{$ENDIF}
9 | Interfaces, // this includes the LCL widgetset
10 | Forms, Main
11 | { you can add units after this };
12 |
13 | {$R *.res}
14 |
15 | begin
16 | {$IF DECLARED(UseHeapTrace)}
17 | GlobalSkipIfNoLeaks := True; // supported as of debugger version 3.2.0
18 | {$ENDIF}
19 |
20 | RequireDerivedFormResource := True;
21 | Application.Scaled := True;
22 | Application.Initialize;
23 | Application.CreateForm(TFormMain, FormMain);
24 | Application.Run;
25 | end.
26 |
27 |
--------------------------------------------------------------------------------
/Demos/Color wheel/Lazarus/src/ColorWheel_Test.lps:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/Demos/Color wheel/Lazarus/src/ColorWheel_Test.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Color wheel/Lazarus/src/ColorWheel_Test.res
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/Apple.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/Apple.gif
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/Bird.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/Bird.bmp
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/Bird.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/Bird.png
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/Cereal.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/Cereal.gif
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/Collage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/Collage.png
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/ColorBars.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/ColorBars.bmp
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/ColorBars2.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/ColorBars2.bmp
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/ColorBars3.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/ColorBars3.bmp
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/ColorBars4.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/ColorBars4.bmp
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/FakePhoto.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/FakePhoto.jpg
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/FakePhoto2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/FakePhoto2.jpg
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/GdiPlus10.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/GdiPlus10.exe
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/GdiPlus11.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/GdiPlus11.exe
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/GrapeBunch.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/GrapeBunch.bmp
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/GrapeBunch001.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/GrapeBunch001.jpg
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/GrapeBunch050.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/GrapeBunch050.jpg
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/GrapeBunch100.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/GrapeBunch100.jpg
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/Grapes.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/Grapes.jpg
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/House.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/House.png
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/HouseAndTree.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/HouseAndTree.gif
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/ImageFile.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/ImageFile.jpg
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/ImageFileR90.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/ImageFileR90.jpg
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/ImageFileSmall.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/ImageFileSmall.jpg
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/Iron.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/Iron.jpg
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/MultiFrame.tif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/MultiFrame.tif
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/RemapInput.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/RemapInput.bmp
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/SampleMetafile.emf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/SampleMetafile.emf
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/SampleMetafileRecording.emf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/SampleMetafileRecording.emf
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/Shapes.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/Shapes.bmp
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/Stripes.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/Stripes.bmp
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/Texture.bmp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/Texture.bmp
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/Texture.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/Texture.jpg
--------------------------------------------------------------------------------
/Demos/Original demo/Bin/Texture1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/Bin/Texture1.jpg
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Alpha Blending Lines and Fills/uDemoColorMatrixAlpha.pas:
--------------------------------------------------------------------------------
1 | unit uDemoColorMatrixAlpha;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoColorMatrixAlpha = class(TDemo)
11 | strict private
12 | procedure DrawRegular;
13 | procedure DrawAlpha;
14 | strict protected
15 | procedure Run; override;
16 | end;
17 |
18 | implementation
19 |
20 | { TDemoColorMatrixAlpha }
21 |
22 | {$REGION}
23 | /// The IGPBitmap interface (which inherits from the IGPImage
24 | /// interface) and the IGPImageAttributes interface provide functionality
25 | /// for getting and setting pixel values. You can use the IGPImageAttributes
26 | /// interface to modify the alpha values for an entire image, or you can call
27 | /// the IGPBitmap.SetPixel method to modify individual pixel values. For
28 | /// more information on setting individual pixel values, see the next example
29 | /// Setting the Alpha Values of Individual Pixels.
30 | ///
31 | /// The following example draws a wide black line and then displays an opaque
32 | /// image that covers part of that line.
33 |
34 | procedure TDemoColorMatrixAlpha.DrawRegular;
35 | var
36 | Bitmap: IGPBitmap;
37 | Pen: IGPPen;
38 | begin
39 | Bitmap := TGPBitmap.Create('Texture1.jpg');
40 | Pen := TGPPen.Create(TGPColor.Create(255, 0, 0, 0), 25);
41 | Graphics.DrawLine(Pen, TGPPoint.Create(10, 35), TGPPoint.Create(200, 35));
42 | Graphics.DrawImage(Bitmap, 30, 0, Bitmap.Width, Bitmap.Height);
43 | end;
44 |
45 | /// The top illustration above shows the resulting image, which is drawn at
46 | /// (30, 0). Note that the wide black line doesn't show through the image.
47 | ///
48 | /// The IGPImageAttributes interface has many properties that you can use
49 | /// to modify images during rendering. In the following example, an
50 | /// IGPImageAttributes object is used to set all the alpha values to 80
51 | /// percent of what they were. This is done by initializing a color matrix and
52 | /// setting the alpha scaling value in the matrix to 0.8. The color matrix is
53 | /// passed to the IGPImageAttributes.SetColorMatrix method, and the
54 | /// IGPImageAttributes object is passed to the DrawImage method of a
55 | /// IGPGraphics object.
56 |
57 | procedure TDemoColorMatrixAlpha.DrawAlpha;
58 | const
59 | ColorMatrix: TGPColorMatrix = (
60 | M: ((1.0, 0.0, 0.0, 0.0, 0.0),
61 | (0.0, 1.0, 0.0, 0.0, 0.0),
62 | (0.0, 0.0, 1.0, 0.0, 0.0),
63 | (0.0, 0.0, 0.0, 0.8, 0.0),
64 | (0.0, 0.0, 0.0, 0.0, 1.0)));
65 | var
66 | Bitmap: IGPBitmap;
67 | Pen: IGPPen;
68 | Attr: IGPImageAttributes;
69 | Width, Height: Integer;
70 | begin
71 | Bitmap := TGPBitmap.Create('Texture1.jpg');
72 | Pen := TGPPen.Create(TGPColor.Create(255, 0, 0, 0), 25);
73 | Attr := TGPImageAttributes.Create;
74 | Attr.SetColorMatrix(ColorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);
75 | Graphics.DrawLine(Pen, TGPPoint.Create(10, 135), TGPPoint.Create(200, 135));
76 | Width := Bitmap.Width;
77 | Height := Bitmap.Height;
78 | Graphics.DrawImage(Bitmap,
79 | TGPRect.Create(30, 100, Width, Height), // Destination rectangle
80 | 0, 0, Width, Height, // Source rectangle
81 | UnitPixel, Attr);
82 | end;
83 | {$ENDREGION}
84 |
85 | procedure TDemoColorMatrixAlpha.Run;
86 | begin
87 | DrawRegular;
88 | DrawAlpha;
89 | end;
90 |
91 | initialization
92 | RegisterDemo('Alpha Blending Lines and Fills\Using a Color Matrix to Set Alpha Values in Images', TDemoColorMatrixAlpha);
93 |
94 | end.
95 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Alpha Blending Lines and Fills/uDemoCompositingMode.pas:
--------------------------------------------------------------------------------
1 | unit uDemoCompositingMode;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoCompositingMode = class(TDemo)
11 | strict private
12 | procedure DrawShapes(const CompositingMode: TGPCompositingMode;
13 | const YOffset: Integer);
14 | strict protected
15 | procedure Run; override;
16 | end;
17 |
18 | implementation
19 |
20 | { TDemoCompositingMode }
21 |
22 | {$REGION}
23 | /// There might be times when you want to create an off-screen bitmap that has
24 | /// the following characteristics:
25 | ///
26 | /// -Colors have alpha values that are less than 255.
27 | /// -Colors are not alpha blended with each other as you create the bitmap.
28 | /// -When you display the finished bitmap, colors in the bitmap are alpha
29 | /// blended with the background colors on the display device.
30 | ///
31 | /// To create such a bitmap, construct a blank IGPBitmap object, and then
32 | /// construct a IGPGraphics object based on that bitmap. Set the
33 | /// compositing mode of the IGPGraphics object to CompositingModeSourceCopy.
34 | ///
35 | /// The following example creates a IGPGraphics object based on a
36 | /// IGPBitmap object. The code uses the IGPGraphics object along with
37 | /// two semitransparent brushes (alpha = 160) to paint on the bitmap. The code
38 | /// fills a red ellipse and a green ellipse using the semitransparent brushes.
39 | /// The green ellipse overlaps the red ellipse, but the green is not blended
40 | /// with the red because the compositing mode of the IGPGraphics object is
41 | /// set to CompositingModeSourceCopy.
42 | ///
43 | /// The code draws the bitmap on the screen twice: once on a white background
44 | /// and once on a multicolored background. The pixels in the bitmap that are
45 | /// part of the two ellipses have an alpha component of 160, so the ellipses are
46 | /// blended with the background colors on the screen.
47 |
48 | procedure TDemoCompositingMode.DrawShapes(
49 | const CompositingMode: TGPCompositingMode; const YOffset: Integer);
50 | var
51 | Bitmap: IGPBitmap;
52 | BitmapGraphics: IGPGraphics;
53 | RedBrush, GreenBrush, Brush: IGPSolidBrush;
54 | begin
55 | // Create a blank bitmap.
56 | Bitmap := TGPBitmap.Create(180, 100);
57 | // Create a IGPGraphics object that can be used to draw on the bitmap.
58 | BitmapGraphics := TGPGraphics.Create(Bitmap);
59 | // Create a red brush and a green brush, each with an alpha value of 160.
60 | RedBrush := TGPSolidBrush.Create(TGPColor.Create(160, 255, 0, 0));
61 | GreenBrush := TGPSolidBrush.Create(TGPColor.Create(160, 0, 255, 0));
62 | // Set the compositing mode using the parameter. When CompositingMode is set
63 | // to CompositingModeSourceCopy, then when overlapping ellipses are drawn,
64 | // the colors of the ellipses are not blended.
65 | BitmapGraphics.CompositingMode := CompositingMode;
66 | BitmapGraphics.FillEllipse(RedBrush, 0, 0, 150, 70);
67 | BitmapGraphics.FillEllipse(GreenBrush, 30, 30, 150, 70);
68 |
69 | // Draw a multicolored background on the screen.
70 | Graphics.CompositingQuality := CompositingQualityGammaCorrected;
71 | Brush := TGPSolidBrush.Create(TGPColor.Aqua);
72 | Graphics.FillRectangle(Brush, 200, YOffset, 60, 100);
73 | Brush.Color := TGPColor.Yellow;
74 | Graphics.FillRectangle(Brush, 260, YOffset, 60, 100);
75 | Brush.Color := TGPColor.Fuchsia;
76 | Graphics.FillRectangle(Brush, 320, YOffset, 60, 100);
77 |
78 | // Display the bitmap on a white background.
79 | Graphics.DrawImage(Bitmap, 0, YOffset);
80 | // Display the bitmap on a multicolored background.
81 | Graphics.DrawImage(Bitmap, 200, YOffset);
82 | end;
83 |
84 | /// The following code calls the routine above 2 times with different compositing
85 | /// modes. Setting the compositing mode to CompositingModeSourceOver causes the
86 | /// ellipses to be blended with each other as well as with the background.
87 |
88 | procedure TDemoCompositingMode.Run;
89 | begin
90 | DrawShapes(CompositingModeSourceCopy, 0);
91 | DrawShapes(CompositingModeSourceOver, 110);
92 | end;
93 | {$ENDREGION}
94 |
95 | initialization
96 | RegisterDemo('Alpha Blending Lines and Fills\Using Compositing Mode to Control Alpha Blending', TDemoCompositingMode);
97 |
98 | end.
99 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Alpha Blending Lines and Fills/uDemoIndividualAlpha.pas:
--------------------------------------------------------------------------------
1 | unit uDemoIndividualAlpha;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoIndividualAlpha = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoIndividualAlpha }
18 |
19 | {$REGION}
20 | /// The previous example Using a Color Matrix to Set Alpha Values in Images
21 | /// shows a nondestructive method for changing the alpha values of an image. The
22 | /// example in that topic renders an image semitransparently, but the pixel data
23 | /// in the bitmap is not changed. The alpha values are altered only during
24 | /// rendering.
25 | ///
26 | /// The following example shows how to change the alpha values of individual
27 | /// pixels. The code in the example actually changes the alpha information in a
28 | /// IGPBitmap object. The approach is much slower than using a color matrix
29 | /// and an IGPImageAttributes object but gives you control over the
30 | /// individual pixels in the bitmap.
31 |
32 | procedure TDemoIndividualAlpha.Run;
33 | var
34 | Bitmap: IGPBitmap;
35 | Width, Height, Row, Column: Integer;
36 | Color: TGPColor;
37 | Pen: IGPPen;
38 | begin
39 | Bitmap := TGPBitmap.Create('Texture1.jpg');
40 | Width := Bitmap.Width;
41 | Height := Bitmap.Height;
42 | for Row := 0 to Height - 1 do
43 | begin
44 | for Column := 0 to Width - 1 do
45 | begin
46 | Color := Bitmap.Pixels[Column, Row];
47 | Color.Alpha := (255 * Column) div Width;
48 | Bitmap.Pixels[Column, Row] := Color;
49 | end;
50 | end;
51 | Pen := TGPPen.Create(TGPColor.Create(255, 0, 0, 0), 25);
52 | Graphics.DrawLine(Pen, TGPPoint.Create(10, 35), TGPPoint.Create(200, 35));
53 | Graphics.DrawImage(Bitmap, 30, 0, Bitmap.Width, Bitmap.Height);
54 | end;
55 |
56 | /// The preceding code example uses nested loops to change the alpha value of
57 | /// each pixel in the bitmap. For each pixel, the IGPBitmap.Pixels property
58 | /// returns the existing color, TGPColor.SetAlpha changes the alpha value
59 | /// of the color, and the modified color is stored in the bitmap again. The
60 | /// alpha value is set based on the column of the bitmap. In the first column,
61 | /// alpha is set to 0. In the last column, alpha is set to 255. So the resulting
62 | /// image goes from fully transparent (on the left edge) to fully opaque (on the
63 | /// right edge).
64 | ///
65 | /// The IGPBitmap.Pixels property gives you control of the individual pixel
66 | /// values. However, using IGPBitmap.Pixels is not nearly as fast as using
67 | /// the IGPImageAttributes interface and the TGPColorMatrix record.
68 | {$ENDREGION}
69 |
70 | initialization
71 | RegisterDemo('Alpha Blending Lines and Fills\Setting the Alpha Values of Individual Pixels', TDemoIndividualAlpha);
72 |
73 | end.
74 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Alpha Blending Lines and Fills/uDemoSemitransparentBrushes.pas:
--------------------------------------------------------------------------------
1 | unit uDemoSemitransparentBrushes;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoSemitransparentBrushes = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoSemitransparentBrushes }
18 |
19 | {$REGION}
20 | /// When you fill a shape, you must pass a IGPBrush object to one of the
21 | /// fill methods of the IGPGraphics interface. The one parameter of the
22 | /// TGPSolidBrush constructor is a TGPColor record.
23 | /// To fill an opaque shape, set the alpha component of the color to 255. To
24 | /// fill a semitransparent shape, set the alpha component to any value from
25 | /// 1 through 254.
26 | ///
27 | /// When you fill a semitransparent shape, the color of the shape is blended
28 | /// with the colors of the background. The alpha component specifies how the
29 | /// shape and background colors are mixed; alpha values near 0 place more weight
30 | /// on the background colors, and alpha values near 255 place more weigh on the
31 | /// shape color.
32 | ///
33 | /// The following example draws an image and then fills three ellipses that
34 | /// overlap the image. The first ellipse uses an alpha component of 255, so it
35 | /// is opaque. The second and third ellipses use an alpha component of 128, so
36 | /// they are semitransparent; you can see the background image through the
37 | /// ellipses. Setting the IGPGraphics.CompositingQuality property causes
38 | /// the blending for the third ellipse to be done in conjunction with gamma
39 | /// correction.
40 |
41 | procedure TDemoSemitransparentBrushes.Run;
42 | var
43 | Image: IGPImage;
44 | OpaqueBrush, SemiTransBrush: IGPSolidBrush;
45 | begin
46 | Image := TGPImage.Create('Texture1.jpg');
47 | Graphics.DrawImage(Image, 50, 50, Image.Width, Image.Height);
48 | OpaqueBrush := TGPSolidBrush.Create(TGPColor.Create(255, 0, 0, 255));
49 | SemiTransBrush := TGPSolidBrush.Create(TGPColor.Create(128, 0, 0, 255));
50 | Graphics.FillEllipse(OpaqueBrush, 35, 45, 45, 30);
51 | Graphics.FillEllipse(SemiTransBrush, 86, 45, 45, 30);
52 | Graphics.CompositingQuality := CompositingQualityGammaCorrected;
53 | Graphics.FillEllipse(SemiTransBrush, 40, 90, 86, 30);
54 | end;
55 | {$ENDREGION}
56 |
57 | initialization
58 | RegisterDemo('Alpha Blending Lines and Fills\Drawing with Opaque and Semitransparent Brushes', TDemoSemitransparentBrushes);
59 |
60 | end.
61 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Alpha Blending Lines and Fills/uDemoSemitransparentLines.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/Alpha Blending Lines and Fills/uDemoSemitransparentLines.pas
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Constructing and Drawing Curves/uDemoBezierSplines.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/Constructing and Drawing Curves/uDemoBezierSplines.pas
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Constructing and Drawing Curves/uDemoCardinalSplines.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/Constructing and Drawing Curves/uDemoCardinalSplines.pas
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Constructing and Drawing Paths/uDemoCreateFigures.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/Constructing and Drawing Paths/uDemoCreateFigures.pas
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Constructing and Drawing Paths/uDemoFillOpenFigures.pas:
--------------------------------------------------------------------------------
1 | unit uDemoFillOpenFigures;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoFillOpenFigures = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoFillOpenFigures }
18 |
19 | {$REGION}
20 | /// You can fill a path by passing a IGPGraphicsPath object to the
21 | /// IGPGraphics.FillPath method. The FillPath method fills the path
22 | /// according to the fill mode (alternate or winding) currently set for the
23 | /// path. If the path has any open figures, the path is filled as if those
24 | /// figures were closed. GDI+ closes a figure by drawing a straight line from
25 | /// its ending point to its starting point.
26 | ///
27 | /// The following example creates a path that has one open figure (an arc) and
28 | /// one closed figure (an ellipse). The IGPGraphics.FillPath method fills
29 | /// the path according to the default fill mode, which is
30 | /// FillModeAlternate.
31 |
32 | procedure TDemoFillOpenFigures.Run;
33 | var
34 | Path: IGPGraphicsPath;
35 | Pen: IGPPen;
36 | Brush: IGPBrush;
37 | begin
38 | Path := TGPGraphicsPath.Create;
39 |
40 | // Add an open figure.
41 | Path.AddArc(0, 0, 150, 120, 30, 120);
42 |
43 | // Add an intrinsically closed figure.
44 | Path.AddEllipse(50, 50, 50, 100);
45 |
46 | Pen := TGPPen.Create(TGPColor.Create(128, 0, 0, 255), 5);
47 | Brush := TGPSolidBrush.Create(TGPColor.Red);
48 |
49 | Graphics.FillPath(Brush, Path);
50 | Graphics.DrawPath(Pen, Path);
51 | end;
52 |
53 | /// The illustration above the output of the preceding code. Note that path is
54 | /// filled (according to FillModeAlternate) as if the open figure were
55 | /// closed by a straight line from its ending point to its starting point.
56 | {$ENDREGION}
57 |
58 | initialization
59 | RegisterDemo('Constructing and Drawing Paths\Filling Open Figures', TDemoFillOpenFigures);
60 |
61 | end.
62 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/FMain.dfm:
--------------------------------------------------------------------------------
1 | object FormMain: TFormMain
2 | Left = 0
3 | Top = 0
4 | Caption = 'GDI+ 1.0 Demos'
5 | ClientHeight = 672
6 | ClientWidth = 1029
7 | Color = clBtnFace
8 | Font.Charset = DEFAULT_CHARSET
9 | Font.Color = clWindowText
10 | Font.Height = -12
11 | Font.Name = 'Segoe UI'
12 | Font.Style = []
13 | OldCreateOrder = True
14 | OnActivate = FormActivate
15 | OnCreate = FormCreate
16 | OnDestroy = FormDestroy
17 | PixelsPerInch = 96
18 | TextHeight = 15
19 | object Splitter: TSplitter
20 | Left = 369
21 | Top = 0
22 | Width = 5
23 | Height = 672
24 | end
25 | object TreeViewDemos: TTreeView
26 | Left = 0
27 | Top = 0
28 | Width = 369
29 | Height = 672
30 | Align = alLeft
31 | Font.Charset = DEFAULT_CHARSET
32 | Font.Color = clWindowText
33 | Font.Height = -13
34 | Font.Name = 'Segoe UI'
35 | Font.Style = []
36 | HideSelection = False
37 | Indent = 19
38 | ParentFont = False
39 | ReadOnly = True
40 | TabOrder = 0
41 | OnChange = TreeViewDemosChange
42 | end
43 | object PanelClient: TPanel
44 | Left = 374
45 | Top = 0
46 | Width = 655
47 | Height = 672
48 | Align = alClient
49 | BevelOuter = bvNone
50 | TabOrder = 1
51 | object SplitterRight: TSplitter
52 | Left = 0
53 | Top = 235
54 | Width = 655
55 | Height = 5
56 | Cursor = crVSplit
57 | Align = alBottom
58 | ExplicitTop = 237
59 | end
60 | object Pages: TPageControl
61 | Left = 0
62 | Top = 0
63 | Width = 655
64 | Height = 235
65 | ActivePage = TabSheetPrint
66 | Align = alClient
67 | TabOrder = 0
68 | object TabSheetGraphic: TTabSheet
69 | Caption = 'Graphic'
70 | object PaintBox: TPaintBox
71 | Left = 15
72 | Top = 15
73 | Width = 632
74 | Height = 190
75 | Align = alClient
76 | OnPaint = PaintBoxPaint
77 | ExplicitLeft = 188
78 | ExplicitTop = 148
79 | ExplicitWidth = 105
80 | ExplicitHeight = 105
81 | end
82 | object PaintBoxTopRuler: TPaintBox
83 | Left = 0
84 | Top = 0
85 | Width = 647
86 | Height = 15
87 | Align = alTop
88 | OnPaint = PaintBoxTopRulerPaint
89 | ExplicitWidth = 689
90 | end
91 | object PaintBoxLeftRuler: TPaintBox
92 | Left = 0
93 | Top = 15
94 | Width = 15
95 | Height = 190
96 | Align = alLeft
97 | OnPaint = PaintBoxLeftRulerPaint
98 | ExplicitTop = 16
99 | ExplicitHeight = 628
100 | end
101 | end
102 | object TabSheetText: TTabSheet
103 | Caption = 'Text'
104 | ImageIndex = 1
105 | object Memo: TMemo
106 | Left = 0
107 | Top = 0
108 | Width = 647
109 | Height = 205
110 | Align = alClient
111 | BorderStyle = bsNone
112 | ReadOnly = True
113 | ScrollBars = ssVertical
114 | TabOrder = 0
115 | end
116 | end
117 | object TabSheetPrint: TTabSheet
118 | Caption = 'Printer'
119 | ImageIndex = 2
120 | object ButtonPrint: TButton
121 | Left = 8
122 | Top = 8
123 | Width = 75
124 | Height = 25
125 | Caption = 'Print'
126 | TabOrder = 0
127 | OnClick = ButtonPrintClick
128 | end
129 | end
130 | end
131 | object RichEdit: TRichEdit
132 | Left = 0
133 | Top = 240
134 | Width = 655
135 | Height = 432
136 | Align = alBottom
137 | Font.Charset = EASTEUROPE_CHARSET
138 | Font.Color = clWindowText
139 | Font.Height = -11
140 | Font.Name = 'Tahoma'
141 | Font.Style = []
142 | ParentFont = False
143 | ReadOnly = True
144 | ScrollBars = ssVertical
145 | TabOrder = 1
146 | end
147 | end
148 | object PrintDialog: TPrintDialog
149 | Left = 424
150 | Top = 32
151 | end
152 | end
153 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Filling Shapes with a Gradient Brush/uDemoGradientGamma.pas:
--------------------------------------------------------------------------------
1 | unit uDemoGradientGamma;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoGradientGamma = class(TDemo)
11 | strict private
12 | procedure Example1;
13 | procedure Example2;
14 | strict protected
15 | procedure Run; override;
16 | end;
17 |
18 | implementation
19 |
20 | { TDemoGradientGamma }
21 |
22 | {$REGION}
23 | /// You can enable gamma correction for a gradient brush by setting the
24 | /// GammaCorrection property of at brush to True. You can disable gamma
25 | /// correction by setting the GammaCorrection property to False. Gamma
26 | /// correction is disabled by default.
27 | ///
28 | /// The following example creates a linear gradient brush and uses that brush to
29 | /// fill two rectangles. The first rectangle is filled without gamma correction
30 | /// and the second rectangle is filled with gamma correction.
31 |
32 | procedure TDemoGradientGamma.Example1;
33 | var
34 | Brush: IGPLinearGradientBrush;
35 | begin
36 | Brush := TGPLinearGradientBrush.Create(TGPPoint.Create(0, 10), TGPPoint.Create(200, 10),
37 | TGPColor.Red, TGPColor.Blue);
38 | Graphics.FillRectangle(Brush, 0, 0, 200, 50);
39 | Brush.GammaCorrection := True;
40 | Graphics.FillRectangle(Brush, 0, 60, 200, 50);
41 | end;
42 |
43 | /// The illustration above shows the two filled rectangles. The top rectangle,
44 | /// which does not have gamma correction, appears dark in the middle. The bottom
45 | /// rectangle, which has gamma correction, appears to have more uniform intensity.
46 | ///
47 | /// The following example creates a path gradient brush based on a star-shaped
48 | /// path. The code uses the path gradient brush with gamma correction disabled
49 | /// (the default) to fill the path. Then the code sets the
50 | /// GammaCorrection property to True to enable gamma correction for the
51 | /// path gradient brush. The call to IGPGraphics.TranslateTransform sets
52 | /// the world transformation of a IGPGraphics object so that the subsequent
53 | /// call to FillPath fills a star that sits to the right of the first
54 | /// star.
55 |
56 | procedure TDemoGradientGamma.Example2;
57 | const
58 | Points: array [0..9] of TGPPoint = (
59 | (X: 75; Y: 120), (X: 100; Y: 170),
60 | (X: 150; Y: 170), (X: 112; Y: 195),
61 | (X: 150; Y: 270), (X: 75; Y: 220),
62 | (X: 0; Y: 270), (X: 37; Y: 195),
63 | (X: 0; Y: 170), (X: 50; Y: 170));
64 | var
65 | Path: IGPGraphicsPath;
66 | Brush: IGPPathGradientBrush;
67 | Colors: array [0..9] of TGPColor;
68 | begin
69 | Path := TGPGraphicsPath.Create;
70 | Path.AddLines(Points);
71 |
72 | Brush := TGPPathGradientBrush.Create(Path);
73 | Brush.CenterColor := TGPColor.Red;
74 |
75 | Colors[0].Initialize(255, 0, 0, 0);
76 | Colors[1].Initialize(255, 0, 255, 0);
77 | Colors[2].Initialize(255, 0, 0, 255);
78 | Colors[3].Initialize(255, 255, 255, 255);
79 | Colors[4].Initialize(255, 0, 0, 0);
80 | Colors[5].Initialize(255, 0, 255, 0);
81 | Colors[6].Initialize(255, 0, 0, 255);
82 | Colors[7].Initialize(255, 255, 255, 255);
83 | Colors[8].Initialize(255, 0, 0, 0);
84 | Colors[9].Initialize(255, 0, 255, 0);
85 | Brush.SetSurroundColors(Colors);
86 |
87 | Graphics.FillPath(Brush, Path);
88 | Brush.GammaCorrection := True;
89 | Graphics.TranslateTransform(200, 0);
90 | Graphics.FillPath(Brush, Path);
91 | end;
92 |
93 | /// The illustration above shows the output of the preceding code. The star on
94 | /// the right has gamma correction. Note that the star on the left, which does
95 | /// not have gamma correction, has areas that appear dark.
96 | {$ENDREGION}
97 |
98 | procedure TDemoGradientGamma.Run;
99 | begin
100 | Example1;
101 | Example2;
102 | end;
103 |
104 | initialization
105 | RegisterDemo('Filling Shapes with a Gradient Brush\Applying Gamma Correction to a Gradient', TDemoGradientGamma);
106 |
107 | end.
108 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Filling Shapes with a Gradient Brush/uDemoLinearGradient.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/Filling Shapes with a Gradient Brush/uDemoLinearGradient.pas
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Filling Shapes with a Gradient Brush/uDemoPathGradient.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/Filling Shapes with a Gradient Brush/uDemoPathGradient.pas
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/GdiPlus10.dpr:
--------------------------------------------------------------------------------
1 | program GdiPlus10;
2 |
3 | // Disable extended RTTI
4 | {$IF CompilerVersion >= 21.0} // >= Delphi 2010
5 | {$WEAKLINKRTTI ON}
6 | {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
7 | {$IFEND}
8 |
9 | {$SetPEFlags 1} // IMAGE_FILE_RELOCS_STRIPPED
10 | {$SetPEFlags $20} // IMAGE_FILE_LARGE_ADDRESS_AWARE
11 |
12 | uses
13 | Forms,
14 | FMain in 'FMain.pas' {FormMain},
15 | GdiPlus in '..\..\..\Lib\GdiPlus.pas',
16 | uDemo in 'uDemo.pas',
17 | uDemoDrawLine in 'Getting Started\uDemoDrawLine.pas',
18 | uDemoDrawString in 'Getting Started\uDemoDrawString.pas',
19 | uDemoDrawLinesAndRectangles in 'Using a Pen to Draw Lines and Shapes\uDemoDrawLinesAndRectangles.pas',
20 | uDemoPenWidthAndAlignment in 'Using a Pen to Draw Lines and Shapes\uDemoPenWidthAndAlignment.pas',
21 | uDemoDrawLineCaps in 'Using a Pen to Draw Lines and Shapes\uDemoDrawLineCaps.pas',
22 | uDemoJoiningLines in 'Using a Pen to Draw Lines and Shapes\uDemoJoiningLines.pas',
23 | uDemoCustomDashedLine in 'Using a Pen to Draw Lines and Shapes\uDemoCustomDashedLine.pas',
24 | uDemoLineTexture in 'Using a Pen to Draw Lines and Shapes\uDemoLineTexture.pas',
25 | uDemoFillSolidColor in 'Using a Brush to Fill Shapes\uDemoFillSolidColor.pas',
26 | uDemoFillHatchPattern in 'Using a Brush to Fill Shapes\uDemoFillHatchPattern.pas',
27 | uDemoFillImageTexture in 'Using a Brush to Fill Shapes\uDemoFillImageTexture.pas',
28 | uDemoTileImage in 'Using a Brush to Fill Shapes\uDemoTileImage.pas',
29 | uDemoLoadDisplayBitmap in 'Using Images, Bitmaps and Metafiles\uDemoLoadDisplayBitmap.pas',
30 | uDemoLoadDisplayMetafile in 'Using Images, Bitmaps and Metafiles\uDemoLoadDisplayMetafile.pas',
31 | uDemoRecordMetafiles in 'Using Images, Bitmaps and Metafiles\uDemoRecordMetafiles.pas',
32 | uDemoCropAndScaleImages in 'Using Images, Bitmaps and Metafiles\uDemoCropAndScaleImages.pas',
33 | uDemoRotateReflectSkew in 'Using Images, Bitmaps and Metafiles\uDemoRotateReflectSkew.pas',
34 | GdiPlusHelpers in '..\..\..\Lib\GdiPlusHelpers.pas',
35 | uSourceCodeConverter in 'uSourceCodeConverter.pas',
36 | uDemoInterpolationMode in 'Using Images, Bitmaps and Metafiles\uDemoInterpolationMode.pas',
37 | uDemoThumbnails in 'Using Images, Bitmaps and Metafiles\uDemoThumbnails.pas',
38 | uDemoCachedBitmap in 'Using Images, Bitmaps and Metafiles\uDemoCachedBitmap.pas',
39 | uDemoAvoidAutomaticScaling in 'Using Images, Bitmaps and Metafiles\uDemoAvoidAutomaticScaling.pas',
40 | uDemoReadWriteMetaData in 'Using Images, Bitmaps and Metafiles\uDemoReadWriteMetaData.pas',
41 | uDemoListInstalledEncoders in 'Using Image Encoders and Decoders\uDemoListInstalledEncoders.pas',
42 | uDemoListInstalledDecoders in 'Using Image Encoders and Decoders\uDemoListInstalledDecoders.pas',
43 | uDemoGetEncoderClsid in 'Using Image Encoders and Decoders\uDemoGetEncoderClsid.pas',
44 | uDemoEncoderParameters in 'Using Image Encoders and Decoders\Encoder Parameters\uDemoEncoderParameters.pas',
45 | uDemoEncoderValue in 'Using Image Encoders and Decoders\Encoder Parameters\uDemoEncoderValue.pas',
46 | uDemoAllEncoderParameters in 'Using Image Encoders and Decoders\Encoder Parameters\uDemoAllEncoderParameters.pas',
47 | uDemoBmpToPng in 'Using Image Encoders and Decoders\uDemoBmpToPng.pas',
48 | uDemoJpegCompression in 'Using Image Encoders and Decoders\uDemoJpegCompression.pas',
49 | uDemoTransformJpeg in 'Using Image Encoders and Decoders\uDemoTransformJpeg.pas',
50 | uDemoCreateMultiFrame in 'Using Image Encoders and Decoders\uDemoCreateMultiFrame.pas',
51 | uDemoSemitransparentLines in 'Alpha Blending Lines and Fills\uDemoSemitransparentLines.pas',
52 | uDemoSemitransparentBrushes in 'Alpha Blending Lines and Fills\uDemoSemitransparentBrushes.pas',
53 | uDemoCompositingMode in 'Alpha Blending Lines and Fills\uDemoCompositingMode.pas',
54 | uDemoColorMatrixAlpha in 'Alpha Blending Lines and Fills\uDemoColorMatrixAlpha.pas',
55 | uDemoIndividualAlpha in 'Alpha Blending Lines and Fills\uDemoIndividualAlpha.pas',
56 | uDemoConstructingFonts in 'Using Text and Fonts\uDemoConstructingFonts.pas',
57 | uDemoDrawingText in 'Using Text and Fonts\uDemoDrawingText.pas',
58 | uDemoFormattingText in 'Using Text and Fonts\uDemoFormattingText.pas',
59 | uDemoInstalledFonts in 'Using Text and Fonts\uDemoInstalledFonts.pas',
60 | uDemoPrivateFontCollection in 'Using Text and Fonts\uDemoPrivateFontCollection.pas',
61 | uDemoFontMetrics in 'Using Text and Fonts\uDemoFontMetrics.pas',
62 | uDemoAntialiasingText in 'Using Text and Fonts\uDemoAntialiasingText.pas',
63 | uDemoCardinalSplines in 'Constructing and Drawing Curves\uDemoCardinalSplines.pas',
64 | uDemoBezierSplines in 'Constructing and Drawing Curves\uDemoBezierSplines.pas',
65 | uDemoLinearGradient in 'Filling Shapes with a Gradient Brush\uDemoLinearGradient.pas',
66 | uDemoPathGradient in 'Filling Shapes with a Gradient Brush\uDemoPathGradient.pas',
67 | uDemoGradientGamma in 'Filling Shapes with a Gradient Brush\uDemoGradientGamma.pas',
68 | uDemoCreateFigures in 'Constructing and Drawing Paths\uDemoCreateFigures.pas',
69 | uDemoFillOpenFigures in 'Constructing and Drawing Paths\uDemoFillOpenFigures.pas',
70 | uDemoGraphicsState in 'Using Graphics Containers\uDemoGraphicsState.pas',
71 | uDemoNestedContainers in 'Using Graphics Containers\uDemoNestedContainers.pas',
72 | uDemoWorldTransformations in 'Transformations\uDemoWorldTransformations.pas',
73 | uDemoTransformationOrder in 'Transformations\uDemoTransformationOrder.pas',
74 | uDemoHitTestRegion in 'Using Regions\uDemoHitTestRegion.pas',
75 | uDemoClipRegion in 'Using Regions\uDemoClipRegion.pas',
76 | uDemoColorMatrixTransform in 'Recoloring\uDemoColorMatrixTransform.pas',
77 | uDemoTranslatingColors in 'Recoloring\uDemoTranslatingColors.pas',
78 | uDemoScalingColors in 'Recoloring\uDemoScalingColors.pas',
79 | uDemoRotatingColors in 'Recoloring\uDemoRotatingColors.pas',
80 | uDemoShearingColors in 'Recoloring\uDemoShearingColors.pas',
81 | uDemoColorRemapTable in 'Recoloring\uDemoColorRemapTable.pas',
82 | uDemoPrintGdiPlusOutput in 'Printing\uDemoPrintGdiPlusOutput.pas';
83 |
84 | {$R *.res}
85 |
86 | begin
87 | ReportMemoryLeaksOnShutdown := True;
88 | Application.Initialize;
89 | Application.MainFormOnTaskbar := True;
90 | Application.CreateForm(TFormMain, FormMain);
91 | Application.Run;
92 | end.
93 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/GdiPlus10.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/GdiPlus10.res
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/GdiPlus10_Icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/GdiPlus10_Icon.ico
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Getting Started/uDemoDrawLine.pas:
--------------------------------------------------------------------------------
1 | unit uDemoDrawLine;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoDrawLine = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | {$REGION}
18 | /// To draw a line in Microsoft Windows GDI+ you need a IGPGraphics object,
19 | /// a IGPPen object, and a TGPColor record. The IGPGraphics
20 | /// object provides the IGPGraphics.DrawLine method, and the IGPPen
21 | /// object holds attributes of the line, such as color and width. The IGPPen
22 | /// object is passed as an argument to the IGPGraphics.DrawLine method.
23 | ///
24 | /// The following code draws a line from (0, 0) to (200, 100). The argument
25 | /// passed to the TGPPen constructor is a reference to a TGPColor
26 | /// record. The four numbers passed to the color constructor represent the
27 | /// alpha, red, green, and blue components of the color. The alpha component
28 | /// determines the transparency of the color; 0 is fully transparent and 255 is
29 | /// fully opaque. The four numbers passed to the IGPGraphics.DrawLine
30 | /// method represent the starting point (0, 0) and the ending point (200, 100)
31 | /// of the line.
32 |
33 | procedure TDemoDrawLine.Run;
34 | var
35 | Pen: IGPPen;
36 | begin
37 | Pen := TGPPen.Create(TGPColor.Create(255, 0, 0, 255));
38 | Graphics.DrawLine(Pen, 0, 0, 200, 100);
39 | end;
40 | {$ENDREGION}
41 |
42 | initialization
43 | RegisterDemo('Getting Started\Drawing a Line', TDemoDrawLine);
44 |
45 | end.
46 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Getting Started/uDemoDrawString.pas:
--------------------------------------------------------------------------------
1 | unit uDemoDrawString;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoDrawString = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | {$REGION}
18 | procedure TDemoDrawString.Run;
19 | var
20 | Brush: IGPSolidBrush;
21 | FontFamily: IGPFontFamily;
22 | Font: IGPFont;
23 | Point: TGPPointF;
24 | begin
25 | Brush := TGPSolidBrush.Create(TGPColor.Create(255, 0, 0, 255));
26 | FontFamily := TGPFontFamily.Create('Times New Roman');
27 | Font := TGPFont.Create(FontFamily, 24, FontStyleRegular, UnitPixel);
28 | Point.Initialize(10, 20);
29 | Graphics.DrawString('Hello World', Font, Point, Brush);
30 | end;
31 |
32 | /// The previous code creates several GDI+ objects. The IGPGraphics object
33 | /// provides the IGPGraphics.DrawString method, which does the actual
34 | /// drawing. The IGPSolidBrush object specifies the color of the string.
35 | ///
36 | /// The IGPFontFamily constructor receives a single, string argument that
37 | /// identifies the font family. The IGPFontFamily object is the first
38 | /// argument passed to the TGPFont constructor. The second argument passed
39 | /// to the TGPFont constructor specifies the font size, and the third
40 | /// argument specifies the style. The value FontStyleRegular is a member
41 | /// of the TFontStyle enumeration. The last argument to the TGPFont
42 | /// constructor indicates that the size of the font (24 in this case) is
43 | /// measured in pixels. The value UnitPixel is a member of the
44 | /// TUnit enumeration.
45 | ///
46 | /// The first argument passed to the IGPGraphics.DrawString method is a
47 | /// wide-character string. The second argument is the IGPFont object. The
48 | /// third argument is a reference to a TGPPointF record that specifies the
49 | /// location where the string will be drawn. The last argument is the
50 | /// IGPBrush object, which specifies the color of the string.
51 |
52 | {$ENDREGION}
53 |
54 | initialization
55 | RegisterDemo('Getting Started\Drawing a String', TDemoDrawString);
56 |
57 | end.
58 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Printing/uDemoPrintGdiPlusOutput.pas:
--------------------------------------------------------------------------------
1 | unit uDemoPrintGdiPlusOutput;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoPrintGdiPlusOutput = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | public
14 | class function Outputs: TDemoOutputs; override;
15 | end;
16 |
17 | implementation
18 |
19 | uses
20 | Printers;
21 |
22 | { TDemoPrintGdiPlusOutput }
23 |
24 | {$REGION}
25 | /// With a few minor adjustments to your code, you can send Microsoft Windows
26 | /// GDI+ output to a printer rather than to a screen. To draw on a printer,
27 | /// obtain a device context handle for the printer and pass that handle to a
28 | /// TGPGraphics constructor. Place your GDI+ drawing commands in between
29 | /// calls to StartDoc and EndDoc.
30 | ///
31 | /// One way to get a device context handle for a printer is to display a print
32 | /// dialog box and allow the user to choose a printer.
33 | ///
34 | /// The following example draws a line, a rectangle, and an ellipse on the
35 | /// printer selected in the print dialog box. Click on the "Print" button above
36 | /// to execute the example.
37 |
38 | procedure TDemoPrintGdiPlusOutput.Run;
39 | var
40 | PrinterGraphics: IGPGraphics;
41 | Pen: IGPPen;
42 | begin
43 | Printer.BeginDoc;
44 | PrinterGraphics := TGPGraphics.Create(Printer.Handle);
45 | Pen := TGPPen.Create(TGPColor.Black);
46 | PrinterGraphics.DrawRectangle(Pen, 200, 500, 200, 150);
47 | PrinterGraphics.DrawEllipse(Pen, 200, 500, 200, 150);
48 | PrinterGraphics.DrawLine(Pen, 200, 500, 400, 650);
49 | Printer.EndDoc;
50 | end;
51 |
52 | /// In the preceding code, the three GDI+ drawing commands are in between calls
53 | /// to the Printer.BeginDoc and Printer.EndDoc methods. All
54 | /// graphics commands between BeginDoc and EndDoc are routed to a
55 | /// temporary metafile. After the call to EndDoc, the printer driver
56 | /// converts the data in the metafile into the format required by the specific
57 | /// printer being used.
58 | ///
59 | /// Note If spooling is not enabled for the printer being used, the
60 | /// graphics output is not routed to a metafile. Instead, individual graphics
61 | /// commands are processed by the printer driver and then sent to the printer.
62 | {$ENDREGION}
63 |
64 | class function TDemoPrintGdiPlusOutput.Outputs: TDemoOutputs;
65 | begin
66 | Result := [doPrint];
67 | end;
68 |
69 | initialization
70 | RegisterDemo('Printing\Sending GDI+ Output to a Printer', TDemoPrintGdiPlusOutput);
71 |
72 | end.
73 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Recoloring/uDemoColorMatrixTransform.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/Recoloring/uDemoColorMatrixTransform.pas
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Recoloring/uDemoColorRemapTable.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/Recoloring/uDemoColorRemapTable.pas
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Recoloring/uDemoRotatingColors.pas:
--------------------------------------------------------------------------------
1 | unit uDemoRotatingColors;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoRotatingColors = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoRotatingColors }
18 |
19 | {$REGION}
20 | /// Rotation in a four-dimensional color space is difficult to visualize. We can
21 | /// make it easier to visualize rotation by agreeing to keep one of the color
22 | /// components fixed. Suppose we agree to keep the alpha component fixed at 1
23 | /// (fully opaque). Then we can visualize a three-dimensional color space with
24 | /// red, green, and blue axes as shown in the following illustration.
25 | ///
26 | /// See the Platform SDK topic "Rotating Colors" for the illustration
27 | ///
28 | /// A color can be thought of as a point in 3-D space. For example, the point
29 | /// (1, 0, 0) in space represents the color red, and the point (0, 1, 0) in
30 | /// space represents the color green.
31 | ///
32 | /// The following illustration shows what it means to rotate the color (1, 0, 0)
33 | /// through an angle of 60 degrees in the Red-Green plane. Rotation in a plane
34 | /// parallel to the Red-Green plane can be thought of as rotation about the blue
35 | /// axis.
36 | ///
37 | /// See the Platform SDK topic "Rotating Colors" for the illustration
38 | ///
39 | /// The following illustration shows how to initialize a color matrix to perform
40 | /// rotations about each of the three coordinate axes (red, green, blue).
41 | ///
42 | /// See the Platform SDK topic "Rotating Colors" for the illustration
43 | ///
44 | /// The following example takes an image that is all one color (1, 0, 0.6) and
45 | /// applies a 60-degree rotation about the blue axis. The angle of the rotation
46 | /// is swept out in a plane that is parallel to the Red-Green plane.
47 |
48 | procedure TDemoRotatingColors.Run;
49 | const
50 | Degrees = 60;
51 | Radians = Degrees * Pi / 180;
52 | var
53 | Bitmap: IGPBitmap;
54 | BitmapGraphics: IGPGraphics;
55 | ImageAttributes: IGPImageAttributes;
56 | ColorMatrix: TGPColorMatrix;
57 | begin
58 | Bitmap := TGPBitmap.Create(100, 100);
59 | BitmapGraphics := TGPGraphics.Create(Bitmap);
60 | BitmapGraphics.Clear(TGPColor.Create(255, 204, 0, 153));
61 | ImageAttributes := TGPImageAttributes.Create;
62 |
63 | ColorMatrix.SetToIdentity;
64 | ColorMatrix.M[0,0] := Cos(Radians);
65 | ColorMatrix.M[1,0] := -Sin(Radians);
66 | ColorMatrix.M[0,1] := Sin(Radians);
67 | ColorMatrix.M[1,1] := Cos(Radians);
68 |
69 | ImageAttributes.SetColorMatrix(ColorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);
70 | Graphics.DrawImage(Bitmap, 10, 10, 100, 100);
71 | Graphics.DrawImage(Bitmap,
72 | 150, 10, 100, 100, // destination rectangle
73 | 0, 0, 100, 100, // source rectangle
74 | UnitPixel, ImageAttributes);
75 | end;
76 |
77 | /// The illustration above shows the original image on the left and the
78 | /// transformed image on the right.
79 | ///
80 | /// The color rotation performed in the preceding code example can be visualized
81 | /// as follows.
82 | ///
83 | /// See the Platform SDK topic "Rotating Colors" for the illustration
84 | {$ENDREGION}
85 |
86 | initialization
87 | RegisterDemo('Recoloring\Rotating Colors', TDemoRotatingColors);
88 |
89 | end.
90 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Recoloring/uDemoScalingColors.pas:
--------------------------------------------------------------------------------
1 | unit uDemoScalingColors;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoScalingColors = class(TDemo)
11 | strict private
12 | procedure Example1;
13 | procedure Example2;
14 | strict protected
15 | procedure Run; override;
16 | end;
17 |
18 | implementation
19 |
20 | { TDemoScalingColors }
21 |
22 | {$REGION}
23 | /// A scaling transformation multiplies one or more of the four color components
24 | /// by a number. The color matrix entries that represent scaling are given in
25 | /// the following table.
26 | ///
27 | /// Component to
28 | /// be scaledMatrix entry
29 | /// Red[0,0]
30 | /// Green[1,1]
31 | /// Blue[2,2]
32 | /// Alpha[3,3]
33 | ///
34 | /// The following example constructs an IGPImage object from the file
35 | /// ColorBars2.bmp. Then the code scales the blue component of each pixel in the
36 | /// image by a factor of 2. The original image is drawn alongside the
37 | /// transformed image.
38 |
39 | procedure TDemoScalingColors.Example1;
40 | const
41 | ColorMatrix: TGPColorMatrix = (
42 | M: ((1.0, 0.0, 0.0, 0.0, 0.0),
43 | (0.0, 1.0, 0.0, 0.0, 0.0),
44 | (0.0, 0.0, 2.0, 0.0, 0.0),
45 | (0.0, 0.0, 0.0, 1.0, 0.0),
46 | (0.0, 0.0, 0.0, 0.0, 1.0)));
47 | var
48 | Image: IGPImage;
49 | ImageAttributes: IGPImageAttributes;
50 | Width, Height: Integer;
51 | begin
52 | Image := TGPImage.Create('ColorBars2.bmp');
53 | ImageAttributes := TGPImageAttributes.Create;
54 | Width := Image.Width;
55 | Height := Image.Height;
56 |
57 | ImageAttributes.SetColorMatrix(ColorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);
58 | Graphics.DrawImage(Image, 10, 10, Width, Height);
59 | Graphics.DrawImage(Image,
60 | 150, 10, Width, Height, // destination rectangle
61 | 0, 0, Width, Height, // source rectangle
62 | UnitPixel, ImageAttributes);
63 | end;
64 |
65 | /// The top illustration above shows the original image on the left and the
66 | /// transformed image on the right.
67 | ///
68 | /// The following table shows the color vectors for the four bars before and
69 | /// after the blue scaling. Note that the blue component in the fourth color bar
70 | /// went from 0.8 to 0.6. That is because GDI+ retains only the fractional part
71 | /// of the result. For example, (2)(0.8) = 1.6, and the fractional part of 1.6
72 | /// is 0.6. Retaining only the fractional part ensures that the result is always
73 | /// in the interval [0, 1].
74 | ///
75 | /// OriginalScaled
76 | /// (0.4, 0.4, 0.4, 1)(0.4, 0.4, 0.8, 1)
77 | /// (0.4, 0.2, 0.2, 1)(0.4, 0.2, 0.4, 1)
78 | /// (0.2, 0.4, 0.2, 1)(0.2, 0.4, 0.4, 1)
79 | /// (0.4, 0.4, 0.8, 1)(0.4, 0.4, 0.6, 1)
80 | ///
81 | /// The following example constructs an IGPImage object from the file
82 | /// ColorBars3.bmp. Then the code scales the red, green, and blue components of
83 | /// each pixel in the image. The red components are scaled down 25 percent, the
84 | /// green components are scaled down 35 percent, and the blue components are
85 | /// scaled down 50 percent.
86 |
87 | procedure TDemoScalingColors.Example2;
88 | const
89 | ColorMatrix: TGPColorMatrix = (
90 | M: ((0.75, 0.0 , 0.0, 0.0, 0.0),
91 | (0.0 , 0.65, 0.0, 0.0, 0.0),
92 | (0.0 , 0.0 , 0.5, 0.0, 0.0),
93 | (0.0 , 0.0 , 0.0, 1.0, 0.0),
94 | (0.0 , 0.0 , 0.0, 0.0, 1.0)));
95 | var
96 | Image: IGPImage;
97 | ImageAttributes: IGPImageAttributes;
98 | Width, Height: Integer;
99 | begin
100 | Image := TGPImage.Create('ColorBars3.bmp');
101 | ImageAttributes := TGPImageAttributes.Create;
102 | Width := Image.Width;
103 | Height := Image.Height;
104 |
105 | ImageAttributes.SetColorMatrix(ColorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);
106 | Graphics.DrawImage(Image, 10, 150, Width, Height);
107 | Graphics.DrawImage(Image,
108 | 150, 150, Width, Height, // destination rectangle
109 | 0, 0, Width, Height, // source rectangle
110 | UnitPixel, ImageAttributes);
111 | end;
112 |
113 | /// The bottom illustration above shows the original image on the left and the
114 | /// transformed image on the right.
115 | ///
116 | /// The following table shows the color vectors for the four bars before and
117 | /// after the red, green and blue scaling.
118 | ///
119 | /// OriginalScaled
120 | /// (0.6, 0.6, 0.6, 1)(0.45, 0.39, 0.3, 1)
121 | /// (0, 1, 1, 1)(0, 0.65, 0.5, 1)
122 | /// (1, 1, 0, 1)(0.75, 0.65, 0, 1)
123 | /// (1, 0, 1, 1)(0.75, 0, 0.5, 1)
124 | {$ENDREGION}
125 |
126 | procedure TDemoScalingColors.Run;
127 | begin
128 | Example1;
129 | Example2;
130 | end;
131 |
132 | initialization
133 | RegisterDemo('Recoloring\Scaling Colors', TDemoScalingColors);
134 |
135 | end.
136 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Recoloring/uDemoShearingColors.pas:
--------------------------------------------------------------------------------
1 | unit uDemoShearingColors;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoShearingColors = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoShearingColors }
18 |
19 | {$REGION}
20 | /// Shearing increases or decreases a color component by an amount proportional
21 | /// to another color component. For example, consider the transformation where
22 | /// the red component is increased by one half the value of the blue component.
23 | /// Under such a transformation, the color (0.2, 0.5, 1) would become
24 | /// (0.7, 0.5, 1). The new red component is 0.2 + (1/2)(1) = 0.7.
25 | ///
26 | /// The following example constructs an IGPImage object from the file
27 | /// ColorBars4.bmp. Then the code applies the shearing transformation described
28 | /// in the preceding paragraph to each pixel in the image.
29 |
30 | procedure TDemoShearingColors.Run;
31 | const
32 | ColorMatrix: TGPColorMatrix = (
33 | M: ((1.0, 0.0, 0.0, 0.0, 0.0),
34 | (0.0, 1.0, 0.0, 0.0, 0.0),
35 | (0.5, 0.0, 1.0, 0.0, 0.0),
36 | (0.0, 0.0, 0.0, 1.0, 0.0),
37 | (0.0, 0.0, 0.0, 0.0, 1.0)));
38 | var
39 | Image: IGPImage;
40 | ImageAttributes: IGPImageAttributes;
41 | Width, Height: Integer;
42 | begin
43 | Image := TGPImage.Create('ColorBars4.bmp');
44 | ImageAttributes := TGPImageAttributes.Create;
45 | Width := Image.Width;
46 | Height := Image.Height;
47 |
48 | ImageAttributes.SetColorMatrix(ColorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);
49 | Graphics.DrawImage(Image, 10, 10, Width, Height);
50 | Graphics.DrawImage(Image,
51 | 150, 10, Width, Height, // destination rectangle
52 | 0, 0, Width, Height, // source rectangle
53 | UnitPixel, ImageAttributes);
54 | end;
55 |
56 | /// The illustration above shows the original image on the left and the
57 | /// transformed image on the right.
58 | ///
59 | /// The following table shows the color vectors for the four bars before and
60 | /// after the shearing transformation.
61 | ///
62 | /// OriginalSheared
63 | /// (0, 0, 1, 1)(0.5, 0, 1, 1)
64 | /// (0.5, 1, 0.5, 1)(0.75, 1, 0.5, 1)
65 | /// (1, 1, 0, 1)(1, 1, 0, 1)
66 | /// (0.4, 0.4, 0.4, 1)(0.6, 0.4, 0.4, 1)
67 | {$ENDREGION}
68 |
69 | initialization
70 | RegisterDemo('Recoloring\Shearing Colors', TDemoShearingColors);
71 |
72 | end.
73 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Recoloring/uDemoTranslatingColors.pas:
--------------------------------------------------------------------------------
1 | unit uDemoTranslatingColors;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoTranslatingColors = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoTranslatingColors }
18 |
19 | {$REGION}
20 | /// A translation adds a value to one or more of the four color components. The
21 | /// color matrix entries that represent translations are given in the following
22 | /// table.
23 | ///
24 | /// Component to
25 | /// be translatedMatrix entry
26 | /// Red[4,0]
27 | /// Green[4,1]
28 | /// Blue[4,2]
29 | /// Alpha[4,2]
30 | ///
31 | /// The following example constructs an IGPImage object from the file
32 | /// ColorBars.bmp. Then the code adds 0.75 to the red component of each pixel in
33 | /// the image. The original image is drawn alongside the transformed image.
34 |
35 | procedure TDemoTranslatingColors.Run;
36 | const
37 | ColorMatrix: TGPColorMatrix = (
38 | M: ((1.0 , 0.0, 0.0, 0.0, 0.0),
39 | (0.0 , 1.0, 0.0, 0.0, 0.0),
40 | (0.0 , 0.0, 1.0, 0.0, 0.0),
41 | (0.0 , 0.0, 0.0, 1.0, 0.0),
42 | (0.75, 0.0, 0.0, 0.0, 1.0)));
43 | var
44 | Image: IGPImage;
45 | ImageAttributes: IGPImageAttributes;
46 | Width, Height: Integer;
47 | begin
48 | Image := TGPImage.Create('ColorBars.bmp');
49 | ImageAttributes := TGPImageAttributes.Create;
50 | Width := Image.Width;
51 | Height := Image.Height;
52 |
53 | ImageAttributes.SetColorMatrix(ColorMatrix, ColorMatrixFlagsDefault, ColorAdjustTypeBitmap);
54 | Graphics.DrawImage(Image, 10, 10, Width, Height);
55 | Graphics.DrawImage(Image,
56 | 150, 10, Width, Height, // destination rectangle
57 | 0, 0, Width, Height, // source rectangle
58 | UnitPixel, ImageAttributes);
59 | end;
60 |
61 | /// The illustration above shows the original image on the left and the
62 | /// transformed image on the right.
63 | ///
64 | /// The following table lists the color vectors for the four bars before and
65 | /// after the red translation. Note that because the maximum value for a color
66 | /// component is 1, the red component in the second row does not change.
67 | /// (Similarly, the minimum value for a color component is 0.)
68 | ///
69 | /// OriginalTranslated
70 | /// Black (0, 0, 0, 1)(0.75, 0, 0, 1)
71 | /// Red (1, 0, 0, 1)(1, 0, 0, 1)
72 | /// Green (0, 1, 0, 1)(0.75, 1, 0, 1)
73 | /// Blue (0, 0, 1, 1)(0.75, 0, 1, 1)
74 | {$ENDREGION}
75 |
76 | initialization
77 | RegisterDemo('Recoloring\Translating Colors', TDemoTranslatingColors);
78 |
79 | end.
80 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Transformations/uDemoTransformationOrder.pas:
--------------------------------------------------------------------------------
1 | unit uDemoTransformationOrder;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoTransformationOrder = class(TDemo)
11 | strict private
12 | procedure Example1;
13 | procedure Example2;
14 | procedure Example3;
15 | strict protected
16 | procedure Run; override;
17 | end;
18 |
19 | implementation
20 |
21 | { TDemoTransformationOrder }
22 |
23 | {$REGION}
24 | /// A single IGPMatrix object can store a single transformation or a
25 | /// sequence of transformations. The latter is called a composite
26 | /// transformation. The matrix of a composite transformation is obtained by
27 | /// multiplying the matrices of the individual transformations.
28 | ///
29 | /// In a composite transformation, the order of the individual transformations
30 | /// is important. For example, if you first rotate, then scale, then translate,
31 | /// you get a different result than if you first translate, then rotate, then
32 | /// scale. In Microsoft Windows GDI+, composite transformations are built from
33 | /// left to right. If S, R, and T are scale, rotation, and translation matrices
34 | /// respectively, then the product SRT (in that order) is the matrix of the
35 | /// composite transformation that first scales, then rotates, then translates.
36 | /// The matrix produced by the product SRT is different from the matrix produced
37 | /// by the product TRS.
38 | ///
39 | /// One reason order is significant is that transformations like rotation and
40 | /// scaling are done with respect to the origin of the coordinate system.
41 | /// Scaling an object that is centered at the origin produces a different result
42 | /// than scaling an object that has been moved away from the origin. Similarly,
43 | /// rotating an object that is centered at the origin produces a different
44 | /// result than rotating an object that has been moved away from the origin.
45 | ///
46 | /// The following example combines scaling, rotation and translation (in that
47 | /// order) to form a composite transformation. The argument
48 | /// MatrixOrderAppend passed to the RotateTransform method
49 | /// specifies that the rotation will follow the scaling. Likewise, the argument
50 | /// MatrixOrderAppend passed to the TranslateTransform method
51 | /// specifies that the translation will follow the rotation. The result is
52 | /// drawn in red.
53 |
54 | procedure TDemoTransformationOrder.Example1;
55 | var
56 | Rect: TGPRect;
57 | Pen: IGPPen;
58 | begin
59 | Rect.Initialize(0, 0, 50, 50);
60 | Pen := TGPPen.Create(TGPColor.Red, 6);
61 | Graphics.ScaleTransform(1.75, 0.5);
62 | Graphics.RotateTransform(28, MatrixOrderAppend);
63 | Graphics.TranslateTransform(150, 150, MatrixOrderAppend);
64 | Graphics.DrawRectangle(Pen, Rect);
65 | end;
66 |
67 | /// The following example makes the same method calls as the previous example,
68 | /// but the order of the calls is reversed. The resulting order of operations is
69 | /// first translate, then rotate, then scale, which produces a very different
70 | /// result than first scale, then rotate, then translate. The result is drawn
71 | /// in green.
72 |
73 | procedure TDemoTransformationOrder.Example2;
74 | var
75 | Rect: TGPRect;
76 | Pen: IGPPen;
77 | begin
78 | Rect.Initialize(0, 0, 50, 50);
79 | Pen := TGPPen.Create(TGPColor.Lime, 6);
80 | Graphics.TranslateTransform(150, 150);
81 | Graphics.RotateTransform(28, MatrixOrderAppend);
82 | Graphics.ScaleTransform(1.75, 0.5, MatrixOrderAppend);
83 | Graphics.DrawRectangle(Pen, Rect);
84 | end;
85 |
86 | /// One way to reverse the order of the individual transformations in a
87 | /// composite transformation is to reverse the order of a sequence of method
88 | /// calls. A second way to control the order of operations is to change the
89 | /// matrix order argument. The following example is the same as the previous
90 | /// example, except that MatrixOrderAppend has been changed to
91 | /// MatrixOrderPrepend. The matrix multiplication is done in the order SRT,
92 | /// where S, R, and T are the matrices for scale, rotate, and translate,
93 | /// respectively. The order of the composite transformation is first scale, then
94 | /// rotate, then translate. The result in drawn in yellow.
95 |
96 | procedure TDemoTransformationOrder.Example3;
97 | var
98 | Rect: TGPRect;
99 | Pen: IGPPen;
100 | begin
101 | Rect.Initialize(0, 0, 50, 50);
102 | Pen := TGPPen.Create(TGPColor.Yellow, 2);
103 | Graphics.TranslateTransform(150, 150, MatrixOrderPrepend);
104 | Graphics.RotateTransform(28, MatrixOrderPrepend);
105 | Graphics.ScaleTransform(1.75, 0.5, MatrixOrderPrepend);
106 | Graphics.DrawRectangle(Pen, Rect);
107 | end;
108 |
109 | /// The result of the preceding example is the same result that we achieved in
110 | /// the first example of this section (that's why the yellow rectangle overlays
111 | /// the red rectangle). This is because we reversed both the order of the method
112 | /// calls and the order of the matrix multiplication.
113 | {$ENDREGION}
114 |
115 | procedure TDemoTransformationOrder.Run;
116 | begin
117 | Example1;
118 | Graphics.ResetTransform;
119 | Example2;
120 | Graphics.ResetTransform;
121 | Example3;
122 | end;
123 |
124 | initialization
125 | RegisterDemo('Transformations\Why Transformation Order Is Significant', TDemoTransformationOrder);
126 |
127 | end.
128 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Transformations/uDemoWorldTransformations.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/Transformations/uDemoWorldTransformations.pas
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Image Encoders and Decoders/Encoder Parameters/uDemoEncoderParameters.pas:
--------------------------------------------------------------------------------
1 | unit uDemoEncoderParameters;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoEncoderParameters = class(TDemo)
11 | strict private
12 | function GetJpegParameters: IGPEncoderParameters;
13 | procedure ShowSecondJpegParameter(const Params: IGPEncoderParameters);
14 | procedure ShowJpegQualityParameter(const Params: IGPEncoderParameters);
15 | strict protected
16 | procedure Run; override;
17 | public
18 | class function Outputs: TDemoOutputs; override;
19 | end;
20 |
21 | implementation
22 |
23 | uses
24 | SysUtils;
25 |
26 | { TDemoEncoderParameters }
27 |
28 | {$REGION}
29 | /// The IGPImage interface provides the GetEncoderParameterList
30 | /// method so that you can determine the parameters that are supported by a
31 | /// given image encoder. The GetEncoderParameterList method returns an
32 | /// array of TEncoderParameter records.
33 | ///
34 | /// The following example obtains the parameter list for the JPEG encoder.
35 | /// It uses the class property TGPImageFormat.Jpeg to obtain the ClsId of the
36 | /// JPEG encoder.
37 |
38 | function TDemoEncoderParameters.GetJpegParameters: IGPEncoderParameters;
39 | var
40 | Bitmap: IGPBitmap;
41 | begin
42 | // Create IGPBitmap (inherited from IGPImage) interface so that we can call
43 | // GetEncoderParameterList.
44 | Bitmap := TGPBitmap.Create(1, 1);
45 |
46 | // Get the parameter list for the JPEG encoder.
47 | Result := Bitmap.GetEncoderParameterList(TGPImageFormat.Jpeg.CodecId);
48 |
49 | TextOutput.Add(Format('There are %d TEncoderParameter records in the array.',
50 | [Result.Count]))
51 | end;
52 |
53 | /// Each of the TEncoderParameter records in the array has the following
54 | /// four public data members:
55 | ///
56 | /// -Guid (TGUID): GUID of the parameter
57 | /// -NumberOfValues (LongWord): Number of the parameter values
58 | /// -ValueType (TGPEncoderParameterValueType): Value type, like ValueTypeLONG etc.
59 | /// -Value (Pointer): A pointer to the parameter values
60 | ///
61 | /// The following example is a continuation of the preceding example. The code
62 | /// looks at the second TEncoderParameter record in the array returned by
63 | /// GetEncoderParameterList.
64 |
65 | procedure TDemoEncoderParameters.ShowSecondJpegParameter(
66 | const Params: IGPEncoderParameters);
67 | var
68 | Param: PGPNativeEncoderParameter;
69 | begin
70 | Assert(Params.Count >= 2);
71 | Param := Params[1];
72 | TextOutput.Add('Parameter[1]');
73 | TextOutput.Add(Format(' The GUID is %s.', [GUIDToString(Param.Guid)]));
74 | TextOutput.Add(Format(' The value type is %d.', [Ord(Param.ValueType)]));
75 | TextOutput.Add(Format(' The number of values is %d.', [Param.NumberOfValues]));
76 | end;
77 |
78 | /// The preceding code should output the following:
79 | ///
80 | /// Parameter[1]
81 | /// The GUID is {1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB}.
82 | /// The value type is 6.
83 | /// The number of values is 1.
84 | ///
85 | /// You can look up the GUID in GdiPlus.pas and find out that the category of
86 | /// this TEncoderParameter record is EncoderQuality. You can use this
87 | /// category (EncoderQuality) of parameter to set the compression level of a
88 | /// JPEG image.
89 | ///
90 | /// The TGPEncoderParameterValueType enumeration indicates that data type 6
91 | /// is EncoderParameterValueTypeLongRange. A long range is a pair of LongInt
92 | /// values.
93 | ///
94 | /// The number of values is one, so we know that the Value member of the
95 | /// TEncoderParameter record is a pointer to an array that has one
96 | /// element. That one element is a pair of LongWord values.
97 | ///
98 | /// The following example is a continuation of the preceding two examples. The
99 | /// code defines a data type called PLongRange (pointer to a long range). A
100 | /// variable of type PLongRange is used to extract the minimum and maximum
101 | /// values that can be passed as a quality setting to the JPEG encoder.
102 |
103 | procedure TDemoEncoderParameters.ShowJpegQualityParameter(
104 | const Params: IGPEncoderParameters);
105 | type
106 | TLongRange = record
107 | Min: LongInt;
108 | Max: LongInt;
109 | end;
110 | PLongRange = ^TLongRange;
111 | var
112 | Param: PGPNativeEncoderParameter;
113 | LongRange: PLongRange;
114 | begin
115 | Assert(Params.Count >= 2);
116 | Param := Params[1];
117 | LongRange := Param.Value;
118 | TextOutput.Add(Format(' The minimum possible quality value is %d.', [LongRange.Min]));
119 | TextOutput.Add(Format(' The maximum possible quality value is %d.', [LongRange.Max]));
120 | end;
121 |
122 | /// The preceding code should produce the following output:
123 | ///
124 | /// The minimum possible quality value is 0.
125 | /// The maximum possible quality value is 100.
126 | ///
127 | /// In the preceding example, the value returned in the TEncoderParameter
128 | /// record is a pair of LongInt values that indicate the minimum and maximum
129 | /// possible values for the quality parameter. In some cases, the values
130 | /// returned in an TEncoderParameter record are members of the
131 | /// TEncoderValue enumeration. The following examples discuss the
132 | /// TEncoderValue enumeration and methods for listing possible parameter
133 | /// values in more detail:
134 | ///
135 | /// -Using the TEncoderValue Enumeration
136 | /// -Listing Parameters and Values for All Encoders
137 | {$ENDREGION}
138 |
139 | class function TDemoEncoderParameters.Outputs: TDemoOutputs;
140 | begin
141 | Result := [doText];
142 | end;
143 |
144 | procedure TDemoEncoderParameters.Run;
145 | var
146 | Params: IGPEncoderParameters;
147 | begin
148 | Params := GetJpegParameters;
149 | TextOutput.Add('');
150 | ShowSecondJpegParameter(Params);
151 | TextOutput.Add('');
152 | ShowJpegQualityParameter(Params);
153 | end;
154 |
155 | initialization
156 | RegisterDemo('Using Image Encoders and Decoders\Encoder Parameters\Determining the Parameters Supported by an Encoder', TDemoEncoderParameters);
157 |
158 | end.
159 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Image Encoders and Decoders/uDemoBmpToPng.pas:
--------------------------------------------------------------------------------
1 | unit uDemoBmpToPng;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoBmpToPng = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | public
14 | class function Outputs: TDemoOutputs; override;
15 | end;
16 |
17 | implementation
18 |
19 | uses
20 | SysUtils;
21 |
22 | { TDemoBmpToPng }
23 |
24 | class function TDemoBmpToPng.Outputs: TDemoOutputs;
25 | begin
26 | Result := [doText, doGraphic];
27 | end;
28 |
29 | {$REGION}
30 | /// To save an image to a disk file, call the Save method of the
31 | /// IGPImage interface. The following example loads a BMP image from a disk
32 | /// file, converts the image to the PNG format, and saves the converted image to
33 | /// a new disk file. The code uses the predefined class property
34 | /// TGPImageFormat.Png to save the image in PNG format.
35 |
36 | procedure TDemoBmpToPng.Run;
37 | var
38 | Image: IGPImage;
39 | begin
40 | Image := TGPImage.Create('Bird.bmp');
41 | Graphics.DrawImage(Image, 10, 10, Image.Width, Image.Height);
42 | try
43 | Image.Save('Bird.png', TGPImageFormat.Png);
44 | TextOutput.Add('Bird.png was saved successfully.');
45 |
46 | Image := TGPImage.Create('Bird.png');
47 | Graphics.DrawImage(Image, 130, 10, Image.Width, Image.Height);
48 | except
49 | on E: Exception do
50 | TextOutput.Add('Failure: ' + E.Message);
51 | end;
52 | end;
53 | {$ENDREGION}
54 |
55 | initialization
56 | RegisterDemo('Using Image Encoders and Decoders\Converting a BMP Image to a PNG Image', TDemoBmpToPng);
57 |
58 | end.
59 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Image Encoders and Decoders/uDemoCreateMultiFrame.pas:
--------------------------------------------------------------------------------
1 | unit uDemoCreateMultiFrame;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoCreateMultiFrame = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | public
14 | class function Outputs: TDemoOutputs; override;
15 | end;
16 |
17 | implementation
18 |
19 | { TDemoCreateMultiFrame }
20 |
21 | class function TDemoCreateMultiFrame.Outputs: TDemoOutputs;
22 | begin
23 | Result := [doGraphic, doText];
24 | end;
25 |
26 | {$REGION}
27 | /// With certain file formats, you can save multiple images (frames) to a single
28 | /// file. For example, you can save several pages to a single TIFF file. To save
29 | /// the first page, call the Save method of the IGPImage interface.
30 | /// To save subsequent pages, call the SaveAdd method of the
31 | /// IGPImage interface.
32 | ///
33 | /// The following example creates a TIFF file with four pages. The images that
34 | /// become the pages of the TIFF file come from four disk files. The code first
35 | /// constructs four IGPImage objects: Multi, Page2, Page3, and Page4. At
36 | /// first, Multi contains only the image from Shapes.bmp, but eventually it
37 | /// contains all four images. As the individual pages are added to the multi
38 | /// IGPImage object, they are also added to the disk file MultiFrame.tif.
39 | ///
40 | /// Note that the code calls Save (not SaveAdd) to save the first
41 | /// page. The first argument passed to the Save method is the name of the
42 | /// disk file that will eventually contain several frames. The second argument
43 | /// passed to the Save method specifies the encoder that will be used to
44 | /// convert the data in the multi IGPImage object to the format (in this
45 | /// case TIFF) required by the disk file. That same encoder is used
46 | /// automatically by all subsequent calls to the SaveAdd method of the
47 | /// multi IGPImage object.
48 | ///
49 | /// The third argument passed to the Save method is an
50 | /// IGPEncoderParameters object. The IGPEncoderParameters object has
51 | /// a single parameter of type EncoderSaveFlag. The value of the parameter
52 | /// is EncoderValueMultiFrame.
53 | ///
54 | /// The code saves the second, third, and fourth pages by calling the
55 | /// SaveAdd method of the multi IGPImage object. The first argument
56 | /// passed to the SaveAdd method is an IGPImage object. The image in
57 | /// that IGPImage object is added to the multi IGPImage object and is
58 | /// also added to the MultiFrame.tif disk file. The second argument passed to
59 | /// the SaveAdd method is the same IGPEncoderParameters object that
60 | /// was used by the Save method. The difference is that the Value of the
61 | /// parameter now is EncoderValueFrameDimensionPage.
62 |
63 | procedure TDemoCreateMultiFrame.Run;
64 | var
65 | Params: IGPEncoderParameters;
66 | Multi, Page2, Page3, Page4: IGPImage;
67 | X, I, PageCount: Integer;
68 | begin
69 | Params := TGPEncoderParameters.Create;
70 | Multi := TGPImage.Create('Shapes.bmp');
71 | Page2 := TGPImage.Create('Cereal.gif');
72 | Page3 := TGPImage.Create('Iron.jpg');
73 | Page4 := TGPImage.Create('House.png');
74 |
75 | // Save the first page (frame).
76 | Params.Add(EncoderSaveFlag, EncoderValueMultiFrame);
77 | Multi.Save('MultiFrame.tif', TGPImageFormat.Tiff, Params);
78 | TextOutput.Add('Page 1 saved successfully');
79 |
80 | // Save the second page (frame).
81 | Params.Clear;
82 | Params.Add(EncoderSaveFlag, EncoderValueFrameDimensionPage);
83 | Multi.SaveAdd(Page2, Params);
84 | TextOutput.Add('Page 2 saved successfully');
85 |
86 | // Save the third page (frame).
87 | Multi.SaveAdd(Page3, Params);
88 | TextOutput.Add('Page 3 saved successfully');
89 |
90 | // Save the fourth page (frame).
91 | Multi.SaveAdd(Page4, Params);
92 | TextOutput.Add('Page 4 saved successfully');
93 |
94 | // Close the multiframe file.
95 | Params.Clear;
96 | Params.Add(EncoderSaveFlag, EncoderValueFlush);
97 | Multi.SaveAdd(Params);
98 | TextOutput.Add('File closed successfully');
99 |
100 | // Reload the TIFF file
101 | Multi := TGPImage.Create('MultiFrame.tif');
102 | PageCount := Multi.GetFrameCount(FrameDimensionPage);
103 | X := 0;
104 | for I := 0 to PageCount - 1 do
105 | begin
106 | Multi.SelectActiveFrame(FrameDimensionPage, I);
107 | Graphics.DrawImage(Multi, X, 0, Multi.Width, Multi.Height);
108 | Inc(X, Multi.Width + 10);
109 | end;
110 | end;
111 |
112 | /// The last section of the code retrieves the individual frames from a
113 | /// multiple-frame TIFF file. When the TIFF file was created, the individual
114 | /// frames were added to the Page dimension. The code displays each of the four
115 | /// pages.
116 | ///
117 | /// The code constructs an IGPImage object from the multiple-frame TIFF
118 | /// file. To retrieve the individual frames (pages), the code calls the
119 | /// SelectActiveFrame method of that IGPImage object. The first
120 | /// argument passed to the SelectActiveFrame method is a GUID that
121 | /// specifies the dimension in which the frames were previously added to the
122 | /// multiple-frame TIFF file. The GUID FrameDimensionPage is used here. Other
123 | /// GUIDs you can use are FrameDimensionTime and FrameDimensionResolution. The
124 | /// second argument passed to the SelectActiveFrame method is the
125 | /// zero-based index of the desired page.
126 | {$ENDREGION}
127 |
128 | initialization
129 | RegisterDemo('Using Image Encoders and Decoders\Creating and Saving a Multiple-Frame Image', TDemoCreateMultiFrame);
130 |
131 | end.
132 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Image Encoders and Decoders/uDemoGetEncoderClsid.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/Using Image Encoders and Decoders/uDemoGetEncoderClsid.pas
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Image Encoders and Decoders/uDemoJpegCompression.pas:
--------------------------------------------------------------------------------
1 | unit uDemoJpegCompression;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoJpegCompression = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | public
14 | class function Outputs: TDemoOutputs; override;
15 | end;
16 |
17 | implementation
18 |
19 | uses
20 | SysUtils;
21 |
22 | { TDemoJpegCompression }
23 |
24 | class function TDemoJpegCompression.Outputs: TDemoOutputs;
25 | begin
26 | Result := [doText, doGraphic];
27 | end;
28 |
29 | {$REGION}
30 | /// To specify the compression level when you save a JPEG image, initialize an
31 | /// IGPEncoderParameters object and pass that object to the Save
32 | /// method of the IGPImage class. The EncoderParameters
33 | /// interface has several overloaded Add methods that you can use to add
34 | /// parameters. To set a JPEG compression level, use the Add method with
35 | /// a parameter type of EncoderQuality and a value between 0 and 100.
36 | ///
37 | /// The following example saves three JPEG images, each with a different quality
38 | /// level. A quality level of 0 corresponds to the greatest compression, and a
39 | /// quality level of 100 corresponds to the least compression.
40 |
41 | procedure TDemoJpegCompression.Run;
42 | var
43 | Image, JpegImage: IGPImage;
44 | Params: IGPEncoderParameters;
45 | Quality: Int32;
46 | begin
47 | Image := TGPImage.Create('GrapeBunch.bmp');
48 | Graphics.DrawImage(Image, 10, 10, Image.Width, Image.Height);
49 |
50 | Params := TGPEncoderParameters.Create;
51 |
52 | // Save the image as a JPEG with quality level 1.
53 | Quality := 1;
54 | Params.Add(EncoderQuality, Quality);
55 | try
56 | Image.Save('GrapeBunch001.jpg', TGPImageFormat.Jpeg, Params);
57 | TextOutput.Add('GrapeBunch001.jpg was saved successfully.');
58 |
59 | JpegImage := TGPImage.Create('GrapeBunch001.jpg');
60 | Graphics.DrawImage(JpegImage, 220, 10, JpegImage.Width, JpegImage.Height);
61 | except
62 | on E: Exception do
63 | TextOutput.Add('Attempt to save GrapeBunch001.jpg failed: ' + E.Message);
64 | end;
65 |
66 | // Save the image as a JPEG with quality level 50.
67 | Quality := 50;
68 | Params.Clear;
69 | Params.Add(EncoderQuality, Quality);
70 | try
71 | Image.Save('GrapeBunch050.jpg', TGPImageFormat.Jpeg, Params);
72 | TextOutput.Add('GrapeBunch050.jpg was saved successfully.');
73 |
74 | JpegImage := TGPImage.Create('GrapeBunch050.jpg');
75 | Graphics.DrawImage(JpegImage, 430, 10, JpegImage.Width, JpegImage.Height);
76 | except
77 | on E: Exception do
78 | TextOutput.Add('Attempt to save GrapeBunch050.jpg failed: ' + E.Message);
79 | end;
80 |
81 | // Save the image as a JPEG with quality level 100.
82 | Quality := 100;
83 | Params.Clear;
84 | Params.Add(EncoderQuality, Quality);
85 | try
86 | Image.Save('GrapeBunch100.jpg', TGPImageFormat.Jpeg, Params);
87 | TextOutput.Add('GrapeBunch100.jpg was saved successfully.');
88 |
89 | JpegImage := TGPImage.Create('GrapeBunch100.jpg');
90 | Graphics.DrawImage(JpegImage, 640, 10, JpegImage.Width, JpegImage.Height);
91 | except
92 | on E: Exception do
93 | TextOutput.Add('Attempt to save GrapeBunch100.jpg failed: ' + E.Message);
94 | end;
95 | end;
96 | {$ENDREGION}
97 |
98 | initialization
99 | RegisterDemo('Using Image Encoders and Decoders\Setting JPEG Compression Level', TDemoJpegCompression);
100 |
101 | end.
102 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Image Encoders and Decoders/uDemoListInstalledDecoders.pas:
--------------------------------------------------------------------------------
1 | unit uDemoListInstalledDecoders;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoListInstalledDecoders = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | public
14 | class function Outputs: TDemoOutputs; override;
15 | end;
16 |
17 | implementation
18 |
19 | { TDemoListInstalledDecoders }
20 |
21 | class function TDemoListInstalledDecoders.Outputs: TDemoOutputs;
22 | begin
23 | Result := [doText];
24 | end;
25 |
26 | {$REGION}
27 | /// Microsoft Windows GDI+ provides the TGPImageCodecInfo.GetImageDecoders
28 | /// class function so that you can determine which image decoders are available
29 | /// on your computer. TGPImageCodecInfo.GetImageDecoders returns an array
30 | /// of IGPImageCodecInfo objects.
31 |
32 | procedure TDemoListInstalledDecoders.Run;
33 | var
34 | Decoders: IGPImageCodecInfoArray;
35 | Decoder: IGPImageCodecInfo;
36 | begin
37 | Decoders := TGPImageCodecInfo.GetImageDecoders;
38 | for Decoder in Decoders do
39 | TextOutput.Add(Decoder.MimeType);
40 | end;
41 |
42 | /// The output above should show at least the following entries:
43 | ///
44 | /// image/bmp
45 | /// image/jpeg
46 | /// image/gif
47 | /// image/x-emf
48 | /// image/x-wmf
49 | /// image/tiff
50 | /// image/png
51 | /// image/x-icon
52 | {$ENDREGION}
53 |
54 | initialization
55 | RegisterDemo('Using Image Encoders and Decoders\Listing Installed Decoders', TDemoListInstalledDecoders);
56 |
57 | end.
58 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Image Encoders and Decoders/uDemoListInstalledEncoders.pas:
--------------------------------------------------------------------------------
1 | unit uDemoListInstalledEncoders;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoListInstalledEncoders = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | public
14 | class function Outputs: TDemoOutputs; override;
15 | end;
16 |
17 | implementation
18 |
19 | { TDemoListInstalledEncoders }
20 |
21 | class function TDemoListInstalledEncoders.Outputs: TDemoOutputs;
22 | begin
23 | Result := [doText];
24 | end;
25 |
26 | {$REGION}
27 | /// Microsoft Windows GDI+ provides the Image class and the Bitmap
28 | /// class for storing images in memory and manipulating images in memory. GDI+
29 | /// writes images to disk files with the help of image encoders and loads images
30 | /// from disk files with the help of image decoders. An encoder translates the
31 | /// data in an Image or Bitmap object into a designated disk file format. A
32 | /// decoder translates the data in a disk file to the format required by the
33 | /// Image and Bitmap objects. GDI+ has built-in encoders and decoders that support the following file types:
34 | ///
35 | /// -BMP
36 | /// -GIF
37 | /// -JPEG
38 | /// -PNG
39 | /// -TIFF
40 | ///
41 | /// GDI+ also has built-in decoders that support the following file types:
42 | ///
43 | /// -WMF
44 | /// -EMF
45 | /// -ICON
46 | ///
47 | /// GDI+ provides the class function TGPImageCodecInfo.GetImageEncoders
48 | /// so that you can determine which image encoders are available on your
49 | /// computer. TGPImageCodecInfo.GetImageEncoders returns an array of
50 | /// IGPImageCodecInfo objects.
51 |
52 | procedure TDemoListInstalledEncoders.Run;
53 | var
54 | Encoders: IGPImageCodecInfoArray;
55 | Encoder: IGPImageCodecInfo;
56 | begin
57 | Encoders := TGPImageCodecInfo.GetImageEncoders;
58 | for Encoder in Encoders do
59 | TextOutput.Add(Encoder.MimeType);
60 | end;
61 |
62 | /// The output above should show at least the following entries:
63 | ///
64 | /// image/bmp
65 | /// image/jpeg
66 | /// image/gif
67 | /// image/tiff
68 | /// image/png
69 | {$ENDREGION}
70 |
71 | initialization
72 | RegisterDemo('Using Image Encoders and Decoders\Listing Installed Encoders', TDemoListInstalledEncoders);
73 |
74 | end.
75 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Image Encoders and Decoders/uDemoTransformJpeg.pas:
--------------------------------------------------------------------------------
1 | unit uDemoTransformJpeg;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoTransformJpeg = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | public
14 | class function Outputs: TDemoOutputs; override;
15 | end;
16 |
17 | implementation
18 |
19 | uses
20 | SysUtils;
21 |
22 | { TDemoTransformJpeg }
23 |
24 | class function TDemoTransformJpeg.Outputs: TDemoOutputs;
25 | begin
26 | Result := [doGraphic, doText];
27 | end;
28 |
29 | {$REGION}
30 | /// When you compress a JPEG image, some of the information in the image is
31 | /// lost. If you open a JPEG file, alter the image, and save it to another JPEG
32 | /// file, the quality will decrease. If you repeat that process many times, you
33 | /// will see a substantial degradation in the image quality.
34 | ///
35 | /// Because JPEG is one of the most popular image formats on the Web, and
36 | /// because people often like to modify JPEG images, GDI+ provides the following
37 | /// transformations that can be performed on JPEG images without loss of
38 | /// information:
39 | ///
40 | /// -Rotate 90 degrees
41 | /// -Rotate 180 degrees
42 | /// -Rotate 270 degrees
43 | /// -Flip horizontally
44 | /// -Flip vertically
45 | ///
46 | /// You can apply one of the transformations shown in the preceding list when
47 | /// you call the Save method of an IGPImage object. If the following
48 | /// conditions are met, then the transformation will proceed without loss of
49 | /// information:
50 | ///
51 | /// -The file used to construct the IGPImage object is a JPEG file.
52 | /// -The width and height of the image are both multiples of 16.
53 | ///
54 | /// If the width and height of the image are not both multiples of 16, GDI+ will
55 | /// do its best to preserve the image quality when you apply one of the rotation
56 | /// or flipping transformations shown in the preceding list.
57 | ///
58 | /// To transform a JPEG image, initialize an IGPEncoderParameters object
59 | /// and pass that object to the Save method of the IGPImage
60 | /// interface. Add a single parameter to the IGPEncoderParameters of type
61 | /// EncoderTransformation and with a value that holds one of the following
62 | /// elements of the TEncoderValue enumeration:
63 | ///
64 | /// -EncoderValueTransformRotate90,
65 | /// -EncoderValueTransformRotate180,
66 | /// -EncoderValueTransformRotate270,
67 | /// -EncoderValueTransformFlipHorizontal,
68 | /// -EncoderValueTransformFlipVertical
69 | ///
70 | /// The following example creates an IGPImage object from a JPEG file and
71 | /// then saves the image to a new file. During the save process, the image is
72 | /// rotated 90 degrees. If the width and height of the image are both multiples
73 | /// of 16, the process of rotating and saving the image causes no loss of
74 | /// information.
75 |
76 | procedure TDemoTransformJpeg.Run;
77 | var
78 | Image: IGPImage;
79 | Width, Height: Integer;
80 | Params: IGPEncoderParameters;
81 | begin
82 | Image := TGPImage.Create('ImageFile.jpg');
83 | Graphics.DrawImage(Image, 0, 0, Image.Width div 2, Image.Height div 2);
84 | Width := Image.Width;
85 | Height := Image.Height;
86 |
87 | TextOutput.Add(Format('The width of the image is %d,', [Width]));
88 | if ((Width mod 16) = 0) then
89 | TextOutput.Add('which is a multiple of 16.')
90 | else
91 | TextOutput.Add('which is not a multiple of 16.');
92 |
93 | TextOutput.Add(Format('The height of the image is %d,', [Height]));
94 | if ((Height mod 16) = 0) then
95 | TextOutput.Add('which is a multiple of 16.')
96 | else
97 | TextOutput.Add('which is not a multiple of 16.');
98 |
99 | Params := TGPEncoderParameters.Create;
100 | Params.Add(EncoderTransformation, EncoderValueTransformRotate90);
101 | Image.Save('ImageFileR90.jpg', TGPImageFormat.Jpeg, Params);
102 |
103 | // Reload rotated image
104 | Image := TGPImage.Create('ImageFileR90.jpg');
105 | Graphics.DrawImage(Image, 330, 0, Image.Width div 2, Image.Height div 2);
106 | end;
107 | {$ENDREGION}
108 |
109 | initialization
110 | RegisterDemo('Using Image Encoders and Decoders\Transforming a JPEG Image Without Loss of Information', TDemoTransformJpeg);
111 |
112 | end.
113 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Images, Bitmaps and Metafiles/uDemoAvoidAutomaticScaling.pas:
--------------------------------------------------------------------------------
1 | unit uDemoAvoidAutomaticScaling;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoAvoidAutomaticScaling = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | {$REGION}
18 | /// If you pass only the upper-left corner of an image to the DrawImage
19 | /// method, Microsoft Windows GDI+ might scale the image, which would decrease
20 | /// performance.
21 | ///
22 | /// The following call to the DrawImage method specifies an upper-left
23 | /// corner of (50, 30) but does not specify a destination rectangle:
24 | ///
25 | /// Graphics.DrawImage(Image, 50, 30); // upper-left corner at (50, 30)
26 | ///
27 | /// Although this is the easiest version of the DrawImage method in terms
28 | /// of the number of required arguments, it is not necessarily the most
29 | /// efficient. If the number of dots per inch on the current display device is
30 | /// different than the number of dots per inch on the device where the image was
31 | /// created, GDI+ scales the image so that its physical size on the current
32 | /// display device is as close as possible to its physical size on the device
33 | /// where it was created.
34 | ///
35 | /// If you want to prevent such scaling, pass the width and height of a
36 | /// destination rectangle to the DrawImage method. The following example
37 | /// draws the same image twice. In the first case, the width and height of the
38 | /// destination rectangle are not specified, and the image is automatically
39 | /// scaled. In the second case, the width and height (measured in pixels) of the
40 | /// destination rectangle are specified to be the same as the width and height
41 | /// of the original image.
42 |
43 | procedure TDemoAvoidAutomaticScaling.Run;
44 | var
45 | Image: IGPImage;
46 | begin
47 | Image := TGPImage.Create('Texture.bmp');
48 | Graphics.DrawImage(Image, 10, 10);
49 | Graphics.DrawImage(Image, 120, 10, Image.Width, Image.Height);
50 | end;
51 | {$ENDREGION}
52 |
53 | initialization
54 | RegisterDemo('Using Images, Bitmaps and Metafiles\Improving Performance by Avoiding Automatic Scaling', TDemoAvoidAutomaticScaling);
55 |
56 | end.
57 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Images, Bitmaps and Metafiles/uDemoCachedBitmap.pas:
--------------------------------------------------------------------------------
1 | unit uDemoCachedBitmap;
2 |
3 | interface
4 |
5 | uses
6 | Windows,
7 | GdiPlus,
8 | uDemo;
9 |
10 | type
11 | TDemoCachedBitmap = class(TDemo)
12 | strict protected
13 | procedure Run; override;
14 | public
15 | class function Outputs: TDemoOutputs; override;
16 | end;
17 |
18 | implementation
19 |
20 | uses
21 | SysUtils;
22 |
23 | { TDemoCachedBitmap }
24 |
25 | class function TDemoCachedBitmap.Outputs: TDemoOutputs;
26 | begin
27 | Result := [doGraphic, doText];
28 | end;
29 |
30 | {$REGION}
31 | /// IGPImage and IGPBitmap objects store images in a device-independent
32 | /// format. A IGPCachedBitmap object stores an image in the format of the
33 | /// current display device. Rendering an image stored in a CachedBitmap
34 | /// object is fast because no processing time is spent converting the image to
35 | /// the format required by the display device.
36 | ///
37 | /// The following example creates a IGPBitmap object and a
38 | /// IGPCachedBitmap object from the file Texture1.jpg. The IGPBitmap
39 | /// and the IGPCachedBitmap are each drawn 30,000 times. If you run the
40 | /// code, you will see that the IGPCachedBitmap images are drawn
41 | /// substantially faster than the IGPBitmap images.
42 | /// You can check the drawing times by clicking on the "Text" tab above.
43 |
44 | procedure TDemoCachedBitmap.Run;
45 | var
46 | Bitmap: IGPBitmap;
47 | Cached: IGPCachedBitmap;
48 | Width, Height, J, K: Integer;
49 | Freq, ST, ET: Int64;
50 | Seconds: Double;
51 | begin
52 | QueryPerformanceFrequency(Freq);
53 | Bitmap := TGPBitmap.Create('Texture1.jpg');
54 | Width := Bitmap.Width;
55 | Height := Bitmap.Height;
56 | Cached := TGPCachedBitmap.Create(Bitmap, Graphics);
57 |
58 | QueryPerformanceCounter(ST);
59 | J := 0;
60 | while (J < 300) do
61 | begin
62 | for K := 0 to 999 do
63 | Graphics.DrawImage(Bitmap, J, J div 2, Width, Height);
64 | Inc(J, 10);
65 | end;
66 | QueryPerformanceCounter(ET);
67 | Seconds := (ET - ST) / Freq;
68 | TextOutput.Add(Format('DrawImage: %.2f seconds',[Seconds]));
69 |
70 | QueryPerformanceCounter(ST);
71 | J := 0;
72 | while (J < 300) do
73 | begin
74 | for K := 0 to 999 do
75 | Graphics.DrawCachedBitmap(Cached, J, 150 + J div 2);
76 | Inc(J, 10);
77 | end;
78 | QueryPerformanceCounter(ET);
79 | Seconds := (ET - ST) / Freq;
80 | TextOutput.Add(Format('DrawCachedBitmap: %.2f seconds',[Seconds]));
81 | end;
82 |
83 | /// Note A IGPCachedBitmap object matches the format of the display
84 | /// device at the time the IGPCachedBitmap object was constructed. If the
85 | /// user of your program changes the display settings, your code should
86 | /// construct a new IGPCachedBitmap object. The DrawCachedBitmap
87 | /// method will fail if you pass it a IGPCachedBitmap object that was
88 | /// created prior to a change in the display format.
89 | {$ENDREGION}
90 |
91 | initialization
92 | RegisterDemo('Using Images, Bitmaps and Metafiles\Using a Cached Bitmap to Improve Performance', TDemoCachedBitmap);
93 |
94 | end.
95 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Images, Bitmaps and Metafiles/uDemoCropAndScaleImages.pas:
--------------------------------------------------------------------------------
1 | unit uDemoCropAndScaleImages;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoCropAndScaleImages = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | {$REGION}
18 | /// The IGPGraphics interface provides several DrawImage methods,
19 | /// some of which have source and destination rectangle parameters that you can
20 | /// use to crop and scale images.
21 | ///
22 | /// The following example constructs an IGPImage object from the file
23 | /// Apple.gif. The code draws the entire apple image in its original size. The
24 | /// code then calls the DrawImage method of a IGPGraphics object to
25 | /// draw a portion of the apple image in a destination rectangle that is larger
26 | /// than the original apple image.
27 | ///
28 | /// The DrawImage method determines which portion of the apple to draw by
29 | /// looking at the source rectangle, which is specified by the third, fourth,
30 | /// fifth, and sixth arguments. In this case, the apple is cropped to 75 percent
31 | /// of its width and 75 percent of its height.
32 | ///
33 | /// The DrawImage method determines where to draw the cropped apple and
34 | /// how big to make the cropped apple by looking at the destination rectangle,
35 | /// which is specified by the second argument. In this case, the destination
36 | /// rectangle is 30 percent wider and 30 percent taller than the original image.
37 |
38 | procedure TDemoCropAndScaleImages.Run;
39 | var
40 | Image: IGPImage;
41 | Width, Height: Integer;
42 | DestinationRect: TGPRectF;
43 | begin
44 | Image := TGPImage.Create('Apple.gif');
45 | Width := Image.Width;
46 | Height := Image.Height;
47 |
48 | // Make the destination rectangle 30 percent wider and
49 | // 30 percent taller than the original image.
50 | // Put the upper-left corner of the destination
51 | // rectangle at (150, 20).
52 | DestinationRect.Initialize(150, 20, 1.3 * Width, 1.3 * Height);
53 |
54 | // Draw the image unaltered with its upper-left corner at (0, 0).
55 | Graphics.DrawImage(Image, 0, 0);
56 |
57 | // Draw a portion of the image. Scale that portion of the image
58 | // so that it fills the destination rectangle.
59 | Graphics.DrawImage(Image, DestinationRect,
60 | 0, 0, // upper-left corner of source rectangle
61 | 0.75 * Width, // width of source rectangle
62 | 0.75 * Height, // height of source rectangle
63 | UnitPixel);
64 | end;
65 | {$ENDREGION}
66 |
67 | initialization
68 | RegisterDemo('Using Images, Bitmaps and Metafiles\Cropping and Scaling Images', TDemoCropAndScaleImages);
69 |
70 | end.
71 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Images, Bitmaps and Metafiles/uDemoInterpolationMode.pas:
--------------------------------------------------------------------------------
1 | unit uDemoInterpolationMode;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoInterpolationMode = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | {$REGION}
18 | /// The interpolation mode of a IGPGraphics object influences the way
19 | /// Microsoft Windows GDI+ scales (stretches and shrinks) images. The
20 | /// TInterpolationMode enumeration defines several interpolation modes,
21 | /// some of which are shown in the following list:
22 | ///
23 | /// - InterpolationModeNearestNeighbor
24 | /// - InterpolationModeBilinear
25 | /// - InterpolationModeHighQualityBilinear
26 | /// - InterpolationModeBicubic
27 | /// - InterpolationModeHighQualityBicubic
28 | ///
29 | /// To stretch an image, each pixel in the original image must be mapped to a
30 | /// group of pixels in the larger image. To shrink an image, groups of pixels in
31 | /// the original image must be mapped to single pixels in the smaller image. The
32 | /// effectiveness of the algorithms that perform these mappings determines the
33 | /// quality of a scaled image. Algorithms that produce higher-quality scaled
34 | /// images tend to require more processing time. In the preceding list,
35 | /// InterpolationModeNearestNeighbor is the lowest-quality mode and
36 | /// InterpolationModeHighQualityBicubic is the highest-quality mode.
37 | ///
38 | /// To set the interpolation mode, pass one of the members of the
39 | /// TInterpolationMode enumeration to the InterpolationMode
40 | /// property of a IGPGraphics object.
41 | ///
42 | /// The following example draws an image and then shrinks the image with three
43 | /// different interpolation modes:
44 |
45 | procedure TDemoInterpolationMode.Run;
46 | var
47 | Image: IGPImage;
48 | Width, Height: Integer;
49 | begin
50 | Image := TGPImage.Create('GrapeBunch.bmp');
51 | Width := Image.Width;
52 | Height := Image.Height;
53 |
54 | // Draw the image with no shrinking or stretching.
55 | Graphics.DrawImage(Image,
56 | TGPRect.Create(10, 10, Width, Height), // destination rectangle
57 | 0, 0, // upper-left corner of source rectangle
58 | Width, // width of source rectangle
59 | Height, // height of source rectangle
60 | UnitPixel);
61 |
62 | // Shrink the image using low-quality interpolation.
63 | Graphics.InterpolationMode := InterpolationModeNearestNeighbor;
64 | Graphics.DrawImage(Image,
65 | TGPRectF.Create(10, 250, 0.6 * Width, 0.6 * Height), // destination rectangle
66 | 0, 0, // upper-left corner of source rectangle
67 | Width, // width of source rectangle
68 | Height, // height of source rectangle
69 | UnitPixel);
70 |
71 | // Shrink the image using medium-quality interpolation.
72 | Graphics.InterpolationMode := InterpolationModeHighQualityBilinear;
73 | Graphics.DrawImage(Image,
74 | TGPRectF.Create(150, 250, 0.6 * Width, 0.6 * Height), // destination rectangle
75 | 0, 0, // upper-left corner of source rectangle
76 | Width, // width of source rectangle
77 | Height, // height of source rectangle
78 | UnitPixel);
79 |
80 | // Shrink the image using high-quality interpolation.
81 | Graphics.InterpolationMode := InterpolationModeHighQualityBicubic;
82 | Graphics.DrawImage(Image,
83 | TGPRectF.Create(290, 250, 0.6 * Width, 0.6 * Height), // destination rectangle
84 | 0, 0, // upper-left corner of source rectangle
85 | Width, // width of source rectangle
86 | Height, // height of source rectangle
87 | UnitPixel);
88 | end;
89 | {$ENDREGION}
90 |
91 | initialization
92 | RegisterDemo('Using Images, Bitmaps and Metafiles\Using Interpolation Mode to Control Image Quality During Scaling', TDemoInterpolationMode);
93 |
94 | end.
95 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Images, Bitmaps and Metafiles/uDemoLoadDisplayBitmap.pas:
--------------------------------------------------------------------------------
1 | unit uDemoLoadDisplayBitmap;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoLoadDisplayBitmap = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | {$REGION}
18 | /// Microsoft Windows GDI+ provides the IGPImage interface for working with
19 | /// raster images (bitmaps) and vector images (metafiles). The IGPBitmap
20 | /// interface and the IGPMetafile interface both inherit from the
21 | /// IGPImage interface. The IGPBitmap interface expands on the
22 | /// capabilities of the IGPImage interface by providing additional methods
23 | /// for loading, saving, and manipulating raster images. The IGPMetafile
24 | /// interface expands on the capabilities of the IGPImage interface by
25 | /// providing additional methods for recording and examining vector images.
26 | ///
27 | /// To display a raster image (bitmap) on the screen, you need an IGPImage
28 | /// object and a IGPGraphics object. Pass the name of a file (or a pointer
29 | /// to a stream) to an TGPImage constructor. After you have created an
30 | /// IGPImage object, pass that IGPImage object to the DrawImage
31 | /// method of a IGPGraphics object.
32 | ///
33 | /// The following example creates an IGPImage object from a JPEG file and
34 | /// then draws the image with its upper-left corner at (60, 10):
35 |
36 | procedure TDemoLoadDisplayBitmap.Run;
37 | var
38 | Image: IGPImage;
39 | begin
40 | Image := TGPImage.Create('Grapes.jpg');
41 | Graphics.DrawImage(Image, 60, 10);
42 | end;
43 |
44 | /// The IGPImage interface provides basic methods for loading and
45 | /// displaying raster images and vector images. The IGPBitmap interface,
46 | /// which inherits from the IGPImage interface, provides more specialized
47 | /// methods for loading, displaying, and manipulating raster images. For
48 | /// example, you can construct a IGPBitmap object from an icon handle
49 | /// (HICON).
50 | {$ENDREGION}
51 |
52 | initialization
53 | RegisterDemo('Using Images, Bitmaps and Metafiles\Loading and Displaying Bitmaps', TDemoLoadDisplayBitmap);
54 |
55 | end.
56 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Images, Bitmaps and Metafiles/uDemoLoadDisplayMetafile.pas:
--------------------------------------------------------------------------------
1 | unit uDemoLoadDisplayMetafile;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoLoadDisplayMetafile = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | {$REGION}
18 | /// The IGPImage interface provides basic methods for loading and
19 | /// displaying raster images and vector images. The IGPMetafile interface,
20 | /// which inherits from the IGPImage class, provides more specialized
21 | /// methods for recording, displaying, and examining vector images.
22 | ///
23 | /// To display a vector image (metafile) on the screen, you need an
24 | /// IGPImage object and a IGPGraphics object. Pass the name of a file
25 | /// (or a pointer to a stream) to an TGPImage constructor. After you have
26 | /// created an IGPImage object, pass that IGPImage object to the
27 | /// DrawImage method of a IGPGraphics object.
28 | ///
29 | /// The following example creates an IGPImage object from an EMF (enhanced
30 | /// metafile) file and then draws the image with its upper-left corner at
31 | /// (60, 10):
32 |
33 | procedure TDemoLoadDisplayMetafile.Run;
34 | var
35 | Image: IGPImage;
36 | begin
37 | Image := TGPImage.Create('SampleMetafile.emf');
38 | Graphics.DrawImage(Image, 60, 10);
39 | end;
40 | {$ENDREGION}
41 |
42 | initialization
43 | RegisterDemo('Using Images, Bitmaps and Metafiles\Loading and Displaying Metafiles', TDemoLoadDisplayMetafile);
44 |
45 | end.
46 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Images, Bitmaps and Metafiles/uDemoRecordMetafiles.pas:
--------------------------------------------------------------------------------
1 | unit uDemoRecordMetafiles;
2 |
3 | interface
4 |
5 | uses
6 | Windows,
7 | GdiPlus,
8 | uDemo;
9 |
10 | type
11 | TDemoRecordMetafiles = class(TDemo)
12 | strict protected
13 | procedure Run; override;
14 | end;
15 |
16 | implementation
17 |
18 | uses
19 | SysUtils;
20 |
21 | {$REGION}
22 | /// The IGPMetafile interface, which inherits from the IGPImage
23 | /// interface, allows you to record a sequence of drawing commands. The recorded
24 | /// commands can be stored in memory, saved to a file, or saved to a stream.
25 | /// Metafiles can contain vector graphics, raster images, and text.
26 | ///
27 | /// The following example creates a IGPMetafile object. The code uses the
28 | /// IGPMetafile object to record a sequence of graphics commands and then
29 | /// saves the recorded commands in a file named SampleMetafileRecording.emf.
30 | /// Note that the TGPMetafile constructor receives a device context handle,
31 | /// and the TGPGraphics constructor receives the IGPMetafile object.
32 | /// The recording stops (and the recorded commands are saved to the file) when
33 | /// the IGPGraphics object goes out of scope. The last line of code display
34 | /// the metafile by passing the IGPMetafile object to the DrawImage
35 | /// method of the IGPGraphics object. Note that the code uses the same
36 | /// IGPMetafile object to record and to display (play back) the metafile.
37 |
38 | procedure TDemoRecordMetafiles.Run;
39 | var
40 | DC: HDC;
41 | Metafile: IGPMetafile;
42 | MetaGraphics: IGPGraphics;
43 | GreenPen: IGPPen;
44 | SolidBrush: IGPSolidBrush;
45 | FontFamily: IGPFontFamily;
46 | Font: IGPFont;
47 | begin
48 | DeleteFile('SampleMetafileRecording.emf');
49 | DC := GetDC(0);
50 | try
51 | Metafile := TGPMetafile.Create('SampleMetafileRecording.emf', DC);
52 | MetaGraphics := TGPGraphics.Create(Metafile);
53 | GreenPen := TGPPen.Create(TGPColor.Create(255, 0, 255, 0));
54 | SolidBrush := TGPSolidBrush.Create(TGPColor.Create(255, 0, 0, 255));
55 |
56 | // Add a rectangle and an ellipse to the metafile.
57 | MetaGraphics.DrawRectangle(GreenPen, TGPRect.Create(50, 10, 25, 75));
58 | MetaGraphics.DrawEllipse(GreenPen, TGPRect.Create(100, 10, 25, 75));
59 |
60 | // Add an ellipse (drawn with antialiasing) to the metafile.
61 | MetaGraphics.SmoothingMode := SmoothingModeHighQuality;
62 | MetaGraphics.DrawEllipse(GreenPen, TGPRect.Create(150, 10, 25, 75));
63 |
64 | // Add some text (drawn with antialiasing) to the metafile.
65 | FontFamily := TGPFontFamily.Create('Arial');
66 | Font := TGPFont.Create(FontFamily, 24, FontStyleRegular, UnitPixel);
67 |
68 | MetaGraphics.TextRenderingHint := TextRenderingHintAntiAlias;
69 | MetaGraphics.RotateTransform(30);
70 | MetaGraphics.DrawString('Smooth Text', Font, TGPPointF.Create(50, 50), SolidBrush);
71 |
72 | MetaGraphics := nil; // End of recording metafile.
73 | finally
74 | ReleaseDC(0, DC);
75 | end;
76 |
77 | // Play back the metafile.
78 | Graphics.DrawImage(Metafile, 200, 100);
79 | end;
80 |
81 | /// Note To record a metafile, you must construct a IGPGraphics
82 | /// object based on a IGPMetafile object. The recording of the metafile
83 | /// ends when that IGPGraphics object is deleted or goes out of scope.
84 | ///
85 | /// A metafile contains its own graphics state, which is defined by the
86 | /// IGPGraphics object used to record the metafile. Any properties of the
87 | /// IGPGraphics object (clip region, world transformation, smoothing mode,
88 | /// and the like) that you set while recording the metafile will be stored in
89 | /// the metafile. When you display the metafile, the drawing will be done
90 | /// according to those stored properties.
91 | {$ENDREGION}
92 |
93 | initialization
94 | RegisterDemo('Using Images, Bitmaps and Metafiles\Recording Metafiles', TDemoRecordMetafiles);
95 |
96 | end.
97 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Images, Bitmaps and Metafiles/uDemoRotateReflectSkew.pas:
--------------------------------------------------------------------------------
1 | unit uDemoRotateReflectSkew;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoRotateReflectSkew = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | {$REGION}
18 | /// You can rotate, reflect, and skew an image by specifying destination points
19 | /// for the upper-left, upper-right, and lower-left corners of the original
20 | /// image. The three destination points determine an affine transformation that
21 | /// maps the original rectangular image to a parallelogram. (The lower-right
22 | /// corner of the original image is mapped to the fourth corner of the
23 | /// parallelogram, which is calculated from the three specified destination
24 | /// points.)
25 | ///
26 | /// For example, suppose the original image is a rectangle with upper-left
27 | /// corner at (0, 0), upper-right corner at (100, 0), and lower-left corner at
28 | /// (0, 50). Now suppose we map those three points to destination points as
29 | /// in the following code:
30 |
31 | procedure TDemoRotateReflectSkew.Run;
32 | const
33 | DestinationPoints: TGPPlgPoints = (
34 | (X: 200; Y: 20), // destination for upper-left point of original
35 | (X: 110; Y: 100), // destination for upper-right point of original
36 | (X: 250; Y: 30)); // destination for lower-left point of original
37 | var
38 | Image: IGPImage;
39 | begin
40 | Image := TGPImage.Create('Stripes.bmp');
41 | // Draw the image unaltered with its upper-left corner at (0, 0).
42 | Graphics.DrawImage(Image, 0, 0);
43 | // Draw the image mapped to the parallelogram.
44 | Graphics.DrawImage(Image, DestinationPoints);
45 | end;
46 |
47 | /// The illustration shows the original image and the image mapped to the
48 | /// parallelogram. The original image has been skewed, reflected, rotated, and
49 | /// translated. The x-axis along the top edge of the original image is mapped
50 | /// to the line that runs through (200, 20) and (110, 100). The y-axis along the
51 | /// left edge of the original image is mapped to the line that runs through
52 | /// (200, 20) and (250, 30).
53 | {$ENDREGION}
54 |
55 | initialization
56 | RegisterDemo('Using Images, Bitmaps and Metafiles\Rotating, Reflecting and Skewing Images', TDemoRotateReflectSkew);
57 |
58 | end.
59 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Images, Bitmaps and Metafiles/uDemoThumbnails.pas:
--------------------------------------------------------------------------------
1 | unit uDemoThumbnails;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoThumbnails = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | {$REGION}
18 | /// A thumbnail image is a small version of an image. You can create a thumbnail
19 | /// image by calling the GetThumbnailImage method of an IGPImage
20 | /// object.
21 | ///
22 | /// The following example constructs an IGPImage object from the file
23 | /// ImageFile.jpg. The original image has a width of 640 pixels and a height of
24 | /// 480 pixels. The code creates a thumbnail image that has a width of 100
25 | /// pixels and a height of 100 pixels.
26 |
27 | procedure TDemoThumbnails.Run;
28 | var
29 | Image, Thumbnail: IGPImage;
30 | begin
31 | Image := TGPImage.Create('ImageFile.jpg');
32 | Thumbnail := Image.GetThumbnailImage(100, 100, nil, nil);
33 | Graphics.DrawImage(Thumbnail, 10, 10, Thumbnail.Width, Thumbnail.Height);
34 | end;
35 | {$ENDREGION}
36 |
37 | initialization
38 | RegisterDemo('Using Images, Bitmaps and Metafiles\Creating Thumbnail Images', TDemoThumbnails);
39 |
40 | end.
41 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Regions/uDemoClipRegion.pas:
--------------------------------------------------------------------------------
1 | unit uDemoClipRegion;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoClipRegion = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoClipRegion }
18 |
19 | {$REGION}
20 | /// One of the properties of the IGPGraphics interface is the clipping
21 | /// region. All drawing done by a given IGPGraphics object is restricted to
22 | /// the clipping region of that IGPGraphics object. You can set the
23 | /// clipping region by calling the SetClip method or setting the
24 | /// Clip property.
25 | ///
26 | /// The following example constructs a path that consists of a single polygon.
27 | /// Then the code constructs a region based on that path. The region is
28 | /// assigned to the Clip property of the IGPGraphics object, and
29 | /// then two strings are drawn.
30 |
31 | procedure TDemoClipRegion.Run;
32 | const
33 | PolyPoints: array [0..3] of TGPPoint = (
34 | (X: 10; Y: 10), (X: 150; Y: 10), (X: 100; Y: 75), (X: 100; Y: 150));
35 | var
36 | Path: IGPGraphicsPath;
37 | Region: IGPRegion;
38 | Pen: IGPPen;
39 | Font: IGPFont;
40 | Brush: IGPBrush;
41 | begin
42 | Path := TGPGraphicsPath.Create;
43 | Path.AddPolygon(PolyPoints);
44 | Region := TGPRegion.Create(Path);
45 | Pen := TGPPen.Create(TGPColor.Black);
46 | Graphics.DrawPath(Pen, Path);
47 |
48 | Graphics.Clip := Region;
49 | Font := TGPFont.Create('Arial', 36, [FontStyleBold], UnitPixel);
50 | Brush := TGPSolidBrush.Create(TGPColor.Red);
51 | Graphics.DrawString('A Clipping Region', Font, TGPPointF.Create(15, 25), Brush);
52 | Graphics.DrawString('A Clipping Region', Font, TGPPointF.Create(15, 68), Brush);
53 | end;
54 |
55 | /// The illustration above shows the clipped strings.
56 | {$ENDREGION}
57 |
58 | initialization
59 | RegisterDemo('Using Regions\Clipping with a Region', TDemoClipRegion);
60 |
61 | end.
62 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Regions/uDemoHitTestRegion.pas:
--------------------------------------------------------------------------------
1 | unit uDemoHitTestRegion;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoHitTestRegion = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoHitTestRegion }
18 |
19 | {$REGION}
20 | /// The Microsoft Windows GDI+ IGPRegion interface allows you to define a
21 | /// custom shape. The shape can be made up of lines, polygons, and curves.
22 | ///
23 | /// Two common uses for regions are hit testing and clipping. Hit testing is
24 | /// determining whether the mouse was clicked in a certain region of the screen.
25 | /// Clipping is restricting drawing to a certain region.
26 | ///
27 | /// The purpose of hit testing is to determine whether the cursor is over a
28 | /// given object, such as an icon or a button. The following example creates a
29 | /// plus-shaped region by forming the union of two rectangular regions. Assume
30 | /// that the parameter MousePoint holds the location of the most recent
31 | /// click. The code checks to see whether MousePoint is in the
32 | /// plus-shaped region. If MousePoint is in the region (a hit), the
33 | /// region is filled with an opaque red brush. Otherwise, the region is filled
34 | /// with a semitransparent red brush.
35 |
36 | procedure TDemoHitTestRegion.Run;
37 |
38 | procedure HitTest(const RegionOffset, MousePoint: TGPPoint);
39 | var
40 | Brush: IGPSolidBrush;
41 | Region1, Region2: IGPRegion;
42 | begin
43 | Brush := TGPSolidBrush.Create(0);
44 | // Create a plus-shaped region by forming the union of Region1 and Region2.
45 | Region1 := TGPRegion.Create(TGPRect.Create(RegionOffset.X + 50, RegionOffset.Y, 50, 150));
46 | Region2 := TGPRegion.Create(TGPRect.Create(RegionOffset.X, RegionOffset.Y + 50, 150, 50));
47 | // The union replaces Region1.
48 | Region1.Union(Region2);
49 |
50 | if (Region1.IsVisible(MousePoint, Graphics)) then
51 | Brush.Color := TGPColor.Create(255, 255, 0, 0)
52 | else
53 | Brush.Color := TGPColor.Create(64, 255, 0, 0);
54 | Graphics.FillRegion(Brush, Region1);
55 |
56 | // Draw MousePoint for reference
57 | Brush.Color := TGPColor.Blue;
58 | Graphics.FillRectangle(Brush, MousePoint.X - 2, MousePoint.Y - 2, 5, 5);
59 | end;
60 |
61 | begin
62 | HitTest(TGPPoint.Create(0, 0), TGPPoint.Create(60, 10));
63 | HitTest(TGPPoint.Create(200, 0), TGPPoint.Create(220, 20));
64 | end;
65 | {$ENDREGION}
66 |
67 | initialization
68 | RegisterDemo('Using Regions\Hit Testing with a Region', TDemoHitTestRegion);
69 |
70 | end.
71 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Text and Fonts/uDemoAntialiasingText.pas:
--------------------------------------------------------------------------------
1 | unit uDemoAntialiasingText;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoAntialiasingText = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoAntialiasingText }
18 |
19 | {$REGION}
20 | /// Microsoft Windows GDI+ provides various quality levels for drawing text.
21 | /// Typically, higher quality rendering takes more processing time than lower
22 | /// quality rendering.
23 | ///
24 | /// The quality level is a property of the IGPGraphics class. To set the
25 | /// quality level, set the TextRenderingHint method of a IGPGraphics
26 | /// object. The TextRenderingHint property receives one of the elements
27 | /// of the TTextRenderingHint enumeration.
28 | ///
29 | /// GDI+ provides traditional antialiasing and a new kind of antialiasing based
30 | /// on Microsoft ClearType display technology only available on Windows XP and
31 | /// Windows Server 2003 and later. ClearType smoothing improves readability on
32 | /// color LCD monitors that have a digital interface, such as the monitors in
33 | /// laptops and high-quality flat desktop displays. Readability on CRT screens
34 | /// is also somewhat improved.
35 | ///
36 | /// ClearType is dependent on the orientation and ordering of the LCD stripes.
37 | /// Currently, ClearType is implemented only for vertical stripes that are
38 | /// ordered RGB. This might be a concern if you are using a tablet PC, where the
39 | /// display can be oriented in any direction, or if you are using a screen that
40 | /// can be turned from landscape to portrait.
41 | ///
42 | /// The following example draws text with two different quality settings.
43 |
44 | procedure TDemoAntialiasingText.Run;
45 | var
46 | FontFamily: IGPFontFamily;
47 | Font: IGPFont;
48 | Brush: IGPSolidBrush;
49 | Rect: TGPRect;
50 | begin
51 | FontFamily := TGPFontFamily.Create('Times New Roman');
52 | Font := TGPFont.Create(FontFamily, 32, FontStyleRegular, UnitPixel);
53 |
54 | Brush := TGPSolidBrush.Create(TGPColor.White);
55 | Rect.Initialize(10, 10, 250, 100);
56 | Graphics.FillRectangle(Brush, Rect);
57 | Brush.Color := TGPColor.Blue;
58 |
59 | Graphics.TextRenderingHint := TextRenderingHintSingleBitPerPixel;
60 | Graphics.DrawString('SingleBitPerPixel', Font, TGPPointF.Create(10, 10), Brush);
61 |
62 | Graphics.TextRenderingHint := TextRenderingHintAntiAlias;
63 | Graphics.DrawString('AntiAlias', Font, TGPPointF.Create(10, 60), Brush);
64 | end;
65 | {$ENDREGION}
66 |
67 | initialization
68 | RegisterDemo('Using Text and Fonts\Antialiasing with Text', TDemoAntialiasingText);
69 |
70 | end.
71 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Text and Fonts/uDemoConstructingFonts.pas:
--------------------------------------------------------------------------------
1 | unit uDemoConstructingFonts;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoConstructingFonts = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoConstructingFonts }
18 |
19 | {$REGION}
20 | /// Microsoft Windows GDI+ provides several classes that form the foundation for
21 | /// drawing text. The IGPGraphics interface has several DrawString
22 | /// methods that allow you to specify various features of text, such as
23 | /// location, bounding rectangle, font, and format. Other interfaces that
24 | /// contribute to text rendering include IGPFontFamily, IGPFont,
25 | /// IGPStringFormat, IGPInstalledFontCollection, and
26 | /// IGPPrivateFontCollection.
27 | ///
28 | /// Microsoft Windows GDI+ groups fonts with the same typeface but different
29 | /// styles into font families. For example, the Arial font family contains the
30 | /// following fonts:
31 | ///
32 | /// -Arial Regular
33 | /// -Arial Bold
34 | /// -Arial Italic
35 | /// -Arial Bold Italic
36 | ///
37 | /// GDI+ uses four styles to form families: regular, bold, italic, and bold
38 | /// italic. Adjectives such as narrow and rounded are not considered styles;
39 | /// rather they are part of the family name. For example, Arial Narrow is a font
40 | /// family whose members are the following:
41 | ///
42 | /// -Arial Narrow Regular
43 | /// -Arial Narrow Bold
44 | /// -Arial Narrow Italic
45 | /// -Arial Narrow Bold Italic
46 | ///
47 | /// Before you can draw text with GDI+, you need to construct a IGPFontFamily
48 | /// object and a IGPFont object. The IGPFontFamily objects specifies
49 | /// the typeface (for example, Arial), and the IGPFont object specifies the
50 | /// size, style, and units.
51 | ///
52 | /// The following example constructs a regular style Arial font with a size of
53 | /// 16 pixels:
54 |
55 | procedure TDemoConstructingFonts.Run;
56 | var
57 | FontFamily: IGPFontFamily;
58 | Font: IGPFont;
59 | Brush: IGPBrush;
60 | begin
61 | FontFamily := TGPFontFamily.Create('Arial');
62 | Font := TGPFont.Create(FontFamily, 16, FontStyleRegular, UnitPixel);
63 | Brush := TGPSolidBrush.Create(TGPColor.Black);
64 | Graphics.DrawString('The Quick Brown Fox Jumps Over The Lazy Dog', Font,
65 | TGPPointF.Create(0, 0), Brush);
66 | end;
67 |
68 | /// In the preceding code, the first argument passed to the TGPFont
69 | /// constructor is the IGPFontFamily object. The second argument specifies
70 | /// the size of the font measured in units identified by the fourth argument.
71 | /// The third argument identifies the style.
72 | ///
73 | /// UnitPixel is a member of the TUnit enumeration, and FontStyleRegular
74 | /// an empty set of type TFontStyle enumeration.
75 | {$ENDREGION}
76 |
77 | initialization
78 | RegisterDemo('Using Text and Fonts\Constructing Font Families and Fonts', TDemoConstructingFonts);
79 |
80 | end.
81 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Text and Fonts/uDemoDrawingText.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/Using Text and Fonts/uDemoDrawingText.pas
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Text and Fonts/uDemoFontMetrics.pas:
--------------------------------------------------------------------------------
1 | unit uDemoFontMetrics;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoFontMetrics = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | public
14 | class function Outputs: TDemoOutputs; override;
15 | end;
16 |
17 | implementation
18 |
19 | uses
20 | SysUtils;
21 |
22 | { TDemoFontMetrics }
23 |
24 | class function TDemoFontMetrics.Outputs: TDemoOutputs;
25 | begin
26 | Result := [doText];
27 | end;
28 |
29 | {$REGION}
30 | /// The IGPFontFamily interface provides the following methods that
31 | /// retrieve various metrics for a particular family/style combination:
32 | ///
33 | /// -GetEmHeight(FontStyle)
34 | /// -GetCellAscent(FontStyle)
35 | /// -GetCellDescent(FontStyle)
36 | /// -GetLineSpacing(FontStyle)
37 | ///
38 | /// The numbers returned by these methods are in font design units, so they are
39 | /// independent of the size and units of a particular IGPFont object.
40 | ///
41 | /// The following example displays the metrics for the regular style of the
42 | /// Arial font family.
43 |
44 | procedure TDemoFontMetrics.Run;
45 | var
46 | FontFamily: IGPFontFamily;
47 | Font: IGPFont;
48 | Ascent, Descent, LineSpacing: Integer;
49 | AscentPixel, DescentPixel, LineSpacingPixel: Single;
50 | begin
51 | FontFamily := TGPFontFamily.Create('Arial');
52 | Font := TGPFont.Create(FontFamily, 16, FontStyleRegular, UnitPixel);
53 |
54 | TextOutput.Add(Format('Font.Size returns %g.', [Font.Size]));
55 | TextOutput.Add(Format('FontFamily.GetEmHeight returns %d.',
56 | [FontFamily.GetEmHeight(FontStyleRegular)]));
57 |
58 | Ascent := FontFamily.GetCellAscent(FontStyleRegular);
59 | AscentPixel := Font.Size * Ascent / FontFamily.GetEmHeight(FontStyleRegular);
60 | TextOutput.Add(Format('The ascent is %d design units, %g pixels.',
61 | [Ascent, AscentPixel]));
62 |
63 | Descent := FontFamily.GetCellDescent(FontStyleRegular);
64 | DescentPixel := Font.Size * Descent / FontFamily.GetEmHeight(FontStyleRegular);
65 | TextOutput.Add(Format('The decent is %d design units, %g pixels.',
66 | [Descent, DescentPixel]));
67 |
68 | LineSpacing := FontFamily.GetLineSpacing(FontStyleRegular);
69 | LineSpacingPixel := Font.Size * LineSpacing / FontFamily.GetEmHeight(FontStyleRegular);
70 | TextOutput.Add(Format('The line spacing is %d design units, %g pixels.',
71 | [LineSpacing, LineSpacingPixel]));
72 | end;
73 |
74 | /// Note the first two lines of output above. The IGPFont object returns a
75 | /// size of 16, and the IGPFontFamily object returns an em height of 2,048.
76 | /// These two numbers (16 and 2,048) are the key to converting between font
77 | /// design units and the units (in this case pixels) of the IGPFont object.
78 | {$ENDREGION}
79 |
80 | initialization
81 | RegisterDemo('Using Text and Fonts\Obtaining Font Metrics', TDemoFontMetrics);
82 |
83 | end.
84 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Text and Fonts/uDemoFormattingText.pas:
--------------------------------------------------------------------------------
1 | unit uDemoFormattingText;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoFormattingText = class(TDemo)
11 | strict private
12 | procedure AligningText;
13 | procedure SettingTabStops;
14 | procedure DrawingVerticalText;
15 | strict protected
16 | procedure Run; override;
17 | end;
18 |
19 | implementation
20 |
21 | { TDemoFormattingText }
22 |
23 | {$REGION}
24 | /// To apply special formatting to text, initialize a IGPStringFormat
25 | /// object and pass that object to the DrawString method of the
26 | /// IGPGraphics interface.
27 | ///
28 | /// To draw formatted text in a rectangle, you need IGPGraphics,
29 | /// IGPFontFamily, IGPFont, TGPRectF, IGPStringFormat and
30 | /// IGPBrush objects.
31 | ///
32 | /// Aligning Text
33 | /// The following example draws text in a rectangle. Each line of text is
34 | /// centered (side to side), and the entire block of text is centered (top to
35 | /// bottom) in the rectangle.
36 |
37 | procedure TDemoFormattingText.AligningText;
38 | var
39 | FontFamily: IGPFontFamily;
40 | Font: IGPFont;
41 | Rect: TGPRectF;
42 | StringFormat: IGPStringFormat;
43 | SolidBrush: IGPBrush;
44 | Pen: IGPPen;
45 | begin
46 | FontFamily := TGPFontFamily.Create('Arial');
47 | Font := TGPFont.Create(FontFamily, 12, [FontStyleBold], UnitPoint);
48 | Rect.Initialize(30, 10, 120, 140);
49 | StringFormat := TGPStringFormat.Create;
50 | SolidBrush := TGPSolidBrush.Create(TGPColor.Create(255, 0, 0, 255));
51 |
52 | // Center-justify each line of text.
53 | StringFormat.Alignment := StringAlignmentCenter;
54 |
55 | // Center the block of text (top to bottom) in the rectangle.
56 | StringFormat.LineAlignment := StringAlignmentCenter;
57 |
58 | Graphics.DrawString('Use IGPStringFormat and TGPRectF objects to center text in a rectangle.',
59 | Font, Rect, StringFormat, SolidBrush);
60 |
61 | Pen := TGPPen.Create(TGPColor.Create(255, 0, 0, 0));
62 | Graphics.DrawRectangle(Pen, Rect);
63 | end;
64 |
65 | /// The preceding code sets two properties of the IGPStringFormat object:
66 | /// Alignment and LineAlignment. The assignment to Alignment
67 | /// specifies that each line of text is centered in the rectangle given by the
68 | /// third argument passed to the DrawString method. The assignment to
69 | /// LineAlignment specifies that the block of text is centered (top to
70 | /// bottom) in the rectangle.
71 | ///
72 | /// The value StringAlignmentCenter is an element of the TStringAlignment
73 | /// enumeration.
74 | ///
75 | /// Setting Tab Stops
76 | /// You can set tab stops for text by calling the SetTabStops method of a
77 | /// IGPStringFormat object and then passing that IGPStringFormat
78 | /// object to the DrawString method of the IGPGraphics interface.
79 | ///
80 | /// The following example sets tab stops at 150, 250, and 350. Then the code
81 | /// displays a tabbed list of names and test scores.
82 |
83 | procedure TDemoFormattingText.SettingTabStops;
84 | const
85 | Tabs: array [0..2] of Single = (150, 100, 100);
86 | Str = 'Name'#9'Test 1'#9'Test 2'#9'Test 3'#13#10+
87 | 'Joe'#9'95'#9'88'#9'91'#13#10+
88 | 'Mary'#9'98'#9'84'#9'90'#13#10+
89 | 'Sam'#9'42'#9'76'#9'98'#13#10+
90 | 'Jane'#9'65'#9'73'#9'92';
91 | var
92 | FontFamily: IGPFontFamily;
93 | Font: IGPFont;
94 | Rect: TGPRectF;
95 | StringFormat: IGPStringFormat;
96 | SolidBrush: IGPBrush;
97 | Pen: IGPPen;
98 | begin
99 | FontFamily := TGPFontFamily.Create('Courier New');
100 | Font := TGPFont.Create(FontFamily, 12, FontStyleRegular, UnitPoint);
101 | Rect.Initialize(170, 10, 450, 100);
102 | StringFormat := TGPStringFormat.Create;
103 | SolidBrush := TGPSolidBrush.Create(TGPColor.Create(255, 0, 0, 255));
104 |
105 | StringFormat.SetTabStops(0, Tabs);
106 |
107 | Graphics.DrawString(Str, Font, Rect, StringFormat, SolidBrush);
108 |
109 | Pen := TGPPen.Create(TGPColor.Create(255, 0, 0, 0));
110 | Graphics.DrawRectangle(Pen, Rect);
111 | end;
112 |
113 | /// The preceding code passes three arguments to the SetTabStops method.
114 | /// The second argument is an array containing the tab offsets. The first
115 | /// argument passed to SetTabStops is 0, which indicates that the first
116 | /// offset in the array is measured from position 0, the left edge of the
117 | /// bounding rectangle.
118 | ///
119 | /// Drawing Vertical Text
120 | /// You can use a IGPStringFormat object to specify that text be drawn
121 | /// vertically rather than horizontally.
122 | ///
123 | /// The following example passes the value [StringFormatFlagsDirectionVertical]
124 | /// to the FormatFlags property of a IGPStringFormat object. That
125 | /// IGPStringFormat object is passed to the IDrawString method of the
126 | /// IGPGraphics interface. The value StringFormatFlagsDirectionVertical is
127 | /// an element of the TStringFormatFlags enumeration.
128 |
129 | procedure TDemoFormattingText.DrawingVerticalText;
130 | var
131 | FontFamily: IGPFontFamily;
132 | Font: IGPFont;
133 | Point: TGPPointF;
134 | StringFormat: IGPStringFormat;
135 | SolidBrush: IGPBrush;
136 | begin
137 | FontFamily := TGPFontFamily.Create('Lucida Console');
138 | Font := TGPFont.Create(FontFamily, 14, FontStyleRegular, UnitPoint);
139 | Point.Initialize(170, 120);
140 | StringFormat := TGPStringFormat.Create;
141 | SolidBrush := TGPSolidBrush.Create(TGPColor.Create(255, 0, 0, 255));
142 |
143 | StringFormat.FormatFlags := [StringFormatFlagsDirectionVertical];
144 |
145 | Graphics.DrawString('Vertical text', Font, Point, StringFormat, SolidBrush);
146 | end;
147 | {$ENDREGION}
148 |
149 | procedure TDemoFormattingText.Run;
150 | begin
151 | AligningText;
152 | SettingTabStops;
153 | DrawingVerticalText;
154 | end;
155 |
156 | initialization
157 | RegisterDemo('Using Text and Fonts\Formatting Text', TDemoFormattingText);
158 |
159 | end.
160 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using Text and Fonts/uDemoInstalledFonts.pas:
--------------------------------------------------------------------------------
1 | unit uDemoInstalledFonts;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoInstalledFonts = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | public
14 | class function Outputs: TDemoOutputs; override;
15 | end;
16 |
17 | implementation
18 |
19 | { TDemoInstalledFonts }
20 |
21 | class function TDemoInstalledFonts.Outputs: TDemoOutputs;
22 | begin
23 | Result := [doText];
24 | end;
25 |
26 | {$REGION}
27 | /// The IGPInstalledFontCollection interface inherits from the
28 | /// IFontCollection abstract base interface. You can use an
29 | /// IGPInstalledFontCollection object to enumerate the fonts installed on
30 | /// the computer. The Families property of an IGPInstalledFontCollection
31 | /// object returns an array of IGPFontFamily objects.
32 | ///
33 | /// The following example lists the names of all the font families installed on
34 | /// the computer. The code retrieves the font family names by using the
35 | /// FamilyName property of each IGPFontFamily object in the array.
36 |
37 | procedure TDemoInstalledFonts.Run;
38 | var
39 | Collection: IGPInstalledFontCollection;
40 | FontFamily: IGPFontFamily;
41 | begin
42 | Collection := TGPInstalledFontCollection.Create;
43 | for FontFamily in Collection.Families do
44 | TextOutput.Add(FontFamily.FamilyName)
45 | end;
46 | {$ENDREGION}
47 |
48 | initialization
49 | RegisterDemo('Using Text and Fonts\Enumerating Installed Fonts', TDemoInstalledFonts);
50 |
51 | end.
52 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using a Brush to Fill Shapes/uDemoFillHatchPattern.pas:
--------------------------------------------------------------------------------
1 | unit uDemoFillHatchPattern;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoFillHatchPattern = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | {$REGION}
18 | /// A hatch pattern is made from two colors: one for the background and one for
19 | /// the lines that form the pattern over the background. To fill a closed shape
20 | /// with a hatch pattern, use a IGPHatchBrush object. The following example
21 | /// demonstrates how to fill an ellipse with a hatch pattern:
22 |
23 | procedure TDemoFillHatchPattern.Run;
24 | var
25 | Brush: IGPHatchBrush;
26 | begin
27 | Brush := TGPHatchBrush.Create(HatchStyleHorizontal, TGPColor.Create(255, 255, 0, 0),
28 | TGPColor.Create(255, 128, 255, 255));
29 | Graphics.FillEllipse(Brush, 0, 0, 100, 60);
30 | end;
31 |
32 | /// The TGPHatchBrush constructor takes three arguments: the hatch style,
33 | /// the color of the hatch line, and the color of the background. The hatch
34 | /// style argument can be any element of the THatchStyle enumeration.
35 | /// There are more than fifty elements in the THatchStyle enumeration; a
36 | /// few of those elements are shown in the following list:
37 | ///
38 | /// - HatchStyleHorizontal
39 | /// - HatchStyleVertical
40 | /// - HatchStyleForwardDiagonal
41 | /// - HatchStyleBackwardDiagonal
42 | /// - HatchStyleCross
43 | /// - HatchStyleDiagonalCross
44 | {$ENDREGION}
45 |
46 | initialization
47 | RegisterDemo('Using a Brush to Fill Shapes\Filling a Shape with a Hatch Pattern', TDemoFillHatchPattern);
48 |
49 | end.
50 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using a Brush to Fill Shapes/uDemoFillImageTexture.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/Using a Brush to Fill Shapes/uDemoFillImageTexture.pas
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using a Brush to Fill Shapes/uDemoFillSolidColor.pas:
--------------------------------------------------------------------------------
1 | unit uDemoFillSolidColor;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoFillSolidColor = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | {$REGION}
18 | /// A Microsoft Windows GDI+Brush object is used to fill the interior of a
19 | /// closed shape. GDI+ defines several fill styles: solid color, hatch pattern,
20 | /// image texture, and color gradient.
21 | ///
22 | /// To fill a shape with a solid color, create a IGPSolidBrush object, and
23 | /// then that IGPSolidBrush object as an argument to one of the fill
24 | /// methods of the IGPGraphics interface. The following example shows how
25 | /// to fill an ellipse with the color red:
26 |
27 | procedure TDemoFillSolidColor.Run;
28 | var
29 | SolidBrush: IGPSolidBrush;
30 | begin
31 | SolidBrush := TGPSolidBrush.Create(TGPColor.Create(255, 255, 0, 0));
32 | Graphics.FillEllipse(SolidBrush, 0, 0, 100, 60);
33 | end;
34 |
35 | /// In the preceding example, the TGPSolidBrush constructor takes a
36 | /// TGPColor record reference as its only argument. The values used by the
37 | /// TGPColor constructor represent the alpha, red, green, and blue
38 | /// components of the color. Each of these values must be in the range 0 through
39 | /// 255. The first 255 indicates that the color is fully opaque, and the second
40 | /// 255 indicates that the red component is at full intensity. The two zeros
41 | /// indicate that the green and blue components both have an intensity of 0.
42 | ///
43 | /// The four numbers (0, 0, 100, 60) passed to the FillEllipse method
44 | /// specify the location and size of the bounding rectangle for the ellipse. The
45 | /// rectangle has an upper-left corner of (0, 0), a width of 100, and a height
46 | /// of 60.
47 | {$ENDREGION}
48 |
49 | initialization
50 | RegisterDemo('Using a Brush to Fill Shapes\Filling a Shape with a Solid Color', TDemoFillSolidColor);
51 |
52 | end.
53 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using a Brush to Fill Shapes/uDemoTileImage.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/Using a Brush to Fill Shapes/uDemoTileImage.pas
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using a Pen to Draw Lines and Shapes/uDemoCustomDashedLine.pas:
--------------------------------------------------------------------------------
1 | unit uDemoCustomDashedLine;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoCustomDashedLine = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | {$REGION}
18 | /// Microsoft Windows GDI+ provides several dash styles that are listed in the
19 | /// TDashStyle enumeration. If those standard dash styles don't suit your
20 | /// needs, you can create a custom dash pattern.
21 | ///
22 | /// To draw a custom dashed line, put the lengths of the dashes and spaces in an
23 | /// array and pass the array as an argument to the SetDashPattern method
24 | /// of a IGPPen object. The following example draws a custom dashed line
25 | /// based on the array [5, 2, 15, 4]. If you multiply the elements of the array
26 | /// by the pen width of 5, you get [25, 10, 75, 20].
27 | /// The displayed dashes alternate in length between 25 and 75, and the spaces
28 | /// alternate in length between 10 and 20.
29 |
30 | procedure TDemoCustomDashedLine.Run;
31 | const
32 | DashValues: array [0..3] of Single = (5, 2, 15, 4);
33 | var
34 | BlackPen: IGPPen;
35 | begin
36 | BlackPen := TGPPen.Create(TGPColor.Create(255, 0, 0, 0), 5);
37 | BlackPen.SetDashPattern(DashValues);
38 | Graphics.DrawLine(BlackPen, TGPPoint.Create(5, 5), TGPPoint.Create(405, 5));
39 | end;
40 |
41 | /// Note that the final dash has to be shorter than 25 units so that the line
42 | /// can end at (405, 5).
43 | {$ENDREGION}
44 |
45 | initialization
46 | RegisterDemo('Using a Pen to Draw Lines and Shapes\Drawing a Custom Dashed Line', TDemoCustomDashedLine);
47 |
48 | end.
49 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using a Pen to Draw Lines and Shapes/uDemoDrawLineCaps.pas:
--------------------------------------------------------------------------------
1 | unit uDemoDrawLineCaps;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoDrawLineCaps = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | {$REGION}
18 | /// You can draw the start or end of a line in one of several shapes called line
19 | /// caps. Microsoft Windows GDI+ supports several line caps, such as round,
20 | /// square, diamond, and arrowhead.
21 | ///
22 | /// You can specify line caps for the start of a line (start cap), the end of a
23 | /// line (end cap), or the dashes of a dashed line (dash cap).
24 | ///
25 | /// The following example draws a line with an arrowhead at one end and a round
26 | /// cap at the other end:
27 |
28 | procedure TDemoDrawLineCaps.Run;
29 | var
30 | Pen: IGPPen;
31 | begin
32 | Pen := TGPPen.Create(TGPColor.Create(255, 0, 0,255), 8);
33 | Pen.StartCap := LineCapArrowAnchor;
34 | Pen.EndCap := LineCapRoundAnchor;
35 | Graphics.DrawLine(Pen, 20, 175, 300, 175);
36 | end;
37 |
38 | /// LineCapArrowAnchor and LineCapRoundAnchor are elements of the
39 | /// TLineCap enumeration.
40 | {$ENDREGION}
41 |
42 | initialization
43 | RegisterDemo('Using a Pen to Draw Lines and Shapes\Drawing a Line with Line Caps', TDemoDrawLineCaps);
44 |
45 | end.
46 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using a Pen to Draw Lines and Shapes/uDemoDrawLinesAndRectangles.pas:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus10/Using a Pen to Draw Lines and Shapes/uDemoDrawLinesAndRectangles.pas
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using a Pen to Draw Lines and Shapes/uDemoJoiningLines.pas:
--------------------------------------------------------------------------------
1 | unit uDemoJoiningLines;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoJoiningLines = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | {$REGION}
18 | /// A line join is the common area that is formed by two lines whose ends meet
19 | /// or overlap. Microsoft Windows GDI+ provides four line join styles: miter,
20 | /// bevel, round, and miter clipped. Line join style is a property of the
21 | /// IGPPen interface. When you specify a line join style for a pen and then
22 | /// use that pen to draw a path, the specified join style is applied to all the
23 | /// connected lines in the path.
24 | ///
25 | /// You can specify the line join style by using the LineJoin property of
26 | /// the IGPPen interface. The following example demonstrates a beveled line
27 | /// join between a horizontal line and a vertical line:
28 |
29 | procedure TDemoJoiningLines.Run;
30 | var
31 | Path: IGPGraphicsPath;
32 | PenJoin: IGPPen;
33 | begin
34 | Path := TGPGraphicsPath.Create;
35 | PenJoin := TGPPen.Create(TGPColor.Create(255, 0, 0, 255), 8);
36 |
37 | Path.StartFigure;
38 | Path.AddLine(TGPPoint.Create(50, 200), TGPPoint.Create(100, 200));
39 | Path.AddLine(TGPPoint.Create(100, 200), TGPPoint.Create(100, 250));
40 |
41 | PenJoin.LineJoin := LineJoinBevel;
42 | Graphics.DrawPath(PenJoin, Path);
43 | end;
44 |
45 | /// In the preceding example, the value (LineJoinBevel) passed to the
46 | /// LineJoin property is an element of the TLineJoin enumeration.
47 | {$ENDREGION}
48 |
49 | initialization
50 | RegisterDemo('Using a Pen to Draw Lines and Shapes\Joining Lines', TDemoJoiningLines);
51 |
52 | end.
53 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using a Pen to Draw Lines and Shapes/uDemoLineTexture.pas:
--------------------------------------------------------------------------------
1 | unit uDemoLineTexture;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoLineTexture = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | {$REGION}
18 | /// Instead of drawing a line or curve with a solid color, you can draw with a
19 | /// texture. To draw lines and curves with a texture, create a
20 | /// IGPTextureBrush object, and pass that IGPTextureBrush object to a
21 | /// TGPPen constructor. The image associated with the texture brush is used
22 | /// to tile the plane (invisibly), and when the pen draws a line or curve, the
23 | /// stroke of the pen uncovers certain pixels of the tiled texture.
24 | ///
25 | /// The following example creates an IGPImage object from the file
26 | /// Texture1.jpg. That image is used to construct a IGPTextureBrush object,
27 | /// and the IGPTextureBrush object is used to construct a IGPPen
28 | /// object. The call to IGPGraphics.DrawImage draws the image with its
29 | /// upper-left corner at (0, 0). The call to Graphics.DrawEllipse uses
30 | /// the IGPPen object to draw a textured ellipse.
31 |
32 | procedure TDemoLineTexture.Run;
33 | var
34 | Image: IGPImage;
35 | Brush: IGPTextureBrush;
36 | TexturedPen: IGPPen;
37 | begin
38 | Image := TGPImage.Create('Texture1.jpg');
39 | Brush := TGPTextureBrush.Create(Image);
40 | TexturedPen := TGPPen.Create(Brush, 30);
41 |
42 | Graphics.DrawImage(Image, 0, 0, Image.Width, Image.Height);
43 | Graphics.DrawEllipse(TexturedPen, 100, 20, 200, 100);
44 | end;
45 | {$ENDREGION}
46 |
47 | initialization
48 | RegisterDemo('Using a Pen to Draw Lines and Shapes\Drawing a Line with a Texture', TDemoLineTexture);
49 |
50 | end.
51 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/Using a Pen to Draw Lines and Shapes/uDemoPenWidthAndAlignment.pas:
--------------------------------------------------------------------------------
1 | unit uDemoPenWidthAndAlignment;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoPenWidthAndAlignment = class(TDemo)
11 | strict private
12 | procedure DrawLine;
13 | procedure DrawRectangle;
14 | strict protected
15 | procedure Run; override;
16 | end;
17 |
18 | implementation
19 |
20 | {$REGION}
21 | /// When you create a IGPPen object, you can supply the pen width as one of
22 | /// the arguments to the constructor. You can also change the pen width by using
23 | /// the Width property.
24 | ///
25 | /// A theoretical line has a width of zero. When you draw a line, the pixels are
26 | /// centered on the theoretical line. The following example draws a specified
27 | /// line twice: once with a black pen of width 1 and once with a green pen of
28 | /// width 10.
29 |
30 | procedure TDemoPenWidthAndAlignment.DrawLine;
31 | var
32 | BlackPen, GreenPen: IGPPen;
33 | begin
34 | BlackPen := TGPPen.Create(TGPColor.Create(255, 0, 0, 0), 1);
35 | GreenPen := TGPPen.Create(TGPColor.Create(255, 0, 255, 0), 10);
36 |
37 | GreenPen.Alignment := PenAlignmentCenter;
38 | Graphics.DrawLine(GreenPen, 10, 100, 100, 50);
39 | Graphics.DrawLine(BlackPen, 10, 100, 100, 50);
40 | end;
41 |
42 | /// The green pixels and the black pixels are centered on the theoretical line.
43 | ///
44 | /// The following example draws a specified rectangle twice: once with a black
45 | /// pen of width 1 and once with a green pen of width 10. The code passes the
46 | /// value PenAlignmentCenter (an element of the TPenAlignment
47 | /// enumeration) to the Alignment property to specify that the pixels
48 | /// drawn with the green pen are centered on the boundary of the rectangle.
49 | /// You can change the green pen's alignment by setting the Alignment
50 | /// property to PenAlignmentInset. Then the pixels in the wide green line
51 | /// appear on the inside of the rectangle
52 |
53 | procedure TDemoPenWidthAndAlignment.DrawRectangle;
54 | var
55 | BlackPen, GreenPen: IGPPen;
56 | begin
57 | BlackPen := TGPPen.Create(TGPColor.Create(255, 0, 0, 0), 1);
58 | GreenPen := TGPPen.Create(TGPColor.Create(255, 0, 255, 0), 10);
59 |
60 | Graphics.DrawRectangle(GreenPen, 10, 120, 50, 50);
61 | Graphics.DrawRectangle(BlackPen, 10, 120, 50, 50);
62 |
63 | GreenPen.Alignment := PenAlignmentInset;
64 | Graphics.DrawRectangle(GreenPen, 80, 120, 50, 50);
65 | Graphics.DrawRectangle(BlackPen, 80, 120, 50, 50);
66 | end;
67 | {$ENDREGION}
68 |
69 | procedure TDemoPenWidthAndAlignment.Run;
70 | begin
71 | DrawLine;
72 | DrawRectangle;
73 | end;
74 |
75 | initialization
76 | RegisterDemo('Using a Pen to Draw Lines and Shapes\Setting Pen Width and Alignment', TDemoPenWidthAndAlignment);
77 |
78 | end.
79 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus10/uDemo.pas:
--------------------------------------------------------------------------------
1 | unit uDemo;
2 |
3 | interface
4 |
5 | uses
6 | Classes,
7 | SysUtils,
8 | GdiPlus;
9 |
10 | type
11 | TDemoOutput = (doGraphic, doText, doPrint);
12 | TDemoOutputs = set of TDemoOutput;
13 |
14 | type
15 | {$TYPEINFO ON} { To make TDemo.UnitName work }
16 | TDemo = class abstract
17 | strict private
18 | FGraphics: IGPGraphics;
19 | FTextOutput: TStrings;
20 | strict protected
21 | procedure Run; virtual; abstract;
22 |
23 | property Graphics: IGPGraphics read FGraphics;
24 | property TextOutput: TStrings read FTextOutput;
25 | public
26 | constructor Create; virtual;
27 | class function Outputs: TDemoOutputs; virtual;
28 | procedure Execute(const ATargetGraphics: IGPGraphics;
29 | const ATextOutput: TStrings);
30 | end;
31 | {$TYPEINFO OFF}
32 | TDemoClass = class of TDemo;
33 |
34 | procedure RegisterDemo(const Path: String; const DemoClass: TDemoClass);
35 | function RegisteredDemos: TStringList;
36 |
37 | implementation
38 |
39 | var
40 | GlobalRegisteredDemos: TStringList = nil;
41 |
42 | procedure RegisterDemo(const Path: String; const DemoClass: TDemoClass);
43 | begin
44 | GlobalRegisteredDemos.AddObject(Path, Pointer(DemoClass));
45 | end;
46 |
47 | function RegisteredDemos: TStringList;
48 | begin
49 | Result := GlobalRegisteredDemos;
50 | end;
51 |
52 | { TDemo }
53 |
54 | constructor TDemo.Create;
55 | begin
56 | inherited Create;
57 | end;
58 |
59 | procedure TDemo.Execute(const ATargetGraphics: IGPGraphics;
60 | const ATextOutput: TStrings);
61 | begin
62 | FGraphics := ATargetGraphics;
63 | FGraphics.ResetTransform;
64 | FTextOutput := ATextOutput;
65 | if Assigned(FTextOutput) then
66 | FTextOutput.BeginUpdate;
67 | try
68 | Run;
69 | finally
70 | if Assigned(FTextOutput) then
71 | FTextOutput.EndUpdate;
72 | end;
73 | end;
74 |
75 | class function TDemo.Outputs: TDemoOutputs;
76 | begin
77 | Result := [doGraphic];
78 | end;
79 |
80 | initialization
81 | GlobalRegisteredDemos := TStringList.Create;
82 |
83 | finalization
84 | FreeAndNil(GlobalRegisteredDemos);
85 |
86 | end.
87 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/Bitmap Effects/uDemoBlur.pas:
--------------------------------------------------------------------------------
1 | unit uDemoBlur;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoBlur = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoBlur }
18 |
19 | {$REGION}
20 | /// The biggest addition to version 1.1 of GDI+ is the support for various
21 | /// bitmap effects. For example you can apply a blur or change the hue of a
22 | /// bitmap. There is even an effect that performs red eye correction on
23 | /// photographs taken with a flash.
24 | ///
25 | /// Each effect requires two declarations: an interface that represents the
26 | /// specific effect (for example IGPBlur, IGPSharpen etc.) and a
27 | /// record for the parameters of the effect (like TGPBlurParams,
28 | /// TGPSharpenParams etc. All effect interfaces inherited form IEffect
29 | /// and have a property called Parameters to set and retrieve the effect
30 | /// parameters.
31 | ///
32 | /// The example below creates an IGPBlur object and sets the blur radius
33 | /// parameter to 5 pixels. The IGPBlur.Parameters property must be set to
34 | /// a record of type TGPBlurParams.
35 | ///
36 | /// There are two ways to apply an effect. The first way is to apply it directly
37 | /// to the bitmap using the IGPBitmap.ApplyEffect method. This will change
38 | /// the contents of the bitmap. You pass the IEffect object as the first
39 | /// parameter to the method. You can supply an optional rect parameter called
40 | /// ROI (for Region Of Interest) if you want to limit the effect to a certain
41 | /// area of the bitmap.
42 | ///
43 | /// The second way to apply an effect is during a IGPGraphics.DrawImage
44 | /// command. This method will leave the original bitmap unchanged but has the
45 | /// disadvantage that the effect has to be recalculated each time the bitmap
46 | /// is drawn. This method will be used in another example.
47 |
48 | procedure TDemoBlur.Run;
49 | var
50 | Bitmap: IGPBitmap;
51 | Blur: IGPBlur;
52 | Params: TGPBlurParams;
53 | begin
54 | // Load and display a bitmap
55 | Bitmap := TGPBitmap.Create('Collage.png');
56 | Graphics.DrawImage(Bitmap, 0, 0, Bitmap.Width, Bitmap.Height);
57 |
58 | // Create a Blur effect
59 | Blur := TGPBlur.Create;
60 | Params.Radius := 5;
61 | Params.ExpandEdge := False;
62 | Blur.Parameters := Params;
63 |
64 | // Apply the effect to the bitmap and draw the result
65 | Bitmap.ApplyEffect(Blur);
66 | Graphics.DrawImage(Bitmap, Bitmap.Width, 0, Bitmap.Width, Bitmap.Height);
67 | end;
68 |
69 | /// The illustration above shows the result. The original image is shown to the
70 | /// left and the blurred one to the right.
71 | {$ENDREGION}
72 |
73 | initialization
74 | RegisterDemo('Bitmap Effects\Blur Effect', TDemoBlur);
75 |
76 | end.
77 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/Bitmap Effects/uDemoBrightnessContrast.pas:
--------------------------------------------------------------------------------
1 | unit uDemoBrightnessContrast;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoBrightnessContrast = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoBrightnessContrast }
18 |
19 | {$REGION}
20 | /// The IGPBrightnessContrast interface enables you to change the
21 | /// brightness and contrast of a bitmap. The effect has 2 parameters:
22 | /// 1. BrightnessLevel (-255..255): If the value is 0, the brightness remains
23 | /// the same. As the value moves from 0 to 255, the brightness of the image
24 | /// increases. As the value moves from 0 to -255, the brightness of the image
25 | /// decreases.
26 | /// 2. ContrastLevel (-100..100): If the value is 0, the contrast remains the
27 | /// same. As the value moves from 0 to 100, the contrast of the image increases.
28 | /// As the value moves from 0 to -100, the contrast of the image decreases.
29 |
30 | procedure TDemoBrightnessContrast.Run;
31 | var
32 | Bitmap: IGPBitmap;
33 | BrightnessContrast: IGPBrightnessContrast;
34 | Params: TGPBrightnessContrastParams;
35 | begin
36 | // Load and display a bitmap
37 | Bitmap := TGPBitmap.Create('Collage.png');
38 | Graphics.DrawImage(Bitmap, 0, 0, Bitmap.Width, Bitmap.Height);
39 |
40 | // Create a Brightness & Contrast effect
41 | BrightnessContrast := TGPBrightnessContrast.Create;
42 | Params.BrightnessLevel := 50;
43 | Params.ContrastLevel := 50;
44 | BrightnessContrast.Parameters := Params;
45 |
46 | // Apply the effect to the bitmap and draw the result
47 | Bitmap.ApplyEffect(BrightnessContrast);
48 | Graphics.DrawImage(Bitmap, Bitmap.Width, 0, Bitmap.Width, Bitmap.Height);
49 | end;
50 | {$ENDREGION}
51 |
52 | initialization
53 | RegisterDemo('Bitmap Effects\Brightness & Contrast Effect', TDemoBrightnessContrast);
54 |
55 | end.
56 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/Bitmap Effects/uDemoColorBalance.pas:
--------------------------------------------------------------------------------
1 | unit uDemoColorBalance;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoColorBalance = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoColorBalance }
18 |
19 | {$REGION}
20 | /// The ColorBalance class enables you to change the color balance (relative
21 | /// amounts of red, green, and blue) of a bitmap. The effect has 3 parameters:
22 | /// 1. CyanRed (-100..100): If the value is 0, there is no change. As the value
23 | /// moves from 0 to 100, the amount of red in the image increases and the amount
24 | /// of cyan decreases. As the value moves from 0 to -100, the amount of red in
25 | /// the image decreases and the amount of cyan increases.
26 | /// 2. MagentaGreen (-100..100): If the value is 0, there is no change. As the
27 | /// value moves from 0 to 100, the amount of green in the image increases and the
28 | /// amount of magenta decreases. As the value moves from 0 to -100, the amount of
29 | /// green in the image decreases and the amount of magenta increases.
30 | /// 3. YellowBlue (-100..100): If the value is 0, there is no change. As the
31 | /// value moves from 0 to 100, the amount of blue in the image increases and the
32 | /// amount of yellow decreases. As the value moves from 0 to -100, the amount of
33 | /// blue in the image decreases and the amount of yellow increases.
34 |
35 | procedure TDemoColorBalance.Run;
36 | var
37 | Bitmap: IGPBitmap;
38 | ColorBalance: IGPColorBalance;
39 | Params: TGPColorBalanceParams;
40 | begin
41 | // Load and display a bitmap
42 | Bitmap := TGPBitmap.Create('Collage.png');
43 | Graphics.DrawImage(Bitmap, 0, 0, Bitmap.Width, Bitmap.Height);
44 |
45 | // Create a Color Balance effect
46 | ColorBalance := TGPColorBalance.Create;
47 | Params.CyanRed := 20;
48 | Params.MagentaGreen := 0;
49 | Params.YellowBlue := -20;
50 | ColorBalance.Parameters := Params;
51 |
52 | // Apply the effect to the bitmap and draw the result
53 | Bitmap.ApplyEffect(ColorBalance);
54 | Graphics.DrawImage(Bitmap, Bitmap.Width, 0, Bitmap.Width, Bitmap.Height);
55 | end;
56 | {$ENDREGION}
57 |
58 | initialization
59 | RegisterDemo('Bitmap Effects\Color Balance Effect', TDemoColorBalance);
60 |
61 | end.
62 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/Bitmap Effects/uDemoColorCurve.pas:
--------------------------------------------------------------------------------
1 | unit uDemoColorCurve;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoColorCurve = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoColorCurve }
18 |
19 | {$REGION}
20 | /// The IGPColorCurve interface encompasses eight separate adjustments:
21 | /// exposure, density, contrast, highlight, shadow, midtone, white saturation,
22 | /// and black saturation. The effect has 3 parameters:
23 | /// 1. Adjustment: Element of the TCurveAdjustments enumeration that
24 | /// specifies the adjustment to be applied (one of the eight mentioned earlier).
25 | /// 2. Channel: Element of the CurveChannel enumeration that specifies the
26 | /// color channel to which the adjustment applies (All, Red, Green or Blue).
27 | /// 3. AdjustValue: Integer that specifies the intensity of the adjustment. The
28 | /// range of acceptable values depends on which adjustment is being applied. To
29 | /// see the range of acceptable values for a particular adjustment, see the
30 | /// TCurveAdjustments enumeration.
31 |
32 | procedure TDemoColorCurve.Run;
33 | var
34 | Bitmap: IGPBitmap;
35 | ColorCurve: IGPColorCurve;
36 | Params: TGPColorCurveParams;
37 | begin
38 | // Load and display a bitmap
39 | Bitmap := TGPBitmap.Create('Collage.png');
40 | Graphics.DrawImage(Bitmap, 0, 0, Bitmap.Width, Bitmap.Height);
41 |
42 | // Create a Color Curve effect
43 | ColorCurve := TGPColorCurve.Create;
44 | Params.Adjustment := AdjustExposure;
45 | Params.Channel := CurveChannelAll;
46 | Params.AdjustValue := -50;
47 | ColorCurve.Parameters := Params;
48 |
49 | // Apply the effect to the bitmap and draw the result
50 | Bitmap.ApplyEffect(ColorCurve);
51 | Graphics.DrawImage(Bitmap, Bitmap.Width, 0, Bitmap.Width, Bitmap.Height);
52 | end;
53 | {$ENDREGION}
54 |
55 | initialization
56 | RegisterDemo('Bitmap Effects\Color Curve Effect', TDemoColorCurve);
57 |
58 | end.
59 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/Bitmap Effects/uDemoColorLUT.pas:
--------------------------------------------------------------------------------
1 | unit uDemoColorLUT;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoColorLUT = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoColorLUT }
18 |
19 | {$REGION}
20 | /// A TGPColorLUTParams record has four members, each being a lookup table
21 | /// for a particular color channel: alpha, red, green, or blue. The lookup
22 | /// tables can be used to make custom color adjustments to bitmaps. Each lookup
23 | /// table is an array of 256 bytes that you can set to values of your choice.
24 |
25 | procedure TDemoColorLUT.Run;
26 | var
27 | Bitmap: IGPBitmap;
28 | ColorLUT: IGPColorLUT;
29 | Params: TGPColorLUTParams;
30 | I: Integer;
31 | begin
32 | // Load and display a bitmap
33 | Bitmap := TGPBitmap.Create('Collage.png');
34 | Graphics.DrawImage(Bitmap, 0, 0, Bitmap.Width, Bitmap.Height);
35 |
36 | // Create a Color LUT effect
37 | ColorLUT := TGPColorLUT.Create;
38 |
39 | for I := 0 to 255 do
40 | begin
41 | // Keep the red channel unchanged
42 | Params.LutR[I] := I;
43 | // Inverse the green channel
44 | Params.LutG[I] := 255 - I;
45 | // Half the intensity of the blue channel
46 | Params.LutB[I] := I div 2;
47 | // Set alpha (opacity) to 80%
48 | Params.LutA[I] := (I * 80) div 100;
49 | end;
50 | ColorLUT.Parameters := Params;
51 |
52 | // Apply the effect to the bitmap and draw the result
53 | Bitmap.ApplyEffect(ColorLUT);
54 | Graphics.DrawImage(Bitmap, Bitmap.Width, 0, Bitmap.Width, Bitmap.Height);
55 | end;
56 | {$ENDREGION}
57 |
58 | initialization
59 | RegisterDemo('Bitmap Effects\Color LUT Effect', TDemoColorLUT);
60 |
61 | end.
62 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/Bitmap Effects/uDemoColorMatrix.pas:
--------------------------------------------------------------------------------
1 | unit uDemoColorMatrix;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoColorMatrix = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoColorMatrix }
18 |
19 | {$REGION}
20 | /// The IGPColorMatrixEffect interface enables you to apply an affine
21 | /// transformation to a bitmap. To specify the transformation, set the elements
22 | /// of a TGPColorMatrix records, and pass that record to the
23 | /// SetParameters method of a IGPColorMatrixEffect object.
24 |
25 | procedure TDemoColorMatrix.Run;
26 | const
27 | ColorMatrix: TGPColorMatrix = (
28 | M: ((1.5, 0.3, 0.0, 0.0, 0.0),
29 | (0.0, 0.8, 0.0, 0.0, 0.0),
30 | (0.0, 0.0, 1.0, 0.0, 0.0),
31 | (0.0, 0.0, 0.0, 1.0, 0.0),
32 | (0.2, 0.3, 0.4, 0.0, 1.0)));
33 | var
34 | Bitmap: IGPBitmap;
35 | ColorMatrixEffect: IGPColorMatrixEffect;
36 | begin
37 | // Load and display a bitmap
38 | Bitmap := TGPBitmap.Create('Collage.png');
39 | Graphics.DrawImage(Bitmap, 0, 0, Bitmap.Width, Bitmap.Height);
40 |
41 | // Create a Color Matrix effect
42 | ColorMatrixEffect := TGPColorMatrixEffect.Create;
43 | ColorMatrixEffect.Parameters := ColorMatrix;
44 |
45 | // Apply the effect to the bitmap and draw the result
46 | Bitmap.ApplyEffect(ColorMatrixEffect);
47 | Graphics.DrawImage(Bitmap, Bitmap.Width, 0, Bitmap.Width, Bitmap.Height);
48 | end;
49 | {$ENDREGION}
50 |
51 | initialization
52 | RegisterDemo('Bitmap Effects\Color Matrix Effect', TDemoColorMatrix);
53 |
54 | end.
55 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/Bitmap Effects/uDemoHueSaturationLightness.pas:
--------------------------------------------------------------------------------
1 | unit uDemoHueSaturationLightness;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoHueSaturationLightness = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoHueSaturationLightness }
18 |
19 | {$REGION}
20 | /// The IGPHueSaturationLightness interface enables you to change the hue,
21 | /// saturation, and lightness of a bitmap. The effect has 3 parameters:
22 | /// 1. HueLevel (-180..180): A value of 0 specifies no change. Positive values
23 | /// specify counterclockwise rotation on the color wheel. Negative values
24 | /// specify clockwise rotation on the color wheel.
25 | /// 2. SaturationLevel (-100..100): A value of 0 specifies no change. Positive
26 | /// values specify increased saturation and negative values specify decreased
27 | /// saturation.
28 | /// 3. LightnessLevel (-100.100): A value of 0 specifies no change. Positive
29 | /// values specify increased lightness and negative values specify decreased
30 | /// lightness.
31 |
32 | procedure TDemoHueSaturationLightness.Run;
33 | var
34 | Bitmap: IGPBitmap;
35 | HueSaturationLightness: IGPHueSaturationLightness;
36 | Params: TGPHueSaturationLightnessParams;
37 | begin
38 | // Load and display a bitmap
39 | Bitmap := TGPBitmap.Create('Collage.png');
40 | Graphics.DrawImage(Bitmap, 0, 0, Bitmap.Width, Bitmap.Height);
41 |
42 | // Create a Hue, Saturation & Lightness effect
43 | HueSaturationLightness := TGPHueSaturationLightness.Create;
44 | Params.HueLevel := -130;
45 | Params.SaturationLevel := -20;
46 | Params.LightnessLevel := 0;
47 | HueSaturationLightness.Parameters := Params;
48 |
49 | // Apply the effect to the bitmap and draw the result
50 | Bitmap.ApplyEffect(HueSaturationLightness);
51 | Graphics.DrawImage(Bitmap, Bitmap.Width, 0, Bitmap.Width, Bitmap.Height);
52 | end;
53 | {$ENDREGION}
54 |
55 | initialization
56 | RegisterDemo('Bitmap Effects\Hue, Saturation & Lightness', TDemoHueSaturationLightness);
57 |
58 | end.
59 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/Bitmap Effects/uDemoLevels.pas:
--------------------------------------------------------------------------------
1 | unit uDemoLevels;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoLevels = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoLevels }
18 |
19 | {$REGION}
20 | /// The IGPLevels interface encompasses three bitmap adjustments:
21 | /// highlight, midtone, and shadow. The effect has 3 parameters:
22 | /// 1: Highlight (0..100): You can use this adjustment to lighten pixels that
23 | /// are already lighter than a certain threshold. Setting highlight to 100
24 | /// specifies no change. Setting highlight to t specifies that a color channel
25 | /// value is increased if it is already greater than t percent of full
26 | /// intensity. For example, setting highlight to 90 specifies that all color
27 | /// channel values greater than 90 percent of full intensity are increased.
28 | /// 2. Midtone (-100..100): Color channel values in the middle of the intensity
29 | /// range are altered more than color channel values near the minimum or maximum
30 | /// intensity. You can use this adjustment to lighten (or darken) an image
31 | /// without loosing the contrast between the darkest and lightest portions of
32 | /// the image. A value of 0 specifies no change. Positive values specify that
33 | /// the midtones are made lighter, and negative values specify that the midtones
34 | /// are made darker.
35 | /// 3. Shadow (0..100): Integer in the range 0 through 100 that specifies which
36 | /// pixels should be darkened. You can use this adjustment to darken pixels that
37 | /// are already darker than a certain threshold. Setting shadow to 0 specifies
38 | /// no change. Setting shadow to t specifies that a color channel value is
39 | /// decreased if it is already less than t percent of full intensity. For
40 | /// example, setting shadow to 10 specifies that all color channel values less
41 | /// than 10 percent of full intensity are decreased.
42 |
43 | procedure TDemoLevels.Run;
44 | var
45 | Bitmap: IGPBitmap;
46 | Levels: IGPLevels;
47 | Params: TGPLevelsParams;
48 | begin
49 | // Load and display a bitmap
50 | Bitmap := TGPBitmap.Create('Collage.png');
51 | Graphics.DrawImage(Bitmap, 0, 0, Bitmap.Width, Bitmap.Height);
52 |
53 | // Create a Levels effect
54 | Levels := TGPLevels.Create;
55 | Params.Highlight := 90;
56 | Params.Midtone := -20;
57 | Params.Shadow := 10;
58 | Levels.Parameters := Params;
59 |
60 | // Apply the effect to the bitmap and draw the result
61 | Bitmap.ApplyEffect(Levels);
62 | Graphics.DrawImage(Bitmap, Bitmap.Width, 0, Bitmap.Width, Bitmap.Height);
63 | end;
64 | {$ENDREGION}
65 |
66 | initialization
67 | RegisterDemo('Bitmap Effects\Levels Effect', TDemoLevels);
68 |
69 | end.
70 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/Bitmap Effects/uDemoRedEyeCorrection.pas:
--------------------------------------------------------------------------------
1 | unit uDemoRedEyeCorrection;
2 |
3 | interface
4 |
5 | uses
6 | Windows,
7 | Types,
8 | GdiPlus,
9 | uDemo;
10 |
11 | type
12 | TDemoRedEyeCorrection = class(TDemo)
13 | strict protected
14 | procedure Run; override;
15 | end;
16 |
17 | implementation
18 |
19 | { TDemoRedEyeCorrection }
20 |
21 | {$REGION}
22 | /// This example show the IGPRedEyeCorrection effect. This effect has two
23 | /// parameters:
24 | /// 1. The number of rectangles in the bitmap to which the effect is applied.
25 | /// You need to supply a rectangle for each eye.
26 | /// 2. A pointer to an array of rectanges. These must be of type Windows.TGPRect
27 | /// (and not of the TGPRect type in the GdiPlus unit). In this example we
28 | /// supply two rectangles that cover the two eyes in the bitmap.
29 | ///
30 | /// This example also shows that you can apply the same effect multiple times.
31 | /// The more times you apply the effect, the stronger it will be.
32 | procedure TDemoRedEyeCorrection.Run;
33 | var
34 | Bitmap: IGPBitmap;
35 | RedEye: IGPRedEyeCorrection;
36 | Params: TGPRedEyeCorrectionParams;
37 | Eyes: array [0..1] of Windows.TRect;
38 | begin
39 | // Load and display a bitmap
40 | Bitmap := TGPBitmap.Create('Collage.png');
41 | Graphics.DrawImage(Bitmap, 0, 0, Bitmap.Width, Bitmap.Height);
42 |
43 | // Create a Red Eye Correction effect
44 | RedEye := TGPRedEyeCorrection.Create;
45 | Eyes[0] := Rect(132, 115, 152, 135);
46 | Eyes[1] := Rect(261, 142, 281, 162);
47 | Params.NumberOfAreas := 2;
48 | Params.Areas := @Eyes[0];
49 | RedEye.Parameters := Params;
50 |
51 | // Apply the effect to the bitmap and draw the result
52 | Bitmap.ApplyEffect(RedEye);
53 | Bitmap.ApplyEffect(RedEye);
54 | Bitmap.ApplyEffect(RedEye);
55 | Bitmap.ApplyEffect(RedEye);
56 | Graphics.DrawImage(Bitmap, Bitmap.Width, 0, Bitmap.Width, Bitmap.Height);
57 | end;
58 | {$ENDREGION}
59 |
60 | initialization
61 | RegisterDemo('Bitmap Effects\Red Eye Correction Effect', TDemoRedEyeCorrection);
62 |
63 | end.
64 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/Bitmap Effects/uDemoSharpen.pas:
--------------------------------------------------------------------------------
1 | unit uDemoSharpen;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoSharpen = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoSharpen }
18 |
19 | {$REGION}
20 | /// This example show the IGPSharpen effect. This effect has two
21 | /// parameters:
22 | /// 1. The sharpening radius (between 0 and 255) determines how many
23 | /// surrounding pixels are involved in calculating the value of each pixel.
24 | /// 2. The amount of sharpening, ranging from 0 (no sharpening) to 100
25 | /// (full sharpening).
26 | ///
27 | /// This example also shows how to apply the effect in a non-destructive way
28 | /// by passing it as a parameter to a new IGPGraphics.DrawImage version.
29 | /// This version of the DrawImage method requires the following
30 | /// parameters:
31 | /// 1. The bitmap to draw.
32 | /// 2. A source rectangle that specifies the portion of the bitmap to draw.
33 | /// 3. A IGPMatrix object that is used to transform the source rectangle
34 | /// to a destination rectangle. In this example, the matrix is translated
35 | /// to the right so the destination rectangle will be right next to the original
36 | /// image.
37 | /// 4. The effect to apply (any IEffect descendant).
38 | /// 5. An optional IGPImageAttributes object.
39 | /// 6. The measurement unit to use
40 |
41 | procedure TDemoSharpen.Run;
42 | var
43 | Bitmap: IGPBitmap;
44 | Sharpen: IGPSharpen;
45 | Params: TGPSharpenParams;
46 | Transform: IGPMatrix;
47 | begin
48 | // Load and display a bitmap
49 | Bitmap := TGPBitmap.Create('Collage.png');
50 | Graphics.DrawImage(Bitmap, 0, 0, Bitmap.Width, Bitmap.Height);
51 |
52 | // Create a Sharpen effect
53 | Sharpen := TGPSharpen.Create;
54 | Params.Radius := 5;
55 | Params.Amount := 100;
56 | Sharpen.Parameters := Params;
57 |
58 | // Draw the bitmap using the effect
59 | Transform := TGPMatrix.Create;
60 | Transform.Translate(Bitmap.Width, 0);
61 | Graphics.DrawImage(Bitmap,
62 | TGPRectF.Create(0, 0, Bitmap.Width, Bitmap.Height),
63 | Transform, Sharpen, nil, UnitPixel);
64 | end;
65 | {$ENDREGION}
66 |
67 | initialization
68 | RegisterDemo('Bitmap Effects\Sharpen Effect', TDemoSharpen);
69 |
70 | end.
71 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/Bitmap Effects/uDemoTint.pas:
--------------------------------------------------------------------------------
1 | unit uDemoTint;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoTint = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoTint }
18 |
19 | {$REGION}
20 | /// The IGPTint interface enables you to apply a tint to a bitmap. The
21 | /// effect has 2 parameters:
22 | /// 1. Hue (-180..180): A value of 0 specifies blue. A positive value specifies
23 | /// a clockwise angle on the color wheel. For example, positive 60 specifies
24 | /// cyan and positive 120 specifies green. A negative value specifies a
25 | /// counter-clockwise angle on the color wheel. For example, negative 60
26 | /// specifies magenta and negative 120 specifies red.
27 | /// 2. Amount (-100..100): specifies how much the hue (given by the hue
28 | /// parameter) is strengthened or weakened. A value of 0 specifies no change.
29 | /// Positive values specify that the hue is strengthened and negative values
30 | /// specify that the hue is weakened.
31 |
32 | procedure TDemoTint.Run;
33 | var
34 | Bitmap: IGPBitmap;
35 | Tint: IGPTint;
36 | Params: TGPTintParams;
37 | begin
38 | // Load and display a bitmap
39 | Bitmap := TGPBitmap.Create('Collage.png');
40 | Graphics.DrawImage(Bitmap, 0, 0, Bitmap.Width, Bitmap.Height);
41 |
42 | // Create a Tint effect
43 | Tint := TGPTint.Create;
44 | Params.Hue := 120;
45 | Params.Amount := 50;
46 | Tint.Parameters := Params;
47 |
48 | // Apply the effect to the bitmap and draw the result
49 | Bitmap.ApplyEffect(Tint);
50 | Graphics.DrawImage(Bitmap, Bitmap.Width, 0, Bitmap.Width, Bitmap.Height);
51 | end;
52 | {$ENDREGION}
53 |
54 | initialization
55 | RegisterDemo('Bitmap Effects\Tint Effect', TDemoTint);
56 |
57 | end.
58 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/Enhancements/uDemoAntialiasing.pas:
--------------------------------------------------------------------------------
1 | unit uDemoAntialiasing;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoAntialiasing = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoAntialiasing }
18 |
19 | {$REGION}
20 | /// GDI+ 1.1 supports an additional smoothing mode called
21 | /// SmoothingModeAntiAlias8x8. This is the highest quality antialiasing
22 | /// mode which produces better quality especially for near-horizontal lines
23 | /// and edges.
24 |
25 | procedure TDemoAntialiasing.Run;
26 | const
27 | SmoothingModes: array [SmoothingModeDefault..SmoothingModeAntiAlias8x8] of String = (
28 | 'SmoothingModeDefault', 'SmoothingModeHighSpeed', 'SmoothingModeHighQuality',
29 | 'SmoothingModeNone', 'SmoothingModeAntiAlias8x4', 'SmoothingModeAntiAlias8x8');
30 | var
31 | SmoothingMode: TGPSmoothingMode;
32 | Font: IGPFont;
33 | BlackBrush, BlueBrush: IGPBrush;
34 | Y: Integer;
35 | Points: array [0..2] of TGPPoint;
36 | begin
37 | Font := TGPFont.Create('Arial', 18, FontStyleRegular, UnitPixel);
38 | BlackBrush := TGPSolidBrush.Create(TGPColor.Black);
39 | BlueBrush := TGPSolidBrush.Create(TGPColor.Blue);
40 | Graphics.Clear(TGPColor.White);
41 |
42 | Y := 0;
43 | for SmoothingMode := SmoothingModeDefault to SmoothingModeAntiAlias8x8 do
44 | begin
45 | Graphics.SmoothingMode := SmoothingMode;
46 |
47 | Graphics.DrawString(SmoothingModes[SmoothingMode], Font,
48 | TGPPointF.Create(5, Y + 25), BlackBrush);
49 |
50 | Points[0].Initialize(250, Y);
51 | Points[1].Initialize(250, Y + 60);
52 | Points[2].Initialize(260, Y + 60);
53 | Graphics.FillPolygon(BlueBrush, Points);
54 |
55 | Points[0].Initialize(270, Y + 40);
56 | Points[1].Initialize(360, Y + 40);
57 | Points[2].Initialize(360, Y + 35);
58 | Graphics.FillPolygon(BlueBrush, Points);
59 |
60 | Graphics.FillEllipse(BlueBrush, 380, Y, 200, 60);
61 | Inc(Y, 70);
62 | end;
63 | end;
64 |
65 | /// In the illustration above you can see that SmoothingModeAntiAlias8x8
66 | /// produces a slightly better rendering of the long flat triangle in the
67 | /// bottom row.
68 | {$ENDREGION}
69 |
70 | initialization
71 | RegisterDemo('Enhancements\Additional Antialiasing Options', TDemoAntialiasing);
72 |
73 | end.
74 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/Enhancements/uDemoHistogram.pas:
--------------------------------------------------------------------------------
1 | unit uDemoHistogram;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoHistogram = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | uses
18 | Math;
19 |
20 | { TDemoHistogram }
21 |
22 | {$REGION}
23 | /// In GDI+ 1.1, the IGPBitmap interface has an extra method called
24 | /// GetHistogram. This method returns a histogram with the statistics
25 | /// of the colors used in the bitmap.
26 | ///
27 | /// The method accepts a single parameter with the type of histogram you want.
28 | /// You can request a histogram for a single channel (for example
29 | /// HistogramFormatB) or for multiple channels (for example
30 | /// HistogramFormatRGB).
31 | ///
32 | /// The example below request the histogram of the RGB channels of a bitmap
33 | /// and draws the histogram next to the bitmap.
34 | ///
35 | /// The IGPHistogram.ChannelCount property returns the number of channels
36 | /// in the histogram. For single channel histograms this value is 1; for RGB
37 | /// histograms this value is 3; and for ARGB/PARGB histograms this value is 4.
38 | ///
39 | /// The IGPHistogram.EntryCount property returns the number of entries in
40 | /// the histogram for each channel. For 8 bit per channel bitmaps, this value
41 | /// is usually 256.
42 | ///
43 | /// Finally, the Values property (which is the default array property
44 | /// for IGPHistogram) returns the histogram values for the given channl
45 | /// and entry index. This value is the number of times a pixel with the given
46 | /// intensity appears in the bitmap. For example, when IGPHistogram[2,30]
47 | /// returns 1000, this means that there are 1000 pixels in the bitmap that have
48 | /// a Blue (channel 2) intensity of 30.
49 | ///
50 | /// The example below finds the maximum value in the histogram and uses that
51 | /// value the scale all values so the histogram can be drawn with the same
52 | /// height as the bitmap.
53 |
54 | procedure TDemoHistogram.Run;
55 | var
56 | Bitmap: IGPBitmap;
57 | Histogram: IGPHistogram;
58 | I, J, X, Y, MaxVal: Integer;
59 | Scale: Double;
60 | Pen: IGPPen;
61 | begin
62 | Bitmap := TGPBitmap.Create('ImageFileSmall.jpg');
63 | Graphics.DrawImage(Bitmap, 10, 10, Bitmap.Width, Bitmap.Height);
64 |
65 | // Retrieve RGB histogram of bitmap
66 | Histogram := Bitmap.GetHistogram(HistogramFormatRGB);
67 |
68 | // Determine the maximum value in the histogram
69 | MaxVal := 0;
70 | for J := 0 to Histogram.ChannelCount - 1 do
71 | for I := 0 to Histogram.EntryCount - 1 do
72 | MaxVal := Max(MaxVal, Histogram[J, I]);
73 |
74 | // Scale maximum value so it displays as the height of the bitmap
75 | Scale := Bitmap.Height / MaxVal;
76 |
77 | // Draw the histogram next to the bitmap
78 | Pen := TGPPen.Create(0);
79 | X := 10 + Bitmap.Width + 10;
80 | Y := 10 + Bitmap.Height;
81 | for I := 0 to Histogram.ChannelCount - 1 do
82 | begin
83 | if (I = 0) then
84 | Pen.Color := TGPColor.Create(128, 255, 0, 0)
85 | else if (I = 1) then
86 | Pen.Color := TGPColor.Create(128, 0, 255, 0)
87 | else
88 | Pen.Color := TGPColor.Create(128, 0, 0, 255);
89 |
90 | for J := 0 to Histogram.EntryCount - 1 do
91 | Graphics.DrawLine(Pen, X + J, Y, X + J, Y - Scale * Histogram[I, J]);
92 | end;
93 | end;
94 |
95 | /// The illustration above shows that the bitmap contains a lot of reds at high
96 | /// intensities. This is mostly the skin color of the apples and pears in the
97 | /// bitmap. At lower intensities, the blues dominate slightly, as these colors
98 | /// appear in the darker grapes and leaves.
99 | {$ENDREGION}
100 |
101 | initialization
102 | RegisterDemo('Enhancements\Getting the Histogram of a Bitmap', TDemoHistogram);
103 |
104 | end.
105 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/Enhancements/uDemoPixelFormatConversion.pas:
--------------------------------------------------------------------------------
1 | unit uDemoPixelFormatConversion;
2 |
3 | interface
4 |
5 | uses
6 | GdiPlus,
7 | uDemo;
8 |
9 | type
10 | TDemoPixelFormatConversion = class(TDemo)
11 | strict protected
12 | procedure Run; override;
13 | end;
14 |
15 | implementation
16 |
17 | { TDemoPixelFormatConversion }
18 |
19 | {$REGION}
20 | /// GDI+ 1.1 provides the IGPBitmap.ConvertFormat method to convert a
21 | /// bitmap to a different pixel format. For example, you can convert a bitmap
22 | /// from a True Color image (24 bits per pixel) to an indexed image (4 or 8
23 | /// bits per pixel) with a color palette.
24 | ///
25 | /// When you create an indexed version of bitmap, you usually want to create an
26 | /// optimal color palette that represents the colors in the bitmap as accurate
27 | /// as possible. You can create such a palette by calling the clas static
28 | /// TGPBitmap.InitializePalette method. You specify how many colors you
29 | /// want in the palette, how the palette should be generated (use
30 | /// PaletteTypeOptimal for an optimal palette) and the bitmap the palette
31 | /// should be created for. The method returns an IGPColorPalette object.
32 | ///
33 | /// You pass the IGPColorPalette to the IGPBitmap.ConvertFormat method
34 | /// along with some other settings such as the requested pixel format and the
35 | /// type of dithering that should be used.
36 | ///
37 | /// The example below loads a bitmap from a file and creates 3 reduced-color
38 | /// versions of it. The first two reduced-color versions result in a 16 color
39 | /// bitmap. The first version uses solid dithering (DitherTypeSolid) and
40 | /// the second version uses diffusion dithering (DitherTypeErrorDiffusion)
41 | /// As you can see in the results above, diffusion dithering usually leads to
42 | /// the best results.
43 | /// The final version is a 256 color conversion (8 bits per pixel) that uses
44 | /// diffusion dithering too. You can see that this bitmap more closely matches
45 | /// the original one.
46 |
47 | procedure TDemoPixelFormatConversion.Run;
48 | var
49 | Bitmap: IGPBitmap;
50 | Palette: IGPColorPalette;
51 | begin
52 | Bitmap := TGPBitmap.Create('ImageFileSmall.jpg');
53 | Graphics.DrawImage(Bitmap, 0, 0, Bitmap.Width, Bitmap.Height);
54 |
55 | // Convert to a 16-color bitmap (4 bits per pixel) using solid dithering
56 | Palette := TGPBitmap.InitializePalette(16, PaletteTypeOptimal, 16, False, Bitmap);
57 | Bitmap.ConvertFormat(PixelFormat4bppIndexed, DitherTypeSolid, PaletteTypeOptimal, Palette, 0);
58 | Graphics.DrawImage(Bitmap, 330, 0, Bitmap.Width, Bitmap.Height);
59 |
60 | // Convert to a 16-color bitmap (4 bits per pixel) using diffusion dithering
61 | Bitmap := TGPBitmap.Create('ImageFileSmall.jpg');
62 | Palette := TGPBitmap.InitializePalette(16, PaletteTypeOptimal, 16, False, Bitmap);
63 | Bitmap.ConvertFormat(PixelFormat4bppIndexed, DitherTypeErrorDiffusion, PaletteTypeOptimal, Palette, 0);
64 | Graphics.DrawImage(Bitmap, 0, 210, Bitmap.Width, Bitmap.Height);
65 |
66 | // Convert to a 256-color bitmap (8 bits per pixel) using diffusion dithering
67 | Bitmap := TGPBitmap.Create('ImageFileSmall.jpg');
68 | Palette := TGPBitmap.InitializePalette(256, PaletteTypeOptimal, 256, False, Bitmap);
69 | Bitmap.ConvertFormat(PixelFormat8bppIndexed, DitherTypeErrorDiffusion, PaletteTypeOptimal, Palette, 0);
70 | Graphics.DrawImage(Bitmap, 330, 210, Bitmap.Width, Bitmap.Height);
71 | end;
72 | {$ENDREGION}
73 |
74 | initialization
75 | RegisterDemo('Enhancements\Convert Pixel Format for Bitmaps', TDemoPixelFormatConversion);
76 |
77 | end.
78 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/FMain.dfm:
--------------------------------------------------------------------------------
1 | object FormMain: TFormMain
2 | Left = 0
3 | Top = 0
4 | Caption = 'GDI+ 1.1 Demos'
5 | ClientHeight = 672
6 | ClientWidth = 1029
7 | Color = clBtnFace
8 | Font.Charset = DEFAULT_CHARSET
9 | Font.Color = clWindowText
10 | Font.Height = -12
11 | Font.Name = 'Segoe UI'
12 | Font.Style = []
13 | OldCreateOrder = True
14 | OnActivate = FormActivate
15 | OnCreate = FormCreate
16 | OnDestroy = FormDestroy
17 | PixelsPerInch = 96
18 | TextHeight = 15
19 | object Splitter: TSplitter
20 | Left = 329
21 | Top = 0
22 | Width = 5
23 | Height = 672
24 | end
25 | object TreeViewDemos: TTreeView
26 | Left = 0
27 | Top = 0
28 | Width = 329
29 | Height = 672
30 | Align = alLeft
31 | Font.Charset = DEFAULT_CHARSET
32 | Font.Color = clWindowText
33 | Font.Height = -13
34 | Font.Name = 'Segoe UI'
35 | Font.Style = []
36 | HideSelection = False
37 | Indent = 19
38 | ParentFont = False
39 | ReadOnly = True
40 | TabOrder = 0
41 | OnChange = TreeViewDemosChange
42 | end
43 | object PanelClient: TPanel
44 | Left = 334
45 | Top = 0
46 | Width = 695
47 | Height = 672
48 | Align = alClient
49 | BevelOuter = bvNone
50 | TabOrder = 1
51 | object SplitterRight: TSplitter
52 | Left = 0
53 | Top = 243
54 | Width = 695
55 | Height = 5
56 | Cursor = crVSplit
57 | Align = alBottom
58 | ExplicitTop = 245
59 | end
60 | object RichEdit: TRichEdit
61 | Left = 0
62 | Top = 248
63 | Width = 695
64 | Height = 424
65 | Align = alBottom
66 | Font.Charset = EASTEUROPE_CHARSET
67 | Font.Color = clWindowText
68 | Font.Height = -11
69 | Font.Name = 'Tahoma'
70 | Font.Style = []
71 | ParentFont = False
72 | ReadOnly = True
73 | ScrollBars = ssVertical
74 | TabOrder = 0
75 | end
76 | object PanelGraphic: TPanel
77 | Left = 0
78 | Top = 0
79 | Width = 695
80 | Height = 243
81 | Align = alClient
82 | BevelOuter = bvNone
83 | TabOrder = 1
84 | Visible = False
85 | object PaintBoxTopRuler: TPaintBox
86 | Left = 0
87 | Top = 0
88 | Width = 695
89 | Height = 15
90 | Align = alTop
91 | OnPaint = PaintBoxTopRulerPaint
92 | ExplicitWidth = 689
93 | end
94 | object PaintBoxLeftRuler: TPaintBox
95 | Left = 0
96 | Top = 15
97 | Width = 15
98 | Height = 228
99 | Align = alLeft
100 | OnPaint = PaintBoxLeftRulerPaint
101 | ExplicitTop = 16
102 | ExplicitHeight = 628
103 | end
104 | object PaintBox: TPaintBox
105 | Left = 15
106 | Top = 15
107 | Width = 680
108 | Height = 228
109 | Align = alClient
110 | OnPaint = PaintBoxPaint
111 | ExplicitLeft = 188
112 | ExplicitTop = 148
113 | ExplicitWidth = 105
114 | ExplicitHeight = 105
115 | end
116 | end
117 | end
118 | end
119 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/GdiPlus11.dpr:
--------------------------------------------------------------------------------
1 | program GdiPlus11;
2 |
3 | // Disable extended RTTI
4 | {$IF CompilerVersion >= 21.0} // >= Delphi 2010
5 | {$WEAKLINKRTTI ON}
6 | {$RTTI EXPLICIT METHODS([]) PROPERTIES([]) FIELDS([])}
7 | {$IFEND}
8 |
9 | {$SetPEFlags 1} // IMAGE_FILE_RELOCS_STRIPPED
10 | {$SetPEFlags $20} // IMAGE_FILE_LARGE_ADDRESS_AWARE
11 |
12 | uses
13 | Forms,
14 | FMain in 'FMain.pas' {FormMain},
15 | GdiPlus in '..\..\..\Lib\GdiPlus.pas',
16 | uDemo in 'uDemo.pas',
17 | GdiPlusHelpers in '..\..\..\Lib\GdiPlusHelpers.pas',
18 | uSourceCodeConverter in 'uSourceCodeConverter.pas',
19 | uDemoAntialiasing in 'Enhancements\uDemoAntialiasing.pas',
20 | uDemoPixelFormatConversion in 'Enhancements\uDemoPixelFormatConversion.pas',
21 | uDemoHistogram in 'Enhancements\uDemoHistogram.pas',
22 | uDemoBlur in 'Bitmap Effects\uDemoBlur.pas',
23 | uDemoSharpen in 'Bitmap Effects\uDemoSharpen.pas',
24 | uDemoRedEyeCorrection in 'Bitmap Effects\uDemoRedEyeCorrection.pas',
25 | uDemoBrightnessContrast in 'Bitmap Effects\uDemoBrightnessContrast.pas',
26 | uDemoHueSaturationLightness in 'Bitmap Effects\uDemoHueSaturationLightness.pas',
27 | uDemoLevels in 'Bitmap Effects\uDemoLevels.pas',
28 | uDemoTint in 'Bitmap Effects\uDemoTint.pas',
29 | uDemoColorBalance in 'Bitmap Effects\uDemoColorBalance.pas',
30 | uDemoColorMatrix in 'Bitmap Effects\uDemoColorMatrix.pas',
31 | uDemoColorLUT in 'Bitmap Effects\uDemoColorLUT.pas',
32 | uDemoColorCurve in 'Bitmap Effects\uDemoColorCurve.pas';
33 |
34 | {$R *.res}
35 |
36 | begin
37 | ReportMemoryLeaksOnShutdown := True;
38 | Application.Initialize;
39 | Application.MainFormOnTaskbar := True;
40 | Application.CreateForm(TFormMain, FormMain);
41 | Application.Run;
42 | end.
43 |
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/GdiPlus11.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus11/GdiPlus11.res
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/GdiPlus11_Icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Demos/Original demo/GdiPlus11/GdiPlus11_Icon.ico
--------------------------------------------------------------------------------
/Demos/Original demo/GdiPlus11/uDemo.pas:
--------------------------------------------------------------------------------
1 | unit uDemo;
2 |
3 | interface
4 |
5 | uses
6 | Classes,
7 | SysUtils,
8 | GdiPlus;
9 |
10 | type
11 | {$TYPEINFO ON} { To make TDemo.UnitName work }
12 | TDemo = class abstract
13 | strict private
14 | FGraphics: IGPGraphics;
15 | strict protected
16 | procedure Run; virtual; abstract;
17 |
18 | property Graphics: IGPGraphics read FGraphics;
19 | public
20 | constructor Create; virtual;
21 | procedure Execute(const ATargetGraphics: IGPGraphics);
22 | end;
23 | {$TYPEINFO OFF}
24 | TDemoClass = class of TDemo;
25 |
26 | procedure RegisterDemo(const Path: String; const DemoClass: TDemoClass);
27 | function RegisteredDemos: TStringList;
28 |
29 | implementation
30 |
31 | var
32 | GlobalRegisteredDemos: TStringList = nil;
33 |
34 | procedure RegisterDemo(const Path: String; const DemoClass: TDemoClass);
35 | begin
36 | GlobalRegisteredDemos.AddObject(Path, Pointer(DemoClass));
37 | end;
38 |
39 | function RegisteredDemos: TStringList;
40 | begin
41 | Result := GlobalRegisteredDemos;
42 | end;
43 |
44 | { TDemo }
45 |
46 | constructor TDemo.Create;
47 | begin
48 | inherited Create;
49 | end;
50 |
51 | procedure TDemo.Execute(const ATargetGraphics: IGPGraphics);
52 | begin
53 | FGraphics := ATargetGraphics;
54 | FGraphics.ResetTransform;
55 | Run;
56 | end;
57 |
58 | initialization
59 | GlobalRegisteredDemos := TStringList.Create;
60 |
61 | finalization
62 | FreeAndNil(GlobalRegisteredDemos);
63 |
64 | end.
65 |
--------------------------------------------------------------------------------
/Doc/GdiPlus10.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Doc/GdiPlus10.gif
--------------------------------------------------------------------------------
/Doc/GdiPlus11.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Doc/GdiPlus11.gif
--------------------------------------------------------------------------------
/Doc/License.txt:
--------------------------------------------------------------------------------
1 | Delphi GDI+ Library for use with Delphi 2009 or later.
2 | Copyright (C) 2009 by Erik van Bilsen.
3 | Email: erik@bilsen.com
4 | Website: www.bilsen.com/gdiplus
5 |
6 | License in plain English:
7 |
8 | 1. I don't promise that this software works. (But if you find any bugs,
9 | please let me know!)
10 | 2. You can use this software for whatever you want. You don't have to pay me.
11 | 3. You may not pretend that you wrote this software. If you use it in a program,
12 | you must acknowledge somewhere in your documentation that you've used this
13 | code.
14 |
15 | In legalese:
16 |
17 | The author makes NO WARRANTY or representation, either express or implied,
18 | with respect to this software, its quality, accuracy, merchantability, or
19 | fitness for a particular purpose. This software is provided "AS IS", and you,
20 | its user, assume the entire risk as to its quality and accuracy.
21 |
22 | Permission is hereby granted to use, copy, modify, and distribute this
23 | software (or portions thereof) for any purpose, without fee, subject to these
24 | conditions:
25 | (1) If any part of the source code for this software is distributed, then the
26 | License.txt file must be included, with this copyright and no-warranty notice
27 | unaltered; and any additions, deletions, or changes to the original files
28 | must be clearly indicated in accompanying documentation.
29 | (2) If only executable code is distributed, then the accompanying
30 | documentation must state that "this software is based in part on the Delphi
31 | GDI+ library by Erik van Bilsen".
32 | (3) Permission for use of this software is granted only if the user accepts
33 | full responsibility for any undesirable consequences; the author accepts
34 | NO LIABILITY for damages of any kind.
--------------------------------------------------------------------------------
/Lib/GdiPlus11.RES:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/Lib/GdiPlus11.RES
--------------------------------------------------------------------------------
/Lib/GdiPlus11.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
10 |
17 |
18 |
19 |
20 |
21 |
28 |
29 |
30 |
31 |
32 |
33 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/Lib/GdiPlus11.rc:
--------------------------------------------------------------------------------
1 | 1 24 "GdiPlus11.manifest"
--------------------------------------------------------------------------------
/Lib/GdiPlus_DCC.inc:
--------------------------------------------------------------------------------
1 |
2 | {$IFNDEF FPC}
3 | {$IF CompilerVersion < 22}
4 | {$DEFINE DCC}
5 | {$IFEND}
6 | {$ENDIF}
7 |
8 | {$IFDEF DCC}
9 |
10 | //{$IF CompilerVersion <= 20}
11 | // {$DEFINE DELPHI2009_OR_BELOW}
12 | //{$IFEND}
13 | //
14 | //{$IF CompilerVersion >= 20}
15 | // {$DEFINE DELPHI2009_OR_ABOVE}
16 | // {$DEFINE DELPHI_UNICODE}
17 | //{$IFEND}
18 | //
19 | //
20 | //{$IF CompilerVersion <= 21}
21 | // {$DEFINE DELPHI2010_OR_BELOW}
22 | //{$IFEND}
23 | //
24 | //{$IF CompilerVersion >= 21}
25 | // {$DEFINE DELPHI2010_OR_ABOVE}
26 | //{$IFEND}
27 | //
28 | //
29 | //{$IF CompilerVersion >= 22}
30 | // {$DEFINE DELPHIXE_OR_UP}
31 | // {$DEFINE HAS_FORMATSETTINGS}
32 | //{$IFEND}
33 | //
34 | {$IF CompilerVersion >= 23}
35 | {$DEFINE DELPHIXE2_OR_ABOVE}
36 | {$DEFINE HAS_SYSTEM_UITYPES}
37 | {$IFEND}
38 | //
39 | //{$IF CompilerVersion >= 24}
40 | // {$DEFINE DELPHI_XE3_OR_ABOVE}
41 | //{$IFEND}
42 | //
43 | //{$IF CompilerVersion >= 25}
44 | // {$DEFINE DELPHI_XE4_OR_ABOVE}
45 | //{$IFEND}
46 |
47 | {$ENDIF} // DCC
48 |
--------------------------------------------------------------------------------
/Lib/GdiPlus_FPC.inc:
--------------------------------------------------------------------------------
1 |
2 | {$IFDEF FPC}
3 |
4 | {$WARN 3018 off : Constructor should be public}
5 | {$WARN 3031 off : Values in enumeration types have to be ascending}
6 | {$WARN 5091 off : Local variable "$1" of a managed type does not seem to be initialized}
7 |
8 | {$ENDIF} // FPC
9 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 |
2 | # GDI+ Library for Delphi and Lazarus
3 |
4 | The **Delphi 2009 GDI+ Library** ported to Lazarus.
5 |
6 |
7 |
8 | - [GDI+ Library for Delphi and Lazarus](#gdi-library-for-delphi-and-lazarus)
9 | - [Delphi 2009 GDI+ Library](#delphi-2009-gdi-library)
10 | - [Original license](#original-license)
11 | - [License for my modifications](#license-for-my-modifications)
12 | - [My modifications](#my-modifications)
13 | - [Screenshots](#screenshots)
14 | - [Installation](#installation)
15 | - [Delphi](#delphi)
16 | - [Lazarus](#lazarus)
17 | - [Changelog](#changelog)
18 |
19 |
20 |
21 | ---
22 |
23 | ## Delphi 2009 GDI+ Library
24 |
25 | This library enables GDI+ functionality for Delphi 2009 and later.
26 |
27 | Author: Erik van Bilsen
28 | Home page: http://www.bilsen.com/gdiplus/index.shtml
29 |
30 | A quote from the author's website:
31 |
32 | This library enables GDI+ functionality for Delphi 2009 and later. It differs from other Delphi GDI+ libraries in the following ways:
33 |
34 | - It is modeled more after the .NET System.Drawing namespace instead of the C++ GDI+ classes. As a result, this library is a bit more **high level** and easier to use.
35 | - It uses **object interfaces** for automatic memory management and ease of use. You don't have to keep track of your graphics objects anymore.
36 | - It uses **exceptions** instead of error codes to handle errors the Delphi way.
37 | - It comes with sample applications that demonstrate the usage of GDI+ through examples from the Windows Platform SDK.
38 | - It supports the **GDI+ version 1.1** extensions that were added with Windows Vista and certain Office versions.
39 | - Optionally provides class helpers for interoperability with Delphi's TBitmap and TCanvas.
40 |
41 | Note that this GDI+ library only works with Delphi 2009 or later. This is because the library uses some new features of Delphi 2009 such as generics, and assumes that all string functions use Unicode strings.
42 |
43 | ---
44 |
45 | ## Original license
46 |
47 | Delphi GDI+ Library for use with Delphi 2009 or later.
48 | Copyright (C) 2009 by Erik van Bilsen.
49 | Email: erik(at)bilsen. com
50 | Website: http://www.bilsen.com/gdiplus
51 |
52 | License in plain English:
53 |
54 | 1. I don't promise that this software works. (But if you find any bugs,
55 | please let me know!)
56 | 2. You can use this software for whatever you want. You don't have to pay me.
57 | 3. You may not pretend that you wrote this software. If you use it in a program,
58 | you must acknowledge somewhere in your documentation that you've used this
59 | code.
60 |
61 | In legalese:
62 |
63 | The author makes NO WARRANTY or representation, either express or implied,
64 | with respect to this software, its quality, accuracy, merchantability, or
65 | fitness for a particular purpose. This software is provided "AS IS", and you,
66 | its user, assume the entire risk as to its quality and accuracy.
67 |
68 | Permission is hereby granted to use, copy, modify, and distribute this
69 | software (or portions thereof) for any purpose, without fee, subject to these
70 | conditions:
71 | (1) If any part of the source code for this software is distributed, then the
72 | License.txt file must be included, with this copyright and no-warranty notice
73 | unaltered; and any additions, deletions, or changes to the original files
74 | must be clearly indicated in accompanying documentation.
75 | (2) If only executable code is distributed, then the accompanying
76 | documentation must state that "this software is based in part on the Delphi
77 | GDI+ library by Erik van Bilsen".
78 | (3) Permission for use of this software is granted only if the user accepts
79 | full responsibility for any undesirable consequences; the author accepts
80 | NO LIABILITY for damages of any kind.
81 |
82 | ---
83 |
84 | ## License for my modifications
85 |
86 | Public domain - You can do with my code whatever you want without any limitations.
87 |
88 | ---
89 |
90 | ## My modifications
91 |
92 | - Lazarus / Free Pascal support.
93 | Required **FPC version 3.2.0 or newer!**.
94 | - A few helper routines in the `GdiPlusHelpers.pas` file.
95 | - New files: `GdiPlus_DCC.inc`, `GdiPlus_FPC.inc`.
96 | - Minor changes to the demo programs (increased font size)
97 | - New demo: Color Wheel
98 | - Package for Lazarus.
99 | - **GDI+ 1.1 extensions enabled by default**
100 | In the original version of the GdiPlus unit, Erik turned off GDI+ 1.1 by default.
101 | To enable GDI+ 1.1 it was necessary to add the `GDIP_0110` to the conditional defines in the project options. This unit was written many years ago when Windows XP was widely used, so it made sense. Currently Windows XP is slowly becoming an "antique" system, so I decided to enable GDI+ 1.1 by default. However, if you want to be compatible with Windows XP, add `GDIP_XP_COMPAT` to conditional defines in your project.
102 |
103 | ---
104 |
105 | ## Screenshots
106 |
107 | Original demo application compiled with Delphi Rio.
108 |
109 | 
110 |
111 | ---
112 |
113 | Additional demo - Color Wheel - compiled with Lazarus 2.0.11 + FPC 3.2.0.
114 |
115 | 
116 |
117 |
118 | ---
119 |
120 | ## Installation
121 |
122 | ### Delphi
123 |
124 | No packages for Delphi. In the IDE options, add to the **Library path** directory with the `GdiPlus.pas` file.
125 |
126 | ### Lazarus
127 |
128 |
129 | Build and install the `packages\Lazarus\lazgdiplus.lpk` package.
130 |
131 | Open/create some project. In the **Project Inspector** add `LazGDIPlus` to **Required Packages**.
132 |
133 |
134 | ---
135 |
136 | ## Changelog
137 |
138 | **16.05.2022**
139 | * GPFontList - Global list of GDI+ compatible fonts
140 | * SetGPPenStyle - Set IGPPen style from TenStyle
141 | * GetGPFontName - Get the first GDI+ compatible font name from the given array
142 | * TransparencyToAlpha
143 | * HatchStyleToStrID
144 | * TryStrIDToHatchStyle
145 |
146 |
147 | **23.09.2020**
148 | Initial commit with the Free Pascal / Lazarus support.
149 |
--------------------------------------------------------------------------------
/clean_DCU.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | del /s *.dcu
4 |
--------------------------------------------------------------------------------
/clean_FPC.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 |
3 | del /s *.ppu
4 | del /s *.o
5 | del /s *.rsj
6 | del /s *.or
7 |
--------------------------------------------------------------------------------
/gdiplus.url:
--------------------------------------------------------------------------------
1 | [InternetShortcut]
2 | URL=http://www.bilsen.com/gdiplus/
3 |
--------------------------------------------------------------------------------
/img/demo1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/img/demo1.png
--------------------------------------------------------------------------------
/img/demo2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jackdp/GDIPlus-Library-for-Delphi-and-Lazarus/7f5053e1ad1c9013fe6a9d2360d025726aadb79a/img/demo2.png
--------------------------------------------------------------------------------
/packages/Lazarus/lazgdiplus.lpk:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 | <_ExternHelp Items="Count"/>
85 |
86 |
87 |
88 |
--------------------------------------------------------------------------------
/packages/Lazarus/lazgdiplus.pas:
--------------------------------------------------------------------------------
1 | { This file was automatically created by Lazarus. Do not edit!
2 | This source is only used to compile and install the package.
3 | }
4 |
5 | unit LazGDIPlus;
6 |
7 | interface
8 |
9 | uses
10 | GdiPlus, GdiPlusHelpers, LazarusPackageIntf;
11 |
12 | implementation
13 |
14 | procedure Register;
15 | begin
16 | end;
17 |
18 | initialization
19 | RegisterPackage('LazGDIPlus', @Register);
20 | end.
21 |
--------------------------------------------------------------------------------
/version.txt:
--------------------------------------------------------------------------------
1 |
2 | Based on GdiPlus 1.2.1
3 | http://www.bilsen.com/gdiplus/GdiPlus1.2.1.zip
4 |
--------------------------------------------------------------------------------