PDA

View Full Version : How to obtain a QI,age from QTcpSocket->readAll



gorka_sm
26th April 2011, 09:19
Hello , I am implementing a QTCP Client for receiving images . I have the following code :


void NetworkControl::aceptar_conexiones()
{

QTcpSocket *soket = new QTcpSocket(this);
const QString direc ="xxxxxxxxxx";
quint16 port = 4445;
soket->connectToHOst(direc,port)
connect(soket,SIGNAL(readyRead()),this,SLOT(leerca racter()))

}

void NetworkControl::leerCaracter()
{

QTcpSocket *socket (QTcpSocket *)sender();
QBYteArray *b1 = socket->readAll();

QImage ax= new QImage("xxxxxxxx");

ax->Load(b1);

}

I would like to obtain a QImage from the QByteArray obtained by socket->readAll(). What would be the best way for obtaining it ?
I use the following code :


QTcpSocket *socket (QTcpSocket *)sender();
QBYteArray *b1 = socket->readAll();

QImage ax= new QImage("/home/aux/real.jpg");

ax->Load(b1);


Any suggestion ?
Thanks.
Gorka

I use the following

Hello , I am trying to obtain a const QIMage from a QByteArray. Does any body know how to obtain it ?
Thanks
Gorka

Hello
I am trying to transmit and represent video streaming from a video WebCam.
The receiver is based on a QTCPSocket , which obtains all the images the following way :

void NetworkControl::leercaracter()
{

QTcpSocket *socket = ( QTcpSocket * )sender()
QByteArray nbytes2 = socket->readAll();

}


I would like to obtain a const QImage from nbytes_2. What is the best way ?

I use the following way but it does not work :


const QImage *im1 = new QImage("xxxxxxxxx");


im1 ->loadfromData(nbytes2);

This code does not compile . Can you propose me any other code ? I need it for creating a MythImage anf MythUIIMage.
Thanks
Gorka

high_flyer
27th April 2011, 08:50
Please don't multipost.