• Delphi 与 DirectX 之 DelphiX(10): TPictureCollectionItem.StretchDraw


    本例效果图:


    代码文件:


    unit Unit1;
    
    interface
    
    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, DXDraws, StdCtrls, DXClass;
    
    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}
    
    var
      PicItem: TPictureCollectionItem;
    
    procedure TForm1.FormCreate(Sender: TObject);
    const
      ImgPath1 = 'C:TempDelphiX.bmp';
    begin
      DXImageList1.DXDraw := DXDraw1;
      PicItem := TPictureCollectionItem(DXImageList1.Items.Add);
      PicItem.Picture.LoadFromFile(ImgPath1);
    end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      DXDraw1.Surface.Fill(0);
      PicItem.StretchDraw(DXDraw1.Surface, DXDraw1.Surface.ClientRect, 0);
      DXDraw1.Flip;
    end;
    
    procedure TForm1.Button2Click(Sender: TObject);
    var
      r: TRect;
    begin
      r.Left := (DXDraw1.Width - PicItem.Width) div 2;
      r.Top := (DXDraw1.Height - PicItem.Height) div 2;
      r.Right := r.Left + PicItem.Width;
      r.Bottom := r.Top + PicItem.Height;
    
      DXDraw1.Surface.Fill(0);
      PicItem.StretchDraw(DXDraw1.Surface, r, 0);
      DXDraw1.Flip;
    end;
    
    end.
    好的代码像粥一样,都是用时间熬出来的
  • 相关阅读:
    链接的具体内容
    多线程下载图片
    Commo*IO组件的简单应用
    文件分割
    mybatis动态sql
    ajax请求与json数据处理
    ModelAndView 配置与使用
    div塌陷,以及页面常用属性
    EasyUI 时间插件使用配置
    Editor富文本编辑器配置【不含图片上传】
  • 原文地址:https://www.cnblogs.com/jijm123/p/14351425.html
Copyright © 2020-2023  润新知