unitfrmmain.pas
来自「《Delphi实用程序100例》配套书源码盘」· PAS 代码 · 共 86 行
PAS
86 行
unit unitFrmMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
newbmp: TBitmap;
i, j, bmpheight, bmpwidth: integer;
begin
newbmp := TBitmap.Create;
newbmp.Width := image1.Width;
newbmp.Height := image1.Height;
bmpheight := image1.Height;
bmpwidth := image1.Width;
i := 0;
while i <= bmpwidth do
begin
j := i;
while j > 0 do
begin
newbmp.Canvas.CopyRect(Rect(j - 1, 0, j, bmpheight), image1.Canvas, Rect(bmpwidth - i + j - 1, 0, bmpwidth - i + j, bmpheight));
newbmp.Canvas.CopyRect(Rect(bmpwidth - j, 0, bmpwidth - j + 1, bmpheight), image1.Canvas, Rect(i - j, 0, i - j + 1, bmpheight));
j := j - 2;
end;
form1.Canvas.Draw(120, 100, newbmp);
i := i + 2;
end;
newbmp.free;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
newbmp: TBitmap;
i, j, bmpheight, bmpwidth: integer;
begin
newbmp := TBitmap.Create;
newbmp.Width := image1.Width;
newbmp.Height := image1.Height;
bmpheight := image1.Height;
bmpwidth := image1.Width;
i := bmpheight;
while i > 0 do
begin
for j := 10 to i do
begin
newbmp.Canvas.CopyRect(Rect(0, j - 10, bmpwidth, j),
image1.Canvas,
Rect(0, i - 10, bmpwidth, i));
form1.Canvas.Draw(120, 100, newbmp);
end;
i := i - 10;
end;
newbmp.free;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?