求VB图片旋转90度代码,请尽量简洁的,不要任意角度的,只要90度的。
求VB图片旋转90度(顺时针旋转和逆时针旋转)代码,要示尽量简洁的,不要任意角度的,只要90度的。最后,我还是自己解决了。解决方法跟四楼的一样(当然方法是一样的,但代码是...
求VB图片旋转90度(顺时针旋转和逆时针旋转)代码,要示尽量简洁的,不要任意角度的,只要90度的。
最后,我还是自己解决了。
解决方法跟四楼的一样(当然方法是一样的,但代码是不同的)。
所以我就选四楼为最佳答案吧。 展开
最后,我还是自己解决了。
解决方法跟四楼的一样(当然方法是一样的,但代码是不同的)。
所以我就选四楼为最佳答案吧。 展开
4个回答
展开全部
控件:Picture1,Picture2。
代码如下。
========================
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function PlgBlt Lib "gdi32" (ByVal hdcDest As Long, lpPoint As POINTAPI, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal nYSrc As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hbmMask As Long, ByVal xMask As Long, ByVal yMask As Long) As Long
Private Sub Form_Click()
Dim p(3) As POINTAPI
Dim dx As Integer, dy As Integer
dx = ScaleX(Picture1.Picture.Width, vbHimetric, vbPixels)
dy = ScaleY(Picture1.Picture.Height, vbHimetric, vbPixels)
p(0).x = dy
p(1).x = dy
p(1).y = dx
'这是顺时针,如果要逆时针,上面三行改为:
'p(0).y = dx
'p(2).x = dy
'p(2).y = dx
PlgBlt Picture2.hDC, p(0), Picture1.hDC, 0, 0, dx, dy, 0, 0, 0
End Sub
Private Sub Form_Load()
Picture1.Picture = LoadPicture("E:\JPG;GIF\Garfiled\1978\ga780619.gif") '这里写你自己的图片路径
End Sub
代码如下。
========================
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function PlgBlt Lib "gdi32" (ByVal hdcDest As Long, lpPoint As POINTAPI, ByVal hdcSrc As Long, ByVal nXSrc As Long, ByVal nYSrc As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hbmMask As Long, ByVal xMask As Long, ByVal yMask As Long) As Long
Private Sub Form_Click()
Dim p(3) As POINTAPI
Dim dx As Integer, dy As Integer
dx = ScaleX(Picture1.Picture.Width, vbHimetric, vbPixels)
dy = ScaleY(Picture1.Picture.Height, vbHimetric, vbPixels)
p(0).x = dy
p(1).x = dy
p(1).y = dx
'这是顺时针,如果要逆时针,上面三行改为:
'p(0).y = dx
'p(2).x = dy
'p(2).y = dx
PlgBlt Picture2.hDC, p(0), Picture1.hDC, 0, 0, dx, dy, 0, 0, 0
End Sub
Private Sub Form_Load()
Picture1.Picture = LoadPicture("E:\JPG;GIF\Garfiled\1978\ga780619.gif") '这里写你自己的图片路径
End Sub
博思aippt
2024-07-20 广告
2024-07-20 广告
作为深圳市博思云创科技有限公司的工作人员,对于Word文档生成PPT的操作,我们有以下建议:1. 使用另存为功能:在Word中编辑完文档后,点击文件->另存为,选择PowerPoint演示文稿(*.pptx)格式,即可将文档内容转换为PPT...
点击进入详情页
本回答由博思aippt提供
展开全部
逆时针旋转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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
答案同求
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
这个要调用API函数
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询