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


本例效果图:

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;

    DXImageList1: TDXImageList;

    Button1: TButton;

    procedure FormCreate(Sender: TObject);

    procedure Button1Click(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';

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;



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;



end.


 
   

你可能感兴趣的:(Delphi)