Thanks very much wysota.
I changed my client code to the following:
// Block until data is available for reading
if(!video_socket.waitForReadyRead())
{
qWarning()<<"ERROR: could not read image: "<<video_socket.errorString();
return;
}
// Read the image from the socket via the data stream
in>>received_image;
qDebug()<<"Image received";
// Block until data is available for reading
if(!video_socket.waitForReadyRead())
{
qWarning()<<"ERROR: could not read image: "<<video_socket.errorString();
return;
}
// Read the image from the socket via the data stream
in>>received_image;
qDebug()<<"Image received";
To copy to clipboard, switch view to plain text mode
And server to:
// Write the image to the socket via the data stream
out<<captured_image.getImage();
// Block until the data stream has been written to the socket
if(!video_socket.waitForBytesWritten())
qWarning()<<"ERROR: Unable to send image: "<<video_socket.errorString();
qDebug()<<"Image sent";
// Write the image to the socket via the data stream
out<<captured_image.getImage();
// Block until the data stream has been written to the socket
if(!video_socket.waitForBytesWritten())
qWarning()<<"ERROR: Unable to send image: "<<video_socket.errorString();
qDebug()<<"Image sent";
To copy to clipboard, switch view to plain text mode
And for some images it works perfectly.
However, for other images (seems to be the larger the image the more likely it is to happen), I get the following message:
libpng error: Read Error
A bit of googling shows this may be a Linux problem rather than a problem with what I am doing in Qt. However, I havent managed to find a reason for it yet. I've tried different QDataStream versions (Qt_4_0 to Qt_4_5) but the error stil occurs. My libpng (Ubuntu distro) seems to be all up to date (at least from the repository anyway). Hmmm....
Bookmarks