Передаю изображение с сервера на клиент, но черный экран. Клиент
FILE* f = fopen("Screen.tga", "wb");
if (!f) {
}
unsigned char tgaHeader[12] = { 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
unsigned char header[6];
n = read(sockfd, (char*)tgaHeader, sizeof(tgaHeader));
fwrite((unsigned char*)tgaHeader, sizeof(tgaHeader), 1, f);
n = read(sockfd, (char*)header, sizeof(header));
fwrite((unsigned char*)header, sizeof(header), 1, f);
// Записываем данные изображения:
bzero(buffer, buflen);
n = read(sockfd, buffer, buflen);
unsigned long j = (unsigned long)atol(buffer);
std::cout << buffer << std::endl;
std::cout<<'\n' << "j=" << j << std::endl;
bzero(buffer, buflen);
n = read(sockfd, buffer, j);
fwrite((unsigned char*)buffer,j, 1, f);
bzero(buffer, buflen);
fclose(f);
FILE*sFile =fopen("Screen.tga", "wb");
if (!sFile) {
}
header[0] = ScreenWidth % 256;
header[1] = ScreenWidth / 256;
header[2] = ScreenHeight % 256;
header[3] = ScreenHeight / 256;
header[4] = BMI.bmiHeader.biBitCount;
header[5] = 0;
fwrite(tgaHeader, sizeof(tgaHeader), 1, sFile);
n = write(newsockfd[current], (char*)tgaHeader, sizeof(tgaHeader));
fwrite(header, sizeof(header), 1, sFile);
n = write(newsockfd[current], (char*)header, sizeof(header));
fwrite(ImageBuffer, BMI.bmiHeader.biSizeImage, 1, sFile);
char* s = new char[100];
ultoa(BMI.bmiHeader.biSizeImage, s,100);
for (int i = 0; i < 100; i++)
((type*)args)[current].lalk->buffer[i] = s[i];
n = write(newsockfd[current], ((type*)args)[current].lalk->buffer, buflen);
n = write(newsockfd[current], (char*)ImageBuffer, BMI.bmiHeader.biSizeImage);
fclose(sFile);