在C中使用socket_stream进行jpg文件传输

时间:2022-10-02 19:11:10

I was wondering if sending a file with a jpg extension through a socket_stream, this automatically makes the transformation of bytes to jpg ? or need to implement some algorithm to transform the lot of bytes to image... Please could somebody explain me the way to do?

我想知道是否通过socket_stream发送带有jpg扩展名的文件,这会自动将字节转换为jpg吗?或者需要实现一些算法来将大量字节转换为图像...请问有人可以解释一下我的方法吗?

1 个解决方案

#1


JPEG images are nothing but a bunch of bytes organized according to the JPEG format. A network socket isn't going to organize random bytes into the JPEG format. You can send the bytes that make up a JPEG formatted image across a socket as a binary blob, receive it on the other end, and write it to a file with a .jpg extension. An application can interpret this file as a JPEG image based on the extension and try to display it. But you are still responsible for providing a set of bytes that are organized as a JPEG image.

JPEG图像只不过是根据JPEG格式组织的一堆字节。网络套接字不会将随机字节组织成JPEG格式。您可以将组成JPEG格式图像的字节作为二进制blob发送到套接字,在另一端接收,然后将其写入带有.jpg扩展名的文件。应用程序可以根据扩展名将此文件解释为JPEG图像,并尝试显示它。但是您仍然负责提供一组组织为JPEG图像的字节。

#1


JPEG images are nothing but a bunch of bytes organized according to the JPEG format. A network socket isn't going to organize random bytes into the JPEG format. You can send the bytes that make up a JPEG formatted image across a socket as a binary blob, receive it on the other end, and write it to a file with a .jpg extension. An application can interpret this file as a JPEG image based on the extension and try to display it. But you are still responsible for providing a set of bytes that are organized as a JPEG image.

JPEG图像只不过是根据JPEG格式组织的一堆字节。网络套接字不会将随机字节组织成JPEG格式。您可以将组成JPEG格式图像的字节作为二进制blob发送到套接字,在另一端接收,然后将其写入带有.jpg扩展名的文件。应用程序可以根据扩展名将此文件解释为JPEG图像,并尝试显示它。但是您仍然负责提供一组组织为JPEG图像的字节。