這個(gè)問(wèn)題不是小問(wèn)題。如果只是90度轉(zhuǎn),vb.net的picture控件有RotateFlip方法。
創(chuàng)新互聯(lián)主營(yíng)衛(wèi)輝網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,成都App制作,衛(wèi)輝h5微信小程序定制開(kāi)發(fā)搭建,衛(wèi)輝網(wǎng)站營(yíng)銷(xiāo)推廣歡迎衛(wèi)輝等地區(qū)企業(yè)咨詢(xún)
任意角度,可以參考這個(gè)
;cs-lang=csharp
圖片的變換涉及坐標(biāo)處理,要自己算。
還有可以用Windows Presentation Foundation (WPF) 編程,里面的image控件好像也能旋轉(zhuǎn)圖片。
如果是VB6,恐怕只能用API函數(shù)了,百度一下“vb 旋轉(zhuǎn)圖片” “VB api函數(shù)”了解一下
vb.net 怎么來(lái)回切換圖片?1、添加控件Picturebox1和控件Timer1,將Timer1的Interval屬性改為1000(即1秒),Enabled屬性改為T(mén)rue
2、假設(shè)你要循環(huán)切換4張圖片,你可以添加如下代碼即可實(shí)現(xiàn):
Dim a As Integer = 0
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
If a = 4 Then
a = 0
Else
a = a + 1
End If
If a = 0 Then Me.PictureBox1.Image = Image.FromFile("1.jpg")
If a = 1 Then Me.PictureBox1.Image = Image.FromFile("2.jpg")
If a = 2 Then Me.PictureBox1.Image = Image.FromFile("3.jpg")
If a = 3 Then Me.PictureBox1.Image = Image.FromFile("4.jpg")
End Sub
直接反轉(zhuǎn)的沒(méi)有,改用PictureBox 的繪圖方法是可以的,只是稍為繁瑣點(diǎn)。
如:
Picture1.PaintPicture LoadPicture("C:\Users\Administrator\Desktop\09.jpg"), Picture1.ScaleWidth, 0, -Picture1.ScaleWidth
就是只要把寬度或高度參數(shù)變?yōu)樨?fù)值,就會(huì)返轉(zhuǎn)換過(guò)來(lái)。左右反轉(zhuǎn)的話,x軸的起點(diǎn)在圖片框右邊。縱向反轉(zhuǎn),Y軸上的起點(diǎn)在下邊。
啟動(dòng)vb6建立一個(gè)標(biāo)準(zhǔn)exe工程,首先添加兩個(gè)圖片框(picture1和picture2),添加三個(gè)命令按鈕command1(caption=“正常顯示”)、command2(caption=“180度倒立”)、command3(caption=“45度旋轉(zhuǎn)”),雙擊窗體,寫(xiě)入以下代碼:
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度旋轉(zhuǎn)
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()‘正常復(fù)制
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旋轉(zhuǎn)
Picture2.Cls
Callbmp_rotate(Picture1,Picture2,3.14/4)
EndSub
PrivateSubForm_Load()
OnErrorResumeNext
Me.Caption=App.Title"添加應(yīng)用程序標(biāo)題
Me.Left=(Screen.Width-Me.Width)/2
Me.Top=(Screen.Height-Me.Height)/2"窗體具中
Picture1.ScaleMode=3
Picture2.ScaleMode=3
EndSub
當(dāng)前標(biāo)題:vb.net實(shí)現(xiàn)圖片翻轉(zhuǎn)的簡(jiǎn)單介紹
標(biāo)題路徑:http://jinyejixie.com/article40/dopsdho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)、品牌網(wǎng)站建設(shè)、微信公眾號(hào)、網(wǎng)站建設(shè)、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)頁(yè)設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)