linux c++利用zlib向windows c# tcp传输图片

    技术2022-07-16  82

    工作环境:linux主机驱动相机拍摄图片,向windows服务器发送图片,发送方式采用tcp传输图片,为了加速传输采用zlib压缩算法;

    1.linux安装zlib源码,windows使用zlib.net.dll库方式

    2.c 部分代码:

    //压缩 char* Compress(char* src,int srcLen, int* comprLen){ int compressrate = 2; int err; int len = srcLen;//strlen(src) 1; //std::cout << "len:"<<len<<",srcLen:"<<srcLen<<std::endl; if(len != srcLen) { std::cout << "strlen != srcLen" << std::endl; } *comprLen = len*compressrate*sizeof(int); //std::cout << "ori comprLen:" << *comprLen << std::endl; Byte *compr = (Byte*)calloc((uInt)(*comprLen), 1); if (compr == Z_NULL) { printf("out of memory\n"); return NULL; } err = compress(compr,(uLong*)comprLen,(const Bytef*)src,(uLong)len); CHECK_ERR(err, &
    Processed: 0.044, SQL: 9