0

Making a randomly generated noise image, was wondering possible solutions of how to send it to other players.

I know the best method is to just send the seed, which is probably the solution I will go with, but I was curious as to if there is a good method to send an image across the XNA/C#/Xbox networks.

SimpleRookie
  • 305
  • 1
  • 3
  • 14

1 Answers1

1

You could technically serialize the Texture2D via a stream and send a Byte Array over the network. Then deserialize the data on the other end. This might be useful on something like a dedicated server with special pictures or custom maps that you want to pass to everyone without making them go get them somewhere. For the record, in your case I agree that seed is the way to go, if for no other reason than because you're lucky enough to have that options, and sending an int is much easier than a byte array. That being said, try something like this:

Texture2D image = Content.Load<Texture2D>("test"); //Or rather however you ended up making your texture
MemoryStream stream = new MemoryStream();
image.SaveAsJpeg(stream, image.Width, image.Height);
byte[] data = stream.ToArray();

Then you can pass data over the network and deserialize it on the other side.

Dan B
  • 357
  • 1
  • 2
  • 15