繪制線條采用Draw開頭的方法,顏色參數(shù)用Pen類;
創(chuàng)新互聯(lián)專注于企業(yè)全網(wǎng)營銷推廣、網(wǎng)站重做改版、贛州網(wǎng)站定制設計、自適應品牌網(wǎng)站建設、H5開發(fā)、商城系統(tǒng)網(wǎng)站開發(fā)、集團公司官網(wǎng)建設、外貿(mào)營銷網(wǎng)站建設、高端網(wǎng)站制作、響應式網(wǎng)頁設計等建站業(yè)務,價格優(yōu)惠性價比高,為贛州等各大城市提供網(wǎng)站開發(fā)制作服務。
繪制有填充色的封閉圖形采用Fill開頭的方法,顏色參數(shù)用Brush類;
例如:
'繪制一個實心圓,該圓在:直線x=200,y=200,x=200+100,y=200+100所劃矩形區(qū)域內(nèi)
Me.CreateGraphics.FillEllipse(New SolidBrush(Color.Orange), 200, 200, 100, 100)
'繪制一個空心圓,該圓在:直線x=200,y=200,x=200+100,y=200+100所劃矩形區(qū)域內(nèi)
Me.CreateGraphics.DrawEllipse(New Pen(Color.Black), 200, 200, 100, 100)
這個問題不是小問題。如果只是90度轉,vb.net的picture控件有RotateFlip方法。
任意角度,可以參考這個
;cs-lang=csharp
圖片的變換涉及坐標處理,要自己算。
還有可以用Windows Presentation Foundation (WPF) 編程,里面的image控件好像也能旋轉圖片。
如果是VB6,恐怕只能用API函數(shù)了,百度一下“vb 旋轉圖片” “VB api函數(shù)”了解一下
啟動vb6建立一個標準exe工程,首先添加兩個圖片框(picture1和picture2),添加三個命令按鈕command1(caption=“正常顯示”)、command2(caption=“180度倒立”)、command3(caption=“45度旋轉”),雙擊窗體,寫入以下代碼:
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