答案:如果你换成Picturebox就直接拿去用,程序中的函数
可以旋转任意角度,调用方法如下
PI =3.1415926 是全局变量
xuanzhuan 90 * PI / 180 '逆时针90度
'==================以下旋转原始图片==============================
Function xuanzhuan(sida#) '暂时先每个旋转单独处理
tm计时器.Interval = 100
tm计时器.Enabled = True
Dim pt(1 To 3) As POINTAPI, p4 As POINTAPI '旋转原图
Dim DX As Long, DY As Long
Dim aaaa As Long, offsetX As Long, offsetY As Long
'Dim sida As Double
Dim MaxX As Long, MaxY As Long, MinX As Long, MinY As Long
Dim x As Single, y As Single
sida = -sida '444444旋转原始病理图
lb正在处理.Caption = "正在旋转图片......"
DX = Me.ScaleX(pctrecorse.Picture.Width, vbHimetric, vbPixels)
DY = Me.ScaleX(pctrecorse.Picture.Height, vbHimetric, vbPixels)
pt(1).x = DY * Sin(sida)
pt(1).y = DY - DY * Cos(sida)
pt(2).x = pt(1).x + DX * Cos(sida)
pt(2).y = pt(1).y + DX * Sin(sida)
pt(3).x = 0: pt(3).y = DY
'p4不用在pt()之阵列,它是由pt(1)-pt(3)所推出
p4.x = pt(3).x + DX * Cos(sida)
p4.y = pt(3).y + DX * Sin(sida)
'以下的工作只是为了让旋转后的图在Picture5的中间显示
MaxX = IIf(pt(1).x > pt(2).x, pt(1).x, pt(2).x)
MaxX = IIf(MaxX > pt(3).x, MaxX, pt(3).x)
MaxX = IIf(MaxX > p4.x, MaxX, p4.x)
MinX = IIf(pt(1).x < pt(2).x, pt(1).x, pt(2).x)
MinX = IIf(MinX < pt(3).x, MinX, pt(3).x)
MinX = IIf(MinX < p4.x, MinX, p4.x)
MaxY = IIf(pt(1).y > pt(2).y, pt(1).y, pt(2).y)
MaxY = IIf(MaxY > pt(3).y, MaxY, pt(3).y)
MaxY = IIf(MaxY > p4.y, MaxY, p4.y)
MinY = IIf(pt(1).y < pt(2).y, pt(1).y, pt(2).y)
MinY = IIf(MinY < pt(3).y, MinY, pt(3).y)
MinY = IIf(MinY < p4.y, MinY, p4.y)
offsetX = (Picture5.ScaleWidth - MaxX + MinX) \ 2 - MinX
offsetY = (Picture5.ScaleHeight - (MaxY - MinY)) \ 2 - MinY
pt(1).x = pt(1).x + offsetX: pt(1).y = pt(1).y + offsetY
pt(2).x = pt(2).x + offsetX: pt(2).y = pt(2).y + offsetY
pt(3).x = pt(3).x + offsetX: pt(3).y = pt(3).y + offsetY
Picture5.Picture = LoadPicture()
'目标设备场景,POINTAPI结构数组中使用的第一个条目,图象的源设备场景,源图象左上角的x,y坐标
'nWidth,nHeight源图象大小用逻辑坐标表示,指向一个单色掩模,掩模位图欲使用区域左上角的x,y坐标
aaaa = PlgBlt(Picture5.hDC, pt(1), pctrecorse.hDC, 0, 0, DX, DY, 0, 0, 0)
SavePicture Me.Picture5.Image, App.Path & "\" & "RESOURCES\旋转之后.bmp" '保存旋转后的图片,以便下次截图时打开
Picture5.Picture = LoadPicture(App.Path & "\" & "RESOURCES\旋转之后.bmp")
pct原始病例图片.Picture = Picture5.Picture
pctrecorse.Picture = Picture5.Picture '这样可以连续旋转
End Function
上一个:诚求vb6的代码,有能力的帮帮忙
下一个:VB怎么调用默认的杀毒软件查杀一个文件