I have a client in android and server in C++, written using Qt, connected with a TCP/IP socket. The connection works fine.
What I need is that client sends a byte array (image bitmap) to server and server to retrieve the image and displays it. I have no how to retrieve the byte array, convert it as an image and show it in Qt.
This is my code so far.
The Android client sends image as bytearray. This code works ok, tested with android server.
ImageView imageView=(ImageView) findViewById(R.id.imageView1);
Bitmap bmp=((BitmapDrawable)imageView.getDrawable()).getBitmap();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bmp.compress(CompressFormat.PNG, 0 , bos);
byte[] array = bos.toByteArray();
OutputStream out = socket.getOutputStream();
DataOutputStream dos = new DataOutputStream(out);
dos.writeInt(array.length);
dos.write(array, 0, array.length);
This is how I get the data on the server.
void MyThread::readyRead()
{
QByteArray Data = socket->readAll();
qDebug()<<Data;
}
Can somebody please give me a hand on how to retrieve the byte array from java client and display it as image in Qt-based server? or how to the decode the bytearray?