Commit a28bf5d2 authored by Andreas Kempe's avatar Andreas Kempe

It is now possible to show and send images.

parent 63a7a3b6
......@@ -62,25 +62,18 @@ void main_window::handle_recv_data()
{
data_packet* packet = socket->get_next_packet();
//TODO: Handle packet!
qDebug() << "Received a packet!";
switch (packet->get_op_code())
{
case op_codes::IMG_DATA:
{
qDebug() << "Received a data packet with op code IMG_DATA and a payload of size "
<< packet->get_payload_size() << " byte(s).";
Magick::Image recv_img;
// Get the image from the packet and display it.
std::string enc_img(packet->get_payload());
Magick::Blob blob;
blob.base64(enc_img);
recv_img.read(blob);
recv_img.write("output.png");
qDebug() << "Saved the image as \"output.png\"!";
mandel_image->loadFromData((const uchar*) blob.data(), blob.length());
item->setPixmap(QPixmap::fromImage(*mandel_image));
}
}
......
......@@ -6,7 +6,11 @@
enum op_codes : quint32
{
IMG_DATA = 0x1
/* Used to send image data to the client.
* The image should be in the payload
* encoded as base64 using ImageMagicks
* Blob-class. */
IMG_DATA = 0x1
};
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment