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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. How to convert Image to Byte and Byte to Image(to pass the image to another PC while working on Socket Programming )?

How to convert Image to Byte and Byte to Image(to pass the image to another PC while working on Socket Programming )?

Scheduled Pinned Locked Moved C#
sysadminhelptutorialquestion
2 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
    CoderForEver
    wrote on last edited by
    #1

    hi friends, I tried to send Image through a network .... I can send text data...it is easy one .... but when I try to convert the Image in to byte. This is the code that converts String to bye

    String message;
    Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);

    This is the code that converts byte to string

    String responseData = String.Empty;

                Int32 bytes = stream.Read(data, 0, data.Length);
                responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
    

    But I cant find any method that converts image to byte .... can any body help me? Thank you for your time.

    V 1 Reply Last reply
    0
    • C CoderForEver

      hi friends, I tried to send Image through a network .... I can send text data...it is easy one .... but when I try to convert the Image in to byte. This is the code that converts String to bye

      String message;
      Byte[] data = System.Text.Encoding.ASCII.GetBytes(message);

      This is the code that converts byte to string

      String responseData = String.Empty;

                  Int32 bytes = stream.Read(data, 0, data.Length);
                  responseData = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
      

      But I cant find any method that converts image to byte .... can any body help me? Thank you for your time.

      V Offline
      V Offline
      vaghelabhavesh
      wrote on last edited by
      #2

      How about using the File.ReadAllBytes [^] method? Edit : This will help you a lot C# Image to Byte Array and Byte Array to Image Converter Class[^]

      If you fail to plan, you plan to fail! Books are as useful to a stupid person as a mirror is useful to a blind person. - Chanakya

      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