基本信息
源码名称:delphi 画图示例源码(LiveBinding)
源码大小:3.56M
文件格式:.rar
开发语言:Pascal
更新时间:2018-02-14
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
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.