Урок на делфи 82. Сдвигаем рисунок вбок.


задание на delphi. Задание на Delphi. Как в Image1 сдвинуть изображение?

unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
temp1:TStringList;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i:Integer;
temp2:TStringList;
begin
temp2:=TStringList.Create;
for I := 0 to 10000000 do
temp2.Add('000000000000000000000000000000000000000000000000000000000000000');
temp2.Clear;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i:Integer;
temp2:TStringList;
begin
temp2:=TStringList.Create;
for I := 0 to 10000000 do
temp2.Add('000000000000000000000000000000000000000000000000000000000000000');
temp2.Free;
end;
procedure TForm1.Button3Click(Sender: TObject);
var i:Integer;
temp2:TStringList;
begin
temp2:=TStringList.Create;
for I := 0 to 10000000 do
temp2.Add('000000000000000000000000000000000000000000000000000000000000000');
FreeAndNil(temp2);
end;
procedure TForm1.Button4Click(Sender: TObject);
var i:Integer;
temp2:TStringList;
begin
temp2:=TStringList.Create;
for I := 0 to 10000000 do
temp2.Add('000000000000000000000000000000000000000000000000000000000000000');
temp2.Destroy;
end;
end.
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
pic,temp:TBitmap;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
temp.Canvas.CopyRect(Rect(0, 0, pic.Width, pic.Height), pic.Canvas, Rect(Button1.Tag, 0, pic.Width+Button1.Tag, pic.Height));
Image1.Picture.Assign(temp);
Button1.Tag:=Button1.Tag+2;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
pic:=TBitmap.Create;
pic.LoadFromFile('..\..\pic.bmp');
temp:=TBitmap.Create;
temp.Height:=pic.Height;
temp.Width:=pic.Width;
Image1.Proportional:=true;
end;
end.



Скачать