將PictureBox控件里的圖片,保存為文件:
站在用戶的角度思考問題,與客戶深入溝通,找到利辛網(wǎng)站設(shè)計與利辛網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個性化、用戶體驗(yàn)好的作品,建站類型包括:網(wǎng)站制作、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、域名與空間、網(wǎng)頁空間、企業(yè)郵箱。業(yè)務(wù)覆蓋利辛地區(qū)。
1,文件格式不變化:
PictureBox1.Image.Save("C:\" Format(Now, "HH-mm-ss") ".bmp")
2,文件格式有變化:
PictureBox1.Image.Save("C:\" Format(Now, "HH-mm-ss") ".bmp", System.Drawing.Imaging.ImageFormat.Bmp)
Dim bmp As New Bitmap("打開圖片的路徑")
bmp.Save("保存圖片的路徑")
Dim t As New TextBox()
Dim p As New PictureBox
p.Image = bmp 'picture等支持image的控件。
t.CreateGraphics.DrawImage(bmp, New Point) '文本控件。
Me.BackgroundImage = bmp '窗體
第一步先用新的文件名來保存圖像文件
第二步Dispose釋放引用的圖片文件
第三步刪除舊的圖片文件
第四步將新的圖像文件 重命名為 舊的圖片文件名
這樣就可以達(dá)到你的目的了
Imports System.Drawing.Imaging
Public Class Form1
Dim imageName As String = "C:\Documents and Settings\...\1126.jpg "
Dim i As Image = Image.FromFile(imageName)
Dim g As Graphics = Graphics.FromImage(i) '此處從背景圖創(chuàng)建Greaphics
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'劃線
Dim BluePen As New Pen(Color.Blue, 5)
BluePen.DashStyle = Drawing2D.DashStyle.Solid
g.DrawLine(BluePen, 100.0F, 170, 500.0F, 170)
g.Dispose()
PictureBox1.Image = i
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
'退出
Me.Close()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
'存盤
i.Save( "C:\testimage.jpg ", ImageFormat.Jpeg)
i.Dispose()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
PictureBox1.Image = i
End Sub
End Class