'因為要保存picturebox中的圖片必須要設(shè)置autoredraw屬性為true,所以也寫出來了.
10年積累的成都網(wǎng)站制作、網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識你,你也不認(rèn)識我。但先網(wǎng)站設(shè)計后付款的網(wǎng)站建設(shè)流程,更有襄城免費網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
Private Sub Form_Load()
Picture1.AutoRedraw = True
End Sub
Private Sub Command1_Click()
SavePicture Picture1.Image, App.Path "\1.bmp"
End Sub
我理解你
我寫過圖片網(wǎng)絡(luò)傳輸?shù)暮湍阋蟮囊粯?/p>
為了不把圖片寫到硬盤 又從硬盤讀取
而直接保存圖片內(nèi)存流 進行網(wǎng)絡(luò)傳輸
從網(wǎng)絡(luò)讀取的圖片byte數(shù)組轉(zhuǎn)成圖片代碼如下
Dim mStream As New IO.MemoryStream
mStream.Write(b, 0, b.length) '這里b就是你的一維數(shù)組了
Dim Img As New Bitmap(mStream)
mStream.Close()
mStream.Dispose()
下面是把圖片保存到一維數(shù)組的方法
Dim Stream As New IO.MemoryStream
im.Save(Stream, System.Drawing.Imaging.ImageFormat.Jpeg)
im = Nothing
Stream.Flush()
Dim b As Byte() = Stream.ToArray
Stream.Dispose()
繪圖代碼寫在Paint事件中,如
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim g As Graphics = Me.CreateGraphics
g.DrawLine(Pens.Red, 100, 100, 200, 100)
End Sub
'方法二:在 PictureBox1上顯示圖像----圖畫在Bitmap
PictureBox1.Image = Nothing
Dim wid As Integer = PictureBox1.ClientSize.Width
Dim hgt As Integer = PictureBox1.ClientSize.Height
Dim bm As New Bitmap(wid, hgt)
Dim g As Graphics = Graphics.FromImage(bm)
'畫圖代碼
'畫圖代碼
PictureBox1.Image = bm
PictureBox1.Refresh()
g.Dispose()
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