使用滑块实现图片的放大和缩小


本文整理自网络,侵删。

 关键代码如下:

var
Form1: TForm1;
x,y:Integer;
implementation

{$R *.dfm}

procedure TForm1.TrackBar1Change(Sender: TObject);
begin
if TrackBar1.Position=0 then
begin
image1.Width:=x;
image1.Height:=y;
Exit;
end;
image1.Width:=Ceil(x*( TrackBar1.Position));
image1.Height:=Ceil(y*( TrackBar1.Position));
image1.Top:=Ceil(1/2*(Self.Height-image1.Height));
Image1.Left:=Ceil(1/2*(Self.Width-image1.Width));
end;

procedure TForm1.FormShow(Sender: TObject);
begin
x:=image1.Width;
y:=image1.Height;
image1.Top:=Ceil(1/2*(Self.Height-image1.Height));
Image1.Left:=Ceil(1/2*(Self.Width-image1.Width));
end;

end.

需要引用Math单元..

相关阅读 >>

Delphi 从 exe 或 dll 中获取图标的函数

Delphi png 图片的十六进制字符流

Delphi adoquery查询更改用户

Delphi 用 superobject 解析淘宝上的 json 数据

Delphi 关于字符串, 之前没这样用过

Delphi 在电脑屏幕上显示图片

Delphi getvolumeinformation获取硬盘分区信息

Delphi 关闭指定窗口标题的窗口

Delphi下的纯pascal的十六进制转十进制

Delphi twebbrowser 响应回车键(ewb响应正常,无需额外代码)

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...