DO NOT DEAL WITH THIS MEMBER
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?
🤝
DO NOT DEAL WITH THIS MEMBER
(Dec 21, 2019 11:16 AM)C++ Wrote: 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?
🤝
Can you explain "copy/paste the bytes manually"
DO NOT DEAL WITH THIS MEMBER
(Dec 21, 2019 11:54 AM)NYANxCAT Wrote: Can you explain "copy/paste the bytes manually"
Opening notepad++, copying the whole text then pasting in another .png file.
its not working like this read the image bytes by io.file.readallbytes and send it
Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
DO NOT DEAL WITH THIS MEMBER
(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.
Read this:
https://princetonuniversity.github.io/PU...otcamp.pdf
We have nothing to work with. How do you expect to get answers if we don't know anything about what you've tried, what you were expecting and what actually happened?
DO NOT DEAL WITH THIS MEMBER
(Dec 21, 2019 06:07 PM)Washi Wrote: Read this:
https://princetonuniversity.github.io/PU...otcamp.pdf
We have nothing to work with. How do you expect to get answers if we don't know anything about what you've tried, what you were expecting and what actually happened?
That is exactly why I stopped replying.
Here's an example with TcpClient (which is basically the same as a regular TCP Socket)
DO NOT DEAL WITH THIS MEMBER
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);
using (Image image = Image.FromStream(new MemoryStream(asd1)))
{
image.Save(fileName); // Or Png
}
Throws out this expection: "System.ArgumentException: Parameter is not valid."
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
Be Nice For Once 15hVUVz7xA4kazHdk2BuErENGCskVwjYXP
DO NOT DEAL WITH THIS MEMBER
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;
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
(Dec 23, 2019 07:30 AM)C++ Wrote: 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);
using (Image image = Image.FromStream(new MemoryStream(asd1)))
{
image.Save(fileName); // Or Png
}
Throws out this expection: "System.ArgumentException: Parameter is not valid."
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? ❓
DO NOT DEAL WITH THIS MEMBER
(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.
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...
Why would you transform the binary data to a base64 string if the socket network stream accepts binary data as input just fine? ❓
I solved it, but thanks for your help.
Lmfao jesus christ this thread was a train wreck.
|