Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Convert png images to string of Hexadecimals

Convert png images to string of Hexadecimals

Scheduled Pinned Locked Moved Visual Basic
csharptutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cory Kimble
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • C Cory Kimble

      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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      C 1 Reply Last reply
      0
      • D Dave Kreskowiak

        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

        C Offline
        C Offline
        Cory Kimble
        wrote on last edited by
        #3

        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?

        D 1 Reply Last reply
        0
        • C Cory Kimble

          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?

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups