Delphi 与 DirectX 之 DelphiX(7): 给 TDXImageList 加载图片的最后方案

  • A+
所属分类:[开发技巧]

操做一下 万一老师给出的 TDXImageList 加载图片的方案.思路如下

1.将TDXImageLIst跟TPictureCollectionItem关联,然后向TPictureCollectionItem的picture中添加图片.

2.用TDXImageLIst的draw方式来显示图片.

本例效果图:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DXDraws, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    DXDraw1: TDXDraw;
    DXImageList1: TDXImageList;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  with DXImageList1 do
  begin
    Items[0].Draw(DXDraw.Surface,0,0,0);
    Items[1].Draw(DXDraw.Surface, 0, Items[0].Height, 0);
    DXDraw.Flip;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
const
  ImgPath1 = 'C:\Temp\DelphiX.bmp';
  ImgPath2 = 'C:\Temp\DelphiX.jpg';
var
  PicItem: TPictureCollectionItem;
begin
  DXImageList1.DXDraw := DXDraw1;
  DXImageList1.Items.Add;
  Picitem := DXImageList1.Items[DXImageList1.Items.Count-1] ;
  Picitem.Picture.LoadFromFile(ImgPath1);

  DXImageList1.Items.Add;
  Picitem := DXImageList1.Items[DXImageList1.Items.Count-1] ;
  Picitem.Picture.LoadFromFile(ImgPath2);
end;

end.
 

 

7DXimagelist最终载入方案.rar

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin
广告也精彩
avatar
广告也精彩

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: