Delphi与DirectX之DelphiX(16):DXImageList1.Items.Find()

本例效果图:


代码文件:

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DXDraws, StdCtrls;
type
TForm1 = class(TForm)
DXDraw1: TDXDraw;
DXImageList1: TDXImageList;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{加载图片并命名, 这也可以在设计时做}
procedure TForm1.FormCreate(Sender: TObject);
const
ImgPath1 = 'C:\Temp\DelphiX.bmp';
ImgPath2 = 'C:\Temp\DelphiX.jpg';
begin
DXImageList1.DXDraw := DXDraw1;
DXImageList1.Items.Add;
DXImageList1.Items[DXImageList1.Items.Count-1].Picture.LoadFromFile(ImgPath1);
DXImageList1.Items[DXImageList1.Items.Count-1].Name := 'img1';
DXImageList1.Items.Add;
DXImageList1.Items[DXImageList1.Items.Count-1].Picture.LoadFromFile(ImgPath2);
DXImageList1.Items[DXImageList1.Items.Count-1].Name := 'img2';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
DXDraw1.Surface.Fill(0);
DXImageList1.Items.Find('img1').Draw(DXDraw1.Surface, 0, 0, 0);
DXDraw1.Flip;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
DXDraw1.Surface.Fill(0);
DXImageList1.Items.Find('img2').Draw(DXDraw1.Surface, 0, 0, 0);
DXDraw1.Flip;
end;
end.

时间: 2024-09-19 08:58:28

Delphi与DirectX之DelphiX(16):DXImageList1.Items.Find()的相关文章

Delphi与DirectX之DelphiX(17):TPictureCollectionItem.PatternWidth、Patte

Delphi与DirectX之DelphiX(17):TPictureCollectionItem.PatternWidth.PatternHeight 本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DXDraws, StdCtrls; type TForm1 = class(TForm) DXD

Delphi与DirectX之DelphiX(7)

Delphi与DirectX 之DelphiX(7): 给TDXImageList加载图片的最后方案 本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DXDraws, StdCtrls; type TForm1 = class(TForm) DXDraw1: TDXDraw; DXImageList

Delphi与DirectX之DelphiX(6)

Delphi与DirectX之DelphiX(6): 让TDXImageList和常规VCL交互使用 本例测试了两个问题: 1.其他 VCL 加载的图片能否给 TDXImageList 使用; 2.TDXImageList 中的图片能否给其他 VCL 使用. 例子中先用 TPicture 加载了图片, 然后给 TDXImageList; 然后把图片绘制在了窗体上, 而非 TDXDraw 中. 继续了解点 TDXImageList: TDXImageList 控件只有两个属性: DXDraw 和

Delphi与DirectX之DelphiX(87): TDIB.DrawTransparent、DrawTranslucent、Dra

Delphi与DirectX之DelphiX(87): TDIB.DrawTransparent.DrawTranslucent.DrawAlpha(); TDIB.DrawTransparent: 按指定的透明色透明; TDIB.DrawTranslucent: 先按指定的透明色透明, 然后再半透明; DIB.DrawAlpha: 先按指定的透明色透明, 再按指定的透明度透明. 本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages,

Delphi与DirectX之DelphiX(8) 第一个简单动画

本例效果图(用 gif 动画演示, 无论如何也出不来 DirectX 的流畅效果): 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DXDraws, StdCtrls, DXClass; type TForm1 = class(TForm) DXDraw1: TDXDraw; DXImageList1: TDX

Delphi与DirectX之DelphiX(15)

此类函数有: TPictureCollectionItem.DrawWaveX(); TPictureCollectionItem.DrawWaveXAdd(); TPictureCollectionItem.DrawWaveXAlpha(); TPictureCollectionItem.DrawWaveXSub(); TPictureCollectionItem.DrawWaveY(); TPictureCollectionItem.DrawWaveYAdd(); TPictureColle

Delphi与DirectX之DelphiX(14)

TPictureCollectionItem.DrawRotate(); 的同类函数还有: TPictureCollectionItem.DrawRotateAdd(); TPictureCollectionItem.DrawRotateSub(); TPictureCollectionItem.DrawRotateAlpha(); TPictureCollectionItem.DrawRotateAddCol(); TPictureCollectionItem.DrawRotateSubCol

Delphi与DirectX之DelphiX(13)

本例效果图(实际效果是相当流畅的, gif 只能说明个动作趋势): 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DXDraws, StdCtrls, DXClass, ComCtrls; type TForm1 = class(TForm) DXDraw1: TDXDraw; DXImageList1: TD

Delphi与DirectX之DelphiX(12)

本例效果图: 代码文件: unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DXDraws, StdCtrls, DXClass, ComCtrls; type TForm1 = class(TForm) DXDraw1: TDXDraw; DXImageList1: TDXImageList; TrackBar1: TTra