Domanda

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

With this piece of code I'm able to track and open image. Now I want to access data of image and want to display. For this I have to convert image to text file. How is it possible?. In C# there is function called Readimage. What function will help me to read image in VB?

È stato utile?

Soluzione

I think you need to use File.ReadAllBytes that opens a binary file, reads the contents of the file into a byte array, and then closes the file.

Dim data() as Byte = File.ReadAllBytes(path)
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top