怎样把picturebox的最中间点设为坐标原点?

来源:百度知道 编辑:UC知道 时间:2024/05/05 17:03:30
怎样把picturebox的最中间点设为坐标原点?急等编码。。。
还有,如何让Y轴向上为正?

'scale方法用于设定用户坐标系。坐标原点在picture1中心。
'关键代码如下:
picture1.scalemode=3
picture1.scale(-20,20)-(-20,20)

vb中的坐标是从左上角开始的,最小是(0,0),向右下角越来越大的。

想把picturebox的中间设为(0,0)
需要一个转换
x,y为picturebox中的任一点坐标
pW,pH为picturebox的宽度和高度

x0=x-pw/2
y0=y-ph/2

x0,y0为(x,y)点以picturebox中间为原点转换后的坐标

记住,这时的坐标轴方向和一般情况下数学里的坐标轴方向不同。

Picture1.Scale (-Picture1.Width / 2, Picture1.Height / 2)-(Picture1.Width / 2, -Picture1.Height / 2)