Public?Class?Form1
十余年的邳州網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開(kāi)發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。全網(wǎng)營(yíng)銷推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整邳州建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)從事“邳州網(wǎng)站設(shè)計(jì)”,“邳州網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
Private?Sub?Form1_Load(ByVal?sender?As?System.Object,?ByVal?e?As?System.EventArgs)?Handles?MyBase.Load
? Button1.BackgroundImage?=?My.Resources.a
End?Sub
Private?Sub?Button1_MouseEnter(ByVal?sender?As?Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.MouseEnter
? Button1.BackgroundImage?=?My.Resources.b
End?Sub
Private?Sub?Button1_MouseLeave(ByVal?sender?As?Object,?ByVal?e?As?System.EventArgs)?Handles?Button1.MouseLeave
? Button1.BackgroundImage?=?My.Resources.a
End?Sub
End?Class
當(dāng)然,你先得制作兩張大小一樣的圖片
VB系統(tǒng)的坐標(biāo)原點(diǎn)在左上角,X軸的正方向是水平向右,而Y軸的正方向是垂直向下。所以,要繪制三角函數(shù)的曲線,自己可以通過(guò)改變點(diǎn)坐標(biāo)的方法來(lái)實(shí)現(xiàn),當(dāng)然,VB.NET提供了相應(yīng)的方法可以來(lái)實(shí)現(xiàn)坐標(biāo)變換,也可以通過(guò)VB.Net的Graphics類提供的平移、旋轉(zhuǎn)等轉(zhuǎn)換來(lái)實(shí)現(xiàn)。
下面是我通過(guò)自己變換實(shí)現(xiàn)的示例,提供參考;我的環(huán)境是VB.NET 2010
Imports System.Math
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
? '1,獲得一個(gè)Graphics對(duì)象
? Dim MyGraphics As Graphics
? MyGraphics = PictureBox1.CreateGraphics
? '2,定義一個(gè)Pen對(duì)象,用于繪制圖形(輪廓線)
? Dim MyPen As New Pen(Color.Black, 1)
? '3,定義一個(gè)Brush對(duì)象,用于填充圖形(如果需要填充的話)
? Dim MyBrush As New SolidBrush(Color.Orange)
? MyGraphics.DrawLine(MyPen, 0, 200, 700, 200)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
? '1,獲得一個(gè)Graphics對(duì)象
? Dim MyGraphics As Graphics
? MyGraphics = PictureBox1.CreateGraphics
? '2,定義一個(gè)Pen對(duì)象,用于繪制圖形(輪廓線)
? Dim MyPen As New Pen(Color.Black, 1)
? '3,定義一個(gè)Brush對(duì)象,用于填充圖形(如果需要填充的話)
? Dim MyBrush As New SolidBrush(Color.Orange)
? '聲明橫向和縱向比例變量
? Dim Heng As Integer = 20
? Dim Zong As Integer = 50
? '先獲得正弦值,保存到點(diǎn)坐標(biāo)數(shù)組
? Dim MyPoints(700) As Point
? Dim i As Integer
? For i = 0 To 700
? ? ? MyPoints(i) = New Point(i * Heng, 200 + Sin(i) * Zong)
? Next
? '采用繪制光滑線連接點(diǎn)的方式繪制曲線
? MyGraphics.DrawCurve(MyPen, MyPoints)
End Sub
End Class
顯示的效果圖:
在VB.NET操作縮放圖像中的顯示和保存縮放圖像,用到Image和Graphics類,在VSDotNet2K3下面Reference里自動(dòng)添加了引用System.Drawing,直接用就行。
實(shí)現(xiàn)VB.NET操作縮放圖像代碼如下:DimimgAsImageImage=Image.FromFile
(D:\Image\tstImage.jpg)
''tstImage是原先的圖片DimgrfxAsGraphics=Me
.CreateGraphics
grfx.DrawImage(img,0,0,img.Width*
3,img.Height*3)''在Form里顯示
DimimgnewAsNewSystem.Drawing.Bitmap
(img,img.Height*3,img.Width*3)
''新建一個(gè)放大的圖片
imgnew.Save(D:\Image\tstNewImage.jpg,
System.Drawing.Imaging.ImageFormat.Jpeg)
''保存放大后圖片
你可以建一個(gè)Form,然后在Form里拖進(jìn)一個(gè)Button,把上面的代碼放在Button_Click事件里面源碼天空
,執(zhí)行就行了。
對(duì)上面VB.NET操作縮放圖像代碼的解釋:
1.要獲取Graphics對(duì)象只能從某一事件的參數(shù)中獲取或者使用窗體和控件對(duì)象的CreateGraphics方法來(lái)獲取-----上面代碼使用Me.CreateGraphics來(lái)引用這個(gè)對(duì)象。
2.加載一個(gè)圖片用Image類的FromFile或者FromStream方法
3.用DrawImage來(lái)顯示一個(gè)圖片,該方法有30多個(gè)重載方法,可以查MSDN了解細(xì)節(jié)。
4.保存時(shí)的一個(gè)問(wèn)題:我們必須先建一個(gè)對(duì)象,用于存縮放圖像。
如果是簡(jiǎn)單的移動(dòng),先把圖形繪制到大小和PictureBox的Bitmap上,然后再繪制到PictureBox就行。
不過(guò)在VB.NET中用GDI繪制最好用BufferedGraphics圖形緩沖區(qū),速度馬馬虎虎(VB就這樣了),但是不閃爍,不存在背景擦除的問(wèn)題。
***怎樣讓移動(dòng)圖像顯示更快一些*** Hide Controls When Setting Properties to Avoid Multiple Repaints Every repaint is expensive. The fewer repaints Visual Basic must perform, the faster your application will appear. One way to reduce the number of repaints is to make controls invisible while you are manipulating them. For example, suppose you want to resize several list boxes in the Resize event for the form: Sub Form_Resize () Dim i As Integer, sHeight As Integer sHeight = ScaleHeight / 4 For i = 0 To 3 lstDisplay(i).Move 0, i * sHeight, _ ScaleWidth, sHeight Next End Sub This creates four separate repaints, one for each list box. You can reduce the number of repaints by placing all the list boxes within a picture box, and hiding the picture box before you move and size the list boxes. Then, when you make the picture box visible again, all of the list boxes are painted in a single pass: 在vb中用move方法移動(dòng)圖片時(shí),速度有些慢,當(dāng)圖片很大時(shí),這時(shí)可以用下面的方法: Sub Form_Resize () Dim i As Integer, sHeight As Integer picContainer.Visible = False picContainer.Move 0, 0, ScaleWidth, ScaleHeight sHeight = ScaleHeight / 4 For i = 0 To 3 lstDisplay(i).Move 0, i * sHeight, _ ScaleWidth, sHeight Next picContainer.Visible = True End Sub Note that this example uses the Move method instead of setting the Top and Left properties. The Move method sets both properties in a single operation, saving additional repaints.
試試這個(gè)圖片幻燈片
有12345數(shù)字一起切換
有小圖大圖一起切換
里面有教程和源碼