Hi, I'm a total freshy in programming, hope my question make sence.
I'm working on a program which converts image to byte
I want the byte code information so that i can use it for further processing
so i convert the byte to string and wrote it into a .txt file
But instead of expected binary numbers, i get these kinda stuff:
Below is my C# code:
//this function convert image to byte array then stored to byte called haha
byte haha = imageToByteArray(pictureBox1.Image);
//this part of the operation convert byte array to string called hihi
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
hihi = enc.GetString(haha);
//this part of the operation write hihi into .txt file
string codetxtfile = "C:/Users/Trainee/Desktop/Test.txt";
objWriter = new System.IO.StreamWriter(codetxtfile);
How do i convert the image to byte and show it in binary code in .txt file? Please
I'm trying to convert the pixel color data on a 8 bit depth grayscale image(256 types of black to white) to numbers, i want these numbers to be in proper arrangement according to the pixel, as in lines of pixels in the image will be converted to line of numbers.
0= black, 255= white , 1-254= intermediate grey between black and white
So, for a gray scale image
i want the generated code to be like:
0811FF00...... (in hexadecimal), where 08= 8th grey, 11= 17th grey, FF=white, and 00= black
00001000000101111111111100000000..... (in binary code), where 00001000= 8th grey, 00010111=17th grey, 11111111= white, and 00000000= black
Previosly, i thought image to byte conversion will give arrays of binary numbers(each represent a pixel depth), i guess i was wrong.
Anyone can guide me in this please?