Delphi 与 DirectX 之 DelphiX(13): TPictureCollectionItem.DrawRotate

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

本例效果图(实际效果是相当流畅的, gif 只能说明个动作趋势):

代码:

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    DXDraw1: TDXDraw;
    dxtmr1: TDXTimer;
    dxmglst1: TDXImageList;
    procedure FormCreate(Sender: TObject);
    procedure dxtmr1Timer(Sender: TObject; LagCount: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

var
  PicItem: TPictureCollectionItem;
  Angle: Cardinal;

{$R *.dfm}

procedure TForm1.dxtmr1Timer(Sender: TObject; LagCount: Integer);
begin
  DXDraw1.Surface.Fill(0);
  PicItem.DrawRotate(DXDraw1.Surface,
                     DXDraw1.Width div 2, DXDraw1.Height div 2, {位置}
                     PicItem.Width, PicItem.Height,             {大小}
                     0,                                         {调色板}
                     0.5,0.5,                                   {旋转中心:0....1}
                     Byte(Angle));                               {旋转角度}
  Inc(Angle);
  DXDraw1.Flip;
end;

procedure TForm1.FormCreate(Sender: TObject);
const
  ImgPath1 = 'C:\Temp\DelphiX.bmp';
begin
  DXDraw1.Align := alClient;
  dxtmr1.Interval := 0;
  dxmglst1.DXDraw := DXDraw1;
  PicItem := TPictureCollectionItem(dxmglst1.Items.Add);
  PicItem.Picture.LoadFromFile(ImgPath1);
end;

end.
 

13图片旋转.rar

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

发表评论

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