vb中关于image的小例题

来源:百度知道 编辑:UC知道 时间:2024/06/24 11:55:29
image中装了一张图片,要求实现图片位置中心不变的情况下,调整图片大小,两个命令按钮,一个放大一个缩小。
调整大小会了,可是实现不了"图片位置中心不变"。
顺便问问,picturebox里能调整其中图片大小么。

先定:中心坐标x,中心坐标y
image1.height=*
image1.height=*
image1.left=中心坐标x-image1.width/2
image1.top=中心坐标y-image1.height/2
这样中心就不会变了。
picturebox里不能调整其中图片大小。

Image好说,把Stretch属性设置为True,代码如下。
==================
Private Sub Command1_Click()
Image1.Move Image1.Left - Image1.Width * 0.1, Image1.Top - Image1.Height * 0.1, Image1.Width * 1.2, Image1.Height * 1.2
End Sub

Private Sub Command2_Click()
Image1.Move Image1.Left + Image1.Width * 0.1, Image1.Top + Image1.Height * 0.1, Image1.Width * 0.8, Image1.Height * 0.8
End Sub

picturebox不里按像素改变图片大小,但或以切掉一部份或以空白来补图片,实际大小是不变的.

中心位置不变可以用
top : image1.top=picture1.height/2-image1.height/2
left: image1.left=picture1.width/2-image1.width/2