Last active
August 29, 2015 14:02
-
-
Save muhammadyaseen/edeb15c41504ee6f71a4 to your computer and use it in GitHub Desktop.
This program writes the HEX representation of a JPEG image to the Console Window
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.IO; | |
namespace JPEGProcess | |
{ | |
/// <summary> | |
/// This program writes the HEX representation of a JPEG image to the Console Window | |
/// Image path is hardcoded (bad thing!) | |
/// | |
/// The Line is broken after 15 HEX chars to enhance readability | |
/// | |
/// The Start Of Image 'FF D8' and End of Image 'FF D9' can be seen on Console | |
/// </summary> | |
/// | |
/// <author> | |
/// Muhammad Yaseen | |
/// </author> | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
//Get the hex representation of specified image | |
var converted = BitConverter.ToString(File.ReadAllBytes(@"E:\test2.jpg")); | |
//remove the '-' character inserted by ToString() | |
List<string> lines = converted.Split(new char[] { '-' }).ToList(); | |
string line = String.Empty; | |
//print in lines of 15 HEX chars | |
for (int i = 0; i < lines.Count(); i++) | |
{ | |
Console.Write(lines[i] + " "); | |
if ( (i+1) % 15 == 0) Console.WriteLine(); | |
} | |
Console.WriteLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment