Convert png images to string of Hexadecimals
-
I am having trouble finding documentation on how to, using Vb.net to read a png file into a string and convert to Hex. Dow anyone have any code examples for me? Thank you
-
I am having trouble finding documentation on how to, using Vb.net to read a png file into a string and convert to Hex. Dow anyone have any code examples for me? Thank you
What do you mean by "reading a png file into a string and convert to Hex"?? Any file is just a stream of byte values, 0x00 thru 0xFF. Converting those to Hex is as easy as using
String.Format("{0:X2}", value)
to return a single value as a Hex string. What you do with those strings is up to you.A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008 -
What do you mean by "reading a png file into a string and convert to Hex"?? Any file is just a stream of byte values, 0x00 thru 0xFF. Converting those to Hex is as easy as using
String.Format("{0:X2}", value)
to return a single value as a Hex string. What you do with those strings is up to you.A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008I am reading the png like this. (I don't know if this is the best way.
Dim ascii() As Byte = File.ReadAllBytes("C:\3604.png")
I want to put This into a string.dim str as string = String.Format("{0:X2}", ascii)
Does not work. Is there an easy way besides looping through each byte and copying it to string? -
I am reading the png like this. (I don't know if this is the best way.
Dim ascii() As Byte = File.ReadAllBytes("C:\3604.png")
I want to put This into a string.dim str as string = String.Format("{0:X2}", ascii)
Does not work. Is there an easy way besides looping through each byte and copying it to string?Cory Kimble wrote:
dim str as string = String.Format("{0:X2}", ascii) Does not work.
Sure it does, when you convert each and every byte in the array, individually. You can't send an array to Format and expect it to iterate over the array for you.
Cory Kimble wrote:
Is there an easy way besides looping through each byte and copying it to string?
Nope. That's the only method you have.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007, 2008