新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
VB.NET讀取圖像辦法詳解
VB.NET可以幫助我們輕松的實(shí)現(xiàn)許多功能。下面我們可以通過(guò)一段代碼范例來(lái)對(duì)VB.NET讀取圖像這一操作方法進(jìn)行詳細(xì)的解讀,從而對(duì)VB.NET的靈活簡(jiǎn)便性有一個(gè)深入的了解,幫助我們提高編程效率。#t#

創(chuàng)新互聯(lián)專注于平魯網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗(yàn)。 熱誠(chéng)為您提供平魯營(yíng)銷型網(wǎng)站建設(shè),平魯網(wǎng)站制作、平魯網(wǎng)頁(yè)設(shè)計(jì)、平魯網(wǎng)站官網(wǎng)定制、微信小程序開(kāi)發(fā)服務(wù),打造平魯網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供平魯網(wǎng)站排名全網(wǎng)營(yíng)銷落地服務(wù)。
VB.NET讀取圖像代碼示例:
- Public Function GetImageFromFile()
Function GetImageFromFile(ByVal
pstrFileName As String) As Boolean - Dim strExt As String = "" '擴(kuò)展文件名
- Dim blnFlag As Boolean = False
- If ((pstrFileName.IndexOf(":")
< 0) AndAlso (Not PictureHolder.
mstrPath Is Nothing)) Then - pstrFileName = (PictureHolder.
mstrPath & pstrFileName) - End If
- If Not File.Exists(pstrFileName) Then
- Return False
- End If
VB.NET讀取圖像取得擴(kuò)展名
- strExt = Path.GetExtension
(pstrFileName).ToLower- If strExt.Equals(".cur") Then
- Try
- Dim cursor As New Windows.Forms.
Cursor(pstrFileName)- Dim targetRect As New Rectangle
(New Point(0, 0), cursor.Size)- Me.mobjImage = New Bitmap(cursor
.Size.Width, cursor.Size.Height)- Dim g As GraphicsGraphics =
Graphics.FromImage(Me.mobjImage)- cursor.Draw(g, targetRect)
- cursor.Dispose()
- Return True
- Catch obj1 As Exception
- Return False
- End Try
- End If
- Try
- Using stream As IO.FileStream = New IO.
FileStream(pstrFileName, FileMode.
Open, FileAccess.Read)- Dim stream2 As New IO.MemoryStream
- Do While True
- Dim count As Integer = stream.Read
(PictureHolder.mbtyImage, 0,
PictureHolder.mbtyImage.Length)- If (count = 0) Then
- Exit Do
- End If
- stream2.Write(PictureHolder.
mbtyImage, 0, count)- Loop
- stream2.Flush()
- stream2.Position = 0
若為 ico 類型,則使用 Drawing.Icon 打開(kāi)圖像
- If strExt.Equals(".ico") Then
- Me.mobjImage = New Drawing.
Icon(stream2).ToBitmap- Else
- Me.mobjImage = Drawing.Image.
FromStream(stream2)- End If
- blnFlag = True
- End Using
- Catch obj2 As Exception
- blnFlag = False
- End Try
- Return blnFlag
- End Function
VB.NET讀取圖像的相關(guān)介紹就為大家介紹到這里。
網(wǎng)站名稱:VB.NET讀取圖像辦法詳解
網(wǎng)頁(yè)路徑:http://www.dlmjj.cn/article/dhcpppg.html


咨詢
建站咨詢
