再学GDI+[22]: TGPLinearGradientBrush

TGPLinearGradientBrush.Create(
 rect: TGPRect;      {线性渐变的界限}
 color1, color2: TGPColor; {线性渐变起始色与终止色}
 mode: TLinearGradientMode {渐变方向, 见下表}
);
TGPLinearGradientBrush.Create(
 rect: TGPRectF;
 color1, color2: TGPColor;
 mode: TLinearGradientMode
);

本例效果图:

代码文件:unit Unit1;
interface
uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls, TeCanvas;
type
 TForm1 = class(TForm)
  ComboBox1: TComboBox;
  ButtonColor1: TButtonColor;
  ButtonColor2: TButtonColor;
  procedure FormCreate(Sender: TObject);
  procedure FormPaint(Sender: TObject);
  procedure ButtonColor1Click(Sender: TObject);
  procedure ButtonColor2Click(Sender: TObject);
  procedure ComboBox1Change(Sender: TObject);
 end;
var
 Form1: TForm1;
implementation
{$R *.dfm}
uses GDIPOBJ, GDIPAPI, TypInfo;
procedure TForm1.FormCreate(Sender: TObject);
var
 i: Integer;
begin
 for i := 0 to 3 do
  ComboBox1.Items.Add(GetEnumName(TypeInfo(TLinearGradientMode), i));
 ComboBox1.ItemIndex := 1;
 ButtonColor1.Caption := '色1   ';
 ButtonColor2.Caption := '色2   ';
 ButtonColor1.SymbolColor := clYellow;
 ButtonColor2.SymbolColor := clRed;
end;
procedure TForm1.FormPaint(Sender: TObject);
var
 g: TGPGraphics;
 lb: TGPLinearGradientBrush;
 c1,c2: TGPColor;
 r: TGPRect;
begin
 g := TGPGraphics.Create(Canvas.Handle);
 r := MakeRect(60, 40, ClientWidth - 120, ClientHeight - 50);
 c1 := ColorRefToARGB(ButtonColor1.SymbolColor);
 c2 := ColorRefToARGB(ButtonColor2.SymbolColor);
 lb := TGPLinearGradientBrush.Create(r, c1, c2, TLinearGradientMode (ComboBox1.ItemIndex));
 g.FillEllipse(lb, r);
 lb.Free;
 g.Free;
end;
procedure TForm1.ButtonColor1Click(Sender: TObject);
begin
 Repaint;
end;
procedure TForm1.ButtonColor2Click(Sender: TObject);
begin
 Repaint;
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
 Repaint;
end;
end.

时间: 2024-10-03 06:22:58

再学GDI+[22]: TGPLinearGradientBrush的相关文章

再学GDI+[24]: TGPLinearGradientBrush

TGPLinearGradientBrush.Create( const point1, point2: TGPPoint; {线性渐变起始点与终止点} color1, color2: TGPColor {线性渐变起始色与终止色} ); TGPLinearGradientBrush.Create( const point1, point2: TGPPointF; color1, color2: TGPColor ); 本例效果图: 代码文件:unit Unit1; interface uses

再学GDI+[23]: TGPLinearGradientBrush

TGPLinearGradientBrush.Create( rect: TGPRect; {变化范围} color1, color2: TGPColor; {起始色与终止色} angle: Single; {旋转角度} isAngleScalable: BOOL = FALSE {是否受 TLinearGradientMode 的影响, 可选值, 默认不 受影响} ); TGPLinearGradientBrush.Create( rect: TGPRectF; color1, color2:

再学GDI+[102]: TGPImage(22)

本例运行结果:Clsid: {557CF400-1A04-11D3-9A73-0000F81EF32E} FormatID: {B96B3CAB-0728-11D3-9D7B-0000F81EF32E} CodecName: Built-in BMP Codec DllName: FormatDescription: BMP FilenameExtension: *.BMP;*.DIB;*.RLE MimeType: image/bmp Flags: 65543 Version: 1 SigCo

再学GDI+[95]: TGPImage(15)

我通过做此例同时证实了 GDI+ 可以直接显示 png.gif.tif 格式的透明图片. //红色与绿色绕蓝色旋转(r 是弧度) ColorMatrix: TColorMatrix = ( (Cos(r), Sin(r), 0.0, 0.0, 0.0), (-Sin(r), Cos(r), 0.0, 0.0, 0.0), (0.0, 0.0, 1.0, 0.0, 0.0), (0.0, 0.0, 0.0, 1.0, 0.0), (0.0, 0.0, 0.0, 0.0, 1.0)); //绿色与蓝

再学GDI+[99]: TGPImage(19)

本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TForm1 = class(TForm) OpenDialog1: TOpenDialog; Button1: TButton; Button2: TButton; procedure FormCrea

再学GDI+[97]: TGPImage(17)

获取GDI+所支持的可编码.可解码的图像格式 其实这和 TGPImage 是没有关系的. 本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm1 = class(TForm) Memo1: TMemo; procedure FormCreate(Sender: TO

再学GDI+[81]: TGPImage(1)

已知 GDI+ 可以支持的图像格式: BMP.JPEG.GIF.TIFF.PNG.ICO.WMF.EMF TGPGraphics.DrawImage 函数有太多重载了, 一起列在这吧:function DrawImage(image: TGPImage; const point: TGPPointF): TStatus; overload; function DrawImage(image: TGPImage; x, y: Single): TStatus; overload; function

再学GDI+[76]: 区域(5)

本来这个例子是要获取区域的详细信息的, 但非常遗憾, 这个版本的 GDI+ 的头文件少定义了一个 TRegionData 类! 不过也不要紧, 通过 TRegionData 主要也是获取区域中的矩形数据, GetRegionScans 函数可以完成这个任务! 本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialog

再学GDI+[73]: 区域(2)

Intersect {交集} Union {联合} Xor_ {减去交集} Exclude {减去} Complement {不相交} //GDI+ 的区域能和矩形.路径.另一个区域三种对象进行运算. 本例效果图: 代码文件:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type T