![]() |
|
[C#] Understanding image bytes/ Sending image bytes through TCP - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C#] Understanding image bytes/ Sending image bytes through TCP (/showthread.php?tid=6034580) Pages: Pages
1
2
|
Understanding image bytes/ Sending image bytes through TCP - C++ - Dec 21, 2019 Hey, I'm here trying to send image bytes through TCP. But it's not working. I even tried to copy/paste the bytes manually and didn't work, why this? 🤝 RE: Understanding image bytes/ Sending image bytes through TCP - NYANxCAT - Dec 21, 2019 (Dec 21, 2019 11:16 AM)WeeE Wrote: Hey, I'm here trying to send image bytes through TCP. Can you explain "copy/paste the bytes manually" RE: Understanding image bytes/ Sending image bytes through TCP - C++ - Dec 21, 2019 (Dec 21, 2019 11:54 AM)˗ˏˋ NYAN CAT ˎˊ˗ Wrote: Can you explain "copy/paste the bytes manually" Opening notepad++, copying the whole text then pasting in another .png file. RE: Understanding image bytes/ Sending image bytes through TCP - HFDone - Dec 21, 2019 its not working like this read the image bytes by io.file.readallbytes and send it RE: Understanding image bytes/ Sending image bytes through TCP - C++ - Dec 21, 2019 (Dec 21, 2019 02:56 PM)HFDone Wrote: its not working like this read the image bytes by io.file.readallbytes and send it I don't want to read the bytes of the image nor save the image somewhere. It's stored in bytes and I send it through TCP. The example I gave above was just explaining that even if I tried to change the bytes of the .png won't work. RE: Understanding image bytes/ Sending image bytes through TCP - Washi - Dec 21, 2019 Read this: https://princetonuniversity.github.io/PUbootcamp/sessions/technical-questions/HowToAskQuestions2018Bootcamp.pdf Spoiler (Click to View) RE: Understanding image bytes/ Sending image bytes through TCP - NYANxCAT - Dec 21, 2019 (Dec 21, 2019 06:07 PM)Washi Wrote: Read this: That is exactly why I stopped replying. RE: Understanding image bytes/ Sending image bytes through TCP - gigajew - Dec 21, 2019 Here's an example with TcpClient (which is basically the same as a regular TCP Socket) RE: Understanding image bytes/ Sending image bytes through TCP - C++ - Dec 23, 2019 Here's what I got: After the TCP connection is made and receiving the bytes: asd is the string that is received by TCP. Code byte[] asd1 = System.Text.Encoding.ASCII.GetBytes(asd);RE: Understanding image bytes/ Sending image bytes through TCP - HFDone - Dec 23, 2019 why you using string you cant do it like "Opening notepad++, copying the whole text then pasting in another .png file." theres few problems with it giga gave you example and me too if you must use string then convert the image to base64 string and back RE: Understanding image bytes/ Sending image bytes through TCP - C++ - Dec 23, 2019 Yes but since I don't save the image I can't use the method you said. Here's how I create the bytearray: Bitmap memoryImage; memoryImage = new Bitmap(1000, 900); Size s = new Size(memoryImage.Width, memoryImage.Height); Graphics memoryGraphics = Graphics.FromImage(memoryImage); memoryGraphics.CopyFromScreen(0, 0, 0, 0, s); //That's it! Save the image in the directory and this will work like charm. string fileName = string.Format(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\Screen1shot" + "_" + DateTime.Now.ToString("(dd_MMMM_hh_mm_ss_tt)") + ".png"); // save it //memoryImage.Save(fileName); byte[] byteArray = new byte[0]; using (MemoryStream stream = new MemoryStream()) { memoryImage.Save(stream, System.Drawing.Imaging.ImageFormat.Png); stream.Close(); byteArray = stream.ToArray(); } Console.WriteLine(System.Text.Encoding.ASCII.GetString(byteArray)); return byteArray; RE: Understanding image bytes/ Sending image bytes through TCP - kelsin123j - Dec 25, 2019 not going to bother to read the garbage you just posted, but you can just get the byte array of image, convert that to base64 string, then send that RE: Understanding image bytes/ Sending image bytes through TCP - Washi - Dec 25, 2019 (Dec 23, 2019 07:30 AM)WeeE Wrote: Here's what I got: As stated before in my previous reply, you really gotta be more specific if you want to get meaningful answers. There is a lot of things unclear in your posts. What line or function call is it occurring? Why are you using strings to store the image data? What is meant by copied manually? An image is binary data, not textual data. This could very well be the core of your issues, though the only thing we can do is guess, as we cannot see the full picture or inside your head... (Dec 25, 2019 01:45 PM)kelsin123j Wrote: not going to bother to read the garbage you just posted, but you can just get the byte array of image, convert that to base64 string, then send that Why would you transform the binary data to a base64 string if the socket network stream accepts binary data as input just fine? ❓ RE: Understanding image bytes/ Sending image bytes through TCP - C++ - Dec 25, 2019 (Dec 25, 2019 05:40 PM)Washi Wrote: As stated before in my previous reply, you really gotta be more specific if you want to get meaningful answers. There is a lot of things unclear in your posts. I solved it, but thanks for your help. RE: Understanding image bytes/ Sending image bytes through TCP - Systers - Dec 29, 2019 Lmfao jesus christ this thread was a train wreck. |