在VB.NET下面如何显示和保存缩放图像
实现代码如下:
革吉ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!
Dim img As Image = Image.FromFile("D:\Image\tstImage.jpg") 'tstImage是原先的图片
Dim grfx As Graphics = Me.CreateGraphics
grfx.DrawImage(img, 0, 0, img.Width * 3, img.Height * 3) '在Form里显示
Dim imgnew As New System.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事件里面,执行就行了。
对上面代码的解释:
1.要获取Graphics对象只能从某一事件的参数中获取或者使用窗体和控件对象的CreateGraphics方法来获取-----上面代码使用Me.CreateGraphics来引用这个对象。
2.加载一个图片用Image类的FromFile或者FromStream方法
3.用DrawImage来显示一个图片,该方法有30多个重载方法,可以查MSDN了解细节。
4.保存时的一个问题:我们必须先建一个对象,用于存缩放图像。
vb点虐 从数据库读取图片循环显示
假如b窗体是form2,在a窗体中调用B窗体,直接dim frm as new form2,然后frm.show()就OK
在VB.NET中,如何让DataGridView中的照片在PictureBox中显示
byte[] bytes=(byte[])dt.Rows[0]["Photo"];
System.IO.MemoryStream ms=new System.IO.MemoryStream(bytes);
pictureBox1.Image=Image.FromStream(ms);
VB.NET如何实现图片渐显?
'这个拿去试一试,两个图片框,一个用来适应图片,一个用来适应窗体
'两个按钮控件,一个用来显示图片,一个用来隐藏图片
'两个时钟控件一个用来控制显示速度,一个用来选择图片
'图片文件夹自己建,放在文件夹当前目录下
'试过了,没问题.要还需要别的显示模式,提出要求
Dim Pic_num As Long
Dim Pic_Name() As String
Dim pic_star As Long
Dim p_width As Single
Dim p_height As Single
Dim bili_w As Single
Dim bili_h As Single
Private Sub Command1_Click() '加载并显示图片
If Pic_num 0 Then
Timer1.Enabled = True
Timer1.Interval = 2000
Else
MsgBox ("没有图片显示!")
End If
End Sub
Private Sub Command2_Click()
Picture1.Picture = Nothing '隐藏图片
Picture2.Cls
Timer1.Enabled = False
Timer2.Enabled = False
End Sub
Private Sub Form_Load()
Dim L_name As String
Pic_num = 0
ReDim Pic_Name(Pic_num)
L_name = Dir(App.Path "\pic\*.JPG")
Do While L_name ""
ReDim Preserve Pic_Name(Pic_num)
Pic_Name(Pic_num) = L_name
Pic_num = Pic_num + 1
L_name = Dir
Loop
L_name = Dir(App.Path "\pic\*.BMP")
Do While L_name ""
ReDim Preserve Pic_Name(Pic_num)
Pic_Name(Pic_num) = L_name
Pic_num = Pic_num + 1
L_name = Dir
Loop
Command1.Caption = "循环显示图片"
Command2.Caption = "隐藏图片"
Picture1.AutoSize = True
Picture1.AutoRedraw = True
Picture1.Visible = False
Picture2.AutoSize = False
Picture2.AutoRedraw = True
Picture2.Visible = True
Timer1.Interval = 10
Timer1.Enabled = False
Timer2.Interval = 50
Timer2.Enabled = False
If Pic_num 0 Then
Picture1.Picture = LoadPicture(App.Path "\pic\" Pic_Name(L_id))
Picture2.PaintPicture Picture1.Picture, 0, 0, Picture2.ScaleWidth, Picture2.ScaleHeight, 0, 0, Picture1.ScaleWidth, Picture1.ScaleHeight
Else
MsgBox ("没有图片显示!")
End If
End Sub
Private Sub Timer1_Timer()
Dim L_id As Long
Randomize
L_id = Int(Pic_num * Rnd)
Picture1.Picture = LoadPicture(App.Path "\pic\" Pic_Name(L_id))
bili_w = Picture1.ScaleWidth / Picture2.ScaleWidth
bili_h = Picture1.ScaleHeight / Picture2.ScaleHeight
p_width = Picture2.Width / 100
p_height = Picture2.Height / 100
pic_star = 0
Timer1.Enabled = False
Timer2.Enabled = True
End Sub
Private Sub Timer2_Timer()
If pic_star 101 Then
pic_star = pic_star + 1
Picture2.PaintPicture Picture1.Picture, 0, 0, 100 * p_width, pic_star * p_height, 0, 0, bili_w * pic_star * p_width, bili_h * pic_star * p_height
Else
pic_star = 0
Timer1.Enabled = True
Timer2.Enabled = False
End If
End Sub
当前题目:关于vb点虐 图片展示的信息
文章分享:http://scgulin.cn/article/ddjgeid.html