Imports System.Drawing.Imaging
Imports System.Runtime.InteropServices
Imports System.IO
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Dim OpenFileDialog1 As OpenFileDialog
'If OpenFileDialog1.ShowDialog <> Windows.Forms.DialogResult.Cancel Then
'PictureBox1.Image = Image.FromFile(OpenFileDialog1.FileName)
'End If
Dim openFileDialog1 As OpenFileDialog = New OpenFileDialog
' Set filter options and filter index.
openFileDialog1.Filter = "BMP Files (*.bmp)|*.bmp|All Files (*.*)|*.*"
openFileDialog1.FilterIndex = 1
openFileDialog1.Multiselect = True
' Call the ShowDialog method to show the dialogbox.
Dim UserClickedOK As Boolean = openFileDialog1.ShowDialog
PictureBox1.Image = Image.FromFile(openFileDialog1.FileName)
End Sub
End Class
使用這段代碼,我可以跟蹤和打開圖像。現在我想訪問圖像的數據並想要顯示。爲此,我必須將圖像轉換爲文本文件。這怎麼可能?。在C#
中有函數Readimage
。什麼函數將幫助我在VB中讀取圖像?如何將BMP圖像文件轉換爲VB中的文本文件
您不能將位圖轉換爲文本文件,除非它是ASCII藝術! http://upload.wikimedia.org/wikipedia/commons/a/a3/ASCII_Panzer_unt_Sattelzug.png –
是的,他可以通過將其讀入Byte數組,然後創建一個包含該內容的.txt文件。但是文本文件的內容將完全不可讀。 – equisde