Form2 in the following code contains my idea of what I posted: I was amazed how close you got to what I posted in my original reply. :) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Clickĭim sb As New ("")ĭim pic() As Byte = System.IO.File.ReadAllBytes("C:\test\mypic.jpg") My 64圆4 was done as soon as i hit the button doing it this way. I thought it just appended it like a string. I did not realize that the textbox text was reset every time you added text with the (&=). That can add a string to an existing sting, convert the result of the StringBuilder to a string and then draw the string in TextBox1? That is, make 1 string and set that string to TextBox1.Text. Wouldn't it be quicker to construct a string using a StringBuilder This happens for every byte in the image file.
TextBox1 is then erased and the new string drawn on the area of TextBox1. Ĭould you tell me what I'm doing wrong (and/or) post an example of how the code should look like please? I would have liked to see something like: FF, A0, 55, 02, EF, etc. RichTextBox1.Text = MyStringBuilder.ToString()Īs you can see after the line telling the string to be displayed in the picture box, I have guessed at what you suggested. Could you please help me understand what went wrong? Private Sub ButtonConvert_Click(sender As System.Object, e As System.EventArgs) Handles ButtonConvert.Clickĭim MyStringBuilder As New So something has worked, but i didn't see and hex, just (.) dots. At first the textbox started to fill with dots (.) and after a minute or so the image came up in the picturebox. For my test jpg image I created a 10 pixel by 10 pixel image in photoshop and just colored it in with small squares of different colors, something I tried to follow your suggestion and wrote some code (see below), but as a novice have probably mucked it up. What I want to know now is how I can convert the image to a hex byte array and print it to a text box.
MsgBoxStyle.Information, "File Path Error!") MsgBox("File Path Error" & Environment.NewLine & "Type in a valid path to the file for conversion", PictureBox1.Image = Image.FromStream(New IO.MemoryStream(bytes))Ĭatch ex As System.IO.FileNotFoundException If (TextBoxImageToConvert.TextLength 0) Thenĭim bytes = My.() I have used this to find an image on my computer and display it on a picture box: Private Sub ButtonConvert_Click(sender As System.Object, e As System.EventArgs) Handles ButtonConvert.Click
I want to know how to convert an image to an array of hex bytes. I am using Visual Studio 2010, writing in Visual Basic.