大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
Public Class Form1
十余年的邳州网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。全网营销推广的优势是能够根据用户设备显示端的尺寸不同,自动调整邳州建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“邳州网站设计”,“邳州网站推广”以来,每个客户项目都认真落实执行。
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
当然,你先得制作两张大小一样的图片
VB系统的坐标原点在左上角,X轴的正方向是水平向右,而Y轴的正方向是垂直向下。所以,要绘制三角函数的曲线,自己可以通过改变点坐标的方法来实现,当然,VB.NET提供了相应的方法可以来实现坐标变换,也可以通过VB.Net的Graphics类提供的平移、旋转等转换来实现。
下面是我通过自己变换实现的示例,提供参考;我的环境是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,获得一个Graphics对象
Dim MyGraphics As Graphics
MyGraphics = PictureBox1.CreateGraphics
'2,定义一个Pen对象,用于绘制图形(轮廓线)
Dim MyPen As New Pen(Color.Black, 1)
'3,定义一个Brush对象,用于填充图形(如果需要填充的话)
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,获得一个Graphics对象
Dim MyGraphics As Graphics
MyGraphics = PictureBox1.CreateGraphics
'2,定义一个Pen对象,用于绘制图形(轮廓线)
Dim MyPen As New Pen(Color.Black, 1)
'3,定义一个Brush对象,用于填充图形(如果需要填充的话)
Dim MyBrush As New SolidBrush(Color.Orange)
'声明横向和纵向比例变量
Dim Heng As Integer = 20
Dim Zong As Integer = 50
'先获得正弦值,保存到点坐标数组
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
'采用绘制光滑线连接点的方式绘制曲线
MyGraphics.DrawCurve(MyPen, MyPoints)
End Sub
End Class
显示的效果图:
在VB.NET操作缩放图像中的显示和保存缩放图像,用到Image和Graphics类,在VSDotNet2K3下面Reference里自动添加了引用System.Drawing,直接用就行。
实现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)
''新建一个放大的图片
imgnew.Save(D:\Image\tstNewImage.jpg,
System.Drawing.Imaging.ImageFormat.Jpeg)
''保存放大后图片
你可以建一个Form,然后在Form里拖进一个Button,把上面的代码放在Button_Click事件里面源码天空
,执行就行了。
对上面VB.NET操作缩放图像代码的解释:
1.要获取Graphics对象只能从某一事件的参数中获取或者使用窗体和控件对象的CreateGraphics方法来获取-----上面代码使用Me.CreateGraphics来引用这个对象。
2.加载一个图片用Image类的FromFile或者FromStream方法
3.用DrawImage来显示一个图片,该方法有30多个重载方法,可以查MSDN了解细节。
4.保存时的一个问题:我们必须先建一个对象,用于存缩放图像。
如果是简单的移动,先把图形绘制到大小和PictureBox的Bitmap上,然后再绘制到PictureBox就行。
不过在VB.NET中用GDI绘制最好用BufferedGraphics图形缓冲区,速度马马虎虎(VB就这样了),但是不闪烁,不存在背景擦除的问题。
***怎样让移动图像显示更快一些*** 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方法移动图片时,速度有些慢,当图片很大时,这时可以用下面的方法: 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.
试试这个图片幻灯片
有12345数字一起切换
有小图大图一起切换
里面有教程和源码