send bitmap with winsock

2019-05-21 10:41发布

问题:

How could you send a bitmap over winsock without saving it to a file then sending that? It would also be helpful if you knew how to convert the data after being recieved back into a bitmap.

回答1:

What programming language are you using?

Basically, you've got to store the bitmap data into some kind of byte buffer, then send the bytes over the wire, and read the bitmap back out of the byte buffer at the other end.

As such, there are four tasks:

  • Save bitmap to buffer
  • Write data across wire using a socket
  • Read data from wire using a socket
  • Load a bitmap from a buffer

Which tasks in particular are you not clear about?