在vb中如何旋转图片?
一个picturebox读入一张jpg图,如何在这个picturebox中实现jpg图90度和180度旋转?...
一个picturebox读入一张jpg图,如何在这个picturebox中实现jpg图90度和180度旋转?
展开
展开全部
逆时针旋转90度
Dim p()
ScaleMode = 3
Picture1.AutoRedraw = True
Picture1.ScaleMode = 3
w = Picture1.ScaleWidth
h = Picture1.ScaleHeight
ReDim p(w - 1, h - 1)
For i = 0 To w - 1
For j = 0 To h - 1
p(i, j) = Picture1.Point(i, j)
Next j
Next i
Picture1.Width = h + 4 * Picture1.BorderStyle
Picture1.Height = w + 4 * Picture1.BorderStyle
For i = 0 To h - 1
For j = 0 To w - 1
Picture1.PSet (i, w - j - 1), p(j, i)
Next j
Next i
顺时针旋转90度把Picture1.PSet (i, w - j - 1), p(j, i)
改为Picture1.PSet (h - i - 1, j), p(j, i)
旋转180度把最后七行改为
For i = 0 To w - 1
For j = 0 To h - 1
Picture1.PSet (i, j), p(w - i - 1, h - j - 1)
Next j
Next i
Dim p()
ScaleMode = 3
Picture1.AutoRedraw = True
Picture1.ScaleMode = 3
w = Picture1.ScaleWidth
h = Picture1.ScaleHeight
ReDim p(w - 1, h - 1)
For i = 0 To w - 1
For j = 0 To h - 1
p(i, j) = Picture1.Point(i, j)
Next j
Next i
Picture1.Width = h + 4 * Picture1.BorderStyle
Picture1.Height = w + 4 * Picture1.BorderStyle
For i = 0 To h - 1
For j = 0 To w - 1
Picture1.PSet (i, w - j - 1), p(j, i)
Next j
Next i
顺时针旋转90度把Picture1.PSet (i, w - j - 1), p(j, i)
改为Picture1.PSet (h - i - 1, j), p(j, i)
旋转180度把最后七行改为
For i = 0 To w - 1
For j = 0 To h - 1
Picture1.PSet (i, j), p(w - i - 1, h - j - 1)
Next j
Next i
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询