這個問題不是小問題。如果只是90度轉(zhuǎn),vb.net的picture控件有RotateFlip方法。
創(chuàng)新互聯(lián)建站從2013年成立,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目網(wǎng)站設(shè)計(jì)制作、網(wǎng)站建設(shè)網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元慶城做網(wǎng)站,已為上家服務(wù),為慶城各地企業(yè)和個人服務(wù),聯(lián)系電話:18980820575
任意角度,可以參考這個
;cs-lang=csharp
圖片的變換涉及坐標(biāo)處理,要自己算。
還有可以用Windows Presentation Foundation (WPF) 編程,里面的image控件好像也能旋轉(zhuǎn)圖片。
如果是VB6,恐怕只能用API函數(shù)了,百度一下“vb 旋轉(zhuǎn)圖片” “VB api函數(shù)”了解一下
public Byte[] getphoto(string photopath) //參數(shù)圖片地址,主要用到的類有FileStream
{
string str = photopath;
FileStream file = new FileStream(str, FileMode.Open, FileAccess.Read);
Byte[] bytBLOBData = new Byte[file.Length];
file.Read(bytBLOBData, 0, bytBLOBData.Length);
file.Close();
return bytBLOBData;
}//這是定義函數(shù)..
繪制線條采用Draw開頭的方法,顏色參數(shù)用Pen類;
繪制有填充色的封閉圖形采用Fill開頭的方法,顏色參數(shù)用Brush類;
例如:
'繪制一個實(shí)心圓,該圓在:直線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)
'GetPixel和SetPixel太慢了.系統(tǒng)有現(xiàn)成的API用. '本例子需要兩個PictureBox,名稱分別為PicBack和PicShow.一個CommandButton,名稱:Command1. '在PicShow里載入一張圖片,然后運(yùn)行,點(diǎn)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 Long Points(0).x = -srcWidth * 0.5 Points(0).y = -srcHeight * 0.5 Points(1).x = Points(0).x + srcWidth Points(1).y = Points(0).y Points(2).x = Points(0).x Points(2).y = Points(0).y + srcHeight sSin = 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 * sSin + Points(0).y * sCos) + yPos DefPoints(1).x = (Points(1).x * sCos - Points(1).y * sSin) + xPos DefPoints(1).y = (Points(1).x * sSin + Points(1).y * sCos) + yPos DefPoints(2).x = (Points(2).x * sCos - Points(2).y * sSin) + xPos DefPoints(2).y = (Points(2).x * sSin + Points(2).y * sCos) + yPos PlgBlt picDestHdc, DefPoints(0), picSrcHdc, srcXoffset, srcYoffset, srcWidth, srcHeight, 0, 0, 0 End Sub Private Sub Form_Load() picShow.ScaleMode = vbPixels picBack.ScaleMode = vbPixels End Sub Private Sub Command1_Click() DanRotate picBack.hDC, 100, 100, 45, picShow.hDC, 0, 0, picShow.ScaleWidth,picShow.ScaleHeight '(函數(shù)解釋)DanRotate 目標(biāo)(輸出)的設(shè)備場景,X坐標(biāo),Y坐標(biāo),旋轉(zhuǎn)角度,源設(shè)備場景,源設(shè)備場景X坐標(biāo),源設(shè)備場景Y坐標(biāo) picBack.Refresh '刷新窗體 End Sub