vb.net图片循转角度 vb怎么用命令按钮使图片移动

如何用VB程序令一张图片随着倒计时一秒一秒的转动,转动角度是时钟秒针每秒转动的角度6°这个相对你来说真的有点难,要么用pset一点一点的画,要么用API函数 。建议你作以下考虑:
采用一个进度条来动态显示
采用图片上来滚动来动态显示
画一个表盘来动态显示
个人觉得用第二种,也就是窗体上一个图片框,里面三张图片分别画着所有的时,分,秒,然后根据设定,调整三张图片的坐标,使之正好显示设定的值 。开始计时后 , 按时间调整图片坐标慢慢滚动 。
我这是基于VB6来说,如果高版本的VB.Net可以旋转控件或其中的图片,则另当别论 。
VB中如何旋转图片?新浪微博的图可以旋转啊 , 一般旋转都是90度,180度吧,没有10度,20度旋转的,除非在买图秀秀或PS等作图工具里 。下面是新浪的截图
怎么用vb实现图形的旋转?启动vb6建立一个标准exe工程vb.net图片循转角度 , 首先添加两个图片框(picture1和picture2)vb.net图片循转角度 , 添加三个命令按钮command1(caption=“正常显示”)、command2(caption=“180度倒立”)、command3(caption=“45度旋转”)vb.net图片循转角度,双击窗体vb.net图片循转角度,写入以下代码vb.net图片循转角度:
PrivateConstSRCCOPY=HCC0020
PrivateConstPi=3.14
PrivateDeclareFunctionSetPixelLib"gdi32"(ByValhdcAsLong, ByValxAsLong,ByValyAsLong,ByValcrColorAsLong)AsLong
PrivateDeclareFunctionGetPixelLib"gdi32"(ByValhdcAsLong, ByValxAsLong,ByValyAsLong)AsLong
PrivateDeclareFunctionStretchBltLib"gdi32"(ByValhdcAsLong, ByValxAsLong,ByValyAsLong,ByValnWidthAsLong,ByValnHeightAsLong, ByValhSrcDCAsLong,ByValxSrcAsLong,ByValySrcAsLong,ByValnSrcWidth AsLong,ByValnSrcHeightAsLong,ByValdwRopAsLong)AsLong
privateSubbmp_rotate(pic1AsPictureBox,pic2AsPictureBox,ByValtheta)‘45度旋转
Dimc1xAsInteger,c1yAsInteger
Dimc2xAsInteger,c2yAsInteger
DimaAsSingle
Dimp1xAsInteger,p1yAsInteger
Dimp2xAsInteger,p2yAsInteger
DimnAsInteger,rAsInteger
c1x=pic1.ScaleWidth\2
c1y=pic1.ScaleHeight\2
c2x=pic2.ScaleWidth\2
c2y=pic2.ScaleHeight\2
Ifc2x$#@60;c2yThenn=c2yElsen=c2x
n=n-1
pic1hDC=pic1.hdc
pic2hDC=pic2.hdc
Forp2x=0Ton
Forp2y=0Ton
Ifp2x=0Thena=Pi/2Elsea=Atn(p2y/p2x)
r=Sqr(1*p2x*p2x 1*p2y*p2y)
p1x=r*Cos(a theta)
p1y=r*Sin(a theta)
c0=GetPixel(pic1hDC,c1x p1x,c1y p1y)
c1=GetPixel(pic1hDC,c1x-p1x,c1y-p1y)
c2=GetPixel(pic1hDC,c1x p1y,c1y-p1x)
c3=GetPixel(pic1hDC,c1x-p1y,c1y p1x)
Ifc0$#@60;$#@62;-1ThenSetPixelpic2hDC,c2x p2x,c2y p2y,c0
Ifc1$#@60;$#@62;-1ThenSetPixelpic2hDC,c2x-p2x,c2y-p2y,c1
Ifc2$#@60;$#@62;-1ThenSetPi pic2hDC,c2x p2y,c2y-p2x,c2
Ifc3$#@60;$#@62;-1ThenSetPixelpic2hDC,c2x-p2y,c2y p2x,c3
Next
Next
EndSub
PrivateSubCommand1_Click()‘正常复制
Picture2.Cls
px=Picture1.ScaleWidth
py=Picture1.ScaleHeight
StretchBltPicture2.hdc,px,0,-px,py,Picture1.hdc,0,0,px,py,SRCCOPY
EndSub
PrivateSubCommand2_Click()‘180度倒立
Picture2.Cls
px=Picture1.ScaleWidth
py=Picture1.ScaleHeight
StretchBltPicture2.hdc,0,py,px,-py,Picture1.hdc,0,0,px,py,SRCCOPY
EndSub
PrivateSubCommand3_Click()‘45旋转
Picture2.Cls
Callbmp_rotate(Picture1,Picture2,3.14/4)
EndSub
PrivateSubForm_Load()
OnErrorResumeNext
Me.Caption=App.Title"添加应用程序标题
Me.Left=(Screen.Width-Me.Width)/2
Me.Top=(Screen.Height-Me.Height)/2"窗体具中
Picture1.ScaleMode=3
Picture2.ScaleMode=3
EndSub
vb里面怎么样让一张图片旋转?'GetPixel和SetPixel太慢了.系统有现成的API用. '本例子需要两个PictureBox,名称分别为PicBack和PicShow.一个CommandButton,名称:Command1. '在PicShow里载入一张图片,然后运行,点command1按钮,你就可以看到效果. Option Explicit 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 Type POINTAPI x As Long y As Long End Type Const NotPI = 3.14159265238 / 180 Private Sub DanRotate(ByRef picDestHdc As Long, xPos As Long, yPos As Long, ByVal Angle As Long, ByRef picSrcHdc As Long, srcXoffset As Long, srcYoffset As Long, ByVal srcWidth As Long, ByVal srcHeight As Long) Dim Points(3) As POINTAPI Dim DefPoints(3) As POINTAPI Dim sSin As Single, sCos As Single Dim ret As LongPoints(0).x = -srcWidth * 0.5 Points(0).y = -srcHeight * 0.5Points(1).x = Points(0).xsrcWidth Points(1).y = Points(0).yPoints(2).x = Points(0).x Points(2).y = Points(0).ysrcHeightsSin = Sin(Angle * NotPI) sCos = Cos(Angle * NotPI) DefPoints(0).x = (Points(0).x * sCos - Points(0).y * sSin)xPos DefPoints(0).y = (Points(0).x * sSinPoints(0).y * sCos)yPosDefPoints(1).x = (Points(1).x * sCos - Points(1).y * sSin)xPos DefPoints(1).y = (Points(1).x * sSinPoints(1).y * sCos)yPosDefPoints(2).x = (Points(2).x * sCos - Points(2).y * sSin)xPos DefPoints(2).y = (Points(2).x * sSinPoints(2).y * sCos)yPosPlgBlt picDestHdc, DefPoints(0), picSrcHdc, srcXoffset, srcYoffset, srcWidth, srcHeight, 0, 0, 0 End Sub Private Sub Form_Load() picShow.ScaleMode = vbPixelspicBack.ScaleMode = vbPixels End Sub Private Sub Command1_Click() DanRotate picBack.hDC, 100, 100, 45, picShow.hDC, 0, 0, picShow.ScaleWidth,picShow.ScaleHeight '(函数解释)DanRotate 目标(输出)的设备场景,X坐标,Y坐标,旋转角度,源设备场景,源设备场景X坐标,源设备场景Y坐标 picBack.Refresh '刷新窗体 End Sub
vb中,怎么可以把一张图片旋转起来这个问题不是小问题 。如果只是90度转 , vb.net的picture控件有RotateFlip方法 。
任意角度,可以参考这个
;cs-lang=csharp
图片的变换涉及坐标处理,要自己算 。
还有可以用Windows Presentation Foundation (WPF) 编程,里面的image控件好像也能旋转图片 。
如果是VB6 , 恐怕只能用API函数了,百度一下“vb 旋转图片”“VB api函数”了解一下
在vb中如何旋转图片?逆时针旋转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 = h4 * Picture1.BorderStyle
Picture1.Height = w4 * 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
【vb.net图片循转角度 vb怎么用命令按钮使图片移动】关于vb.net图片循转角度和vb怎么用命令按钮使图片移动的介绍到此就结束了 , 不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读