找传奇、传世资源到传世资源站!

delphi 画图示例源码(LiveBinding)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

【例子介绍】

【相关图片】

from clipboard

from clipboard

【源码结构】

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.stdCtrls,Vcl.ExtCtrls,
  Data.Bind.EngExt, Vcl.Bind.DBEngExt, System.Rtti, System.Bindings.Outputs,
  Vcl.Bind.Editors, Data.Bind.Components;

type
  TMain = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    edtTop: TEdit;
    edtLeft: TEdit;
    edtWidth: TEdit;
    edtHeight: TEdit;
    Panel1: TPanel;
    Image1: TImage;
    BindingsList1: TBindingsList;
    LinkControlToPropertyTop: TLinkControlToProperty;
    LinkControlToPropertyLeft: TLinkControlToProperty;
    LinkControlToPropertyHeight: TLinkControlToProperty;
    LinkControlToPropertyWidth: TLinkControlToProperty;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure RedrawImage;
  end;

var
  Main: TMain;

implementation

{$R *.dfm}
procedure TMain.Button1Click(Sender: TObject);
begin
  RedrawImage;
end;

procedure TMain.FormCreate(Sender: TObject);
begin
  RedrawImage;
end;

procedure TMain.RedrawImage;
var
  I, J: Integer;
  Bitmap: TBitmap;

begin
  { create a bitmap picture in the memory }
  Bitmap := TBitmap.Create;

  { use the dimensions of the Image1 control }
  Bitmap.Width := Image1.Width;
  Bitmap.Height := Image1.Height;

  { dynamically render a color spectrum }
  for I := 0 to Bitmap.Width do
    for J := 0 to Bitmap.Height do
      Bitmap.Canvas.Pixels[I, J] := RGB(I, J, 128);

  { assign the bitmap to Image1 }
  Image1.Picture.Bitmap := Bitmap;

  { free up used memory }
  Bitmap.Free;
end;
end.

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复