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:
㼿①㼍㽰㼥㼢⌿㼈Вୂ⠿♲㼈㼸ሴ㽦䕖㼿ᄿ㼿㼿甞Ԛ䨿㽂㼿㽗㽳㴿፮倿᰿㼐搿㼿〿ℿ㼈晠᥌焈䁮戌㼿ਬ
└㑿ቮ〿䐿簿ᄤ㽁⥾㼍㼐ࠨᠢⴿ愄㼸ᡒ㼢䀿͖㼹㼹㽢䐿㼿㼿㼿ᠿ㼿㽳㼿㼿㼿㼿挗㼎ဓ㼜ℜ㼀㼃ᠿ㼿㼿п㼱
㼿ᄿ㼿ͪ渿㼔兘䀋瀿฿㼁硁ࠞ㽀㼅簿䀋ᴿ䀿ᐿ堂ᅈ㼿㼿ਿ㼖㽳儿∎愔⌿䀃࠹㽡㽝吿ȕ␈䌄砸㼿⌿㼃ᨃ
ℍ⸸兆┿〿㽄稿㼳㽸Ȕ㤼ㄍ㔿䈿欿㼿㼝ᨁ㼣㼿㼋䜿㼿ဿ硁ᱡ㼂㼿樁㼿㽀㼕嘴㼿ᅥ㽤㼿ᡄݐ婤㼎㽹̡㤿㼃
䙄㼸戔怿焋㴿᠇ᠿ䁂㼰㼿䈓尨ℊ⌿㼄ᴿ㽃摃㼿᰿㼼㽓䈖㼿㼏̿ဿ฿㽁㽟㼿đ㥨愍眿㼿ㄿ⠿㼿㽳㽶㽱Ġ刿䄈
ဿ㼿㼽昰∊瀿Kᔿ恁၏㼿㼭㼐㼙㼀愋ℼ瀃ၚ㼿ٽ㽀З怿㼎夐⌿㼿儐㜿砿ሿ㽂㽻㼿ܿ㼿㼅൘㼁ᤸ᥅㴿㼓匿㼿
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
string 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";
System.IO.StreamWriter objWriter;
objWriter = new System.IO.StreamWriter(codetxtfile);
objWriter.Write(hihi);
objWriter.Close();
MessageBox.Show("Done!");
How do i convert the image to byte and show it in binary code in .txt file? Please
Question Update:
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.
For eg.
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
or
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?